OMNeT++ Simulation Library  5.6.1
cPathFigure Class Reference

#include <ccanvas.h>

Description

A figure that displays a "path", a complex shape or line modeled after SVG paths.

A path is may consist of any number of straight line segments, Bezier curves and arcs. The path can be disjoint as well. Closed paths may be filled. The drawing of filled self-intersecting polygons is controlled by the fill rule property. Line and fill color, and several other properties are inherited from cAbstractShapeFigure.

The path may be specified with a string similar to an SVG path, or assembled by calling methods that append new segments (straight lines, arcs or Bezier curves) to the existing path.

Inheritance diagram for cPathFigure:
cAbstractShapeFigure cFigure cOwnedObject cNamedObject cObject

Classes

struct  ArcRel
 Represents the "a" path command with parameters. More...
 
struct  ArcTo
 Represents the "A" path command with parameters. More...
 
struct  ClosePath
 Represents the "Z" path command. More...
 
struct  CubicBezierCurveRel
 Represents the "c" path command with parameters. More...
 
struct  CubicBezierCurveTo
 Represents the "C" path command with parameters. More...
 
struct  CurveRel
 Represents the "q" path command with parameters. More...
 
struct  CurveTo
 Represents the "Q" path command with parameters. More...
 
struct  HorizontalLineRel
 Represents the "h" path command with parameters. More...
 
struct  HorizontalLineTo
 Represents the "H" path command with parameters. More...
 
struct  LineRel
 Represents the "l" path command with parameters. More...
 
struct  LineTo
 Represents the "L" path command with parameters. More...
 
struct  MoveRel
 Represents the "m" path command with parameters. More...
 
struct  MoveTo
 Represents the "M" path command with parameters. More...
 
struct  PathItem
 Represents an item in a cPathFigure path. More...
 
struct  SmoothCubicBezierCurveRel
 Represents the "s" path command with parameters. More...
 
struct  SmoothCubicBezierCurveTo
 Represents the "S" path command with parameters. More...
 
struct  SmoothCurveRel
 Represents the "t" path command with parameters. More...
 
struct  SmoothCurveTo
 Represents the "T" path command with parameters. More...
 
struct  VerticalLineRel
 Represents the "v" path command with parameters. More...
 
struct  VerticalLineTo
 Represents the "V" path command with parameters. More...
 

Public Member Functions

Constructors, destructor, assignment.
 cPathFigure (const char *name=nullptr)
 
 cPathFigure (const cPathFigure &other)
 
virtual ~cPathFigure ()
 
cPathFigureoperator= (const cPathFigure &other)
 
Redefined cObject and cFigure member functions.
virtual cPathFiguredup () const override
 
virtual std::string str () const override
 
virtual void parse (cProperty *property) override
 
virtual void moveLocal (double dx, double dy) override
 
virtual const char * getRendererClassName () const override
 
Styling
virtual JoinStyle getJoinStyle () const
 
virtual void setJoinStyle (JoinStyle joinStyle)
 
virtual CapStyle getCapStyle () const
 
virtual void setCapStyle (CapStyle capStyle)
 
virtual FillRule getFillRule () const
 
virtual void setFillRule (FillRule fillRule)
 
Geometry
virtual const PointgetOffset () const
 
virtual void setOffset (const Point &offset)
 
Path manipulation
virtual const char * getPath () const
 
virtual void setPath (const char *path)
 
virtual int getNumPathItems () const
 
virtual const PathItemgetPathItem (int k) const
 
virtual void clearPath ()
 
virtual void addMoveTo (double x, double y)
 
virtual void addMoveRel (double dx, double dy)
 
virtual void addLineTo (double x, double y)
 
virtual void addLineRel (double dx, double dy)
 
virtual void addHorizontalLineTo (double x)
 
virtual void addHorizontalLineRel (double dx)
 
virtual void addVerticalLineTo (double y)
 
virtual void addVerticalLineRel (double dy)
 
virtual void addArcTo (double rx, double ry, double phi, bool largeArc, bool sweep, double x, double y)
 
virtual void addArcRel (double rx, double ry, double phi, bool largeArc, bool sweep, double dx, double dy)
 
