Skip to content

Commit

Permalink
Re #2: Add opacity slider
Browse files Browse the repository at this point in the history
  • Loading branch information
chriscyyeung committed Sep 14, 2021
1 parent 341d1ad commit d510366
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions MarkupToModel/MarkupToModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def setup(self):
# (in the selected parameter node).
self.ui.inputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.updateParameterNodeFromGUI)
self.ui.outputSelector.connect("currentNodeChanged(vtkMRMLNode*)", self.updateParameterNodeFromGUI)
self.ui.opacitySlider.connect("valueChanged(double)", self.updateParameterNodeFromGUI)

# Buttons
self.ui.applyButton.connect('clicked(bool)', self.onApplyButton)
Expand Down Expand Up @@ -235,6 +236,7 @@ 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._parameterNode.EndModify(wasModified)

Expand Down Expand Up @@ -318,6 +320,7 @@ def process(self, inputMarkups, outputModel):
outputModel.CreateDefaultDisplayNodes()
outputModel.GetDisplayNode().SetSliceIntersectionVisibility(True)
outputModel.GetDisplayNode().SetColor(1, 0, 0)
outputModel.GetDisplayNode().SetOpacity(0.5)
return True

#
Expand Down
37 changes: 35 additions & 2 deletions MarkupToModel/Resources/UI/MarkupToModel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>271</width>
<height>140</height>
<width>270</width>
<height>159</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
Expand Down Expand Up @@ -67,6 +67,29 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Opacity:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="qMRMLSliderWidget" name="opacitySlider">
<property name="singleStep">
<double>0.010000000000000</double>
</property>
<property name="pageStep">
<double>0.100000000000000</double>
</property>
<property name="maximum">
<double>1.000000000000000</double>
</property>
<property name="value">
<double>0.500000000000000</double>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -105,11 +128,21 @@
<header>ctkCollapsibleButton.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ctkSliderWidget</class>
<extends>QWidget</extends>
<header>ctkSliderWidget.h</header>
</customwidget>
<customwidget>
<class>qMRMLNodeComboBox</class>
<extends>QWidget</extends>
<header>qMRMLNodeComboBox.h</header>
</customwidget>
<customwidget>
<class>qMRMLSliderWidget</class>
<extends>ctkSliderWidget</extends>
<header>qMRMLSliderWidget.h</header>
</customwidget>
<customwidget>
<class>qMRMLWidget</class>
<extends>QWidget</extends>
Expand Down
Binary file modified MarkupToModel/__pycache__/MarkupToModel.cpython-36.pyc
Binary file not shown.

0 comments on commit d510366

Please sign in to comment.