Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify home logic #68

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 26 additions & 41 deletions {{cookiecutter.project_name}}/Modules/Scripted/Home/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,22 @@ def setup(self):
self.layout.addWidget(self.uiWidget)
self.ui = slicer.util.childWidgetVariables(self.uiWidget)

# Remove unneeded UI elements
self.modifyWindowUI()
# Get references to relevant underlying modules
# NA

# Create logic class
self.logic = HomeLogic()

# Setup scene defaults
self.setupNodes()

# Dark palette does not propagate on its own?
self.uiWidget.setPalette(slicer.util.mainWindow().style().standardPalette())

# Remove unneeded UI elements
self.modifyWindowUI()
self.setCustomUIVisible(True)

# Apply style
self.applyApplicationStyle()

def setupNodes(self):
self.logic.setup3DView()
self.logic.setupSliceViewers()

def cleanup(self):
"""Called when the application closes and the module widget is destroyed."""
pass
Expand Down Expand Up @@ -122,44 +117,34 @@ def setCustomUIVisible(self, visible: bool):

def applyApplicationStyle(self):
SlicerCustomAppUtilities.applyStyle([slicer.app], self.resourcePath("Home.qss"))


class HomeLogic(ScriptedLoadableModuleLogic):
"""This class should implement all the actual
computation done by your module. The interface
should be such that other python code can import
this class and make use of the functionality without
requiring an instance of the Widget.
Uses ScriptedLoadableModuleLogic base class, available at:
https://github.com/Slicer/Slicer/blob/main/Base/Python/slicer/ScriptedLoadableModule.py
"""

def run(self, inputVolume, outputVolume, imageThreshold, enableScreenshots=0): # noqa: ANN001
"""
Run the actual algorithm
"""
pass

def setup3DView(self):
layoutManager = slicer.app.layoutManager() # noqa: F841
# layoutManager.setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutOneUp3DView)
# controller = slicer.app.layoutManager().threeDWidget(0).threeDController()
# controller.setBlackBackground()
# controller.set3DAxisVisible(False)
# controller.set3DAxisLabelVisible(False)
# controller.setOrientationMarkerType(3) # Axis marker
# controller.setStyleSheet("background-color: #000000")

def setupSliceViewers(self):
self.styleThreeDWidget()
self.styleSliceWidgets()

def styleThreeDWidget(self):
viewNode = slicer.app.layoutManager().threeDWidget(0).mrmlViewNode() # noqa: F841
# viewNode.SetBackgroundColor(0.0, 0.0, 0.0)
# viewNode.SetBackgroundColor2(0.0, 0.0, 0.0)
# viewNode.SetBoxVisible(False)
# viewNode.SetAxisLabelsVisible(False)
# viewNode.SetOrientationMarkerType(slicer.vtkMRMLViewNode.OrientationMarkerTypeAxes)

def styleSliceWidgets(self):
for name in slicer.app.layoutManager().sliceViewNames():
sliceWidget = slicer.app.layoutManager().sliceWidget(name)
self.setupSliceViewer(sliceWidget)
self.styleSliceWidget(sliceWidget)

def setupSliceViewer(self, sliceWidget: slicer.qMRMLSliceWidget):
def styleSliceWidget(self, sliceWidget: slicer.qMRMLSliceWidget):
controller = sliceWidget.sliceController() # noqa: F841
# controller.setStyleSheet("background-color: #000000")
# controller.sliceViewLabel = ""
# slicer.util.findChild(sliceWidget, "PinButton").visible = False
# slicer.util.findChild(sliceWidget, "ViewLabel").visible = False
# slicer.util.findChild(sliceWidget, "FitToWindowToolButton").visible = False
# slicer.util.findChild(sliceWidget, "SliceOffsetSlider").spinBoxVisible = False


class HomeLogic(ScriptedLoadableModuleLogic):
"""
Implements underlying logic for the Home module.
"""

pass
Loading