SlicerQR Development

I’m not sure what you mean by “intersection planes view”. You can show/hide slice planes and change volume rendering settings.

You can add keyboard shortcut at Qt level or add an observer to the keypress event to each 3D viewer’s interactor (you can search for vtk.vtkCommand.KeyPressEvent for examples; or use a scripted displayable manager to capture keyboard events).

@lassoan Oh, ok. Then I should ask, how do I show/hide the slice planes with Python commands.

Then how do I set the renderings to nothing.

Thanks

I think you are looking for the following: Show slice views in 3D window

@jamesobutler, @lassoan, @pieper

Thanks @jamesobutler,

That works. I appreciate that. Now I can display the renderings without the slice planes. Great!

How do I clear out the renderings to switch to another rendering? I can switch from the opacity rendering to the MIP, but not from the MIP to any other rendering. I think if I can reset or clear the MIP first, it might work. How do I clear out the rendering?

Thanks

You can choose a different rendering preset and set rendering technique to slicer.vtkMRMLViewNode.Composite.

@jcfr

Hello JC, I’m seeing that I can’t set the 3D view to display MIPS or 3D rendering with the SlicerQREADS build. But when I run the SlicerQREADS module inside of the Slicer app, I can perform the 3D render with my Python changes. Did you remove this capability from SlicerQREADS?

Thanks

Did you remove this capability from SlicerQREADS?

Since MIP was not part of the requirements, the VolumeRendering module providing the functionality has been disabled:

@lasson, thanks you so much that worked! :slight_smile:

1 Like

@jcfr

Hello JC, I’m looking to remove slice planes rendering in the 3D view because I want to replace it with a surface render. How can I clear that out?

Thanks.

@spycolyf I believe you are looking for the following example in the Slicer Script repository titled Show slice views in 3D window. You had posted previously an image (seen below) which was detailing volume rendering being shown at the same time as Slice views showing in the 3D View.
image.

@lassoan

Could you extract from 1/159 to 43/159 of this topic to a new topic, “Slicer Module Local Installation Footprint” (for want of a much better name)?

Thanks.

Done. The new topic is here:

@jcfr @pieper @lassoan

Hello JC,

Whenever the user zooms and pans, and then pushes the EnableWLButton to window/level, the zoom and pan resets forcing the user to zoom and pan all over again. The code that causes this is…

self._parameterNode.SetParameter("WindowLevelEnabled", "true" if self.ui.EnableWLButton.checked else "false")

How do I use the WL widget without resetting the zoom and pan?

Thanks

This doesn’t happen in regular slicer so it must be something to do with your customizations not handling the end of the pan/zoom interactions.

Yes, that;s true. Slicer does not have this issue. However @jcfr implements many if the UI actions using the self._parameterNode.SetParameter function and each of them reset my views, Here are all of those features that use the self._parameterNode.SetParameter function, each resetting my views…

    self._parameterNode.SetParameter("ReferenceMarkersVisible", "true" if self.ui.ShowReferenceMarkersButton.checked else "false")
    self._parameterNode.SetParameter("SlabEnabled", "true" if slabEnabled else "false")
    self._parameterNode.SetParameter("SlabMode", QReadsLogic.slabModeToString(self.slabModeButtonGroup.checkedId()))
    self._parameterNode.SetParameter("SlabThicknessInMm", str(self.ui.SlabThicknessSliderWidget.value))
    self._parameterNode.SetParameter("InverseGray", "true" if self.ui.InverseGrayButton.checked else "false")
    self._parameterNode.SetParameter("Zoom", self.ui.ZoomComboBox.currentText)
    self._parameterNode.SetParameter("OrientationMarkerType",
      str(slicer.util.getNodesByClass('vtkMRMLAbstractViewNode')[0].GetOrientationMarkerType()))
    self._parameterNode.SetParameter("RulerVisible", "true" if self.ui.RulerVisibleButton.checked else "false")
    self._parameterNode.SetParameter("OrientationMarkerType", str(nextOrientationMarkerType))

OK, might have something to do with this…

def setParameterNode(self, inputParameterNode):
    """
    Set and observe parameter node.
    Observation is needed because when the parameter node is changed then the GUI must be updated immediately.
    """
    if inputParameterNode:
      self.logic.setDefaultParameters(inputParameterNode)

    # Unobserve previously selected parameter node and add an observer to the newly selected.
    # Changes of parameter node are observed so that whenever parameters are changed by a script or any other module
    # those are reflected immediately in the GUI.
    if self._parameterNode is not None:
      self.removeObserver(self._parameterNode, vtk.vtkCommand.ModifiedEvent, self.updateGUIFromParameterNode)
    self._parameterNode = inputParameterNode
    if self._parameterNode is not None:
      self.addObserver(self._parameterNode, vtk.vtkCommand.ModifiedEvent, self.updateGUIFromParameterNode)

    # Initial GUI update
    self.updateGUIFromParameterNode()

@jcfr, is there a way to, for instance, enable he window/level widget without resetting the views?

Thanks

Hi Doug, I looked at the code here:

This two functions or calls may have something to do with the causes of view-reset you are looking for:

centerSlice
sliceLogic.FitSliceToAll()

I started looking for keywords in code as reset and found that. I also looked for ‘sliceLogic’ mentions as it may be related to the cause of your problem.

Hope this helps

OK, thanks @mau_igna_06, I’ll have a look at that. But since only self._parameterNode.SetParameter calls cause this slice view reset behavior, I’m suspecting it’s the setParameterNode function causing it.

Have a look…

Each of the following calls reset the views…

    self._parameterNode.SetParameter("ReferenceMarkersVisible", "true" if self.ui.ShowReferenceMarkersButton.checked else "false")
    self._parameterNode.SetParameter("SlabEnabled", "true" if slabEnabled else "false")
    self._parameterNode.SetParameter("SlabMode", QReadsLogic.slabModeToString(self.slabModeButtonGroup.checkedId()))
    self._parameterNode.SetParameter("SlabThicknessInMm", str(self.ui.SlabThicknessSliderWidget.value))
    self._parameterNode.SetParameter("InverseGray", "true" if self.ui.InverseGrayButton.checked else "false")
    self._parameterNode.SetParameter("Zoom", self.ui.ZoomComboBox.currentText)
    self._parameterNode.SetParameter("OrientationMarkerType",
      str(slicer.util.getNodesByClass('vtkMRMLAbstractViewNode')[0].GetOrientationMarkerType()))
    self._parameterNode.SetParameter("RulerVisible", "true" if self.ui.RulerVisibleButton.checked else "false")
    self._parameterNode.SetParameter("OrientationMarkerType", str(nextOrientationMarkerType))

Do you think the following function is the culprit? It does a removeObserver followed by an add observer

def setParameterNode(self, inputParameterNode):
    """
    Set and observe parameter node.
    Observation is needed because when the parameter node is changed then the GUI must be updated immediately.
    """
    if inputParameterNode:
      self.logic.setDefaultParameters(inputParameterNode)

    # Unobserve previously selected parameter node and add an observer to the newly selected.
    # Changes of parameter node are observed so that whenever parameters are changed by a script or any other module
    # those are reflected immediately in the GUI.
    if self._parameterNode is not None:
      self.removeObserver(self._parameterNode, vtk.vtkCommand.ModifiedEvent, self.updateGUIFromParameterNode)
    self._parameterNode = inputParameterNode
    if self._parameterNode is not None:
      self.addObserver(self._parameterNode, vtk.vtkCommand.ModifiedEvent, self.updateGUIFromParameterNode)

    # Initial GUI update
    self.updateGUIFromParameterNode()