Przeglądaj źródła

Rename ctkVTKVolumePropertyWidget::thresholdVisibility

expose thresholdEnabledChanged signal.
Julien Finet 13 lat temu
rodzic
commit
bcb1b39eea

+ 12 - 8
Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.cpp

@@ -59,7 +59,7 @@ public:
   void computeRange(double* range);
   void computeRange(double* range);
   void updateThresholdSlider(vtkPiecewiseFunction* opacityFunction);
   void updateThresholdSlider(vtkPiecewiseFunction* opacityFunction);
   void setThreshold(double min, double max, double opacity);
   void setThreshold(double min, double max, double opacity);
-  
+
   vtkVolumeProperty* VolumeProperty;
   vtkVolumeProperty* VolumeProperty;
   int                CurrentComponent;
   int                CurrentComponent;
   QToolButton*       ShowOpacityThresholdWidgetButton;
   QToolButton*       ShowOpacityThresholdWidgetButton;
@@ -93,7 +93,7 @@ void ctkVTKVolumePropertyWidgetPrivate::setupUi(QWidget* widget)
                    q, SIGNAL(chartsExtentChanged()));
                    q, SIGNAL(chartsExtentChanged()));
 
 
   this->ScalarOpacityWidget->view()->addCompositeFunction(0, 0, true, true);
   this->ScalarOpacityWidget->view()->addCompositeFunction(0, 0, true, true);
-  vtkCompositeControlPointsItem* composite = 
+  vtkCompositeControlPointsItem* composite =
   vtkCompositeControlPointsItem::SafeDownCast(
   vtkCompositeControlPointsItem::SafeDownCast(
     this->ScalarOpacityWidget->view()->opacityFunctionPlots()[1]);
     this->ScalarOpacityWidget->view()->opacityFunctionPlots()[1]);
   composite->SetColorFill(true);
   composite->SetColorFill(true);
@@ -109,6 +109,9 @@ void ctkVTKVolumePropertyWidgetPrivate::setupUi(QWidget* widget)
   QObject::connect(this->ShowOpacityThresholdWidgetButton,
   QObject::connect(this->ShowOpacityThresholdWidgetButton,
                    SIGNAL(toggled(bool)),
                    SIGNAL(toggled(bool)),
                    q, SLOT(onThresholdOpacityToggled(bool)));
                    q, SLOT(onThresholdOpacityToggled(bool)));
+  QObject::connect(this->ShowOpacityThresholdWidgetButton,
+                   SIGNAL(toggled(bool)),
+                   q, SIGNAL(thresholdEnabledChanged(bool)));
   this->ScalarOpacityWidget->addExtraWidget(
   this->ScalarOpacityWidget->addExtraWidget(
     this->ShowOpacityThresholdWidgetButton);
     this->ShowOpacityThresholdWidgetButton);
   this->ScalarOpacityThresholdWidget->setVisible(false);
   this->ScalarOpacityThresholdWidget->setVisible(false);
@@ -122,7 +125,7 @@ void ctkVTKVolumePropertyWidgetPrivate::setupUi(QWidget* widget)
 
 
   this->GradientGroupBox->setCollapsed(true);
   this->GradientGroupBox->setCollapsed(true);
   this->AdvancedGroupBox->setCollapsed(true);
   this->AdvancedGroupBox->setCollapsed(true);
-  
+
   QObject::connect(this->InterpolationComboBox, SIGNAL(currentIndexChanged(int)),
   QObject::connect(this->InterpolationComboBox, SIGNAL(currentIndexChanged(int)),
                    q, SLOT(setInterpolationMode(int)));
                    q, SLOT(setInterpolationMode(int)));
   QObject::connect(this->ShadeCheckBox, SIGNAL(toggled(bool)),
   QObject::connect(this->ShadeCheckBox, SIGNAL(toggled(bool)),
@@ -230,7 +233,8 @@ void ctkVTKVolumePropertyWidget::updateFromVolumeProperty()
       d->VolumeProperty->GetGradientOpacity() : 0;
       d->VolumeProperty->GetGradientOpacity() : 0;
     }
     }
 
 
-  d->ScalarOpacityThresholdWidget->setPiecewiseFunction(this->isThresholdVisible() ? opacityFunction : 0);
+  d->ScalarOpacityThresholdWidget->setPiecewiseFunction(
+    this->isThresholdEnabled() ? opacityFunction : 0);
 
 
   this->qvtkDisconnect(0, vtkCommand::EndInteractionEvent,
   this->qvtkDisconnect(0, vtkCommand::EndInteractionEvent,
                        this, SLOT(updateRange()));
                        this, SLOT(updateRange()));
