Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RobotAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software
ArmarX
RobotAPI
Commits
c09bd60c
Commit
c09bd60c
authored
2 years ago
by
Christoph Pohl
Browse files
Options
Downloads
Patches
Plain Diff
Add possibility to update remote gui values from inside the program
parent
f5146909
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp
+165
-65
165 additions, 65 deletions
...API/libraries/aron_component_config/RemoteGuiVisitors.cpp
with
165 additions
and
65 deletions
source/RobotAPI/libraries/aron_component_config/RemoteGuiVisitors.cpp
+
165
−
65
View file @
c09bd60c
...
...
@@ -35,7 +35,8 @@ if (in_list_) return;
namespace
armarx
::
aron
::
component_config
{
void
MakeConfigGuiVisitor
::
visitObjectOnEnter
(
DataInput
&
dict
,
TypeInput
&
)
void
MakeConfigGuiVisitor
::
visitObjectOnEnter
(
DataInput
&
dict
,
TypeInput
&
)
{
ARMARX_TRACE
;
ARMARX_CHECK_NOT_NULL
(
dict
);
...
...
@@ -43,8 +44,8 @@ namespace armarx::aron::component_config
if
(
dict
->
getPath
().
hasElement
())
{
std
::
string
name
=
pathToName
(
dict
);
group_hierarchy_
.
emplace_back
(
std
::
make_shared
<
RemoteGui
::
detail
::
GroupBoxBuilder
>
(
RemoteGui
::
makeGroupBox
(
name
)));
group_hierarchy_
.
emplace_back
(
std
::
make_shared
<
RemoteGui
::
detail
::
GroupBoxBuilder
>
(
RemoteGui
::
makeGroupBox
(
name
)));
}
else
{
group_hierarchy_
.
push_back
(
builder_
);
...
...
@@ -52,7 +53,8 @@ namespace armarx::aron::component_config
}
void
MakeConfigGuiVisitor
::
visitObjectOnExit
(
DataInput
&
dict
,
TypeInput
&
)
void
MakeConfigGuiVisitor
::
visitObjectOnExit
(
DataInput
&
dict
,
TypeInput
&
)
{
ARMARX_TRACE
;
auto
builder
=
*
group_hierarchy_
.
back
();
...
...
@@ -63,39 +65,51 @@ namespace armarx::aron::component_config
}
}
void
MakeConfigGuiVisitor
::
visitInt
(
DataInput
&
i
,
TypeInput
&
)
void
MakeConfigGuiVisitor
::
visitInt
(
DataInput
&
i
,
TypeInput
&
)
{
INPUT_GUARD
(
i
);
auto
value
=
data
::
Int
::
DynamicCastAndCheck
(
i
);
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeIntSpinBox
(
pathToName
(
i
)).
value
(
value
->
getValue
()).
min
(
-
1000
).
max
(
1000
));
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeIntSpinBox
(
pathToName
(
i
)).
value
(
value
->
getValue
())
.
min
(
-
1000
)
.
max
(
1000
));
}
void
MakeConfigGuiVisitor
::
visitFloat
(
DataInput
&
f
,
TypeInput
&
)
void
MakeConfigGuiVisitor
::
visitFloat
(
DataInput
&
f
,
TypeInput
&
)
{
INPUT_GUARD
(
f
);
auto
value
=
data
::
Float
::
DynamicCastAndCheck
(
f
);
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeFloatSpinBox
(
pathToName
(
f
)).
value
(
value
->
getValue
()).
min
(
-
1000
).
max
(
1000
));
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeFloatSpinBox
(
pathToName
(
f
)).
value
(
value
->
getValue
())
.
min
(
-
1000
)
.
max
(
1000
));
}
void
MakeConfigGuiVisitor
::
visitDouble
(
DataInput
&
d
,
TypeInput
&
)
void
MakeConfigGuiVisitor
::
visitDouble
(
DataInput
&
d
,
TypeInput
&
)
{
INPUT_GUARD
(
d
);
auto
value
=
data
::
Double
::
DynamicCastAndCheck
(
d
);
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeFloatSpinBox
(
pathToName
(
d
)).
value
(
value
->
getValue
()).
min
(
-
1000
).
max
(
1000
));
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeFloatSpinBox
(
pathToName
(
d
)).
value
(
value
->
getValue
())
.
min
(
-
1000
)
.
max
(
1000
));
}
void
MakeConfigGuiVisitor
::
visitBool
(
DataInput
&
b
,
TypeInput
&
)
void
MakeConfigGuiVisitor
::
visitBool
(
DataInput
&
b
,
TypeInput
&
)
{
INPUT_GUARD
(
b
);
auto
value
=
data
::
Bool
::
DynamicCastAndCheck
(
b
);
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeCheckBox
(
pathToName
(
b
)).
value
(
value
->
getValue
()).
label
(
b
->
getPath
().
getLastElement
()));
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeCheckBox
(
pathToName
(
b
)).
value
(
value
->
getValue
())
.
label
(
b
->
getPath
().
getLastElement
()));
}
void
MakeConfigGuiVisitor
::
visitString
(
DataInput
&
string
,
TypeInput
&
)
void
MakeConfigGuiVisitor
::
visitString
(
DataInput
&
string
,
TypeInput
&
)
{
INPUT_GUARD
(
string
);
auto
value
=
data
::
String
::
DynamicCastAndCheck
(
string
);
...
...
@@ -107,12 +121,14 @@ namespace armarx::aron::component_config
{
}
RemoteGui
::
detail
::
GroupBoxBuilder
MakeConfigGuiVisitor
::
getGroupBoxBuilder
()
const
RemoteGui
::
detail
::
GroupBoxBuilder
MakeConfigGuiVisitor
::
getGroupBoxBuilder
()
const
{
return
*
builder_
;
}
void
MakeConfigGuiVisitor
::
visitListOnEnter
(
DataInput
&
o
,
TypeInput
&
t
)
void
MakeConfigGuiVisitor
::
visitListOnEnter
(
DataInput
&
o
,
TypeInput
&
t
)
{
auto
group
=
RemoteGui
::
makeSimpleGridLayout
(
pathToName
(
o
)
+
"_grid"
).
cols
(
20
);
auto
data
=
data
::
List
::
DynamicCastAndCheck
(
o
);
...
...
@@ -122,13 +138,12 @@ namespace armarx::aron::component_config
switch
(
type
->
getAcceptedType
()
->
getDescriptor
())
{
case
type
::
Descriptor
::
STRING
:
group
.
addChild
(
RemoteGui
::
makeLineEdit
(
pathToName
(
el
)).
value
(
data
::
String
::
DynamicCast
(
el
)
->
getValue
()),
10
);
group
.
addChild
(
RemoteGui
::
makeLineEdit
(
pathToName
(
el
)).
value
(
data
::
String
::
DynamicCast
(
el
)
->
getValue
()),
10
);
break
;
case
type
::
Descriptor
::
INT
:
group
.
addChild
(
RemoteGui
::
makeLineEdit
(
pathToName
(
el
))
.
value
(
std
::
to_string
(
data
::
Int
::
DynamicCast
(
el
)
->
getValue
())),
10
);
group
.
addChild
(
RemoteGui
::
makeLineEdit
(
pathToName
(
el
))
.
value
(
std
::
to_string
(
data
::
Int
::
DynamicCast
(
el
)
->
getValue
())),
10
);
break
;
default:
throw
armarx
::
NotImplementedYetException
();
...
...
@@ -137,32 +152,38 @@ namespace armarx::aron::component_config
group
.
addChild
(
RemoteGui
::
makeButton
(
pathToName
(
el
)
+
"_button"
).
label
(
"-"
).
toolTip
(
"Remove List Element"
),
2
);
}
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeGroupBox
(
pathToName
(
o
)
+
"_grp"
).
label
(
o
->
getPath
().
getLastElement
()).
collapsed
(
true
)
.
addChild
(
group
).
addChild
(
RemoteGui
::
makeButton
(
pathToName
(
o
)
+
"_add"
)
.
label
(
"+"
)
.
toolTip
(
"Add new list entry."
)));
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeGroupBox
(
pathToName
(
o
)
+
"_grp"
).
label
(
o
->
getPath
().
getLastElement
())
.
collapsed
(
true
)
.
addChild
(
group
)
.
addChild
(
RemoteGui
::
makeButton
(
pathToName
(
o
)
+
"_add"
).
label
(
"+"
)
.
toolTip
(
"Add new list entry."
)));
in_list_
=
true
;
}
void
MakeConfigGuiVisitor
::
visitListOnExit
(
DataInput
&
,
TypeInput
&
)
void
MakeConfigGuiVisitor
::
visitListOnExit
(
DataInput
&
,
TypeInput
&
)
{
in_list_
=
false
;
}
void
MakeConfigGuiVisitor
::
visitIntEnum
(
DataInput
&
o
,
TypeInput
&
t
)
void
MakeConfigGuiVisitor
::
visitIntEnum
(
DataInput
&
o
,
TypeInput
&
t
)
{
INPUT_GUARD
(
o
);
auto
data
=
data
::
Int
::
DynamicCastAndCheck
(
o
);
auto
type
=
type
::
IntEnum
::
DynamicCast
(
t
);
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeComboBox
(
pathToName
(
o
)).
options
(
type
->
getAcceptedValueNames
())
.
value
(
type
->
getValueName
(
data
->
getValue
())));
group_hierarchy_
.
back
()
->
addChild
(
RemoteGui
::
makeComboBox
(
pathToName
(
o
)).
options
(
type
->
get
Accepted
ValueName
s
())
.
value
(
type
->
getValueName
(
data
->
getValue
())));
}
void
MakeConfigGuiVisitor
::
visitDictOnEnter
(
const
std
::
shared_ptr
<
data
::
Variant
>&
,
const
std
::
shared_ptr
<
type
::
Variant
>&
)
MakeConfigGuiVisitor
::
visitDictOnEnter
(
const
std
::
shared_ptr
<
data
::
Variant
>&
o
,
const
std
::
shared_ptr
<
type
::
Variant
>&
t
)
{
in_list_
=
true
;
}
...
...
@@ -179,90 +200,167 @@ namespace armarx::aron::component_config
{
}
void
GetValueFromMapVisitor
::
visitInt
(
DataInput
&
i
,
TypeInput
&
)
void
GetValueFromMapVisitor
::
visitInt
(
DataInput
&
i
,
TypeInput
&
)
{
INPUT_GUARD
(
i
);
auto
value
=
data
::
Int
::
DynamicCastAndCheck
(
i
);
proxy_
->
getValue
(
value
->
getValue
(),
pathToName
(
i
));
i
=
value
;
const
std
::
string
name
=
pathToName
(
i
);
auto
gui_value
=
proxy_
->
getValue
<
int
>
(
name
);
if
(
value
->
getValue
()
!=
gui_value
.
get
())
{
if
(
proxy_
->
hasValueChanged
(
name
))
{
value
->
setValue
(
gui_value
.
get
());
i
=
value
;
}
else
{
proxy_
->
setValue
(
value
->
getValue
(),
name
);
}
}
}
void
GetValueFromMapVisitor
::
visitFloat
(
DataInput
&
f
,
TypeInput
&
)
void
GetValueFromMapVisitor
::
visitFloat
(
DataInput
&
f
,
TypeInput
&
)
{
INPUT_GUARD
(
f
);
auto
value
=
data
::
Float
::
DynamicCastAndCheck
(
f
);
proxy_
->
getValue
(
value
->
getValue
(),
pathToName
(
f
));
f
=
value
;
const
std
::
string
name
=
pathToName
(
f
);
auto
gui_value
=
proxy_
->
getValue
<
float
>
(
name
);
if
(
value
->
getValue
()
!=
gui_value
.
get
())
{
if
(
proxy_
->
hasValueChanged
(
name
))
{
value
->
setValue
(
gui_value
.
get
());
f
=
value
;
}
else
{
proxy_
->
setValue
(
value
->
getValue
(),
name
);
}
}
}
void
GetValueFromMapVisitor
::
visitDouble
(
DataInput
&
d
,
TypeInput
&
)
void
GetValueFromMapVisitor
::
visitDouble
(
DataInput
&
d
,
TypeInput
&
)
{
INPUT_GUARD
(
d
);
auto
value
=
data
::
Double
::
DynamicCastAndCheck
(
d
);
float
val_f
;
proxy_
->
getValue
(
val_f
,
pathToName
(
d
));
value
->
getValue
()
=
val_f
;
d
=
value
;
const
std
::
string
name
=
pathToName
(
d
);
// TODO: does double work here?
auto
gui_value
=
proxy_
->
getValue
<
float
>
(
name
);
if
(
value
->
getValue
()
!=
gui_value
.
get
())
{
if
(
proxy_
->
hasValueChanged
(
name
))
{
value
->
setValue
(
gui_value
.
get
());
d
=
value
;
}
else
{
proxy_
->
setValue
(
static_cast
<
float
>
(
value
->
getValue
()),
name
);
}
}
}
void
GetValueFromMapVisitor
::
visitBool
(
DataInput
&
b
,
TypeInput
&
)
void
GetValueFromMapVisitor
::
visitBool
(
DataInput
&
b
,
TypeInput
&
)
{
INPUT_GUARD
(
b
);
auto
value
=
data
::
Bool
::
DynamicCastAndCheck
(
b
);
proxy_
->
getValue
(
value
->
getValue
(),
pathToName
(
b
));
b
=
value
;
const
std
::
string
name
=
pathToName
(
b
);
auto
gui_value
=
proxy_
->
getValue
<
bool
>
(
name
);
if
(
value
->
getValue
()
!=
gui_value
.
get
())
{
if
(
proxy_
->
hasValueChanged
(
name
))
{
value
->
setValue
(
gui_value
.
get
());
b
=
value
;
}
else
{
proxy_
->
setValue
(
value
->
getValue
(),
name
);
}
}
}
void
GetValueFromMapVisitor
::
visitString
(
DataInput
&
string
,
TypeInput
&
)
void
GetValueFromMapVisitor
::
visitString
(
DataInput
&
string
,
TypeInput
&
)
{
INPUT_GUARD
(
string
);
auto
value
=
data
::
String
::
DynamicCastAndCheck
(
string
);
proxy_
->
getValue
(
value
->
getValue
(),
pathToName
(
string
));
string
=
value
;
const
std
::
string
name
=
pathToName
(
string
);
auto
gui_value
=
proxy_
->
getValue
<
std
::
string
>
(
name
);
if
(
value
->
getValue
()
!=
gui_value
.
get
())
{
if
(
proxy_
->
hasValueChanged
(
name
))
{
value
->
setValue
(
gui_value
.
get
());
string
=
value
;
}
else
{
proxy_
->
setValue
(
value
->
getValue
(),
name
);
}
}
}
type
::
Descriptor
GetValueFromMapVisitor
::
getDescriptor
(
DataInput
&
o
,
TypeInput
&
t
)
type
::
Descriptor
GetValueFromMapVisitor
::
getDescriptor
(
DataInput
&
o
,
TypeInput
&
t
)
{
return
data
::
ConstTypedVariantVisitor
::
GetDescriptor
(
o
,
t
);
}
GetValueFromMapVisitor
::
MapElements
GetValueFromMapVisitor
::
getObjectElements
(
DataInput
&
o
,
TypeInput
&
t
)
GetValueFromMapVisitor
::
MapElements
GetValueFromMapVisitor
::
getObjectElements
(
DataInput
&
o
,
TypeInput
&
t
)
{
return
component_config
::
getObjectElements
(
o
,
t
);
}
GetValueFromMapVisitor
::
MapElements
GetValueFromMapVisitor
::
getDictElements
(
DataInput
&
o
,
TypeInput
&
t
)
GetValueFromMapVisitor
::
MapElements
GetValueFromMapVisitor
::
getDictElements
(
DataInput
&
o
,
TypeInput
&
t
)
{
return
component_config
::
getDictElements
(
o
,
t
);
}
GetValueFromMapVisitor
::
ListElements
GetValueFromMapVisitor
::
getListElements
(
DataInput
&
o
,
TypeInput
&
t
)
GetValueFromMapVisitor
::
ListElements
GetValueFromMapVisitor
::
getListElements
(
DataInput
&
o
,
TypeInput
&
t
)
{
return
component_config
::
getListElements
(
o
,
t
);
}
GetValueFromMapVisitor
::
PairElements
GetValueFromMapVisitor
::
getPairElements
(
DataInput
&
o
,
TypeInput
&
t
)
GetValueFromMapVisitor
::
PairElements
GetValueFromMapVisitor
::
getPairElements
(
DataInput
&
o
,
TypeInput
&
t
)
{
return
component_config
::
getPairElements
(
o
,
t
);
}
GetValueFromMapVisitor
::
TupleElements
GetValueFromMapVisitor
::
getTupleElements
(
DataInput
&
o
,
TypeInput
&
t
)
GetValueFromMapVisitor
::
TupleElements
GetValueFromMapVisitor
::
getTupleElements
(
DataInput
&
o
,
TypeInput
&
t
)
{
return
component_config
::
getTupleElements
(
o
,
t
);
}
void
GetValueFromMapVisitor
::
visitIntEnum
(
DataInput
&
o
,
TypeInput
&
t
)
void
GetValueFromMapVisitor
::
visitIntEnum
(
DataInput
&
o
,
TypeInput
&
t
)
{
INPUT_GUARD
(
o
);
auto
data
=
data
::
Int
::
DynamicCastAndCheck
(
o
);
auto
type
=
type
::
IntEnum
::
DynamicCastAndCheck
(
t
);
std
::
string
str
;
const
std
::
string
name
=
pathToName
(
o
);
proxy_
->
getValue
(
str
,
pathToName
(
o
));
data
->
getValue
()
=
type
->
getValue
(
str
);
o
=
data
;
if
(
data
->
getValue
()
!=
type
->
getValue
(
str
))
{
if
(
proxy_
->
hasValueChanged
(
name
))
{
data
->
getValue
()
=
type
->
getValue
(
str
);
o
=
data
;
}
else
{
proxy_
->
setValue
(
type
->
getValueName
(
data
->
getValue
()),
name
);
}
}
}
void
GetValueFromMapVisitor
::
visitListOnEnter
(
DataInput
&
o
,
TypeInput
&
t
)
void
GetValueFromMapVisitor
::
visitListOnEnter
(
DataInput
&
o
,
TypeInput
&
t
)
{
auto
data
=
data
::
List
::
DynamicCastAndCheck
(
o
);
auto
type
=
type
::
List
::
DynamicCast
(
t
);
...
...
@@ -311,12 +409,14 @@ namespace armarx::aron::component_config
in_list_
=
true
;
}
void
GetValueFromMapVisitor
::
visitListOnExit
(
DataInput
&
,
TypeInput
&
)
void
GetValueFromMapVisitor
::
visitListOnExit
(
DataInput
&
,
TypeInput
&
)
{
in_list_
=
false
;
}
bool
GetValueFromMapVisitor
::
tabRebuildRequired
()
const
bool
GetValueFromMapVisitor
::
tabRebuildRequired
()
const
{
return
tab_rebuild_required_
;
}
...
...
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