diff --git a/src/Gui/SoFCColorBar.cpp b/src/Gui/SoFCColorBar.cpp index 3beb39b5c2..fa70beeb2d 100644 --- a/src/Gui/SoFCColorBar.cpp +++ b/src/Gui/SoFCColorBar.cpp @@ -90,8 +90,7 @@ public: ~SoFCColorBarProxyObject() {} void customEvent(QEvent *) { - if (bar->customize()) - bar->Notify(0); + bar->customize(bar->getActiveBar()); this->deleteLater(); } @@ -197,14 +196,18 @@ float SoFCColorBar::getMaxValue () const return this->getActiveBar()->getMaxValue(); } -bool SoFCColorBar::customize() +void SoFCColorBar::triggerChange(SoFCColorBarBase*) +{ + Notify(0); +} + +void SoFCColorBar::customize(SoFCColorBarBase* child) { try { - return this->getActiveBar()->customize(); + return child->customize(this); } catch (const Base::ValueError& e) { e.ReportException(); - return false; } } diff --git a/src/Gui/SoFCColorBar.h b/src/Gui/SoFCColorBar.h index 5d98259659..a492ba2da3 100644 --- a/src/Gui/SoFCColorBar.h +++ b/src/Gui/SoFCColorBar.h @@ -95,11 +95,16 @@ public: virtual float getMaxValue () const = 0; /** * Opens a dialog to customize the current settings of the color bar. - * Returns true if the settings have been changed, false otherwise. * * This method must be implemented in subclasses. */ - virtual bool customize() = 0; + virtual void customize(SoFCColorBarBase*) = 0; + /** + * Forward a triggered change + */ + virtual void triggerChange(SoFCColorBarBase* base) { + base->triggerChange(this); + } /** Returns the name of the color bar. * * This method must be implemented in subclasses. @@ -173,7 +178,11 @@ public: /** * Customizes the currently active color bar. */ - bool customize(); + void customize(SoFCColorBarBase*); + /** + * Notify observers + */ + void triggerChange(SoFCColorBarBase*); /** Returns the name of the color bar. */ const char* getColorBarName() const { return "Color Bar"; } diff --git a/src/Gui/SoFCColorGradient.cpp b/src/Gui/SoFCColorGradient.cpp index 0c580094d5..dafdf400a1 100644 --- a/src/Gui/SoFCColorGradient.cpp +++ b/src/Gui/SoFCColorGradient.cpp @@ -294,7 +294,7 @@ bool SoFCColorGradient::isVisible (float fVal) const return true; } -bool SoFCColorGradient::customize() +void SoFCColorGradient::customize(SoFCColorBarBase* parentNode) { QWidget* parent = Gui::getMainWindow()->activeWindow(); Gui::Dialog::DlgSettingsColorGradientImp dlg(parent); @@ -326,8 +326,6 @@ bool SoFCColorGradient::customize() setRange(fMin, fMax, dec); rebuildGradient(); - return true; + triggerChange(parentNode); } - - return false; } diff --git a/src/Gui/SoFCColorGradient.h b/src/Gui/SoFCColorGradient.h index df1d273440..4163876858 100644 --- a/src/Gui/SoFCColorGradient.h +++ b/src/Gui/SoFCColorGradient.h @@ -68,9 +68,8 @@ public: float getMaxValue () const { return _cColGrad.getMaxValue(); } /** * Opens a dialog to customize the current settings of the color gradient bar. - * Returns true if the settings have been changed, false otherwise. */ - bool customize(); + void customize(SoFCColorBarBase*); /** Returns the name of the color bar. */ const char* getColorBarName() const { return "Color Gradient"; } diff --git a/src/Gui/SoFCColorLegend.h b/src/Gui/SoFCColorLegend.h index 8c17bcba0e..17d1142330 100644 --- a/src/Gui/SoFCColorLegend.h +++ b/src/Gui/SoFCColorLegend.h @@ -65,7 +65,7 @@ public: float getMaxValue () const { return _currentLegend.getMaxValue(); } std::size_t countColors () const { return _currentLegend.hasNumberOfFields(); } - bool customize() { return false; } + void customize(SoFCColorBarBase*) { } const char* getColorBarName() const { return "Color Legend"; } // virtual void handleEvent(SoHandleEventAction * action);