virtual void addCurveTo (double x1, double y1, double x, double y)
 
virtual void addCurveRel (double dx1, double dy1, double dx, double dy)
 
virtual void addSmoothCurveTo (double x, double y)
 
virtual void addSmoothCurveRel (double dx, double dy)
 
virtual void addCubicBezierCurveTo (double x1, double y1, double x2, double y2, double x, double y)
 
virtual void addCubicBezierCurveRel (double dx1, double dy1, double dx2, double dy2, double dx, double dy)
 
virtual void addSmoothCubicBezierCurveTo (double x2, double y2, double x, double y)
 
virtual void addSmoothCubicBezierCurveRel (double dx2, double dy2, double dx, double dy)
 
virtual void addClosePath ()
 
- Public Member Functions inherited from cAbstractShapeFigure
 cAbstractShapeFigure (const char *name=nullptr)
 
 cAbstractShapeFigure (const cAbstractShapeFigure &other)
 
cAbstractShapeFigureoperator= (const cAbstractShapeFigure &other)
 
virtual bool isFilled () const
 
virtual void setFilled (bool filled)
 
virtual bool isOutlined () const
 
virtual void setOutlined (bool outlined)
 
virtual const Color & getLineColor () const
 
virtual void setLineColor (const Color &lineColor)
 
virtual const Color & getFillColor () const
 
virtual void setFillColor (const Color &fillColor)
 
virtual LineStyle getLineStyle () const
 
virtual void setLineStyle (LineStyle lineStyle)
 
virtual double getLineWidth () const
 
virtual void setLineWidth (double lineWidth)
 
virtual double getLineOpacity () const
 
virtual void setLineOpacity (double lineOpacity)
 
virtual double getFillOpacity () const
 
virtual void setFillOpacity (double fillOpacity)
 
virtual bool getZoomLineWidth () const
 
virtual void setZoomLineWidth (bool zoomLineWidth)
 
- Public Member Functions inherited from cFigure
 cFigure (const char *name=nullptr)
 
 cFigure (const cFigure &other)
 
virtual ~cFigure ()
 
cFigureoperator= (const cFigure &other)
 
virtual void forEachChild (cVisitor *v) override
 
int getId () const
 
virtual bool isVisible () const
 
virtual void setVisible (bool visible)
 
virtual const TransformgetTransform () const
 
virtual void setTransform (const Transform &transform)
 
virtual void resetTransform ()
 
virtual double getZIndex () const
 
virtual void setZIndex (double zIndex)
 
virtual double getEffectiveZIndex () const
 
virtual const char * getTooltip () const
 
virtual void setTooltip (const char *tooltip)
 
virtual cObjectgetAssociatedObject () const
 
virtual void setAssociatedObject (cObject *obj)
 
virtual const char * getTags () const
 
virtual void setTags (const char *tags)
 
virtual cFiguregetParentFigure () const
 
virtual cCanvasgetCanvas () const
 
virtual int getNumFigures () const
 
virtual cFiguregetFigure (int pos) const
 
virtual cFiguregetFigure (const char *name) const
 
virtual int findFigure (const char *name) const
 
virtual int findFigure (const cFigure *figure) const
 
virtual bool containsFigures () const
 
virtual cFigurefindFigureRecursively (const char *name) const
 
virtual cFiguregetFigureByPath (const char *path) const
 
virtual void addFigure (cFigure *figure)
 
virtual void addFigure (cFigure *figure, int pos)
 
_OPPDEPRECATED void addFigureAbove (cFigure *figure, cFigure *referenceFigure)
 
_OPPDEPRECATED void addFigureBelow (cFigure *figure, cFigure *referenceFigure)
 
virtual cFigureremoveFigure (cFigure *figure)
 
virtual cFigureremoveFigure (int pos)
 
virtual cFigureremoveFromParent ()
 
virtual bool isAbove (const cFigure *figure) const
 
virtual bool isBelow (const cFigure *figure) const
 
virtual void insertAbove (cFigure *referenceFigure)
 
virtual void insertBelow (cFigure *referenceFigure)
 
