rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

IlvGraphicPath Class Reference

Graphic class. More...

#include <ilviews/graphics/path.h>

Inheritance diagram for IlvGraphicPath:
IlvSimpleGraphic IlvGraphic

List of all members.

Public Member Functions

 IlvGraphicPath (IlvDisplay *display, IlUInt count, IlvPointArray *paths, IlBoolean copyPoints=((IlBoolean) 1), IlvPalette *palette=0)
 Constructor.
 IlvGraphicPath (IlvDisplay *display, IlUInt count, IlvPoint *points, IlBoolean copyPoints=((IlBoolean) 1), IlvPalette *palette=0)
 Constructor.
virtual ~IlvGraphicPath ()
 Destructor.
virtual void applyTransform (const IlvTransformer *t)
 Applies a transformation function to the graphic object.
const IlvRectbbox () const
 Retrieves the bounding box.
virtual void boundingBox (IlvRect &rect, const IlvTransformer *t=0) const
 Retrieves the bounding box.
const char * className () const
 Returns the class name of an object.
virtual IlBoolean contains (const IlvPoint &p, const IlvPoint &tp, const IlvTransformer *t=0) const
 Checks if a point is contained.
virtual IlvGraphiccopy () const
 Copies this object.
virtual void draw (IlvPort *dst, const IlvTransformer *t=0, const IlvRegion *clip=0) const
 Draws the path and its drawing data.
IlvPalettegetBackgroundPalette () const
 Retrieves the background palette.
IlUInt getBBoxExtent () const
 Gets the bounding box extent.
virtual IlvClassInfogetClassInfo () const
 Gets class information.
IlvDrawRule getDrawRule () const
 Retrieves the draw rule.
IlDouble getLength (const IlvPointArray &path) const
 Computes the length of a path.
IlDouble getLength () const
 Computes the length of this graphic path.
IlDouble getLocation (IlDouble distance, IlvPoint *pos=0, IlDouble *angle=0, IlUInt *path=0, IlUInt *segment=0, IlvTransformer *t=0) const
 Computes a location along this path.
virtual IlDouble getLocation (IlUInt count, const IlvPointArray *paths, IlDouble distance=0., IlvPoint *pos=0, IlDouble *angle=0, IlUInt *path=0, IlUInt *segment=0) const
 Computes a location along a path.
IlUInt getNumPaths () const
 Retrieves the number of paths.
IlvPathDrawingDatagetPathDrawingData () const
 Gets the drawing data.
const IlvPointArraygetPaths () const
 Retrieves the paths.
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 setAlpha (IlvIntensity)
 Sets the alpha value of the object.
virtual void setAntialiasingMode (IlvAntialiasingMode)
 Sets the anti-aliasing mode of the object.
virtual void setBackground (IlvColor *bg)
 Sets the background color.
void setBBoxExtent (IlUInt extent)
 Sets the bounding box extent.
void setDrawRule (IlvDrawRule val)
 Sets the draw rule.
virtual void setForeground (IlvColor *fg)
 Sets the foreground color.
virtual void setMode (IlvDrawMode mode)
 Sets the drawing mode.
virtual void setPalette (IlvPalette *pal)
 Sets the palette.
void setPathDrawingData (IlvPathDrawingData *data)
 Sets the drawing data.
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 IlvClassInfoHasProperty (const IlSymbol *key, IlBoolean p=((IlBoolean) 0))
 Checks for the existence of a property for this object's class hierarchy.
