Skip to content

Commit 09ce566

Browse files
Use of BaseViewer selection mechanism to add live selection feedback in the 3D view (#18)
* Implement first version of a drawSelection. This is just for drafting. A lot to do in a different way * Refactor to handle sofa's PR#5636 * Add multiple selection in the scene graph. * Add selection parameters in the Viewer's tab and move the "documentation" in its own QDialog windget.
1 parent c852722 commit 09ce566

File tree

9 files changed

+276
-74
lines changed

9 files changed

+276
-74
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ set(UI_FILES
228228
${SRC_ROOT}/GUI.ui
229229
${SRC_ROOT}/MouseManager.ui
230230
${SRC_ROOT}/PluginManager.ui
231+
${SRC_ROOT}/ViewerShortcuts.ui
231232
${SRC_ROOT}/VideoRecorderManager.ui
232233
)
233234
set(QRC_FILES

src/sofa/qt/GUI.ui

Lines changed: 173 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
</property>
111111
<addaction name="separator"/>
112112
<addaction name="helpShowDocBrowser"/>
113+
<addaction name="actionViewerShowDocumentation"/>
113114
<addaction name="helpAboutAction"/>
114115
</widget>
115116
<addaction name="fileMenu"/>
@@ -127,7 +128,7 @@
127128
<property name="minimumSize">
128129
<size>
129130
<width>200</width>
130-
<height>551</height>
131+
<height>594</height>
131132
</size>
132133
</property>
133134
<attribute name="dockWidgetArea">
@@ -167,38 +168,6 @@
167168
<property name="sizeConstraint">
168169
<enum>QLayout::SetNoConstraint</enum>
169170
</property>
170-
<item row="2" column="0">
171-
<widget class="QPushButton" name="ResetViewButton">
172-
<property name="enabled">
173-
<bool>true</bool>
174-
</property>
175-
<property name="toolTip">
176-
<string>Set the camera to initial position and orientation</string>
177-
</property>
178-
<property name="text">
179-
<string>Reset &amp;View</string>
180-
</property>
181-
<property name="shortcut">
182-
<string>Alt+V</string>
183-
</property>
184-
</widget>
185-
</item>
186-
<item row="0" column="0">
187-
<widget class="QPushButton" name="startButton">
188-
<property name="toolTip">
189-
<string>Launch the Simulation</string>
190-
</property>
191-
<property name="text">
192-
<string>&amp;Animate</string>
193-
</property>
194-
<property name="shortcut">
195-
<string>Alt+A</string>
196-
</property>
197-
<property name="checkable">
198-
<bool>true</bool>
199-
</property>
200-
</widget>
201-
</item>
202171
<item row="2" column="1">
203172
<widget class="QPushButton" name="SaveViewButton">
204173
<property name="enabled">
@@ -231,32 +200,6 @@
231200
</property>
232201
</widget>
233202
</item>
234-
<item row="0" column="1">
235-
<widget class="QPushButton" name="stepButton">
236-
<property name="toolTip">
237-
<string>Compute the simulation at time t+DT</string>
238-
</property>
239-
<property name="text">
240-
<string>S&amp;tep</string>
241-
</property>
242-
<property name="shortcut">
243-
<string>Alt+T</string>
244-
</property>
245-
<property name="autoRepeat">
246-
<bool>true</bool>
247-
</property>
248-
</widget>
249-
</item>
250-
<item row="3" column="0" colspan="2">
251-
<widget class="QPushButton" name="screenshotButton">
252-
<property name="text">
253-
<string>Save S&amp;creenshot</string>
254-
</property>
255-
<property name="shortcut">
256-
<string>Alt+C</string>
257-
</property>
258-
</widget>
259-
</item>
260203
<item row="1" column="1">
261204
<layout class="QHBoxLayout" name="_15">
262205
<property name="sizeConstraint">
@@ -306,6 +249,64 @@
306249
</item>
307250
</layout>
308251
</item>
252+
<item row="2" column="0">
253+
<widget class="QPushButton" name="ResetViewButton">
254+
<property name="enabled">
255+
<bool>true</bool>
256+
</property>
257+
<property name="toolTip">
258+
<string>Set the camera to initial position and orientation</string>
259+
</property>
260+
<property name="text">
261+
<string>Reset &amp;View</string>
262+
</property>
263+
<property name="shortcut">
264+
<string>Alt+V</string>
265+
</property>
266+
</widget>
267+
</item>
268+
<item row="3" column="0" colspan="2">
269+
<widget class="QPushButton" name="screenshotButton">
270+
<property name="text">
271+
<string>Save S&amp;creenshot</string>
272+
</property>
273+
<property name="shortcut">
274+
<string>Alt+C</string>
275+
</property>
276+
</widget>
277+
</item>
278+
<item row="0" column="0">
279+
<widget class="QPushButton" name="startButton">
280+
<property name="toolTip">
281+
<string>Launch the Simulation</string>
282+
</property>
283+
<property name="text">
284+
<string>&amp;Animate</string>
285+
</property>
286+
<property name="shortcut">
287+
<string>Alt+A</string>
288+
</property>
289+
<property name="checkable">
290+
<bool>true</bool>
291+
</property>
292+
</widget>
293+
</item>
294+
<item row="0" column="1">
295+
<widget class="QPushButton" name="stepButton">
296+
<property name="toolTip">
297+
<string>Compute the simulation at time t+DT</string>
298+
</property>
299+
<property name="text">
300+
<string>S&amp;tep</string>
301+
</property>
302+
<property name="shortcut">
303+
<string>Alt+T</string>
304+
</property>
305+
<property name="autoRepeat">
306+
<bool>true</bool>
307+
</property>
308+
</widget>
309+
</item>
309310
</layout>
310311
</item>
311312
<item>
@@ -339,7 +340,7 @@
339340
</size>
340341
</property>
341342
<property name="currentIndex">
342-
<number>0</number>
343+
<number>4</number>
343344
</property>
344345
<widget class="QWidget" name="TabGraph">
345346
<attribute name="title">
@@ -563,13 +564,13 @@ State 2: dirty, in that state the button reflect the fact that the scene graph v
563564
</item>
564565
</layout>
565566
</widget>
566-
<widget class="QWidget" name="TabPage">
567+
<widget class="QWidget" name="tabViewer">
567568
<attribute name="title">
568569
<string>Viewer</string>
569570
</attribute>
570571
<layout class="QVBoxLayout" name="_22">
571572
<item>
572-
<layout class="QHBoxLayout" name="_23">
573+
<layout class="QHBoxLayout" name="tabViewerResolution">
573574
<property name="spacing">
574575
<number>0</number>
575576
</property>
@@ -644,7 +645,111 @@ State 2: dirty, in that state the button reflect the fact that the scene graph v
644645
</layout>
645646
</item>
646647
<item>
647-
<widget class="QTextBrowser" name="textEdit1"/>
648+
<layout class="QVBoxLayout" name="tabViewerShowObjectNode">
649+
<item>
650+
<widget class="QGroupBox" name="showNode">
651+
<property name="sizePolicy">
652+
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
653+
<horstretch>0</horstretch>
654+
<verstretch>0</verstretch>
655+
</sizepolicy>
656+
</property>
657+
<property name="title">
658+
<string>Show node</string>
659+
</property>
660+
<layout class="QVBoxLayout" name="verticalLayout_4">
661+
<item>
662+
<layout class="QVBoxLayout" name="verticalLayout_3">
663+
<item>
664+
<widget class="QCheckBox" name="showNodeBoundingBox">
665+
<property name="text">
666+
<string>bounding boxes</string>
667+
</property>
668+
</widget>
669+
</item>
670+
</layout>
671+
</item>
672+
</layout>
673+
</widget>
674+
</item>
675+
<item>
676+
<widget class="QGroupBox" name="showObject">
677+
<property name="sizePolicy">
678+
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
679+
<horstretch>0</horstretch>
680+
<verstretch>0</verstretch>
681+
</sizepolicy>
682+
</property>
683+
<property name="title">
684+
<string>Show object</string>
685+
</property>
686+
<layout class="QVBoxLayout" name="verticalLayout">
687+
<item>
688+
<layout class="QVBoxLayout" name="verticalLayout_2">
689+
<item>
690+
<widget class="QCheckBox" name="showObjectBoundingBox">
691+
<property name="text">
692+
<string>bounding boxes</string>
693+
</property>
694+
</widget>
695+
</item>
696+
<item>
697+
<widget class="QCheckBox" name="showObjectPositions">
698+
<property name="text">
699+
<string>positions</string>
700+
</property>
701+
</widget>
702+
</item>
703+
<item>
704+
<widget class="QCheckBox" name="showObjectSurfaces">
705+
<property name="text">
706+
<string>surfaces</string>
707+
</property>
708+
</widget>
709+
</item>
710+
<item>
711+
<widget class="QCheckBox" name="showObjectVolumes">
712+
<property name="text">
713+
<string>volumes</string>
714+
</property>
715+
</widget>
716+
</item>
717+
<item>
718+
<widget class="QCheckBox" name="showObjectIndices">
719+
<property name="text">
720+
<string>indices</string>
721+
</property>
722+
</widget>
723+
</item>
724+
<item>
725+
<widget class="QWidget" name="renderingScale" native="true">
726+
<layout class="QHBoxLayout" name="horizontalLayout_3">
727+
<item>
728+
<widget class="QLabel" name="label">
729+
<property name="text">
730+
<string>rendering scale</string>
731+
</property>
732+
</widget>
733+
</item>
734+
<item>
735+
<widget class="QDoubleSpinBox" name="value">
736+
<property name="singleStep">
737+
<double>0.100000000000000</double>
738+
</property>
739+
<property name="value">
740+
<double>0.020000000000000</double>
741+
</property>
742+
</widget>
743+
</item>
744+
</layout>
745+
</widget>
746+
</item>
747+
</layout>
748+
</item>
749+
</layout>
750+
</widget>
751+
</item>
752+
</layout>
648753
</item>
649754
</layout>
650755
</widget>
@@ -823,6 +928,11 @@ State 2: dirty, in that state the button reflect the fact that the scene graph v
823928
<string>Data Graph Window</string>
824929
</property>
825930
</action>
931+
<action name="actionViewerShowDocumentation">
932+
<property name="text">
933+
<string>Viewer's shortcuts</string>
934+
</property>
935+
</action>
826936
</widget>
827937
<layoutdefault spacing="2" margin="5"/>
828938
<includes>

src/sofa/qt/QSofaListView.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ QSofaListView::QSofaListView(const SofaListViewAttribute& attribute,
7777

7878
setRootIsDecorated(true);
7979
setIndentation(8);
80-
80+
setSelectionMode(QAbstractItemView::ExtendedSelection);
8181
graphListener_ = new GraphListenerQListView(this);
8282

8383
this->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -300,6 +300,14 @@ void QSofaListView::updateMatchingObjectmodel(QTreeWidgetItem* item, int)
300300
updateMatchingObjectmodel(item);
301301
}
302302

303+
const std::set<Base::SPtr> QSofaListView::getCurrentSelectedBases() const
304+
{
305+
std::set<Base::SPtr> items;
306+
for(auto item : selectedItems())
307+
items.insert(graphListener_->findObject(item));
308+
return items;
309+
}
310+
303311
void QSofaListView::updateMatchingObjectmodel(QTreeWidgetItem* item)
304312
{
305313
BaseData* data = nullptr;

src/sofa/qt/QSofaListView.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class SOFA_QT_API QSofaListView : public SofaSceneGraphWidget
8080
void setPropertyWidget(QDisplayPropertyWidget* propertyWid) {propertyWidget = propertyWid;}
8181
void addInPropertyWidget(QTreeWidgetItem *item, bool clear);
8282

83+
const std::set<core::Base::SPtr> getCurrentSelectedBases() const;
84+
8385
void Clear(sofa::simulation::Node* rootNode);
8486

8587
/// Updates the view so it is synchronized with the simulation graph.

0 commit comments

Comments
 (0)