Skip to content

Commit

Permalink
ENH: add icons to control visibility of planning objects
Browse files Browse the repository at this point in the history
Related #150
mauigna06 committed Oct 6, 2024
1 parent 3aba373 commit 469e9ed
Showing 4 changed files with 122 additions and 31 deletions.
88 changes: 62 additions & 26 deletions BoneReconstructionPlanner/BoneReconstructionPlanner.py
Original file line number Diff line number Diff line change
@@ -260,6 +260,16 @@ def setup(self):
lockIconPath = os.path.join(os.path.dirname(__file__), 'Resources/Icons/lock_48.svg')
self.ui.lockVSPButton.setIcon(qt.QIcon(lockIconPath))

visibilityIconPath = os.path.join(os.path.dirname(__file__), 'Resources/Icons/visibility_48.svg')
self.ui.showMandiblePlanesToolButton.setIcon(qt.QIcon(visibilityIconPath))
self.ui.showMandiblePlanesToolButton.setIconSize(qt.QSize(24,24))
self.ui.showMandiblePlanesToolButton.setMinimumSize(24,24)

axesIconPath = os.path.join(os.path.dirname(__file__), 'Resources/Icons/axes.svg')
self.ui.showMandiblePlanesInteractionHandlesToolButton.setIcon(qt.QIcon(axesIconPath))
self.ui.showMandiblePlanesInteractionHandlesToolButton.setIconSize(qt.QSize(24,24))
self.ui.showMandiblePlanesInteractionHandlesToolButton.setMinimumSize(24,24)

booleanOperationsIconPath = os.path.join(os.path.dirname(__file__), 'Resources/Icons/construction_48.svg')
self.ui.create3DModelOfTheReconstructionButton.setIcon(qt.QIcon(booleanOperationsIconPath))
self.ui.makeBooleanOperationsToFibulaSurgicalGuideBaseButton.setIcon(qt.QIcon(booleanOperationsIconPath))
@@ -366,8 +376,8 @@ def setup(self):
self.ui.showFibulaSegmentsLengthsCheckBox.connect('stateChanged(int)', self.updateParameterNodeFromGUI)
self.ui.showOriginalMandibleCheckBox.connect('stateChanged(int)', self.updateParameterNodeFromGUI)
self.ui.showBiggerSawBoxesInteractionHandlesCheckBox.connect('stateChanged(int)', self.updateParameterNodeFromGUI)
self.ui.showMandiblePlanesInteractionHandlesCheckBox.connect('stateChanged(int)', self.onShowMandiblePlanesInteractionHandlesCheckBox)
self.ui.showMandiblePlanesInteractionHandlesCheckBox_2.connect('stateChanged(int)', self.onShowMandiblePlanesInteractionHandlesCheckBox)
self.ui.showMandiblePlanesToolButton.connect('clicked(bool)', self.updateParameterNodeFromGUI)
self.ui.showMandiblePlanesInteractionHandlesToolButton.connect('clicked(bool)', self.updateParameterNodeFromGUI)
self.ui.orientation3DCubeCheckBox.connect('stateChanged(int)', self.onOrientation3DCubeCheckBox)
self.ui.lightsRenderingComboBox.textActivated.connect(self.onLightsRenderingComboBox)

@@ -674,29 +684,46 @@ def updateGUIFromParameterNode(self, caller=None, event=None):
else:
self.ui.customTitaniumPlateGenerationCollapsibleButton.hide()


lockVSPChecked = self._parameterNode.GetParameter("lockVSP") == "True"

showMandiblePlanesChecked = self._parameterNode.GetParameter("showMandiblePlanes") == "True"
self.ui.showMandiblePlanesToolButton.checked = showMandiblePlanesChecked
self.setMandiblePlanesVisibility(showMandiblePlanesChecked)

showMandiblePlanesInteractionHandlesChecked = self._parameterNode.GetParameter("showMandiblePlanesInteractionHandles") == "True"
showMandiblePlanesInteractionHandles = (
showMandiblePlanesChecked and showMandiblePlanesInteractionHandlesChecked and
(not lockVSPChecked)
)
self.ui.showMandiblePlanesInteractionHandlesToolButton.checked = (
showMandiblePlanesInteractionHandles
)
self.setMandiblePlanesInteractionHandlesVisibility(showMandiblePlanesInteractionHandles)
self.ui.showMandiblePlanesInteractionHandlesToolButton.enabled = (
showMandiblePlanesChecked and
(not lockVSPChecked)
)


shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
mandibularPlanesFolder = shNode.GetItemByName("Mandibular planes")
mandibularPlanesList = createListFromFolderID(mandibularPlanesFolder)
if self._parameterNode.GetParameter("lockVSP") == "True":
self.logic.setInteractiveHandlesVisibilityOfMarkups(
mandibularPlanesList,
visibility=False
)
self.logic.setMarkupsListLocked(mandibularPlanesList,locked=True)
fibulaLine = self._parameterNode.GetNodeReference("fibulaLine")
mandibularCurve = self._parameterNode.GetNodeReference("mandibleCurve")
planningObjectsList = mandibularPlanesList + [fibulaLine,mandibularCurve]
if lockVSPChecked:
self.setMandiblePlanesVisibility(showMandiblePlanesChecked)
self.logic.setMarkupsListLocked(planningObjectsList,locked=True)
self.logic.removeMandiblePlaneObservers()
#
self.ui.lockVSPButton.checked = True
self.ui.parametersOfVSPFrame.enabled = False
self.ui.updateVSPButtonsFrame.enabled = False
self.ui.create3DModelOfTheReconstructionButton.enabled = False

else:
self.logic.setInteractiveHandlesVisibilityOfMarkups(
mandibularPlanesList,
visibility=True
)
self.logic.setMarkupsListLocked(mandibularPlanesList,locked=False)
#self.setMandiblePlanesVisibility(True)
self.logic.setMarkupsListLocked(planningObjectsList,locked=False)
self.logic.removeMandiblePlaneObservers() # in case they already exist
self.logic.addMandiblePlaneObservers()
#
@@ -728,11 +755,6 @@ def updateGUIFromParameterNode(self, caller=None, event=None):
self.ui.showBiggerSawBoxesInteractionHandlesCheckBox.checked = showBiggerSawBoxesInteractionHandlesChecked
self.setBiggerSawBoxesInteractionHandlesVisibility(showBiggerSawBoxesInteractionHandlesChecked)

showMandiblePlanesInteractionHandlesChecked = self._parameterNode.GetParameter("showMandiblePlanesInteractionHandles") == "True"
self.ui.showMandiblePlanesInteractionHandlesCheckBox.checked = showMandiblePlanesInteractionHandlesChecked
self.ui.showMandiblePlanesInteractionHandlesCheckBox_2.checked = showMandiblePlanesInteractionHandlesChecked
self.setMandiblePlanesInteractionHandlesVisibility(showMandiblePlanesInteractionHandlesChecked)

# All the GUI updates are done
self._updatingGUIFromParameterNode = False

@@ -819,6 +841,14 @@ def updateParameterNodeFromGUI(self, caller=None, event=None):
self._parameterNode.SetParameter("useNonDecimatedBoneModelsForPreview","True")
else:
self._parameterNode.SetParameter("useNonDecimatedBoneModelsForPreview","False")
if self.ui.showMandiblePlanesToolButton.checked:
self._parameterNode.SetParameter("showMandiblePlanes","True")
else:
self._parameterNode.SetParameter("showMandiblePlanes","False")
if self.ui.showMandiblePlanesInteractionHandlesToolButton.checked:
self._parameterNode.SetParameter("showMandiblePlanesInteractionHandles","True")
else:
self._parameterNode.SetParameter("showMandiblePlanesInteractionHandles","False")
if self.ui.checkSecurityMarginOnMiterBoxCreationCheckBox.checked:
self._parameterNode.SetParameter("checkSecurityMarginOnMiterBoxCreation","True")
else:
@@ -859,12 +889,6 @@ def updateParameterNodeFromGUI(self, caller=None, event=None):

self._parameterNode.EndModify(wasModified)

def onShowMandiblePlanesInteractionHandlesCheckBox(self, checked):
if checked:
self._parameterNode.SetParameter("showMandiblePlanesInteractionHandles", "True")
else:
self._parameterNode.SetParameter("showMandiblePlanesInteractionHandles", "False")

def onLightsRenderingComboBox(self, text):
lightsLogic = slicer.modules.lights.widgetRepresentation().self().logic
viewNodesList = slicer.util.getNodesByClass("vtkMRMLViewNode")
@@ -972,6 +996,15 @@ def setBiggerSawBoxesInteractionHandlesVisibility(self, visibility):
displayNode = sawBoxesPlanesList[i].GetDisplayNode()
displayNode.SetHandlesInteractive(visibility)

def setMandiblePlanesVisibility(self, visibility):
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
mandibularPlanesFolder = shNode.GetItemByName("Mandibular planes")
mandibularPlanesList = createListFromFolderID(mandibularPlanesFolder)

for i in range(len(mandibularPlanesList)):
displayNode = mandibularPlanesList[i].GetDisplayNode()
displayNode.SetVisibility(visibility)

def setMandiblePlanesInteractionHandlesVisibility(self, visibility):
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
mandibularPlanesFolder = shNode.GetItemByName("Mandibular planes")
@@ -1073,6 +1106,8 @@ def setDefaultParameters(self, parameterNode):
parameterNode.SetParameter("showOriginalMandible","False")
if not parameterNode.GetParameter("showBiggerSawBoxesInteractionHandles"):
parameterNode.SetParameter("showBiggerSawBoxesInteractionHandles","False")
if not parameterNode.GetParameter("showMandiblePlanes"):
parameterNode.SetParameter("showMandiblePlanes","True")
if not parameterNode.GetParameter("showMandiblePlanesInteractionHandles"):
parameterNode.SetParameter("showMandiblePlanesInteractionHandles","True")
if not parameterNode.GetParameter("lockVSP"):
@@ -1404,7 +1439,8 @@ def setInteractiveHandlesVisibilityOfMarkups(self,markupsList,visibility):

def setMarkupsListLocked(self,markupsList,locked):
for i in range(len(markupsList)):
markupsList[i].SetLocked(locked)
if markupsList[i] is not None:
markupsList[i].SetLocked(locked)

def addMandiblePlaneObservers(self):
shNode = slicer.vtkMRMLSubjectHierarchyNode.GetSubjectHierarchyNode(slicer.mrmlScene)
2 changes: 2 additions & 0 deletions BoneReconstructionPlanner/Resources/Icons/axes.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>686</width>
<height>3625</height>
<height>3456</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
@@ -574,11 +574,63 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QCheckBox" name="showMandiblePlanesInteractionHandlesCheckBox">
<property name="text">
<string>Show mandible planes interaction handles</string>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<property name="sizeConstraint">
<enum>QLayout::SetMaximumSize</enum>
</property>
</widget>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_47">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Mandible planes</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="showMandiblePlanesToolButton">
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="showMandiblePlanesInteractionHandlesToolButton">
<property name="text">
<string/>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="showOriginalMandibleCheckBox">

0 comments on commit 469e9ed

Please sign in to comment.