From 7cfe7bb3a1b06054e286de8b9414720f90e59b29 Mon Sep 17 00:00:00 2001 From: Edoardo Pasca <14138589+paskino@users.noreply.github.com> Date: Wed, 25 Sep 2024 23:41:07 +0100 Subject: [PATCH] add max opacity control as spinbox --- .../viewer/ui/VolumeRenderSettingsDialog.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Wrappers/Python/ccpi/viewer/ui/VolumeRenderSettingsDialog.py b/Wrappers/Python/ccpi/viewer/ui/VolumeRenderSettingsDialog.py index 7e38c8cd..99b79e0e 100644 --- a/Wrappers/Python/ccpi/viewer/ui/VolumeRenderSettingsDialog.py +++ b/Wrappers/Python/ccpi/viewer/ui/VolumeRenderSettingsDialog.py @@ -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 @@ -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) @@ -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(): @@ -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)