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
1fc00353
Commit
1fc00353
authored
3 years ago
by
Fabian Paus
Browse files
Options
Downloads
Patches
Plain Diff
ArViz: Add context menu interaction
parent
8b71e4d0
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
source/RobotAPI/gui-plugins/ArViz/ArVizWidgetController.cpp
+80
-5
80 additions, 5 deletions
source/RobotAPI/gui-plugins/ArViz/ArVizWidgetController.cpp
source/RobotAPI/gui-plugins/ArViz/ArVizWidgetController.h
+1
-1
1 addition, 1 deletion
source/RobotAPI/gui-plugins/ArViz/ArVizWidgetController.h
with
81 additions
and
6 deletions
source/RobotAPI/gui-plugins/ArViz/ArVizWidgetController.cpp
+
80
−
5
View file @
1fc00353
...
...
@@ -59,9 +59,6 @@ namespace armarx
updateTimer
=
new
QTimer
(
this
);
connect
(
updateTimer
,
&
QTimer
::
timeout
,
this
,
QOverload
<>::
of
(
&
This
::
onUpdate
));
timingObserverTimer
=
new
QTimer
(
this
);
connect
(
timingObserverTimer
,
&
QTimer
::
timeout
,
this
,
QOverload
<>::
of
(
&
This
::
onTimingObserverUpdate
));
replayTimer
=
new
QTimer
(
this
);
connect
(
replayTimer
,
&
QTimer
::
timeout
,
this
,
QOverload
<>::
of
(
&
This
::
onReplayTimerTick
));
...
...
@@ -175,14 +172,13 @@ namespace armarx
currentRecordingSelected
=
false
;
changeMode
(
ArVizWidgetMode
::
Live
);
timingObserverTimer
->
start
(
33
);
updateTimer
->
start
(
33
);
}
void
ArVizWidgetController
::
onDisconnectGui
()
{
timingObserverTimer
->
stop
();
visualizer
.
stop
();
updateTimer
->
stop
();
changeMode
(
ArVizWidgetMode
::
NotConnected
);
}
...
...
@@ -436,6 +432,35 @@ namespace armarx
visualizer
.
selection
->
deselectAll
();
}
void
ArVizWidgetController
::
onContextMenuClicked
()
{
viz
::
ElementInteractionData
*
selected
=
visualizer
.
selectedElement
;
if
(
selected
==
nullptr
)
{
ARMARX_WARNING
<<
"Selected element is null, but a context menu option was clicked!"
;
return
;
}
QPushButton
*
clickedButton
=
static_cast
<
QPushButton
*>
(
sender
());
QLayout
*
layout
=
widget
.
groupBoxContextMenu
->
layout
();
int
count
=
layout
->
count
();
for
(
int
i
=
0
;
i
<
count
;
++
i
)
{
QPushButton
*
button
=
static_cast
<
QPushButton
*>
(
layout
->
itemAt
(
i
)
->
widget
());
if
(
button
==
clickedButton
)
{
viz
::
data
::
InteractionFeedback
&
interaction
=
visualizer
.
interactionFeedbackBuffer
.
emplace_back
();
interaction
.
component
=
selected
->
layer
.
first
;
interaction
.
layer
=
selected
->
layer
.
second
;
interaction
.
element
=
selected
->
element
;
interaction
.
type
=
viz
::
data
::
InteractionFeedbackType
::
CONTEXT_MENU_CHOSEN
;
interaction
.
chosenContextMenuEntry
=
i
;
return
;
}
}
}
static
QString
toQString
(
viz
::
ElementInteractionData
const
&
inter
)
{
std
::
string
id
=
inter
.
layer
.
first
+
"/"
...
...
@@ -450,9 +475,57 @@ namespace armarx
// Show the currently selected element
QString
selectedElementName
(
"<None>"
);
QLayout
*
contextMenuLayout
=
widget
.
groupBoxContextMenu
->
layout
();
if
(
visualizer
.
selectedElement
)
{
selectedElementName
=
toQString
(
*
visualizer
.
selectedElement
);
// Show context menu options if enabled
int
currentCount
=
contextMenuLayout
->
count
();
viz
::
data
::
InteractionDescription
const
&
desc
=
visualizer
.
selectedElement
->
interaction
;
std
::
vector
<
std
::
string
>
const
&
options
=
desc
.
contextMenuOptions
;
int
newCount
=
0
;
if
(
desc
.
enableFlags
&
viz
::
data
::
InteractionEnableFlags
::
CONTEXT_MENU
)
{
newCount
=
(
int
)
options
.
size
();
}
if
(
newCount
!=
currentCount
)
{
// Remove all items
QLayoutItem
*
item
;
while
((
item
=
contextMenuLayout
->
takeAt
(
0
))
!=
nullptr
)
{
delete
item
->
widget
();
delete
item
;
}
for
(
std
::
string
const
&
option
:
options
)
{
QPushButton
*
button
=
new
QPushButton
(
QString
::
fromStdString
(
option
),
widget
.
groupBoxContextMenu
);
connect
(
button
,
&
QPushButton
::
clicked
,
this
,
&
ArVizWidgetController
::
onContextMenuClicked
);
contextMenuLayout
->
addWidget
(
button
);
}
}
else
{
for
(
int
i
=
0
;
i
<
currentCount
;
++
i
)
{
QLayoutItem
*
item
=
contextMenuLayout
->
itemAt
(
i
);
QPushButton
*
button
=
static_cast
<
QPushButton
*>
(
item
->
widget
());
button
->
setText
(
QString
::
fromStdString
(
options
[
i
]));
}
}
}
else
{
QLayoutItem
*
item
;
while
((
item
=
contextMenuLayout
->
takeAt
(
0
))
!=
nullptr
)
{
delete
item
->
widget
();
delete
item
;
}
}
widget
.
labelSelectedElement
->
setText
(
selectedElementName
);
...
...
@@ -468,6 +541,8 @@ namespace armarx
widget
.
listInteractiveElements
->
addItem
(
elementID
);
}
}
onTimingObserverUpdate
();
}
void
ArVizWidgetController
::
onTimingObserverUpdate
()
...
...
This diff is collapsed.
Click to expand it.
source/RobotAPI/gui-plugins/ArViz/ArVizWidgetController.h
+
1
−
1
View file @
1fc00353
...
...
@@ -139,6 +139,7 @@ namespace armarx
void
showFilteredLayers
(
bool
visible
);
void
onDeselectElement
();
void
onContextMenuClicked
();
void
onUpdate
();
void
onTimingObserverUpdate
();
...
...
@@ -176,7 +177,6 @@ namespace armarx
QPointer
<
SimpleConfigDialog
>
configDialog
;
QTimer
*
updateTimer
;
QTimer
*
timingObserverTimer
;
viz
::
CoinVisualizer_UpdateTiming
lastTiming
;
StringVariantBaseMap
timingMap
;
...
...
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