static IlvGraphicread (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.

Detailed Description

Graphic class.

Library: views

An IlvGraphicPath is a collection of polypoints.

Depending on the value of the DrawRule attribute of the object, the polypoints are drawn as polylines (IlvStrokeOnly), filled polygons (IlvFillOnly), or both; that is, filled polygons with an outline (IlvStrokeAndFill).

The palette defined by the IlvSimpleGraphic superclass is used to draw the outline of the polygon. IlvGraphicPath defines a second palette (backgroundPalette) to fill the polygons.

The main differences between an IlvGraphicPath and a set of IlvPolygons are the following:

IlvGraphicPath also allows user-specific actions when the polypoints are drawn. This is done by attaching a data structure to the IlvGraphicPath. At each redraw, the graphic path "travels" along the collection of paths, triggering a data structure method at each step. This mechanism is described in the sections on the member function setPathDrawingData and the class IlvPathSteppingData and its subclass IlvPathDrawingData.

Both of the IlvGraphicPath constructors automatically compute the background palette from the resource of the regular palette. Foreground color and background color are swapped; other resources are identical.

See also:
IlvPathDrawingData, IlvPathSteppingData, IlvPointArray,

Constructor & Destructor Documentation

IlvGraphicPath::IlvGraphicPath ( IlvDisplay display,
IlUInt  count,
IlvPoint points,
IlBoolean  copyPoints = ((IlBoolean) 1),
IlvPalette palette = 0 
)

Constructor.

This constructor initializes an IlvGraphicPath containing only one polypoint.

Parameters:
display The display instance.
count The number of points that define this graphic path.
points The array of at least count points that defines the shape of this object.
copyPoints Indicates, if set to IlTrue, that the array is copied. If this parameter is set to IlFalse, then the point array points is internally stored in the object.
palette The palette instance.
IlvGraphicPath::IlvGraphicPath ( IlvDisplay display,
IlUInt  count,
IlvPointArray paths,
IlBoolean  copyPoints = ((IlBoolean) 1),
IlvPalette palette = 0 
)

Constructor.

This constructor initializes an IlvGraphicPath containing several polypoints.

Parameters:
display The display instance.
count The number of paths that define this graphic path.
paths The array of at least count point arrays that define the shape of this object. This array is destroyed in this object's destructor.
copyPoints If set to IlTrue, both paths and the point that they contain are copied. Otherwise, paths is stored by this object, and deleted in its constructor.
palette The palette instance.
virtual IlvGraphicPath::~IlvGraphicPath (  )  [virtual]

Destructor.

The destructor unlocks the background palette and deletes the array of IlvPointArray. If setPathDrawingData has been called, the corresponding IlvPathDrawingData is deleted as well.


Member Function Documentation

static void IlvGraphicPath::AddProperty ( const IlSymbol key,
IlAny  value 
) [static]

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.

Parameters:
key The key to be associated.
value The value to be associated.

Reimplemented from IlvSimpleGraphic.

virtual void IlvGraphicPath::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.

Warning:
[note] 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.
Parameters:
t The transformer value. If 0, no transformation is performed.

Implements IlvGraphic.

const IlvRect& IlvGraphicPath::bbox (  )  const

Retrieves the bounding box.

Returns:
The smallest box containing all the points of the object.
virtual void IlvGraphicPath::boundingBox ( IlvRect rect,
const IlvTransformer t = 0 
) const [virtual]

Retrieves the bounding box.

This member function has the same specification as for IlvGraphic::boundingBox, only the box is extended in the four directions by the value returned by getBBoxExtent.

Parameters:
rect The rectangle that will be set to the bounding box of this object, when transformed with t.
t The transformer that must be used when computing the bounding box.

Implements IlvGraphic.

const char* IlvGraphicPath::className (  )  const

Returns the class name of an object.

This method is equivalent to getClassInfo()->getClassName().

Returns:
The class name of the object. For example, for an IlvRectangle object, the className function returns "IlvRectangle".

Reimplemented from IlvSimpleGraphic.

virtual IlBoolean IlvGraphicPath::contains ( const IlvPoint p,
const IlvPoint tp,
const IlvTransformer t = 0 
) const [virtual]

Checks if a point is contained.

This member function has the same specifications as for IlvGraphic::contains. The returned value depends on the DrawRule. The drawing data is not taken into account by this member function.

Parameters:
p The point to be tested, in the object coordinate system.
tp The point to be tested, in the transformed coordinate system.
t The transformer that transforms p to tp.
Returns:
A Boolean value that indicates whether or not the provided points are located inside this graphic path.

Reimplemented from IlvGraphic.

virtual IlvGraphic* IlvGraphicPath::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.

Returns:
A copy of the object.
See also:
IlvPredefinedIOMembers.

Implements IlvGraphic.

virtual void IlvGraphicPath::draw ( IlvPort dst,
const IlvTransformer t = 0,
const IlvRegion clip = 0 
) const [virtual]

Draws the path and its drawing data.

This member function has specifications as for IlvGraphic::draw, but after drawing the graphic path according to the DrawRule, it sets the drawing data by calling IlvPathDrawingData::initDraw and calls the IlvPathSteppingData::stepping member function which starts the iteration along the collection of polypoints.
If the transformer t is not 0, a new array of IlvPointArray containing transformed points is passed to the drawing data, instead of the original array of IlvPointArray.

Parameters:
dst The destination drawing port.
t The transformer used in this drawing.
clip The clipping region that must be used.

Implements IlvGraphic.

IlvPalette* IlvGraphicPath::getBackgroundPalette (  )  const

Retrieves the background palette.

Returns:
The background palette of the object. This palette is used to fill the polygons defined by the collection of IlvPointArray (not applicable if the draw rule is set to IlvStrokeOnly).
IlUInt IlvGraphicPath::getBBoxExtent (  )  const

Gets the bounding box extent.

Returns:
The value of the bounding box extent.
See also:
setBBoxExtent.
virtual IlvClassInfo* IlvGraphicPath::getClassInfo (  )  const [virtual]

Gets class information.

Returns a pointer to the IlvClassInfo object associated with this object's class.

Returns:
A pointer to the class information object of the class of this object.

Reimplemented from IlvSimpleGraphic.

IlvDrawRule IlvGraphicPath::getDrawRule (  )  const

Retrieves the draw rule.

Returns:
The draw rule of the object.
IlDouble IlvGraphicPath::getLength ( const IlvPointArray path  )  const

Computes the length of a path.

This method uses the virtual method getLocation.

Parameters:
path The array of points whose length is queried.
Returns:
The length of path.
IlDouble IlvGraphicPath::getLength (  )  const

Computes the length of this graphic path.

This method uses the virtual method getLocation.

Returns:
The length of the graphic path.
IlDouble IlvGraphicPath::getLocation ( IlDouble  distance,
IlvPoint pos = 0,
IlDouble angle = 0,
IlUInt path = 0,
IlUInt segment = 0,
IlvTransformer t = 0 
) const

Computes a location along this path.

This member function is similar to the virtual method getLocation, but it operates on the array of polypoints stored by this object and allows the application of a transformation. This member function actually calls getLocation.

See the previous getLocation() for a complete description of all the parameters of this member function.

Parameters:
distance The distance, along the path, where the point location is computed.
pos The point location.
angle The tangent to the path at the indicated location, in degrees.
path The index of the polypoints that is traversed at the indicated distance.
segment The index of the last point, in the polypoint indicated by path, that is traversed at the indicated distance.
t The transformer that is applied to the internal path before the point location is computed.
virtual IlDouble IlvGraphicPath::getLocation ( IlUInt  count,
const IlvPointArray paths,
IlDouble  distance = 0.,
IlvPoint pos = 0,
IlDouble angle = 0,
IlUInt path = 0,
IlUInt segment = 0 
) const [virtual]

Computes a location along a path.

This member function does not use the internal array of polypoints of the object but the one specified by the parameters count and paths.

Parameters:
count The number of paths stored in the array paths.
paths The array of at least count paths that are travelled along.
distance If set to 0 (the default value) or to a positive value greater than the path's total length, the remaining parameters pos, angle, path and segment are ignored; the method just computes the length of each polypoint in the array and returns the sum of these lengths.
If set to a negative value, the result is undetermined.
If set to a positive value smaller than the total length of the path, it is interpreted as the distance to travel along the path. The remaining parameters can provide information about the point situated at this distance from the beginning of the path.
pos Ignored if distance is set to 0. Otherwise, if it is not 0, this parameter must point to a variable that is set to the coordinates of the point on the path at the distance distance from its start.
angle Ignored if distance is set to 0. Otherwise, if it is not 0, this parameter must point to a variable that is set to the angle, in degrees of the tangent to the path at the distance distance from its start.
path Ignored if distance is set to 0. Otherwise, if it is not 0, this parameter must point to a variable that is set to the index of the point array stored in paths that is reached along the path at the distance distance from its start.
segment Ignored if distance is set to 0. Otherwise, if it is not 0, this parameter must point to a variable that is set to the index of the point in the array designated by path that is reached along the path at the distance distance from its start, so that pos is located somewhere on the segment [paths[ipath]->points[ipoint], paths[ipath]->points[ipoint+1]].
Returns:
The total length of the path if distance is 0 or a value greater than the total length of the path. A negative value is returned in other cases.
IlUInt IlvGraphicPath::getNumPaths (  )  const

Retrieves the number of paths.

Returns:
The number of IlvPointArray paths managed by the object.
IlvPathDrawingData* IlvGraphicPath::getPathDrawingData (  )  const

Gets the drawing data.

Returns:
The drawing data structure that has been set by setPathDrawingData.
const IlvPointArray* IlvGraphicPath::getPaths (  )  const

Retrieves the paths.

Returns:
The array of IlvPointArray managed by the object.
static IlAny IlvGraphicPath::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.

Parameters:
key The key with which the property value is associated.
checkSuperClass IlTrue specifies iterative search on superclasses.
Returns:
The property value associated with the proper name key, or 0.

Reimplemented from IlvSimpleGraphic.

static const IlvClassInfo* IlvGraphicPath::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.

Parameters:
key The key with which the property value is associated.
checkSuperClass IlTrue specifies iterative search on superclasses.
Returns:
A pointer to the ClassInfo that indicates a class where the key property exists, or 0.

Reimplemented from IlvSimpleGraphic.

IlBoolean IlvGraphicPath::isSubtypeOf ( const IlvClassInfo classInfo  )  const

Checks whether this object's class is a subclass.

This method is equivalent to getClassInfo()->isSubtypeOf(classInfo).

Parameters:
classInfo The name of a class on which the object's class is tested.
Returns:
Either IlTrue or IlFalse, depending on whether or not this object's class is a subclass of the class indicated by classInfo.

Reimplemented from IlvSimpleGraphic.

IlBoolean IlvGraphicPath::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).

