Skip to content

Commit

Permalink
add max opacity control as spinbox
Browse files Browse the repository at this point in the history
  • Loading branch information
paskino committed Sep 25, 2024
1 parent 1865cdb commit 7cfe7bb
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Wrappers/Python/ccpi/viewer/ui/VolumeRenderSettingsDialog.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from eqt.ui import FormDialog, UISliderWidget
from PySide2 import QtCore, QtWidgets
from PySide2 import QtCore, QtWidgets, QtGui

from ccpi.viewer.ui.helpers import color_scheme_list

Expand Down Expand Up @@ -56,6 +56,11 @@ def __init__(self, parent=None, title=None, scale_factor=1):
self.addWidget(color_range_slider_max, "Color range max", "color_range_slider_max")
self.addWidget(color_range_label_max, "", "color_range_label_max")

# Max opacity
max_opacity_label = QtWidgets.QLabel("Max opacity")
max_opacity_input = QtWidgets.QDoubleSpinBox(self.groupBox)
self.addWidget(max_opacity_input, max_opacity_label, "max_opacity_input")

# Disable 3D related widgets if volume visibility is not checked
volume_visibility_checked = self.getWidget("volume_visibility").isChecked()
self.getWidget("opacity_mapping").setEnabled(volume_visibility_checked)
Expand Down Expand Up @@ -110,6 +115,12 @@ def set_viewer(self, viewer):
self.getWidget("windowing_slider_max").setValue(99 * self.scale_factor)
self.getWidget("windowing_slider_max").sliderReleased.connect(self.change_volume_opacity_max)

# MaxOpacity slider max
self.getWidget("max_opacity_input").setRange(0,1)
self.getWidget("max_opacity_input").setDecimals(3)
self.getWidget("max_opacity_input").setValue(viewer.style.GetVolumeRenderParameters()['max_opacity'])
self.getWidget("max_opacity_input").valueChanged.connect(self.change_volume_max_opacity)

def change_color_range_min(self):
"""Change the volume color range min value."""
if self.getWidget("color_range_slider_min").value() >= self.getWidget("color_range_slider_max").value():
Expand Down Expand Up @@ -155,6 +166,11 @@ def change_volume_opacity(self):
elif opacity == "Scalar":
self.viewer.setScalarOpacityPercentiles(opacity_min, opacity_max)

def change_volume_max_opacity(self):
"""Change the volume opacity mapping max value."""
mo = self.getWidget("max_opacity_input").value()
self.viewer.setMaximumOpacity(mo)

def reset_volume_clipping(self):
"""Reset the volume clipping to the default state."""
self.getWidget("volume_clipping").setChecked(False)
Expand Down

0 comments on commit 7cfe7bb

Please sign in to comment.