OMNeT++ Simulation Library
5.4.1
|
#include <ccanvas.h>
Abstract base class for figures that display text. Text may be multi-line.
The location of the text on the canvas is determined jointly by the position and anchor properties. The anchor tells how to position the text relative to the positioning point. For example, if anchor is ANCHOR_CENTER then the text is centered on the point; if anchor is ANCHOR_N then the text will be drawn so that its top center is at the positioning point. The values ANCHOR_BASELINE_START, ANCHOR_BASELINE_MIDDLE, ANCHOR_BASELINE_END refer to the beginning, middle and end of the baseline of the (first line of the) text as anchor point. Anchor defaults to ANCHOR_CENTER.
Other properties in this class define the font, color and opacity of the text.
Public Member Functions | |
Constructors, destructor, assignment. | |
cAbstractTextFigure (const char *name=nullptr) | |
cAbstractTextFigure (const cAbstractTextFigure &other) | |
cAbstractTextFigure & | operator= (const cAbstractTextFigure &other) |
Redefined cObject and cFigure member functions. | |
virtual cAbstractTextFigure * | dup () const override |
virtual std::string | str () const override |
virtual void | parse (cProperty *property) override |
virtual void | moveLocal (double dx, double dy) override |
Geometry | |
virtual const Point & | getPosition () const |
virtual void | setPosition (const Point &position) |
virtual Anchor | getAnchor () const |
virtual void | setAnchor (Anchor anchor) |
virtual Rectangle | getBounds () const |
Styling | |
virtual const Color & | getColor () const |
virtual void | setColor (const Color &color) |
virtual double | getOpacity () const |
virtual void | setOpacity (double opacity) |
virtual bool | getHalo () const |
virtual void | setHalo (bool enabled) |
virtual const Font & | getFont () const |
virtual void | setFont (Font font) |
Input | |
virtual const char * | getText () const |
virtual void | setText (const char *text) |
![]() | |
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 () |
virtual const char * | getRendererClassName () const =0 |
![]() | |
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 |
![]() | |
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 () |
![]() | |
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 |
![]() | |
virtual void | take (cOwnedObject *obj) |
virtual void | drop (cOwnedObject *obj) |
void | dropAndDelete (cOwnedObject *obj) |
Additional Inherited Members | |
![]() | |
![]() | |
static long | getTotalObjectCount () |
static long | getLiveObjectCount () |
static void | resetObjectCounters () |
static cDefaultList * | getDefaultOwner () |
![]() | |
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 cFigure.
|
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 cLabelFigure, and cTextFigure.
|
overridevirtual |
Returns a one-line string with the most characteristic data of the figure.
Reimplemented from cFigure.
|
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.
|
overridevirtual |
Updates the position of the text, see getPosition().
Implements cFigure.
|
inlinevirtual |
Returns the position of the text. The position and the anchoring mode jointly determine the placement of the text item; see the class description for details.
|
virtual |
Sets the position of the text. The position and the anchoring mode jointly determine the placement of the text item; see the class description for details.
|
inlinevirtual |
Returns the anchoring mode of the text. The position and the anchoring mode jointly determine the placement of the text item; see the class description for details.
|
virtual |
Sets the anchoring mode of the text. The position and the anchoring mode jointly determine the placement of the text item; see the class description for details.
|
virtual |
Returns the bounding box of the text figure.
Caveat: Note that the figure itself only has a position and an anchor available for computing the bounding box, size (and for some cases ascent height) need to be supplied by the user interface of the simulation (cEnvir). The result depends on the details of font rendering and other factors, so the returned numbers and their accuracy may vary across user interfaces (Qtenv vs. Tkenv), operating systems or even installations. Cmdenv and other non-GUI environments may return completely made-up (but not entirely unrealistic) numbers.
|
inlinevirtual |
Returns the text color.
|
virtual |
Sets the text color. The default color is black.
|
inlinevirtual |
Returns the opacity of the figure, a number in the [0,1] interval.
|
virtual |
Sets the line opacity of the figure. The argument must be a number in the [0,1] interval. The default opacity is 1.0.
|
inlinevirtual |
Returns true if a "halo" is displayed around the text.
|
virtual |
Sets the flag that controls whether a partially transparent "halo" should be displayed around the text. The halo improves the readability of the text when it is displayed over a background that has similar color as the text, or when it overlaps with other text items. The default setting is false (no halo).
Note: in Qtenv, halo may be slow to render for text figures (cTextFigure) under some circumstances. There is no such penalty for label figures (cLabelFigure).
|
inlinevirtual |
Returns the font used for the figure.
|
virtual |
Sets the font to be used for the figure. The default font has no specific typeface or size set, allowing the UI to use its preferred font.
|
inlinevirtual |
Returns the text to be displayed.
|
virtual |
Sets the text to be displayed. The text may contain newline and tab characters ("\n", "\t") for formatting.