diff --git a/MarkupToModel/MarkupToModel.py b/MarkupToModel/MarkupToModel.py
index 74b8e61..1ed8150 100644
--- a/MarkupToModel/MarkupToModel.py
+++ b/MarkupToModel/MarkupToModel.py
@@ -135,6 +135,10 @@ def setup(self):
self.ui.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.updateParameterNodeFromGUI)
self.ui.opacitySlider.connect("valueChanged(double)", self.updateParameterNodeFromGUI)
+ self.observedMarkupNode = None
+ self.markupsObserverTag = None
+ self.ui.autoUpdateCheckBox.connect("toggled(bool)", self.onEnableAutoUpdate)
+
# Buttons
self.ui.applyButton.connect('clicked(bool)', self.onApplyButton)
@@ -236,10 +240,24 @@ def updateParameterNodeFromGUI(self, caller=None, event=None):
self._parameterNode.SetNodeReferenceID("InputVolume", self.ui.inputSelector.currentNodeID)
self._parameterNode.SetNodeReferenceID("OutputVolume", self.ui.outputSelector.currentNodeID)
- self.ui.outputSelector.currentNode().GetDisplayNode().SetOpacity(self.ui.opacitySlider.value) #TODO: bugged
+ self.ui.outputSelector.currentNode().GetDisplayNode().SetOpacity(self.ui.opacitySlider.value)
self._parameterNode.EndModify(wasModified)
+ def onEnableAutoUpdate(self, autoUpdate):
+ if self.markupsObserverTag:
+ self.observedMarkupNode.RemoveObserver(self.markupsObserverTag)
+ self.observedMarkupNode = None
+ self.markupsObserverTag = None
+ if autoUpdate and self.ui.inputSelector.currentNode:
+ self.observedMarkupNode = self.ui.inputSelector.currentNode()
+ self.markupsObserverTag = self.observedMarkupNode.AddObserver(
+ slicer.vtkMRMLMarkupsNode.PointModifiedEvent, self.onMarkupsUpdated
+ )
+
+ def onMarkupsUpdated(self, caller=None, event=None):
+ self.onApplyButton()
+
def onApplyButton(self):
"""
Run processing when user clicks "Apply" button.
diff --git a/MarkupToModel/Resources/UI/MarkupToModel.ui b/MarkupToModel/Resources/UI/MarkupToModel.ui
index 91a3c6b..6488039 100644
--- a/MarkupToModel/Resources/UI/MarkupToModel.ui
+++ b/MarkupToModel/Resources/UI/MarkupToModel.ui
@@ -6,8 +6,8 @@
0
0
- 270
- 159
+ 274
+ 191
@@ -67,14 +67,14 @@
- -
+
-
Opacity:
- -
+
-
0.010000000000000
@@ -90,6 +90,20 @@
+ -
+
+
+ Enable auto-udpate
+
+
+
+ -
+
+
+
+
+
+
diff --git a/MarkupToModel/__pycache__/MarkupToModel.cpython-36.pyc b/MarkupToModel/__pycache__/MarkupToModel.cpython-36.pyc
index d740ba3..bda12e3 100644
Binary files a/MarkupToModel/__pycache__/MarkupToModel.cpython-36.pyc and b/MarkupToModel/__pycache__/MarkupToModel.cpython-36.pyc differ