virtual void insertAfter (const cFigure *referenceFigure)
 
virtual void insertBefore (const cFigure *referenceFigure)
 
virtual void raiseAbove (cFigure *figure)
 
virtual void lowerBelow (cFigure *figure)
 
virtual void raiseToTop ()
 
virtual void lowerToBottom ()
 
virtual cFiguredupTree () const
 
virtual void translate (double dx, double dy)
 
virtual void scale (double s)
 
virtual void scale (double sx, double sy)
 
virtual void scale (double sx, double sy, double cx, double cy)
 
virtual void scale (double sx, double sy, const Point &c)
 
virtual void rotate (double phi)
 
virtual void rotate (double phi, double cx, double cy)
 
virtual void rotate (double phi, const Point &c)
 
virtual void skewx (double coeff)
 
virtual void skewy (double coeff)
 
virtual void skewx (double coeff, double cy)
 
virtual void skewy (double coeff, double cx)
 
virtual void move (double dx, double dy)
 
virtual void refreshDisplay ()
 
- Public Member Functions inherited from cOwnedObject
 cOwnedObject ()
 
 cOwnedObject (const char *name, bool namepooling=true)
 
 cOwnedObject (const cOwnedObject &obj)
 
virtual ~cOwnedObject ()
 
cOwnedObjectoperator= (const cOwnedObject &o)
 
virtual void parsimPack (cCommBuffer *buffer) const override
 
virtual void parsimUnpack (cCommBuffer *buffer) override
 
virtual cObjectgetOwner () const override
 
virtual bool isOwnedObject () const override
 
virtual bool isSoftOwner () const
 
- Public Member Functions inherited from cNamedObject
 cNamedObject ()
 
 cNamedObject (const char *name, bool namepooling=true)
 
 cNamedObject (const cNamedObject &obj)
 
virtual ~cNamedObject ()
 
cNamedObjectoperator= (const cNamedObject &o)
 
virtual void setName (const char *s)
 
virtual const char * getName () const override
 
virtual void setNamePooling (bool b)
 
virtual bool getNamePooling ()
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
const cObjectgetThisPtr () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
cObjectfindObject (const char *name, bool deep=true)
 
void copyNotSupported () const
 

Protected Member Functions

virtual const char ** getAllowedPropertyKeys () const override
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Additional Inherited Members

- Public Types inherited from cFigure
enum  FontStyle
 Font style constants: FONT_NONE, FONT_BOLD, etc. More...
 
enum  LineStyle
 Line style constants: LINE_SOLID, LINE_DOTTED, etc. More...
 
enum  CapStyle
 Line cap style constants: CAP_BUTT, CAP_SQUARE, etc. More...
 
enum  JoinStyle
 Line join style constants: JOIN_BEVEL, JOIN_MITER, etc. More...
 
enum  FillRule
 Fill rule constants: FILL_EVENODD, FILL_NONZERO. More...
 
enum  Arrowhead
 Arrowhead style constants: ARROW_NONE, ARROW_SIMPLE, etc. More...
 
enum  Interpolation
 Image interpolation mode constants: INTERPOLATION_NONE, INTERPOLATION_FAST, etc. More...
 
enum  Anchor
 Anchoring mode constants: ANCHOR_CENTER, ANCHOR_N, etc. More...
 
- Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
 
static long getLiveObjectCount ()
 
static void resetObjectCounters ()
 
static cDefaultListgetDefaultOwner ()
 
- Static Public Attributes inherited from cFigure
static const Color BLACK
 
static const Color WHITE
 
static const Color GREY
 
static const Color RED
 
static const Color GREEN
 
static const Color BLUE
 
static const Color YELLOW
 
static const Color CYAN
 
static const Color MAGENTA
 
static const int NUM_GOOD_DARK_COLORS
 
static const int NUM_GOOD_LIGHT_COLORS
 
static const Color GOOD_DARK_COLORS [14]
 
static const Color GOOD_LIGHT_COLORS [10]
 

Member Function Documentation

◆ getAllowedPropertyKeys()

virtual const char** getAllowedPropertyKeys ( ) const
overrideprotectedvirtual

