From 767f93298a7b7a073529828029827792ceaca044 Mon Sep 17 00:00:00 2001 From: Andras Lasso Date: Wed, 14 Sep 2022 16:29:01 -0400 Subject: [PATCH] Update to use markups ROI instead of annotations ROI Annotations module will be removed in Slicer-5.3 --- .../ZFrameRegistrationWithROI.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/ZFrameRegistrationWithROI/ZFrameRegistrationWithROI.py b/ZFrameRegistrationWithROI/ZFrameRegistrationWithROI.py index 99bb6fe..31ce646 100644 --- a/ZFrameRegistrationWithROI/ZFrameRegistrationWithROI.py +++ b/ZFrameRegistrationWithROI/ZFrameRegistrationWithROI.py @@ -90,7 +90,6 @@ def setup(self): ScriptedLoadableModuleWidget.setup(self) self.logic = ZFrameRegistrationWithROILogic() self.setupSliceWidgets() - self.annotationLogic = slicer.modules.annotations.logic() self.zFrameRegistrationClass = OpenSourceZFrameRegistration self.roiObserverTag = None self.coverTemplateROI = None @@ -193,7 +192,7 @@ def addROIObserver(self): @vtk.calldata_type(vtk.VTK_OBJECT) def onNodeAdded(caller, event, calldata): node = calldata - if isinstance(node, slicer.vtkMRMLAnnotationROINode): + if isinstance(node, slicer.vtkMRMLMarkupsROINode): self.removeROIObserver() self.coverTemplateROI = node self.runZFrameRegistrationButton.enabled = self.isRegistrationPossible() @@ -210,13 +209,12 @@ def removeROIObserver(self): self.roiObserverTag = slicer.mrmlScene.RemoveObserver(self.roiObserverTag) def setROIMode(self, mode): - mrmlScene = self.annotationLogic.GetMRMLScene() - selectionNode = mrmlScene.GetNthNodeByClass(0, "vtkMRMLSelectionNode") - selectionNode.SetReferenceActivePlaceNodeClassName("vtkMRMLAnnotationROINode") + selectionNode = slicer.mrmlScene.GetNthNodeByClass(0, "vtkMRMLSelectionNode") + selectionNode.SetReferenceActivePlaceNodeClassName("vtkMRMLMarkupsROINode") if mode == False: - self.annotationLogic.StopPlaceMode(False) + slicer.mrmlScene.GetNodeByID("vtkMRMLInteractionNodeSingleton").SwitchToViewTransformMode() # stop place mode else: - self.annotationLogic.StartPlaceMode(False) + slicer.modules.markups.logic().StartPlaceMode(False) def onApplyZFrameRegistrationButtonClicked(self): self.retryZFrameRegistrationButton.enabled = True @@ -440,7 +438,7 @@ def test_ZFrameRegistrationWithROI1(self): self.delayDisplay('Finished with loading') zFrameRegistrationLogic = ZFrameRegistrationWithROILogic() - ROINode = slicer.vtkMRMLAnnotationROINode() + ROINode = slicer.vtkMRMLMarkupsROINode() ROINode.SetName("ROINodeForCropping") ROICenterPoint = [-6.91920280456543, 15.245062828063965, -101.13504791259766] ROINode.SetXYZ(ROICenterPoint) @@ -545,4 +543,4 @@ def onSplitterClick(self): print(sys.argv) - slicelet = ZFrameRegistrationWithROISlicelet() + slicelet = ZFrameRegistrationWithROISlicelet()