OMNeT++ Simulation Library
5.6.1
|
#include <ccanvas.h>
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.
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 () |
cPathFigure & | operator= (const cPathFigure &other) |
Redefined cObject and cFigure member functions. | |
virtual cPathFigure * | dup () 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 Point & | getOffset () 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 PathItem * | getPathItem (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) | |
cAbstractShapeFigure & | operator= (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 () |
cFigure & | operator= (const cFigure &other) |
virtual void | forEachChild (cVisitor *v) override |
int | getId () const |
virtual bool | isVisible () const |
virtual void | setVisible (bool visible) |
virtual const Transform & | getTransform () 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 cObject * | getAssociatedObject () const |
virtual void | setAssociatedObject (cObject *obj) |
virtual const char * | getTags () const |
virtual void | setTags (const char *tags) |
virtual cFigure * | getParentFigure () const |
virtual cCanvas * | getCanvas () const |
virtual int | getNumFigures () const |
virtual cFigure * | getFigure (int pos) const |
virtual cFigure * | getFigure (const char *name) const |
virtual int | findFigure (const char *name) const |
virtual int | findFigure (const cFigure *figure) const |
virtual bool | containsFigures () const |
virtual cFigure * | findFigureRecursively (const char *name) const |
virtual cFigure * | getFigureByPath (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 cFigure * | removeFigure (cFigure *figure) |
virtual cFigure * | removeFigure (int pos) |
virtual cFigure * | removeFromParent () |
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 cFigure * | dupTree () 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 () |
cOwnedObject & | operator= (const cOwnedObject &o) |
virtual void | parsimPack (cCommBuffer *buffer) const override |
virtual void | parsimUnpack (cCommBuffer *buffer) override |
virtual cObject * | getOwner () 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 () |
cNamedObject & | operator= (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 cObject * | getThisPtr () const |
virtual _OPPDEPRECATED std::string | info () const |
virtual _OPPDEPRECATED std::string | detailedInfo () const |
cObject * | findObject (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 cDefaultList * | getDefaultOwner () |
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] |
|
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.
|
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.
|
overridevirtual |
Returns a one-line string with the most characteristic data of the figure.
Reimplemented from cAbstractShapeFigure.
|
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.
|
overridevirtual |
The move operation modifies the offset field (see getOffset()).
Implements cFigure.
|
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.
|
inlinevirtual |
Returns the join style line segments will be connected with.
|
virtual |
Sets the join style line segments will be connected with. The default join style is miter.
|
inlinevirtual |
Returns the cap style for the figure's line.
|
virtual |
Sets the cap style for the figure's line. The default cap style is butt.
|
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.
|
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.
|
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.
|
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.
|
virtual |
Returns the path as a string.
|
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.
|
inlinevirtual |
Returns the number of path items.
|
inlinevirtual |
|
virtual |
Clears the path by discarding its path items.
|
virtual |
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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>"
|
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"