Gui: change notification between SoFCColorBarBase nodes

This commit is contained in:
wmayer
2022-04-01 19:27:45 +02:00
parent 90c35171ae
commit c50924be03
5 changed files with 24 additions and 15 deletions

View File

@@ -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;
}
}

View File

@@ -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"; }

View File

@@ -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;
}

View File

@@ -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"; }

View File

@@ -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);