From a92a9d0f22662bcce29a2a02fe33a1b4cf04a42b Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 3 Jun 2004 10:16:19 +0000 Subject: [PATCH] Added handling of case when only one colour is used. --- src/osgSim/ScalarBar.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/osgSim/ScalarBar.cpp b/src/osgSim/ScalarBar.cpp index 9cd7ff6ec..599622246 100644 --- a/src/osgSim/ScalarBar.cpp +++ b/src/osgSim/ScalarBar.cpp @@ -119,6 +119,8 @@ void ScalarBar::createDrawables() // Remove any existing Drawables _drawables.erase(_drawables.begin(), _drawables.end()); + if (_numColors==0) return; + osg::Matrix matrix; if(_orientation==HORIZONTAL) { @@ -189,8 +191,8 @@ void ScalarBar::createDrawables() osgText::Font* font = osgText::readFontFile(_textProperties._fontFile.c_str()); std::vector texts(_numLabels); // We'll need to collect pointers to these for later - float labelIncr = (_stc->getMax()-_stc->getMin())/(_numLabels-1); - float labelxIncr = (_width)/(_numLabels-1); + float labelIncr = (_numLabels>0) ? (_stc->getMax()-_stc->getMin())/(_numLabels-1) : 0.0f; + float labelxIncr = (_numLabels>0) ? (_width)/(_numLabels-1) : 0.0f; float labely = arOffset + characterSize*0.3f; for(i=0; i<_numLabels; ++i) {