@@ -404,7 +408,7 @@ void ctkVTKVolumePropertyWidget::setSpecularPower(double value)
 }
 }
 
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
-bool ctkVTKVolumePropertyWidget::isThresholdVisible()const
+bool ctkVTKVolumePropertyWidget::isThresholdEnabled()const
 {
 {
   Q_D(const ctkVTKVolumePropertyWidget);
   Q_D(const ctkVTKVolumePropertyWidget);
   return d->ScalarOpacityThresholdWidget->isVisibleTo(
   return d->ScalarOpacityThresholdWidget->isVisibleTo(
@@ -412,7 +416,7 @@ bool ctkVTKVolumePropertyWidget::isThresholdVisible()const
 }
 }
 
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
-void ctkVTKVolumePropertyWidget::showThreshold(bool enable)
+void ctkVTKVolumePropertyWidget::setThresholdEnabled(bool enable)
 {
 {
   Q_D(ctkVTKVolumePropertyWidget);
   Q_D(ctkVTKVolumePropertyWidget);
   d->ShowOpacityThresholdWidgetButton->setChecked(enable);
   d->ShowOpacityThresholdWidgetButton->setChecked(enable);
@@ -427,7 +431,7 @@ void ctkVTKVolumePropertyWidget::onThresholdOpacityToggled(bool enable)
 }
 }
 
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
-bool ctkVTKVolumePropertyWidget::hasThresholdVisibilityToggle()const
+bool ctkVTKVolumePropertyWidget::isThresholdToggleVisible()const
 {
 {
   Q_D(const ctkVTKVolumePropertyWidget);
   Q_D(const ctkVTKVolumePropertyWidget);
   return d->ShowOpacityThresholdWidgetButton->isVisibleTo(
   return d->ShowOpacityThresholdWidgetButton->isVisibleTo(
@@ -435,7 +439,7 @@ bool ctkVTKVolumePropertyWidget::hasThresholdVisibilityToggle()const
 }
 }
 
 
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
-void ctkVTKVolumePropertyWidget::setThresholdVisibilityToggle(bool showToggle)
+void ctkVTKVolumePropertyWidget::setThresholdToggleVisible(bool showToggle)
 {
 {
   Q_D(ctkVTKVolumePropertyWidget);
   Q_D(ctkVTKVolumePropertyWidget);
   d->ShowOpacityThresholdWidgetButton->setVisible(showToggle);
   d->ShowOpacityThresholdWidgetButton->setVisible(showToggle);

+ 9 - 7
Libs/Visualization/VTK/Widgets/ctkVTKVolumePropertyWidget.h

@@ -41,12 +41,12 @@ class CTK_VISUALIZATION_VTK_WIDGETS_EXPORT ctkVTKVolumePropertyWidget
   ///
   ///
   /// Control wether a range slider widget is used to edit the opacity
   /// Control wether a range slider widget is used to edit the opacity
   /// function instead of a chart editor. False by default
   /// function instead of a chart editor. False by default
-  Q_PROPERTY(bool thresholdVisibility READ isThresholdVisible WRITE showThreshold)
+  Q_PROPERTY(bool thresholdEnabled READ isThresholdEnabled WRITE setThresholdEnabled NOTIFY thresholdEnabledChanged)
 
 
   ///
   ///
   /// Show or hide the opacity threshold slider toggle button.
   /// Show or hide the opacity threshold slider toggle button.
   /// True by default.
   /// True by default.
-  Q_PROPERTY(bool thresholdVisibilityToggle READ hasThresholdVisibilityToggle WRITE setThresholdVisibilityToggle)
+  Q_PROPERTY(bool thresholdToggleVisibility READ isThresholdToggleVisible WRITE setThresholdToggleVisible)
 
 
 public:
 public:
   ctkVTKVolumePropertyWidget(QWidget* parent = 0);
   ctkVTKVolumePropertyWidget(QWidget* parent = 0);
@@ -54,13 +54,14 @@ public:
 
 
   vtkVolumeProperty* volumeProperty()const;
   vtkVolumeProperty* volumeProperty()const;
 
 
-  bool isThresholdVisible()const;
+  bool isThresholdEnabled()const;
 
 
-  bool hasThresholdVisibilityToggle()const;
-  void setThresholdVisibilityToggle(bool showToggle);
+  bool isThresholdToggleVisible()const;
+  void setThresholdToggleVisible(bool showToggle);
 
 
   void chartsBounds(double bounds[4])const;
   void chartsBounds(double bounds[4])const;
   void chartsExtent(double extent[4])const;
   void chartsExtent(double extent[4])const;
+
 public Q_SLOTS:
 public Q_SLOTS:
   void setVolumeProperty(vtkVolumeProperty* volumeProperty);
   void setVolumeProperty(vtkVolumeProperty* volumeProperty);
 
 
@@ -78,9 +79,10 @@ public Q_SLOTS:
   void spreadAllPoints(double factor = 1.,
   void spreadAllPoints(double factor = 1.,
                        bool dontSpreadFirstAndLast = false);
                        bool dontSpreadFirstAndLast = false);
 
 
-  void showThreshold(bool enable);
+  void setThresholdEnabled(bool enable);
 
 
 Q_SIGNALS:
 Q_SIGNALS:
+  void thresholdEnabledChanged(bool enable);
   void chartsExtentChanged();
   void chartsExtentChanged();
 
 
 protected Q_SLOTS:
 protected Q_SLOTS:
@@ -93,7 +95,7 @@ protected Q_SLOTS:
   void setDiffuse(double value);
   void setDiffuse(double value);
   void setSpecular(double value);
   void setSpecular(double value);
   void setSpecularPower(double value);
   void setSpecularPower(double value);
-  
+
   void onThresholdOpacityToggled(bool);
   void onThresholdOpacityToggled(bool);
   /// Called whenever a view (opacity, colors or gradient) has one of its axis
   /// Called whenever a view (opacity, colors or gradient) has one of its axis
   /// modified. It synchronize all the views to see the same.
   /// modified. It synchronize all the views to see the same.