cAbstractShapeFigure Class Reference¶

API: cAbstractShapeFigure Class Reference
API
cAbstractShapeFigure Class Reference
Inheritance diagram for cAbstractShapeFigure:
[legend]

Public Member Functions

Constructors, destructor, assignment.
Redefined cObject and cFigure member functions.
virtual cAbstractShapeFiguredup () const override
virtual std::string str () const override
virtual void parse (cProperty *property) override
Styling
virtual bool isFilled () const
virtual void setFilled (bool filled)
virtual bool isOutlined () const
virtual void setOutlined (bool outlined)
virtual const ColorgetLineColor () const
virtual void setLineColor (const Color &lineColor)
virtual const ColorgetFillColor () 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)
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 moveLocal (double dx, double dy)=0
virtual void move (double dx, double dy)
virtual void refreshDisplay ()
virtual const char * getRendererClassName () const =0
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
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)=default
virtual ~cObject ()
virtual const char * getClassName () const
bool isName (const char *s) const
virtual const char * getFullName () const
virtual std::string getFullPath () const
virtual std::string getClassAndFullName () const
virtual std::string getClassAndFullPath () const
const cObjectgetThisPtr () const
virtual std::ostream & printOn (std::ostream &os) const
virtual bool isSoftOwner () const
cObjectfindObject (const char *name, bool deep=true)
virtual cClassDescriptorgetDescriptor () const
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

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...
enum  Alignment
 Text alignment mode constants: ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER. More...
Static Public Member Functions inherited from cOwnedObject
static long getTotalObjectCount ()
static long getLiveObjectCount ()
static void resetObjectCounters ()
static cSoftOwnergetOwningContext ()

Description

Abstract base class for various shapes.

This class provides line and fill color, line and fill opacity, line style, line width, and other properties for them. Both outline and fill are optional.

When the outline is drawn with a width larger than one pixel, it will be drawn symmetrically, i.e. approximately 50-50% of its width will fall inside and outside the shape.

Transformations such as scaling or skew do affect the width of the line as it is rendered on the canvas. Whether zooming (by the user) should also affect it can be controlled by setting a flag (see setZoomLineWidth()).

The rendering of zero-width lines is currently undefined. It is attempted to be rendered as a one pixel wide line, regardless of transforms and zoom level, but it is not possible on all platform.

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

Reimplemented in cOvalFigure, cPathFigure, cPieSliceFigure, cPolygonFigure, cRectangleFigure, and cRingFigure.

References cFigure::cFigure().

◆ dup()

virtual cAbstractShapeFigure * 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 cFigure.

Reimplemented in cOvalFigure, cPathFigure, cPieSliceFigure, cPolygonFigure, cRectangleFigure, and cRingFigure.

◆ str()

virtual std::string str ( ) const
overridevirtual

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

Reimplemented from cFigure.

Reimplemented in cOvalFigure, cPathFigure, cPieSliceFigure, cPolygonFigure, cRectangleFigure, and cRingFigure.

◆ 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 cFigure.

Reimplemented in cOvalFigure, cPathFigure, cPieSliceFigure, cPolygonFigure, cRectangleFigure, and cRingFigure.

◆ isFilled()

virtual bool isFilled ( ) const
inlinevirtual

Returns true if the figure rendered as filled, and false if not.

◆ setFilled()

virtual void setFilled ( bool filled)
virtual

Sets the flag that controls whether the figure should be filled. The default setting is false (unfilled).

◆ isOutlined()

virtual bool isOutlined ( ) const
inlinevirtual

Returns true if the figure's outline is to be drawn, and false if not.

◆ setOutlined()

virtual void setOutlined ( bool outlined)
virtual

Sets the flag that controls whether the figure's outline should be drawn. The default setting is true.

◆ getLineColor()

virtual const Color & getLineColor ( ) const
inlinevirtual

Returns the color of the figure's outline.

◆ setLineColor()

virtual void setLineColor ( const Color & lineColor)
virtual

Sets the color of the figure's outline. The default outline color is black.

◆ getFillColor()

virtual const Color & getFillColor ( ) const
inlinevirtual

Returns the fill color of the figure.

◆ setFillColor()

virtual void setFillColor ( const Color & fillColor)
virtual

Sets the fill color of the figure. Note that setting the fill color in itself does not make the figure filled, calling setFilled(true) is also needed. The default fill color is blue.

◆ getLineStyle()

virtual LineStyle getLineStyle ( ) const
inlinevirtual

Returns the line style of the figure's outline.

◆ setLineStyle()

virtual void setLineStyle ( LineStyle lineStyle)
virtual

Sets the line style of the figure's outline (dotted, dashed, etc.) The default line style is solid.

◆ getLineWidth()

virtual double getLineWidth ( ) const
inlinevirtual

Returns the line width of the figure's outline. Note that the actual line width will also be affected by the figure transformations and, if zoomLineWidth is set, by the zoom level as well.

◆ setLineWidth()

virtual void setLineWidth ( double lineWidth)
virtual

Sets the line width of the figure's outline. The number must be positive (zero is not allowed). The default line width is 1. See also setZoomLineWidth().

◆ getLineOpacity()

virtual double getLineOpacity ( ) const
inlinevirtual

Returns the opacity of the figure's outline, a number in the [0,1] interval.

◆ setLineOpacity()

virtual void setLineOpacity ( double lineOpacity)
virtual

Sets the opacity of the figure's outline. The argument must be a number in the [0,1] interval. The default opacity is 1.0.

◆ getFillOpacity()

virtual double getFillOpacity ( ) const
inlinevirtual

Returns the opacity of the figure's fill, a number in the [0,1] interval.

◆ setFillOpacity()

virtual void setFillOpacity ( double fillOpacity)
virtual

Sets the opacity of the figure's fill. The argument must be a number in the [0,1] interval. The default opacity is 1.0.

◆ getZoomLineWidth()

virtual bool getZoomLineWidth ( ) const
inlinevirtual

Returns true if zoom level affects the line width the figure's outline is drawn with, and false if it does not.

◆ setZoomLineWidth()

virtual void setZoomLineWidth ( bool zoomLineWidth)
virtual

Sets the flag that controls whether zoom level should affect the line width the figure's outline is drawn with. The default setting is false, i.e. zoom does not affect line width.