From Kristofer, "The osgSim::ScalarBar has a problem in that if the scalarbar has a color in one end that co-incides with the background color, one cannot see where the scalarbar ends. With this patch, we add a line around the perimiter of the bar to mark it.

Secondly, we thought the text-annotation missed ticks that mark out precisely where on the bar the texts relate to, so we added that as well."
This commit is contained in:
Robert Osfield
2014-01-24 16:19:38 +00:00
parent 8ae57c2797
commit 8a334e724b
2 changed files with 75 additions and 13 deletions

View File

@@ -74,7 +74,7 @@ struct MyScalarPrinter: public ScalarBar::ScalarPrinter
};
#endif
osg::Node* createScalarBar()
osg::Node* createScalarBar(bool vertical)
{
#if 1
//ScalarsToColors* stc = new ScalarsToColors(0.0f,1.0f);
@@ -90,9 +90,17 @@ osg::Node* createScalarBar()
ColorRange* cr = new ColorRange(0.0f,1.0f,cs);
ScalarBar* sb = new ScalarBar(20, 11, cr, "ScalarBar", ScalarBar::VERTICAL, 0.1f, new MyScalarPrinter);
ScalarBar* sb = new ScalarBar(20, 11, cr,
vertical ? "Vertical" : "Horizontal",
vertical ? ScalarBar::VERTICAL : ScalarBar::HORIZONTAL,
0.1f, new MyScalarPrinter);
sb->setScalarPrinter(new MyScalarPrinter);
if ( !vertical )
{
sb->setPosition( osg::Vec3(0.5f,-0.5f,0));
}
return sb;
#else
ScalarBar *sb = new ScalarBar;
@@ -137,7 +145,8 @@ int main(int , char **)
osgViewer::Viewer viewer;
osg::Group* group = new osg::Group;
group->addChild(createScalarBar());
group->addChild(createScalarBar(true));
group->addChild(createScalarBar(false));
group->addChild(createScalarBar_HUD());
// add model to viewer.