Parameters:
parentClass A string representing the parent class.
Returns:
Either 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.

static IlvGraphic* IlvGraphicPath::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);
 }
Parameters:
file The name of the file to be read from.
palette The name of the palette for the object.
See also:
DeclareTypeInfoRO, DeclareTypeInfo, IlvPredefinedIOMembers.
Warning:
[note] The read method is not capitalized like other static methods so that it is consistent with the write method.

Reimplemented from IlvGraphic.

static IlBoolean IlvGraphicPath::RemoveProperty ( const IlSymbol key  )  [static]

Removes a property from this object's class.

This static function removes the indicated property to the class of this object.

Parameters:
key The key property to be removed.
Returns:
IlTrue if the key property was actually found, or IlFalse otherwise.

Reimplemented from IlvSimpleGraphic.

static IlBoolean IlvGraphicPath::ReplaceProperty ( const IlSymbol key,
IlAny  value 
) [static]

Replaces a property in this object's class.

This static function replaces the indicated property value to the class of this object.

Parameters:
key The key to be replaced.
value The value to be replaced.
Returns:
IlTrue if the key property was actually found, or IlFalse otherwise.

Reimplemented from IlvSimpleGraphic.

virtual void IlvGraphicPath::setAlpha ( IlvIntensity  alpha  )  [virtual]

Sets the alpha value of the object.

Parameters:
alpha The new alpha value.

Reimplemented from IlvSimpleGraphic.

virtual void IlvGraphicPath::setAntialiasingMode ( IlvAntialiasingMode  mode  )  [virtual]

Sets the anti-aliasing mode of the object.

Parameters:
mode The new anti-aliasing mode.

Reimplemented from IlvSimpleGraphic.

virtual void IlvGraphicPath::setBackground ( IlvColor bg  )  [virtual]

Sets the background color.

This member function sets the background color of the normal palette to bg. It also sets the foreground color of the background palette to bg and, if the drawing data is not 0, sets its background color to bg as well.

Parameters:
bg The new background color of this graphic path, and its drawing data if there is one. The color is locked.

Reimplemented from IlvSimpleGraphic.

void IlvGraphicPath::setBBoxExtent ( IlUInt  extent  ) 

Sets the bounding box extent.

This member function allows you to notify the object that its bounding box should always be augmented by the value extent in all directions. This is specially useful when attaching a drawing data structure to the object: if this data structure is set to draw an additional object along the path, this object should be taken into account when computing the bounding box of the IlvGraphicPath.

Parameters:
extent The new bounding box extent.
void IlvGraphicPath::setDrawRule ( IlvDrawRule  val  ) 

Sets the draw rule.

Parameters:
val The new draw rule of this object. This attribute controls the way polypoints are displayed.
virtual void IlvGraphicPath::setForeground ( IlvColor fg  )  [virtual]

Sets the foreground color.

This member function sets the foreground color of the normal palette to fg. It also sets the background color of the background palette to fg and, if the drawing data is not 0, sets its foreground color to fg as well.

Parameters:
fg The new foreground color of this graphic path, and its drawing data if there is one. The color is locked.

Reimplemented from IlvSimpleGraphic.

virtual void IlvGraphicPath::setMode ( IlvDrawMode  mode  )  [virtual]

Sets the drawing mode.

Sets the draw mode to mode for the palette of the object, its background palette, and the palette of the drawing data (if not 0).

Parameters:
mode The new drawing mode of this object.

Reimplemented from IlvSimpleGraphic.

virtual void IlvGraphicPath::setPalette ( IlvPalette pal  )  [virtual]

Sets the palette.

This member function sets the normal palette to pal. It also sets the background palette to a copy of that palette, except that its foreground and background color are swapped. If the drawing data is not 0, this method sets its palette to pal as well.

Parameters:
pal The new palette of this graphic path, and the one of its drawing data if there is one. The palette is locked.

Reimplemented from IlvSimpleGraphic.

void IlvGraphicPath::setPathDrawingData ( IlvPathDrawingData data  ) 

Sets the drawing data.

Attaches a drawing data structure to the object. If another data structure was set, it is the user's responsibility to delete it. The IlvGraphicPath destructor deletes this structure. IlvGraphicPath only uses this structure in the * draw method.

Parameters:
data the new drawing data of this graphic path.
virtual void IlvGraphicPath::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);
 }
Parameters:
output The the output file to be written to.
See also:
DeclareTypeInfo.

Implements IlvGraphic.

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

© 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.