openscenegraph
ScalarBar
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGSIM_SCALARBAR
15#define OSGSIM_SCALARBAR 1
16
17#include <osgSim/Export>
18#include <osgSim/ColorRange> // The default ScalarsToColors is a ColorRange
19#include <osg/Geode>
20#include <string>
21
22namespace osgSim
23{
44{
45
46public:
47
51 VERTICAL
52 };
53
60 {
61 virtual std::string printScalar(float scalar);
62 };
63
71 {
72 std::string _fontFile;
73 std::pair<int,int> _fontResolution;
76
78 _fontFile("fonts/arial.ttf"),
79 _fontResolution(40,40),
80 _characterSize(0.0f),
81 _color(1.0f,1.0f,1.0f,1.0f)
82 {
83 }
84 };
85
87 ScalarBar(): osg::Geode(),
88 _numColors(256),
89 _numLabels(11),
90 _stc(new ColorRange(0.0f,1.0f)),
91 _title("Scalar Bar"),
92 _position(0.0f,0.0f,0.0f),
93 _width(1.0f),
94 _aspectRatio(0.03),
95 _orientation(HORIZONTAL),
96 _sp(new ScalarPrinter)
97 {
98 createDrawables();
99 }
100
119 ScalarBar(int numColors, int numLabels, ScalarsToColors* stc,
120 const std::string& title,
121 Orientation orientation = HORIZONTAL,
122 float aspectRatio=0.25,
124 osg::Geode(),
125 _numColors(numColors),
126 _numLabels(numLabels),
127 _stc(stc),
128 _title(title),
129 _position(0.0f,0.0f,0.0f),
130 _width(1.0f),
131 _aspectRatio(aspectRatio),
132 _orientation(orientation),
133 _sp(sp)
134 {
135 createDrawables();
136 }
137
139 ScalarBar(const ScalarBar& rhs, const osg::CopyOp& co): osg::Geode(rhs,co),
140 _numColors(rhs._numColors),
141 _numLabels(rhs._numLabels),
142 _stc(rhs._stc), // Consider clone for deep copy?
143 _title(rhs._title),
144 _position(rhs._position),
145 _width(rhs._width),
146 _aspectRatio(rhs._aspectRatio),
147 _orientation(rhs._orientation),
148 _sp(rhs._sp), // Consider clone for deep copy?
149 _textProperties(rhs._textProperties)
150 {
151 }
152
153
155
157 void setNumColors(int numColors);
158
160 int getNumColors() const;
161
165 void setNumLabels(int numLabels);
166
168 int getNumLabels() const;
169
172
175
177 void setTitle(const std::string& title);
178
180 const std::string& getTitle() const;
181
182
184 void setPosition(const osg::Vec3& pos);
185
187 const osg::Vec3& getPosition() const { return _position; }
188
190 void setWidth(float width);
191
193 float getWidth() const { return _width; }
194
197 void setAspectRatio(float aspectRatio);
198
200 float getAspectRatio() const;
201
202
205
208
209
215
218
221
224
226 void update() { createDrawables(); }
227
228protected:
229 virtual ~ScalarBar();
230
234 std::string _title;
236 float _width;
241
243
244};
245
246}
247
248#endif
Definition ColorRange:32
Definition ScalarBar:44
ScalarBar()
Definition ScalarBar:87
ScalarBar(int numColors, int numLabels, ScalarsToColors *stc, const std::string &title, Orientation orientation=HORIZONTAL, float aspectRatio=0.25, ScalarPrinter *sp=new ScalarPrinter)
Definition ScalarBar:119
int getNumLabels() const
float _width
Definition ScalarBar:236
TextProperties _textProperties
Definition ScalarBar:240
const ScalarPrinter * getScalarPrinter() const
void setAspectRatio(float aspectRatio)
float getAspectRatio() const
const TextProperties & getTextProperties() const
ScalarBar::Orientation getOrientation() const
void setTextProperties(const TextProperties &tp)
int getNumColors() const
float _aspectRatio
Definition ScalarBar:237
float getWidth() const
Definition ScalarBar:193
META_Node(osgSim, ScalarBar)
void setTitle(const std::string &title)
int _numColors
Definition ScalarBar:231
osg::ref_ptr< ScalarPrinter > _sp
Definition ScalarBar:239
std::string _title
Definition ScalarBar:234
Orientation
Definition ScalarBar:49
@ HORIZONTAL
a horizontally ascending scalar bar (x-axis)
Definition ScalarBar:50
virtual ~ScalarBar()
const std::string & getTitle() const
void setOrientation(ScalarBar::Orientation orientation)
const ScalarsToColors * getScalarsToColors() const
const osg::Vec3 & getPosition() const
Definition ScalarBar:187
void setScalarPrinter(ScalarPrinter *sp)
osg::Vec3 _position
Definition ScalarBar:235
void setWidth(float width)
void setScalarsToColors(ScalarsToColors *stc)
int _numLabels
Definition ScalarBar:232
void setNumColors(int numColors)
void setNumLabels(int numLabels)
ScalarBar(const ScalarBar &rhs, const osg::CopyOp &co)
Definition ScalarBar:139
void setPosition(const osg::Vec3 &pos)
void update()
Definition ScalarBar:226
osg::ref_ptr< ScalarsToColors > _stc
Definition ScalarBar:233
Orientation _orientation
Definition ScalarBar:238
Definition ScalarsToColors:31
Definition CopyOp:41
Definition Geode:29
Definition Referenced:44
Definition Vec3f:29
Definition Vec4f:28
Definition ref_ptr:32
Definition BlinkSequence:27
author: Julien Valentin 2017 (mp3butcher@hotmail.com)
Definition AlphaFunc:19
#define OSGSIM_EXPORT
Definition osgSim/Export:38
Definition ScalarBar:60
virtual std::string printScalar(float scalar)
Definition ScalarBar:71
osg::Vec4 _color
Definition ScalarBar:75
std::string _fontFile
Definition ScalarBar:72
std::pair< int, int > _fontResolution
Definition ScalarBar:73
TextProperties()
Definition ScalarBar:77
float _characterSize
Definition ScalarBar:74