diff --git a/src/Gui/SoFCColorBar.cpp b/src/Gui/SoFCColorBar.cpp index 40ac63e099..8061140314 100644 --- a/src/Gui/SoFCColorBar.cpp +++ b/src/Gui/SoFCColorBar.cpp @@ -45,7 +45,7 @@ SO_NODE_ABSTRACT_SOURCE(SoFCColorBarBase) /*! Constructor. */ -SoFCColorBarBase::SoFCColorBarBase(): _windowSize(0,0) +SoFCColorBarBase::SoFCColorBarBase() : _boxWidth(-1.0f), _windowSize(0,0) { SO_NODE_CONSTRUCTOR(SoFCColorBarBase); } @@ -80,8 +80,17 @@ void SoFCColorBarBase::GLRenderBelowPath(SoGLRenderAction * action) SoSeparator::GLRenderBelowPath(action); } +void SoFCColorBarBase::setModified() +{ + _boxWidth = -1.0f; +} + float SoFCColorBarBase::getBoundingWidth(const SbVec2s& size) { + if (_boxWidth >= 0.0f) { + return _boxWidth; + } + // These are the same camera settings for front nodes as defined in the 3d view SoOrthographicCamera* cam = new SoOrthographicCamera; cam->position = SbVec3f(0, 0, 5); // the 5 is just a value > 0 @@ -103,6 +112,7 @@ float SoFCColorBarBase::getBoundingWidth(const SbVec2s& size) group->unref(); float boxWidth = maxPt[0] - minPt[0]; + _boxWidth = boxWidth; return boxWidth; } diff --git a/src/Gui/SoFCColorBar.h b/src/Gui/SoFCColorBar.h index 66829f632f..c6515aa779 100644 --- a/src/Gui/SoFCColorBar.h +++ b/src/Gui/SoFCColorBar.h @@ -129,11 +129,16 @@ protected: * This method must be implemented in subclasses. */ virtual void setViewportSize( const SbVec2s& size ) = 0; + /** + * Mark the object as modified. + */ + void setModified(); SoFCColorBarBase (); virtual ~SoFCColorBarBase (); private: + float _boxWidth; SbVec2s _windowSize; }; diff --git a/src/Gui/SoFCColorGradient.cpp b/src/Gui/SoFCColorGradient.cpp index 8c75f30e65..e8fa0e8ae7 100644 --- a/src/Gui/SoFCColorGradient.cpp +++ b/src/Gui/SoFCColorGradient.cpp @@ -108,6 +108,8 @@ void SoFCColorGradient::setMarkerLabel(const SoMFString& label) labels->addChild(text2); } } + + setModified(); } void SoFCColorGradient::setViewportSize(const SbVec2s& size) diff --git a/src/Gui/SoFCColorLegend.cpp b/src/Gui/SoFCColorLegend.cpp index 273f95d410..9085644874 100644 --- a/src/Gui/SoFCColorLegend.cpp +++ b/src/Gui/SoFCColorLegend.cpp @@ -245,6 +245,8 @@ void SoFCColorLegend::setLegendLabels(const App::ColorLegend& legend, int prec) setMarkerLabel(labels); setMarkerValue(values); + + setModified(); } void SoFCColorLegend::modifyPoints(const SbBox2f& box)