Rogue Wave Views 5.5.1 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Graphic class. More...
#include <ilviews/graphics/polypts.h>
Public Member Functions | |
IlvPolyPoints (IlvDisplay *display, IlUInt count, IlvPoint *points, IlvPalette *palette=0, IlBoolean computeBBox=((IlBoolean) 1)) | |
Constructor. | |
virtual void | addPoint (const IlvPoint &point, IlUInt idx) |
Add a point. | |
virtual void | addPoints (IlUInt count, IlvPoint *points, IlUInt index) |
Add an array of points. | |
virtual void | applyTransform (const IlvTransformer *) |
Applies a transformation function to the graphic object. | |
virtual void | boundingBox (IlvRect &, const IlvTransformer *t=0) const |
Retrieves the bounding box of the graphic object. | |
const char * | className () const |
Returns the class name of an object. | |
virtual void | computeBBox (IlvRect &bbox) |
Compute the bounding box cache. | |
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. | |
virtual void | getPoint (IlvPoint &point, IlUInt index) const |
Get a point. | |
IlvPoint * | getPoints (IlvPoint *buffer=0) const |
Get the definition points. | |
IlBoolean | inBBox (const IlvPoint &point) const |
Locate a point in the bounding box cache. | |
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. | |
IlUInt | numberOfPoints () const |
Get the number of points. | |
virtual void | print (ILVSTDPREF ostream &, int level=0) const |
Prints for debugging purposes. | |
virtual IlBoolean | removePoints (IlUInt start, IlUInt count) |
Remove a set of points. | |
virtual void | setPoint (const IlvPoint &point, IlUInt idx) |
Set a point. | |
virtual IlvPoint * | transformPoints (const IlvTransformer *t) const |
Transform all the points. | |
virtual void | translatePoint (const IlvPoint &delta, IlUInt index) |
Translate a point. | |
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. |
Graphic class.
Library: views
IlvPolyPoints
is an abstract class from which is derived every class having shapes composed of several point coordinates. This class lets you derive your own graphic objects that are defined by a series of pairs of coordinates.
For better performance, the bounding box of the object, which is the smallest rectangle that contains all the points that define its shape, is store in a cache.
Note that the bounding box of the objects created from IlvPolyPoints
do not take the graphic properties (such as the line width) into account.
IlvPolyPoints::IlvPolyPoints | ( | IlvDisplay * | display, | |
IlUInt | count, | |||
IlvPoint * | points, | |||
IlvPalette * | palette = 0 , |
|||
IlBoolean | computeBBox = ((IlBoolean) 1) | |||
) |
Constructor.
The constructor initializes an IlvPolyPoints
object with a predefine shape provided in an array of IlvPoint
.
display | The display object that will display this object. | |
count | The number of points of this object. | |
points | An array of at least count points that define the shape of this object. This array is copied by this constructor. | |
palette | The palette that will be used by this object. If left unspecified or set to 0, the default palette of the display (see IlvDisplay::defaultPalette ) will be used. | |
computeBBox | A Boolean value that indicates, if IlTrue that the bounding box of the object should be computed as soon as the object is initialized. You can set it to IlFalse to delay the computation of the bounding box cache. |
Add a point.
The bounding box cache is updated accordingly. Adds a new point to this polypoint object.
point | The point to be added. | |
index | The index, in the point array, where the point will be added. The point is inserted at the index th entry of the point array, that is, after the index th value (the array starts at the rank 0). If the index is greater than the entry number of the point array, point is added after the last entry. |
Add an array of points.
The bounding box cache is updated accordingly.
count | The number of points to be added. | |
points | The array of at least count points that must be added. This array is copied. | |
index | The index, in the point array, where the points will be added. The points are inserted starting at the index th entry of the point array, that is, after the index th value (the array starts at the rank 0). If the index is greater than the entry number of the point array, the points are added after the last entry |
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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
virtual void IlvPolyPoints::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.
virtual void IlvPolyPoints::boundingBox | ( | IlvRect & | bbox, | |
const IlvTransformer * | t = 0 | |||
) | const [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.
Reimplemented in IlvArrowPolyline.
const char* IlvPolyPoints::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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
virtual void IlvPolyPoints::computeBBox | ( | IlvRect & | bbox | ) | [virtual] |
Compute the bounding box cache.
Computes the actual bounding box of the object and stores it in that parameter. Is internally called to store the bounding box in a cache memory.
bbox | Is set to the computed bounding box. |
Reimplemented in IlvSpline, and IlvClosedSpline.
virtual IlvGraphic* IlvPolyPoints::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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
virtual void IlvPolyPoints::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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
virtual IlvClassInfo* IlvPolyPoints::getClassInfo | ( | ) | const [virtual] |
Gets class information.
Returns a pointer to the IlvClassInfo
object associated with this object's class.
Reimplemented from IlvSimpleGraphic.
Reimplemented in IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
Get a point.
point | The point that receives the location of the indicated point. | |
index | The index of the point to be queried. The first point of the object has an index of 0 . |
Get the definition points.
buffer | A buffer large enough to store all the points of this object, or 0. |
0
, then an internal private array is filled and returned. In the latter case, you should not delete the returned array. static IlAny IlvPolyPoints::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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
static const IlvClassInfo* IlvPolyPoints::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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
Locate a point in the bounding box cache.
point | The point that must be checked. |
IlBoolean
value that indicates whether or not the parameter point is located inside the cached bounding box of the object. IlBoolean IlvPolyPoints::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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
IlBoolean IlvPolyPoints::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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
IlUInt IlvPolyPoints::numberOfPoints | ( | ) | const |
Get the number of points.
virtual void IlvPolyPoints::print | ( | ILVSTDPREF ostream & | out, | |
int | level = 0 | |||
) | const [virtual] |
Prints for debugging purposes.
Use for debugging purposes. Depending on the debugging level given as the level parameter, basic information about this object is printed to out. Basic implementation prints the object class name, and its bounding box. When this object is defined by another object (that is, if it is a referenced object), this subobject is described only if the level parameter is not zero. When this object is defined by a group of objects, these subobjects are defined themselves if the level parameter is not zero. In general, the higher level is, the more information you get about the object.
out | The output stream. | |
level | The debugging level. If 0, subobjects are not described. |
Reimplemented from IlvGraphic.
static IlvGraphic* IlvPolyPoints::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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
Remove a set of points.
The bounding box cache is updated accordingly.
start | The starting index of the points to be removed. | |
count | The number of points to be removed. |
IlTrue
, that the operation was successful. It returns IlFalse
if the removal cannot take place, which means that the parameters are illegal. You cannot remove all the points from an IlvPolyPoints
. 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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
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 IlvOutlinePolygon, IlvPolyline, IlvPolygon, IlvArrowPolyline, IlvSpline, IlvClosedSpline, and IlvFilledSpline.
Set a point.
The bounding box cache is updated accordingly.
point | The value that is set to the indicated point. | |
index | The index of the point to be modified. The first point of the object has an index of 0 . |
virtual IlvPoint* IlvPolyPoints::transformPoints | ( | const IlvTransformer * | t | ) | const [virtual] |
Transform all the points.
Allows you to globally apply a transformation efficiently. This member function is used in all methods that compute the object's bounding, and the draw
methods of all the subtypes of IlvPolyPoints
.
t | The transformer that is applied to all the points. |
IlvPolyPoint
's internal point array. You must not delete the returned array. Translate a point.
The bounding box cache is updated accordingly.
delta | The distance vector that is applied to the indicated point. | |
index | The index of the point to be translated. The first point of the object has an index of 0 . |
virtual void IlvPolyPoints::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 IlvArrowPolyline.
© 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.