Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
gepetto-viewer-corba
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gepetto
gepetto-viewer-corba
Commits
bbbc7963
Commit
bbbc7963
authored
6 years ago
by
Joseph Mirabel
Committed by
Joseph Mirabel
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add editor of color properties.
parent
31c24484
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/gepetto/gui/tree-item.hh
+1
-0
1 addition, 0 deletions
include/gepetto/gui/tree-item.hh
src/gui/tree-item.cc
+44
-4
44 additions, 4 deletions
src/gui/tree-item.cc
with
45 additions
and
4 deletions
include/gepetto/gui/tree-item.hh
+
1
−
0
View file @
bbbc7963
...
...
@@ -79,6 +79,7 @@ namespace gepetto {
void
setIntProperty
(
int
value
)
const
;
void
setStringProperty
(
const
QString
&
value
)
const
;
void
setFloatProperty
(
const
double
&
value
)
const
;
void
setColorProperty
(
const
QColor
&
value
)
const
;
private
:
template
<
typename
T
>
void
setProperty
(
const
QObject
*
sender
,
const
T
&
value
)
const
;
...
...
This diff is collapsed.
Click to expand it.
src/gui/tree-item.cc
+
44
−
4
View file @
bbbc7963
...
...
@@ -47,13 +47,13 @@ namespace gepetto {
QComboBox
*
cb
=
new
QComboBox
;
int
value
;
/* bool success = */
enumProp
->
get
(
value
);
in
t
indexSelected
=
0
;
std
::
size_
t
indexSelected
=
0
;
for
(
std
::
size_t
i
=
0
;
i
<
enumMeta
->
values
.
size
();
++
i
)
{
cb
->
addItem
(
enumMeta
->
names
[
i
].
c_str
(),
enumMeta
->
values
[
i
]);
if
(
value
==
enumMeta
->
values
[
i
])
indexSelected
=
i
;
}
cb
->
setCurrentIndex
(
indexSelected
);
cb
->
setCurrentIndex
(
(
int
)
indexSelected
);
if
(
prop
->
hasWriteAccess
())
bti
->
connect
(
cb
,
SIGNAL
(
currentIndexChanged
(
int
)),
SLOT
(
setIntProperty
(
int
)));
else
...
...
@@ -87,6 +87,28 @@ namespace gepetto {
return
dsb
;
}
QWidget
*
colorPropertyEditor
(
BodyTreeItem
*
bti
,
const
graphics
::
PropertyPtr_t
prop
)
{
if
(
!
prop
->
hasWriteAccess
())
return
NULL
;
osgVector4
value
;
/* bool success = */
prop
->
get
(
value
);
QColor
color
;
color
.
setRgbF
((
qreal
)
value
[
0
],(
qreal
)
value
[
1
],(
qreal
)
value
[
2
],(
qreal
)
value
[
3
]);
QPushButton
*
button
=
new
QPushButton
(
"Select color"
);
// Set icon for current color value
/// Color dialog should be opened in a different place
QColorDialog
*
colorDialog
=
new
QColorDialog
(
color
,
MainWindow
::
instance
());
colorDialog
->
setOption
(
QColorDialog
::
ShowAlphaChannel
,
true
);
colorDialog
->
setProperty
(
"propertyName"
,
QString
::
fromStdString
(
prop
->
name
()));
colorDialog
->
connect
(
button
,
SIGNAL
(
clicked
()),
SLOT
(
open
()));
bti
->
connect
(
colorDialog
,
SIGNAL
(
colorSelected
(
QColor
)),
SLOT
(
setColorProperty
(
QColor
)));
return
button
;
}
BodyTreeItem
::
BodyTreeItem
(
QObject
*
parent
,
graphics
::
NodePtr_t
node
)
:
QObject
(
parent
),
QStandardItem
(
QString
(
node
->
getID
().
c_str
())),
...
...
@@ -131,12 +153,18 @@ namespace gepetto {
field
=
stringPropertyEditor
(
this
,
prop
);
}
else
if
(
prop
->
type
()
==
"float"
)
{
field
=
floatPropertyEditor
(
this
,
prop
);
}
else
{
qDebug
()
<<
"Unhandled property"
<<
name
<<
"of type"
<<
prop
->
type
().
c_str
()
<<
"."
;
}
else
if
(
prop
->
type
()
==
"osgVector4"
)
{
if
(
name
.
contains
(
"color"
,
Qt
::
CaseInsensitive
))
{
field
=
colorPropertyEditor
(
this
,
prop
);
}
else
{
field
=
NULL
;
}
}
if
(
field
!=
NULL
)
{
field
->
setProperty
(
"propertyName"
,
name
);
l
->
addRow
(
name
+
':'
,
field
);
}
else
{
qDebug
()
<<
"Unhandled property"
<<
name
<<
"of type"
<<
prop
->
type
().
c_str
()
<<
"."
;
}
}
disconnect
(
SIGNAL
(
requestInitialize
()));
...
...
@@ -151,6 +179,8 @@ namespace gepetto {
std
::
string
name
=
nameVariant
.
toString
().
toStdString
();
boost
::
mutex
::
scoped_lock
lock
(
MainWindow
::
instance
()
->
osg
()
->
osgFrameMutex
());
node_
->
setProperty
<
T
>
(
name
,
value
);
}
else
{
qDebug
()
<<
"Sender has no property propertyName"
<<
sender
;
}
}
}
...
...
@@ -175,6 +205,16 @@ namespace gepetto {
setProperty
(
QObject
::
sender
(),
float
(
value
));
}
void
BodyTreeItem
::
setColorProperty
(
const
QColor
&
value
)
const
{
osgVector4
c
(
(
float
)
value
.
redF
(),
(
float
)
value
.
greenF
(),
(
float
)
value
.
blueF
(),
(
float
)
value
.
alphaF
());
setProperty
(
QObject
::
sender
(),
c
);
}
BodyTreeItem
::~
BodyTreeItem
()
{
if
(
propertyEditors_
->
parent
()
!=
NULL
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment