## class OSGSIM_EXPORT osgSim::ScalarBar

> A ScalarBar is an osg::Geode to render a colored bar representing a range of scalars.

## Inheritance:

### Public Methods

ScalarBar()
  Default constructor.
ScalarBar(int numColors, int numLabels, ScalarsToColors* stc, const std::string& title, Orientation orientation = HORIZONTAL, float aspectRatio=0.25, ScalarPrinter* sp=new ScalarPrinter)
  Construct a ScalarBar with the supplied parameters.
ScalarBar(const ScalarBar& rhs, const osg::CopyOp& co)
  Copy constructor
void setNumColors(int numColors)
  Set the number of distinct colours on the ScalarBar.
int getNumColors() const
  Get the number of distinct colours on the ScalarBar.
void setNumLabels(int numLabels)
  Set the number of labels to display along the ScalarBar.
int getNumLabels() const
  Get the number of labels displayed along the ScalarBar.
void setScalarsToColors(ScalarsToColors* stc)
  Set the ScalarsToColors mapping object for the ScalarBar.
const ScalarsToColors* getScalarsToColors() const
  Get the ScalarsToColors mapping object from the ScalarBar.
void setTitle(const std::string& title)
  Set the title for the ScalarBar, set "" for no title.
std::string getTitle() const
  Get the title for the ScalarBar.
void setOrientation(ScalarBar::Orientation orientation)
  Set the orientation of the ScalarBar.
Orientation getOrientation() const
  Get the orientation of the ScalarBar.
void setAspectRatio(float aspectRatio)
  Set the aspect ration (y/x) for the displayed bar.
float getAspectRatio() const
  Get the aspect ration (y/x) for the displayed bar.
void setScalarPrinter(ScalarPrinter* sp)
  Set a ScalarPrinter object for the ScalarBar.
const ScalarPrinter* getScalarPrinter() const
  Get the ScalarPrinter object
void setTextProperties(const TextProperties& tp)
  Set the TextProperties for the labels & title.
const TextProperties& getTextProperties() const
  Get the TextProperties for the labels & title.
META_Node(osgSim, ScalarBar)

### Public Members

enum Orientation
  ScalarBar orientation specification.
struct ScalarPrinter: public osg::Referenced
  Users may provide their own ScalarPrinter by deriving from this base class and overriding the printScalar() method.
struct TextProperties
  TextProperties allows users to specify a number of properties for the text used to display the labels & title on the ScalarBar.

## Documentation

> A ScalarBar is an osg::Geode to render a colored bar representing a range of scalars. The scalar/color ranges are specified by an instance of ScalarsToColors. There are a number of configurable properties on the ScalarBar, such as the orientation, the number of labels to be displayed across the range, the number of distinct colors to use when rendering the bar, text details etc.

> In summary, the main configurables on the ScalarBar are:

> -# The range of scalars represented by the bar, and the colors corresponding to this range - these are specified by the ScalarsToColors object. -# The number of colors used when rendering the bar geometry - this may be thought of as the bar 'density'. -# The number of text labels to be used when displaying the bar.

> The other configurables should be self-explanatory.

`enum Orientation`
  ScalarBar orientation specification.

  `HORIZONTAL`

  `VERTICAL`
    < a horizontally ascending scalar bar (x-axis)

`struct ScalarPrinter: public osg::Referenced`
  Users may provide their own ScalarPrinter by deriving from this base class and overriding the printScalar() method. Users may map the scalar float passed in to any string they wish.

  `virtual std::string printScalar(float scalar)`

`struct TextProperties`
  TextProperties allows users to specify a number of properties for the text used to display the labels & title on the ScalarBar. Specifiying a character size of 0 will cause the ScalarBar to estimate an appropriate size. Note that the attributes are public, and may be set directly.

  `std::string _fontFile`

  `std::pair<int,int> _fontResolution`

  `int _characterSize`

  `osg::Vec4 _color`

  `TextProperties()`

`ScalarBar()`
  Default constructor.

`ScalarBar(int numColors, int numLabels, ScalarsToColors* stc, const std::string& title, Orientation orientation = HORIZONTAL, float aspectRatio=0.25, ScalarPrinter* sp=new ScalarPrinter)`
  Construct a ScalarBar with the supplied parameters.
  Parameters:
    numColors - Specify the number of colors in the scalar bar. Color interpolation occurs where necessary.
    stc - The ScalarsToColors defining the range of scalars and the colors they map to.
    title - The title to be used when displaying the ScalarBar. Specify "" for no title.
    orientation - The orientation of the ScalarBar. @see Orientation.
    apectRatio - The aspect ration (y/x) for the displayed bar. Bear in mind you may want to change this if you change the orientation.
    sp - A ScalarPrinter object for the ScalarBar. For every displayed ScalarBar label, the scalar value will be passed to the ScalarPrinter object to turn it into a string. Users may override the default ScalarPrinter object to map scalars to whatever strings they wish. @see ScalarPrinter

`ScalarBar(const ScalarBar& rhs, const osg::CopyOp& co)`
  Copy constructor

`void setNumColors(int numColors)`
  Set the number of distinct colours on the ScalarBar.

`int getNumColors() const`
  Get the number of distinct colours on the ScalarBar.

`void setNumLabels(int numLabels)`
  Set the number of labels to display along the ScalarBar. There will be one label at each end point, and evenly distributed labels in between.

`int getNumLabels() const`
  Get the number of labels displayed along the ScalarBar.

`void setScalarsToColors(ScalarsToColors* stc)`
  Set the ScalarsToColors mapping object for the ScalarBar.

`const ScalarsToColors* getScalarsToColors() const`
  Get the ScalarsToColors mapping object from the ScalarBar.

`void setTitle(const std::string& title)`
  Set the title for the ScalarBar, set "" for no title.

`std::string getTitle() const`
  Get the title for the ScalarBar.

`void setOrientation(ScalarBar::Orientation orientation)`
  Set the orientation of the ScalarBar. @see Orientation

`Orientation getOrientation() const`
  Get the orientation of the ScalarBar. @see Orientation

`void setAspectRatio(float aspectRatio)`
  Set the aspect ration (y/x) for the displayed bar. Bear in mind you may want to change this if you change the orientation.

`float getAspectRatio() const`
  Get the aspect ration (y/x) for the displayed bar.

`void setScalarPrinter(ScalarPrinter* sp)`
  Set a ScalarPrinter object for the ScalarBar. For every displayed ScalarBar label, the scalar value will be passed to the ScalarPrinter object to turn it into a string. Users may override the default ScalarPrinter object to map scalars to whatever strings they wish. @see ScalarPrinter

`const ScalarPrinter* getScalarPrinter() const`
  Get the ScalarPrinter object

`void setTextProperties(const TextProperties& tp)`
  Set the TextProperties for the labels & title. @see TextProperties

`const TextProperties& getTextProperties() const`
  Get the TextProperties for the labels & title. @see TextProperties

`META_Node(osgSim, ScalarBar)`

This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java

This page was generated with the help of DOC++.