Returns the list of allowed keys in @figure properties with this figure type, in a nullptr-terminated array of const char* elements. This method is invoked e.g. from parse(), in order to be able to issue error messages for invalid keys in the property. Note that property keys starting with "x-" are already allowed by default. Custom figure classes usually need to override this method together with parse(); see the source code of the library classes for example implementations.

Reimplemented from cAbstractShapeFigure.

◆ dup()

virtual cPathFigure* dup ( ) const
inlineoverridevirtual

Clones the figure, ignoring its child figures. (The copy will have no children.) To clone a figure together with its figure subtree, use dupTree().

Reimplemented from cAbstractShapeFigure.

◆ str()

virtual std::string str ( ) const
overridevirtual

Returns a one-line string with the most characteristic data of the figure.

Reimplemented from cAbstractShapeFigure.

◆ parse()

virtual void parse ( cProperty property)
overridevirtual

This method is invoked by the simulation library to initialize the figure from a @figure NED property. Custom figure classes usually need to override this method (and call the super class' similar method in it).

Note: When overriding parse(), it is usually also necessary to override getAllowedPropertyKeys(), in order to allow new keys in the @figure property.

Reimplemented from cAbstractShapeFigure.

◆ moveLocal()

virtual void moveLocal ( double  dx,
double  dy 
)
overridevirtual

The move operation modifies the offset field (see getOffset()).

Implements cFigure.

◆ getRendererClassName()

virtual const char* getRendererClassName ( ) const
inlineoverridevirtual

Returns the name of the class responsible for rendering this figure. Renderer classes are specific to, and are usually implemented as part of, the graphical user interface library (Tkenv or Qtenv).

Implements cFigure.

◆ getJoinStyle()

virtual JoinStyle getJoinStyle ( ) const
inlinevirtual

Returns the join style line segments will be connected with.

◆ setJoinStyle()

virtual void setJoinStyle ( JoinStyle  joinStyle)
virtual

Sets the join style line segments will be connected with. The default join style is miter.

◆ getCapStyle()

virtual CapStyle getCapStyle ( ) const
inlinevirtual

Returns the cap style for the figure's line.

◆ setCapStyle()

virtual void setCapStyle ( CapStyle  capStyle)
virtual

Sets the cap style for the figure's line. The default cap style is butt.

◆ getFillRule()

virtual FillRule getFillRule ( ) const
inlinevirtual

Returns the fill rule of the path. This attribute is only important with closed, filled, self-intersecting paths (and those that contain such parts). The interpretation of the fill rule is consistent with its SVG definition.

◆ setFillRule()

virtual void setFillRule ( FillRule  fillRule)
virtual

Sets the fill rule of the path. This attribute is only important with closed, filled, self-intersecting paths (and those that contain such parts). The interpretation of the fill rule is consistent with its SVG definition.

The default fill rule is evenodd.

◆ getOffset()

virtual const Point& getOffset ( ) const
inlinevirtual

Returns the coordinate offset of the path. A nonzero offset causes the path to appear translated by the given amount in the local coordinate system.

◆ setOffset()

virtual void setOffset ( const Point offset)
virtual

Sets the coordinate offset of the path. Setting a nonzero offset causes the path to appear translated by the given amount in the local coordinate system. The elements of the path remain unchanged. This method primarily exists so that moveLocal() can be a constant-time operation.

◆ getPath()

virtual const char* getPath ( ) const
virtual

Returns the path as a string.

◆ setPath()

virtual void setPath ( const char *  path)
virtual

Sets the path from a string. It will be parsed, made available via the getNumPathItems(), getPathItem() methods, and may be further modified with the "add" methods.

◆ getNumPathItems()

virtual int getNumPathItems ( ) const
inlinevirtual

Returns the number of path items.

◆ getPathItem()

virtual const PathItem* getPathItem ( int  k) const
inlinevirtual

Returns the kth path item. The returned item may be cast to the appropriate subtype (MoveTo, MoveRel, etc.) after examining its code field.

◆ clearPath()

virtual void clearPath ( )
virtual

Clears the path by discarding its path items.

◆ addMoveTo()

virtual void addMoveTo ( double  x,
double  y 
)
virtual

Appends a MoveTo item to the path. It will move the "pen" to (x,y), and begin a new subpath. Paths should begin with a MoveTo.

SVG equivalent: "M <x> <y>"

◆ addMoveRel()

virtual void addMoveRel ( double  dx,
double  dy 
)
virtual

Appends a MoveRel item to the path. It will move the "pen" from the current point (lastx,lasty) to (lastx+dx,lasty+dy), and begin a new subpath.

SVG equivalent: "m <dx> <dy>"

◆ addLineTo()

virtual void addLineTo ( double  x,
double  y 
)
virtual

Appends a LineTo item to the path. It will draw a line from the last point to (x,y).

SVG equivalent: "L <x> <y>"

◆ addLineRel()

virtual void addLineRel ( double  dx,
double  dy 
)
virtual

Appends a LineRel item to the path. It will draw a line from the current point (lastx, lasty) to (lastx+dx, lasty+dy).

SVG equivalent: "l <dx> <dy>"

◆ addHorizontalLineTo()

virtual void addHorizontalLineTo ( double  x)
virtual

Appends a HorizontalLineTo item to the path. It will draw a line from the current point (lastx, lasty) to (x, lasty).

SVG equivalent: "H <x>"

◆ addHorizontalLineRel()

virtual void addHorizontalLineRel ( double  dx)
virtual

Appends a HorizontalLineRel item to the path. It will draw a line from the current point (lastx, lasty) to (lastx+dx, lasty).

SVG equivalent: "h <dx>"

◆ addVerticalLineTo()

virtual void addVerticalLineTo ( double  y)
virtual

Appends a VerticalLineTo item to the path. It will draw a line from the current point (lastx, lasty) to the (lastx, y) point.

SVG equivalent: "V <y>"

◆ addVerticalLineRel()

virtual void addVerticalLineRel ( double  dy)
virtual

Appends a VerticalLineRel item to the path. It will draw a line from the current point (lastx, lasty) to (lastx, lasty+dy).

SVG equivalent: "v <dy>"

◆ addArcTo()

virtual void addArcTo ( double  rx,
double  ry,
double  phi,
bool  largeArc,
bool  sweep,
double  x,
double  y 
)
virtual

Appends an ArcTo item to the path. It will draw an arc from the last point to the (x,y) point. The size and orientation of the ellipse are defined by two radii (rx, ry) and a phi rotation angle. The center of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. The largeArc and sweep flags determine which of the four possible arcs are chosen. If largeArc=true, then one of the larger (greater than 180 degrees) arcs are chosen, otherwise one of the the smaller ones. If sweep=true, the arc will be drawn in the "positive-angle" direction, otherwise in the negative-angle direction.

SVG equivalent: "A <rx> <ry> <phi> <largeArc> <sweep> <x> <y>"

◆ addArcRel()

virtual void addArcRel ( double  rx,
double  ry,
double  phi,
bool  largeArc,
bool  sweep,
double  dx,
double  dy 
)
virtual

Appends an ArcRel item to the path. It will draw an arc from the last point (lastx, lasty) to (lastx+dx, lasty+dy). Just as with addArcTo(), the size and orientation of the ellipse are defined by two radii (rx, ry) and a phi rotation angle. The center of the ellipse is calculated automatically to satisfy the constraints imposed by the other parameters. The largeArc and sweep flags determine which of the four possible arcs are chosen. If largeArc=true, then one of the larger (greater than 180 degrees) arcs are chosen, otherwise one of the the smaller ones. If sweep=true, the arc will be drawn in the "positive-angle" direction, otherwise in the negative-angle direction.

SVG equivalent: "a <rx> <ry> <phi> <largeArc> <sweep> <dx> <dy>"

◆ addCurveTo()

virtual void addCurveTo ( double  x1,
double  y1,
double  x,
double  y 
)
virtual

Appends a CurveTo item to the path. It will draw a quadratic Bezier curve from the current point to (x,y) using (x1,y1) as the control point.

SVG equivalent: "Q <x1> <y1> <x> <y>"

◆ addCurveRel()

virtual void addCurveRel ( double  dx1,
double  dy1,
double  dx,
double  dy 
)
virtual

Appends a CurveRel item to the path. It will draw a quadratic Bezier curve from the current point (lastx, lasty) to (lastx+dx, lasty+dy) using (lastx+dx1, lasty+dy1) as the control point.

SVG equivalent: "q <dx1> <dy1> <dx> <dy>"

◆ addSmoothCurveTo()

virtual void addSmoothCurveTo ( double  x,
double  y 
)
virtual

Appends a SmoothCurveTo item to the path. It will draw a quadratic Bezier curve from the current point to (x,y). The control point is assumed to be the reflection of the control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not a quadratic Bezier curve command such as Q, q, T or t, assume the control point is coincident with the current point.)

SVG equivalent: "T <x> <y>"

◆ addSmoothCurveRel()

virtual void addSmoothCurveRel ( double  dx,
double  dy 
)
virtual

Appends a SmoothCurveRel item to the path. It will draw a quadratic Bezier curve from the current point (lastx, lasty) to (last+dx, lasty+dy). The control point is assumed to be the reflection of the control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not a quadratic Bezier curve command such as Q, q, T or t, assume the control point is coincident with the current point.)

SVG equivalent: "t <dx> <dy>"

◆ addCubicBezierCurveTo()

virtual void addCubicBezierCurveTo ( double  x1,
double  y1,
double  x2,
double  y2,
double  x,
double  y 
)
virtual

Appends a CubicBezierCurveTo item to the path. It will draw a cubic Bezier curve from the current point to (x,y) using (x1,y1) as the control point at the beginning of the curve and (x2,y2) as the control point at the end of the curve.

SVG equivalent: "C <x1> <y1> <x2> <y2> <x> <y>"

◆ addCubicBezierCurveRel()

virtual void addCubicBezierCurveRel ( double  dx1,
double  dy1,
double  dx2,
double  dy2,
double  dx,
double  dy 
)
virtual

Appends a CubicBezierCurveRel item to the path. It will draw a cubic Bezier curve from the current point (lastx, lasty) to (lastx+dx, lasty+dy) using (lastx+dx1, lasty+dy1) as the control point at the beginning of the curve and (lastx+dx2, lasty+dy2) as the control point at the end of the curve.

SVG equivalent: "c <dx1> <dy1> <dx2> <dy2> <dx> <dy>"

◆ addSmoothCubicBezierCurveTo()

virtual void addSmoothCubicBezierCurveTo ( double  x2,
double  y2,
double  x,
double  y 
)
virtual

Appends a SmoothCubicBezierCurveTo item to the path. It will draw a cubic Bezier curve from the current point to (x,y). The first control point is assumed to be the reflection of the second control point on the previous command relative to the last point. (If there is no previous command or if the previous command was not a cubic Bezier command such as C, c, S or s, assume the first control point is coincident with the current point.) (x2,y2) is the second control point (i.e., the control point at the end of the curve).

SVG equivalent: "S <x2> <y2> <x> <y>"

◆ addSmoothCubicBezierCurveRel()

virtual void addSmoothCubicBezierCurveRel ( double  dx2,
double  dy2,
double  dx,
double  dy 
)
virtual

Appends a SmoothCubicBezierCurveRel item to the path. It will draw a cubic Bezier curve from the current point (lastx, lasty) to (lastx+dx, lasty+dy). The first control point is assumed to be the reflection of the second control point on the previous command relative to the last point. (If there is no previous command or if the previous command was not a cubic Bezier command such as C, c, S or s, assume the first control point is coincident with the current point.) (lastx+dx2, lasty+dy2) is the second control point (i.e., the control point at the end of the curve).

SVG equivalent: "s <dx2> <dy2> <dx> <dy>"

◆ addClosePath()

virtual void addClosePath ( )
virtual

Appends a ClosePath item to the path. It will close the current subpath by drawing a straight line from the current point to current subpath's initial point.

SVG equivalent: "Z" or "z"


The documentation for this class was generated from the following file: