Skip to content

Commit

Permalink
ENH: make device widgets for position, deformation and quantification…
Browse files Browse the repository at this point in the history
… optional

Deformation widget caused slice views to reslice whenever device position is changed

ref: JolleyLab/SlicerHeartPrivate#222
  • Loading branch information
che85 committed Dec 24, 2020
1 parent dd00a0e commit 69b0ece
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 38 deletions.
24 changes: 6 additions & 18 deletions AsdVsdDeviceSimulator/AsdVsdDeviceSimulator.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,9 @@
import os
import qt
import logging
import vtk
import ctk

import slicer
from slicer.ScriptedLoadableModule import *

from CardiacDeviceSimulator import CardiacDeviceSimulatorWidget
#from CardiacDeviceSimulator import CardiacDeviceSimulatorLogic

#from CardiacDeviceSimulatorUtils.widgethelper import UIHelper
#from CardiacDeviceSimulatorUtils.DeviceCompressionQuantificationWidget import DeviceCompressionQuantificationWidget
#from CardiacDeviceSimulatorUtils.DeviceDataTreeWidget import DeviceDataTreeWidget
#from CardiacDeviceSimulatorUtils.DeviceDeformationWidget import DeviceDeformationWidget
#from CardiacDeviceSimulatorUtils.DevicePositioningWidget import DevicePositioningWidget
#from CardiacDeviceSimulatorUtils.DeviceSelectorWidget import DeviceSelectorWidget

from AsdVsdDevices.devices import *


Expand All @@ -30,7 +17,7 @@ class AsdVsdDeviceSimulator(ScriptedLoadableModule):
"""

deviceClasses = [SeptalOccluder, MultiFenestratedSeptalOccluder,
DuctOccluder, DuctOccluderII, MuscularVSDOccluder, CustomDevice]
DuctOccluder, DuctOccluderII, MuscularVSDOccluder, CustomDevice]

def __init__(self, parent):
ScriptedLoadableModule.__init__(self, parent)
Expand Down Expand Up @@ -61,6 +48,10 @@ class AsdVsdDeviceSimulatorWidget(CardiacDeviceSimulatorWidget):
https://github.com/Slicer/Slicer/blob/master/Base/Python/slicer/ScriptedLoadableModule.py
"""

DEVICE_POSITIONING_NEEDED = True
DEVICE_DEFORMATION_NEEDED = False
DEVICE_QUANTIFICATION_NEEDED = False

def __init__(self, parent=None, deviceClasses=None):
CardiacDeviceSimulatorWidget.__init__(self, parent, AsdVsdDeviceSimulator.deviceClasses)
self.logic.moduleName = "AsdVsdDeviceSimulator"
Expand All @@ -75,7 +66,4 @@ def setup(self):
self.devicePositioningWidget.centerlineGroupBox.hide()
# Expand translate and rotate sections
self.devicePositioningWidget.devicePositioningPositionSliderWidget.findChildren(ctk.ctkCollapsibleGroupBox)[0].setChecked(True)
self.devicePositioningWidget.devicePositioningOrientationSliderWidget.findChildren(ctk.ctkCollapsibleGroupBox)[0].setChecked(True)

self.deviceDeformationSection.hide()
self.quantificationSection.hide()
self.devicePositioningWidget.devicePositioningOrientationSliderWidget.findChildren(ctk.ctkCollapsibleGroupBox)[0].setChecked(True)
50 changes: 31 additions & 19 deletions CardiacDeviceSimulator/CardiacDeviceSimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ class CardiacDeviceSimulatorWidget(ScriptedLoadableModuleWidget):

registeredDeviceClasses = []

DEVICE_POSITIONING_NEEDED = True
DEVICE_DEFORMATION_NEEDED = True
DEVICE_QUANTIFICATION_NEEDED = True

@staticmethod
def registerDevice(deviceClass):
"""Register a subclass of CardiacDeviceBase for additional measurements cardiac device models"""
Expand Down Expand Up @@ -96,25 +100,35 @@ def setup(self):
self.parameterNodeSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.onParameterNodeSelectionChanged)

self.deviceSelectorWidget = DeviceSelectorWidget(self.deviceClasses)
[lay, self.deviceSelectionSection] = UIHelper.addCommonSection("Device Selection", self.layout, self.moduleSectionButtonsGroup,
_, self.deviceSelectionSection = UIHelper.addCommonSection("Device Selection", self.layout, self.moduleSectionButtonsGroup,
collapsed=False, widget=self.deviceSelectorWidget)

self.devicePositioningWidget = DevicePositioningWidget()
[lay, self.devicePositioningSection] = UIHelper.addCommonSection("Device Positioning", self.layout, self.moduleSectionButtonsGroup,
collapsed=True, widget=self.devicePositioningWidget)

self.deviceDeformationWidget = DeviceDeformationWidget()
[lay, self.deviceDeformationSection] = UIHelper.addCommonSection("Device Deformation", self.layout, self.moduleSectionButtonsGroup,
collapsed=True, widget=self.deviceDeformationWidget)

self.deviceQuantificationWidget = DeviceCompressionQuantificationWidget()
[lay, self.quantificationSection] = UIHelper.addCommonSection("Quantification", self.layout, self.moduleSectionButtonsGroup,
collapsed=True, widget=self.deviceQuantificationWidget)
self.deviceWidgets = [self.deviceSelectorWidget]

self.devicePositioningSection = None
if self.DEVICE_POSITIONING_NEEDED:
self.devicePositioningWidget = DevicePositioningWidget()
_, self.devicePositioningSection = UIHelper.addCommonSection("Device Positioning", self.layout, self.moduleSectionButtonsGroup,
collapsed=True, widget=self.devicePositioningWidget)
self.deviceWidgets.append(self.devicePositioningWidget)

self.deviceDeformationSection = None
if self.DEVICE_DEFORMATION_NEEDED:
self.deviceDeformationWidget = DeviceDeformationWidget()
_, self.deviceDeformationSection = UIHelper.addCommonSection("Device Deformation", self.layout, self.moduleSectionButtonsGroup,
collapsed=True, widget=self.deviceDeformationWidget)
self.deviceWidgets.append(self.deviceDeformationWidget)

self.quantificationSection = None
if self.DEVICE_QUANTIFICATION_NEEDED:
self.deviceQuantificationWidget = DeviceCompressionQuantificationWidget()
_, self.quantificationSection = UIHelper.addCommonSection("Quantification", self.layout, self.moduleSectionButtonsGroup,
collapsed=True, widget=self.deviceQuantificationWidget)
self.deviceWidgets.append(self.deviceQuantificationWidget)

self.dataTreeWidget = DeviceDataTreeWidget()
self.layout.addWidget(self.dataTreeWidget)

self.deviceWidgets = [self.deviceSelectorWidget, self.devicePositioningWidget, self.deviceDeformationWidget, self.deviceQuantificationWidget, self.dataTreeWidget]
self.deviceWidgets.append(self.dataTreeWidget)

for deviceWidget in self.deviceWidgets:
deviceWidget.setLogic(self.logic)
Expand Down Expand Up @@ -147,7 +161,9 @@ def onParameterNodeSelectionChanged(self):
def updateButtonStates(self):
guiEnabled = self.logic.parameterNode is not None
# self.deviceSelectionSection is always enabled, it creates a parameter node
for guiSection in [self.devicePositioningSection, self.deviceDeformationSection, self.quantificationSection]:
for guiSection in self.deviceWidgets:
if guiSection is self.deviceSelectorWidget:
continue
guiSection.enabled = guiEnabled

def onModuleSectionToggled(self, button, toggled):
Expand Down Expand Up @@ -175,10 +191,6 @@ def onModuleSectionToggled(self, button, toggled):
self.logic.setCenterlineEditingEnabled(button == self.devicePositioningSection)
self.logic.showDeformationHandles(button == self.deviceDeformationSection)

if self.quantificationSection.checked:
# TODO: hide the expanding spacer if quantification section is open
pass


#
# CardiacDeviceSimulatorLogic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def __init__(self, parent=None):
('vtkMRMLSliceNodeGreen', resliceLogic.MODE_CORONAL),
('vtkMRMLSliceNodeYellow', resliceLogic.MODE_SAGITTAL)]


def setup(self):
self.setLayout(qt.QFormLayout())

Expand Down

0 comments on commit 69b0ece

Please sign in to comment.