Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Scale class. More...
#include <ilviews/graphics/scale.h>
Public Member Functions | |
IlvScale (IlvDisplay *display, const IlvRect &drawrect, char *labels[], IlUShort steps=2, IlUShort substeps=0, IlUShort stepsize=10, IlUShort substepsize=5, IlvPalette *palette=0) | |
Constructor. | |
IlvScale (IlvDisplay *display, const IlvRect &drawrect, const char *format=0, IlFloat min=0, IlFloat max=100, IlUShort steps=0, IlUShort substeps=0, IlUShort stepsize=10, IlUShort substepsize=5, IlvPalette *palette=0) | |
Constructor. | |
virtual void | applyTransform (const IlvTransformer *t) |
Applies a transformation function to the graphic object. | |
virtual void | boundingBox (IlvRect &, const IlvTransformer *t=0) const =0 |
Retrieves the bounding box of the graphic object. | |
const char * | className () const |
Returns the class name of an object. | |
virtual IlvGraphic * | copy () const |
Copies this object. | |
virtual void | draw (IlvPort *, const IlvTransformer *t=0, const IlvRegion *clip=0) const =0 |
Draws the graphic object. | |
virtual IlvClassInfo * | getClassInfo () const |
Gets class information. | |
const char * | getFormat () const |
Gets the format of the step labels. | |
const char * | getLabel (IlUShort idx) const |
Gets a label. | |
char *const * | getLabels () const |
Gets the labels. | |
void | getLabelSizes (IlUShort idx, IlvDim &w, IlvDim &h, IlvDim &d) const |
Gets a label's sizes. | |
IlFloat | getMax () const |
Gets the maximum value of the scale. | |
IlFloat | getMin () const |
Gets the minimum value of the scale. | |
IlUShort | getSteps () const |
Gets the number of steps. | |
IlUShort | getStepSize () const |
Gets the step size. | |
IlUShort | getSubSteps () const |
Gets the number of substeps. | |
IlUShort | getSubStepSize () const |
Gets the substep size. | |
IlBoolean | isSubtypeOf (const IlvClassInfo *c) const |
Checks whether this object's class is a subclass. | |
IlBoolean | isSubtypeOf (const char *t) const |
Checks whether this object's class is a subclass of a given parent class. | |
virtual void | setFont (IlvFont *) |
Sets the font of the object. | |
void | setFormat (const char *format) |
Sets the format of the step labels. | |
void | setLabel (IlUShort idx, const char *label) |
Sets a label. | |
void | setLabels (IlUShort count, IlFloat min, IlFloat max, const char *format) |
Sets the labels. | |
void | setLabels (IlUShort count, const char *const *labels=0) |
Sets the labels. | |
void | setMax (IlFloat max) |
Sets the maximum value of the scale. | |
void | setMin (IlFloat min) |
Sets the minimum value of the scale. | |
virtual void | setPalette (IlvPalette *) |
Sets the internal palette to the given palette value. | |
void | setSteps (IlUShort steps) |
Sets the number of steps. | |
void | setStepSize (IlUShort stepsize) |
Sets the step size. | |
void | setSubSteps (IlUShort substeps) |
Sets the number of substeps. | |
void | setSubStepSize (IlUShort substepsize) |
Sets the substep size. | |
virtual void | write (IlvOutputFile &) const |
Writes an object description to a file. | |
Static Public Member Functions | |
static void | AddProperty (const IlSymbol *k, IlAny v) |
Adds a property to this object's class. | |
static IlAny | GetProperty (const IlSymbol *key, IlBoolean p=((IlBoolean) 0)) |
Retrieves the property value associated with the key in this object's class. | |
static const IlvClassInfo * | HasProperty (const IlSymbol *key, IlBoolean p=((IlBoolean) 0)) |
Checks for the existence of a property for this object's class hierarchy. | |
static IlvGraphic * | read (IlvInputFile &, IlvPalette *pal) |
Reads an object description from a file. | |
static IlBoolean | RemoveProperty (const IlSymbol *key) |
Removes a property from this object's class. | |
static IlBoolean | ReplaceProperty (const IlSymbol *k, IlAny v) |
Replaces a property in this object's class. |
Scale class.
Library: views
IlvScale
is an abstract class from which are derived all instances of scale object classes. This class manages the basic required information concerning scales.
IlvCircularScale
, IlvRectangularScale
. IlvScale::IlvScale | ( | IlvDisplay * | display, | |
const IlvRect & | drawrect, | |||
const char * | format = 0 , |
|||
IlFloat | min = 0 , |
|||
IlFloat | max = 100 , |
|||
IlUShort | steps = 0 , |
|||
IlUShort | substeps = 0 , |
|||
IlUShort | stepsize = 10 , |
|||
IlUShort | substepsize = 5 , |
|||
IlvPalette * | palette = 0 | |||
) |
Constructor.
This constructor lets you specify a printf
format, to be used when displaying labels. You can specify a 0
value if you don't want any text. You must provide a minimum and a maximum value in min and max.
display | The display where this object is created. | |
drawrect | The location and size of the scale. | |
format | The printf format of the step labels. | |
min | The minimum value of the scale. | |
max | The maximum value of the scale. | |
steps | The number of major ticks to be drawn, which can be 0 for no scales. | |
substeps | The number of minor ticks displayed between major ones. | |
stepsize | The major tick mark size. | |
substepsize | The minor tick mark size. | |
palette | The palette associated with this object. |
IlvScale::IlvScale | ( | IlvDisplay * | display, | |
const IlvRect & | drawrect, | |||
char * | labels[], | |||
IlUShort | steps = 2 , |
|||
IlUShort | substeps = 0 , |
|||
IlUShort | stepsize = 10 , |
|||
IlUShort | substepsize = 5 , |
|||
IlvPalette * | palette = 0 | |||
) |
Constructor.
This constructor takes an array of text strings to be displayed. There must be at least as many strings as the number of main scales indicated in the steps parameter. The array of text strings is copied.
display | The display where this object is created. | |
drawrect | The location and size of the scale. | |
labels[] | The array of text strings. | |
steps | The number of major ticks to be drawn, which can be 0 for no scales. | |
substeps | The number of minor ticks displayed between major ones. | |
stepsize | The major tick mark size. | |
substepsize | The minor tick mark size. | |
palette | The palette associated with this object. |
Adds a property to this object's class.
This static function associates the given value with the given key for the class of this object only.
key | The key to be associated. | |
value | The value to be associated. |
Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
virtual void IlvScale::applyTransform | ( | const IlvTransformer * | t | ) | [virtual] |
Applies a transformation function to the graphic object.
Applies the transformer t
to the shape of the object. Unless the transformation is a scaling operation, the result of applying it to certain objects can be insignificant. For example, applying a non-scaling transformer to an IlvRectangle
object is meaningless, since the rectangle remains a rectangle. On the other hand, meaningful transformations can be applied to objects that are instances of types such as IlvLine
or IlvPolyPoints
.
applyTransform
is one of the most important method to be rewritten for classes derived from IlvGraphic
, since it is called by the resize
, move
, moveResize
, scale
, etc., methods.t | The transformer value. If 0, no transformation is performed. |
Implements IlvGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
virtual void IlvScale::boundingBox | ( | IlvRect & | bbox, | |
const IlvTransformer * | t = 0 | |||
) | const [pure virtual] |
Retrieves the bounding box of the graphic object.
Sets bbox, the rectangle reference parameter, to be the bounding box of the object. Since the object can appear within a transformed environment (for example, in a multiview editor), an IlvTransformer
object occurs as an optional parameter in order to compute the bounding box in the coordinate system of the transformed environment. When there is no transformation, t is set to 0
.
bbox | The bounding box to be set. | |
t | A transformer value or 0 if there is no transformation. |
Implements IlvGraphic.
Implemented in IlvCircularScale, and IlvRectangularScale.
const char* IlvScale::className | ( | ) | const |
Returns the class name of an object.
This method is equivalent to getClassInfo()->getClassName()
.
IlvRectangle
object, the className function returns "IlvRectangle"
. Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
virtual IlvGraphic* IlvScale::copy | ( | ) | const [virtual] |
Copies this object.
Allocates and returns a copy of this object. If the object is composite, the implementation of this member function makes a copy of the object's components.
IlvPredefinedIOMembers
. Implements IlvGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
virtual void IlvScale::draw | ( | IlvPort * | dst, | |
const IlvTransformer * | t = 0 , |
|||
const IlvRegion * | clip = 0 | |||
) | const [pure virtual] |
Draws the graphic object.
Draws the object in the given IlvPort
using the transformer t
which might have the value 0
. The clip
parameter, which can also be 0
, represents the clipping region relative to the transformed object.
dst | The destination port. | |
t | The transformer value. If 0, no transformation is performed. | |
clip | The clipping region, or 0 if none. |
Implements IlvGraphic.
Implemented in IlvCircularScale, and IlvRectangularScale.
virtual IlvClassInfo* IlvScale::getClassInfo | ( | ) | const [virtual] |
Gets class information.
Returns a pointer to the IlvClassInfo
object associated with this object's class.
Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
const char* IlvScale::getFormat | ( | ) | const |
Gets the format of the step labels.
printf
. const char* IlvScale::getLabel | ( | IlUShort | idx | ) | const |
Gets a label.
idx | The index of the label to retrieve. |
char* const* IlvScale::getLabels | ( | ) | const |
Gets the labels.
Gets a label's sizes.
idx | The index of the step label. | |
w | Is set to the label's width. | |
h | Is set to the label's height. | |
d | Is set to the label's descent value. |
IlFloat IlvScale::getMax | ( | ) | const |
Gets the maximum value of the scale.
IlFloat IlvScale::getMin | ( | ) | const |
Gets the minimum value of the scale.
static IlAny IlvScale::GetProperty | ( | const IlSymbol * | key, | |
IlBoolean | checkSuperClass = ((IlBoolean) 0) | |||
) | [static] |
Retrieves the property value associated with the key in this object's class.
Retrieves the property value associated with the property name key. If the property cannot be found in the class of this object, and if checkSuperClass is set to IlTrue
, then the function operates iteratively on each superclass until the property is found. If the property cannot be found, then 0
is returned.
key | The key with which the property value is associated. | |
checkSuperClass | IlTrue specifies iterative search on superclasses. |
0
. Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
IlUShort IlvScale::getSteps | ( | ) | const |
Gets the number of steps.
IlUShort IlvScale::getStepSize | ( | ) | const |
Gets the step size.
IlUShort IlvScale::getSubSteps | ( | ) | const |
Gets the number of substeps.
IlUShort IlvScale::getSubStepSize | ( | ) | const |
Gets the substep size.
static const IlvClassInfo* IlvScale::HasProperty | ( | const IlSymbol * | key, | |
IlBoolean | checkSuperClass = ((IlBoolean) 0) | |||
) | [static] |
Checks for the existence of a property for this object's class hierarchy.
Retrieves a pointer to the IlvClassInfo
that indicates a class where the key property exists. If the returned value is non-0
, then this property actually exists for this class. If this is not the case and if checkSuperClass is set to IlTrue
, then the function operates iteratively on each superclass until a match is found. If the property cannot be found, then 0
is returned.
key | The key with which the property value is associated. | |
checkSuperClass | IlTrue specifies iterative search on superclasses. |
0
. Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
IlBoolean IlvScale::isSubtypeOf | ( | const IlvClassInfo * | classInfo | ) | const |
Checks whether this object's class is a subclass.
This method is equivalent to getClassInfo()->isSubtypeOf(classInfo)
.
classInfo | The name of a class on which the object's class is tested. |
IlTrue
or IlFalse
, depending on whether or not this object's class is a subclass of the class indicated by classInfo. Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
IlBoolean IlvScale::isSubtypeOf | ( | const char * | parentClass | ) | const |
Checks whether this object's class is a subclass of a given parent class.
This method is equivalent to getClassInfo()->isSubtypeOf(parentClass)
.
parentClass | A string representing the parent class. |
IlTrue
or IlFalse
, depending on whether or not this object's class inherits parentClass attributes. The parentClass parameter should be a string representing the class name of an IlvGraphic
subclass. A call to this member function for a given class instance returns IlTrue
if given the name of its class. Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
static IlvGraphic* IlvScale::read | ( | IlvInputFile & | file, | |
IlvPalette * | palette | |||
) | [static] |
Reads an object description from a file.
Reads an object description from the file input, given the palette graphic attributes. It reads the information that was saved by the member function write
to be able to create a new instance of this object. Usually, because of the availability of the constructor that expects an IlvInputFile
, read should be equivalent to:
IlvGraphic* MyClass::read(IlvInputFile& file, IlvPalette* palette) { return new MyClass(file, palette); }
In the following example, the static member function read
of the IlvLabel
class could have the following form:
IlvGraphic* IlvLabel::read(IlvInputFile& file, IlvPalette* pal) { IlvPoint pos; file.getStream() >> pos; // Read the position field return new IlvLabel(pal->getDisplay(), pos, IlvReadString(file.getStream()), pal); }
file | The name of the file to be read from. | |
palette | The name of the palette for the object. |
DeclareTypeInfoRO
, DeclareTypeInfo
, IlvPredefinedIOMembers
. read
method is not capitalized like other static methods so that it is consistent with the write
method. Reimplemented from IlvGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
Removes a property from this object's class.
This static function removes the indicated property to the class of this object.
key | The key property to be removed. |
IlTrue
if the key property was actually found, or IlFalse
otherwise. Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
Replaces a property in this object's class.
This static function replaces the indicated property value to the class of this object.
key | The key to be replaced. | |
value | The value to be replaced. |
IlTrue
if the key property was actually found, or IlFalse
otherwise. Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
virtual void IlvScale::setFont | ( | IlvFont * | font | ) | [virtual] |
void IlvScale::setFormat | ( | const char * | format | ) |
Sets the format of the step labels.
Sets the format of the step labels. The formats are the same as those used with printf
. If the scale was previously using text labels, it will now use numerical labels.
format | The printf format of the step labels. |
void IlvScale::setLabel | ( | IlUShort | idx, | |
const char * | label | |||
) |
Sets a label.
Sets the idx th label by creating a copy of the label parameter.
idx | The index of the label to be set. | |
label | The label string. |
Sets the labels.
Computes a new array of character strings displayed beside the major scales. These new strings are computed by creating a string representation of a value that goes from min to max, using the format string format in a printf
-like manner. For example:
scale->setLabels(11, 0., 10., "%.2f");
This code creates and stores 11 labels: "0.00"
, "1.00"
to "10.00".
The min value is assigned to the first tick mark and the max value to the last one. max does not have to be greater than min.
count | The number of labels. | |
min | The value assigned to the first tick mark. | |
max | The value assigned to the last tick mark. | |
format | The printf format of the step labels. |
void IlvScale::setLabels | ( | IlUShort | count, | |
const char *const * | labels = 0 | |||
) |
Sets the labels.
This member function changes the array of character strings displayed beside the major scales to the values provided in the labels parameter. A copy of these labels is produced. The count parameter indicates how many labels are stored in the labels array. This number must match the number of tick marks for this scale object.
If labels
is not provided or is 0
, no labels are displayed on the tick marks.
count | The number of labels stored in . | |
labels | The array of text strings. |
void IlvScale::setMax | ( | IlFloat | max | ) |
Sets the maximum value of the scale.
Sets the maximum value of the scale. If the scale was previously using text labels, it will now use numerical labels.
max | The maximum value of the scale. |
void IlvScale::setMin | ( | IlFloat | min | ) |
Sets the minimum value of the scale.
Sets the minimum value of the scale. If the scale was previously using text labels, it will now use numerical labels.
min | The minimum value of the scale. |
virtual void IlvScale::setPalette | ( | IlvPalette * | palette | ) | [virtual] |
Sets the internal palette to the given palette
value.
Sets the internal palette to the given palette
value. The previous palette is unlocked, and palette is locked.
palette | The new palette of this object. |
Reimplemented from IlvSimpleGraphic.
void IlvScale::setSteps | ( | IlUShort | steps | ) |
Sets the number of steps.
Sets the number of major steps (ticks) in this scale to steps.
steps | The number of major ticks to be drawn, which can be 0 for no scales. |
void IlvScale::setStepSize | ( | IlUShort | stepsize | ) |
Sets the step size.
Sets the value of the stepsize parameter as the size of the major tick marks.
stepsize | The major tick mark size. |
void IlvScale::setSubSteps | ( | IlUShort | substeps | ) |
Sets the number of substeps.
Sets the number of minor steps (ticks) in this scale to substeps.
substeps | The number of minor ticks displayed between major ones. |
void IlvScale::setSubStepSize | ( | IlUShort | substepsize | ) |
Sets the substep size.
Sets the value of the substepsize parameter as the size of the minor tick marks.
substepsize | The minor tick mark size. |
virtual void IlvScale::write | ( | IlvOutputFile & | output | ) | const [virtual] |
Writes an object description to a file.
Writes out, in a file, the object description. This description contains all the information necessary to create an exact copy of this object by means of the member function read
. Information concerning any IlvPalette
object attached to this object is written out by the object containers. All other information, such as the position and size of the object, is written out by this virtual member function.
For example, suppose we have an IlvLabel
class that implements a graphic object drawn as a text string at a given position. It maintains its position in an internal IlvPoint
field called _position
and its textual content in an internal character array field called _text
. The only information we need to save is the contents of those fields. So, the member function write
of such an object should have the following form:
void IlvLabel::write(IlvOutputFile& file) const { // Save the position field file.getStream() << IlvSpc() << _position; // Save the text field IlvWriteString(file.getStream(), _text); }
output | The the output file to be written to. |
DeclareTypeInfo
. Implements IlvGraphic.
Reimplemented in IlvCircularScale, and IlvRectangularScale.
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.