OMNeT++ API 6.1
Discrete Event Simulation Library
16 #ifndef __OMNETPP_CCANVAS_H
17 #define __OMNETPP_CCANVAS_H
23 #include "cownedobject.h"
24 #include "opp_pooledstring.h"
75 Point (
double x,
double y) : x(x), y(y) {}
78 Point operator * (
double s)
const ;
79 Point operator / (
double s)
const ;
80 double operator * (
const Point & p)
const ;
81 double distanceTo(
const Point & p)
const ;
82 double getLength()
const ;
83 double getAngle()
const {
return std::atan2(y,x);}
84 Point & translate(
double dx,
double dy) {x += dx; y += dy;
return *
this ;}
85 bool operator==(
const Point & other)
const {
return x == other.x && y == other.y;}
86 std::string str()
const ;
97 double x = 0, y = 0, width = 0, height = 0;
102 Rectangle (
double x,
double y,
double width,
double height) : x(x), y(y), width(width), height(height) {}
103 Point getCenter()
const ;
104 Point getSize()
const ;
105 Rectangle & translate(
double dx,
double dy) {x += dx; y += dy;
return *
this ;}
106 bool operator==(
const Rectangle & other)
const {
return x == other.x && y == other.y && width == other.width && height == other.height;}
107 std::string str()
const ;
127 uint8_t red = 0, green = 0, blue = 0;
132 Color (uint8_t red, uint8_t green, uint8_t blue) : red(red), green(green), blue(blue) {}
133 Color (
const char *color) {*
this = parseColor(color);}
135 bool operator==(
const Color & other)
const {
return red == other.red && green == other.green && blue == other.blue;}
136 std::string str()
const ;
142 static const Color BLACK;
143 static const Color WHITE;
144 static const Color GREY;
145 static const Color RED;
146 static const Color GREEN;
147 static const Color BLUE;
148 static const Color YELLOW;
149 static const Color CYAN;
150 static const Color MAGENTA;
152 static const int NUM_GOOD_DARK_COLORS;
153 static const int NUM_GOOD_LIGHT_COLORS;
154 static const Color GOOD_DARK_COLORS[14];
155 static const Color GOOD_LIGHT_COLORS[10];
167 uint8_t style = FONT_NONE;
172 Font (std::string typeface,
int pointSize=-1, uint8_t style=FONT_NONE) : typeface(typeface), pointSize(pointSize), style(style) {}
173 Font(
const Font& other) =
default ;
174 bool operator==(
const Font& other)
const {
return typeface == other.typeface && pointSize == other.pointSize && style == other.style;}
175 std::string str()
const ;
180 enum FontStyle { FONT_NONE=0, FONT_BOLD=1, FONT_ITALIC=2, FONT_UNDERLINE=4 };
183 enum LineStyle { LINE_SOLID, LINE_DOTTED, LINE_DASHED };
195 enum Arrowhead { ARROW_NONE, ARROW_SIMPLE, ARROW_TRIANGLE, ARROW_BARBED };
198 enum Interpolation { INTERPOLATION_NONE, INTERPOLATION_FAST, INTERPOLATION_BEST };
201 enum Anchor {ANCHOR_CENTER, ANCHOR_N, ANCHOR_E, ANCHOR_S, ANCHOR_W, ANCHOR_NW, ANCHOR_NE, ANCHOR_SE, ANCHOR_SW, ANCHOR_BASELINE_START, ANCHOR_BASELINE_MIDDLE, ANCHOR_BASELINE_END };
204 enum Alignment { ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER };
221 double a = 1, b = 0, c = 0, d = 1, t1 = 0, t2 = 0;
227 Transform (
double a,
double b,
double c,
double d,
double t1,
double t2) : a(a), b(b), c(c), d(d), t1(t1), t2(t2) {}
230 Transform & translate(
double dx,
double dy);
231 Transform & translate(
const Point & p) {
return translate(p.x, p.y);}
232 Transform & scale(
double s) {
return scale(s,s);}
234 Transform & scale(
double sx,
double sy,
double cx,
double cy);
235 Transform & scale(
double sx,
double sy,
const Point & c) {
return scale(sx, sy, c.x, c.y);}
237 Transform & rotate(
double phi,
double cx,
double cy);
238 Transform & rotate(
double phi,
const Point & c) {
return rotate(phi, c.x, c.y);}
241 Transform & skewx(
double coeff,
double cy);
242 Transform & skewy(
double coeff,
double cx);
246 bool operator==(
const Transform & o)
const {
return a == o.a && b == o.b && c == o.c && d == o.d && t1 == o.t1 && t2 == o.t2;}
247 std::string str()
const ;
258 uint8_t red = 0, green = 0, blue = 0, alpha = 0;
263 RGBA (uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha) : red(red), green(green), blue(blue), alpha(alpha) {}
264 explicit RGBA (
const Color & color,
double opacity=1) : red(color.red), green(color.green), blue(color.blue), alpha(toAlpha(opacity)) {}
266 void set(uint8_t r, uint8_t g, uint8_t b, uint8_t a) {red=r; green=g; blue=b; alpha=a;}
267 void operator=(
const Color & color) {red = color.red; green = color.green; blue = color.blue; alpha = 255;}
268 operator Color ()
const {
return Color (red, green, blue);}
269 bool operator==(
const RGBA & o)
const {
return red == o.red && green == o.green && blue == o.blue && alpha == o.alpha;}
270 static uint8_t toAlpha(
double opacity) {
return opacity<=0 ? 0 : opacity>=1.0 ? 255 : (uint8_t)(opacity*255+0.5);}
271 std::string str()
const ;
282 int width = 0, height = 0;
283 RGBA *data =
nullptr ;
285 void allocate(
int width,
int height);
291 Pixmap (
int width,
int height,
const Color & color,
double opacity=1) :
Pixmap (width, height,
RGBA (color, opacity)) {}
295 void setSize(
int width,
int height,
const RGBA & fill_);
296 void setSize(
int width,
int height,
const Color & color,
double opacity);
297 void fill(
const RGBA & fill_);
298 void fill(
const Color & color,
double opacity);
299 int getWidth()
const {
return width;}
300 int getHeight()
const {
return height;}
301 RGBA & pixel(
int x,
int y);
302 const RGBA pixel(
int x,
int y)
const {
return const_cast< Pixmap *
> (
this )->pixel(x,y);}
303 void setPixel(
int x,
int y,
const Color & color,
double opacity=1.0) {
RGBA & p = pixel(x,y); p.set(color.red, color.green, color.blue, RGBA::toAlpha(opacity));}
304 const Color getColor(
int x,
int y)
const {
return (
Color )pixel(x,y);}
305 void setColor(
int x,
int y,
const Color & color) {
RGBA & p = pixel(x,y); p.red = color.red; p.green = color.green; p.blue = color.blue;}
306 double getOpacity(
int x,
int y)
const {
return pixel(x,y).alpha / 255.0;}
307 void setOpacity(
int x,
int y,
double opacity) {pixel(x,y).alpha = RGBA::toAlpha(opacity);}
308 const uint8_t *buffer()
const {
return (uint8_t*)data;}
309 std::string str()
const ;
315 CHANGE_STRUCTURAL = 1,
316 CHANGE_TRANSFORM = 2,
319 CHANGE_INPUTDATA = 16,
329 bool hasTooltip =
false ;
332 cObject *associatedObject =
nullptr ;
334 std::vector<cFigure*> children;
336 uint64_t tagBits = 0;
337 uint8_t localChanges = 0;
338 uint8_t subtreeChanges = 0;
339 mutable bool cachedHashValid =
false ;
340 mutable uint32_t cachedHash = 0;
344 virtual void validatePropertyKeys(
cProperty *property)
const ;
345 virtual bool isAllowedPropertyKey(
const char *key)
const ;
346 virtual cFigure *getRootFigure()
const ;
347 void fireStructuralChange() {fire(CHANGE_STRUCTURAL);}
348 void fireTransformChange() {fire(CHANGE_TRANSFORM);}
349 void fireGeometryChange() {fire(CHANGE_GEOMETRY);}
350 void fireVisualChange() {fire(CHANGE_VISUAL);}
351 void fireInputDataChange() {fire(CHANGE_INPUTDATA);}
352 virtual void fire(uint8_t flags);
353 virtual void hashTo(cHasher& hasher)
const ;
357 static Point parsePoint(cProperty *property,
const char *key,
int index);
358 static std::vector<Point> parsePoints(cProperty *property,
const char *key);
359 static Rectangle parseBounds(cProperty *property,
const Rectangle& defaults);
360 static Transform parseTransform(cProperty *property,
const char *key);
361 static Font parseFont(cProperty *property,
const char *key);
362 static Rectangle computeBoundingBox(
const Point& position,
const Point& size,
double ascent, Anchor anchor);
363 static void concatArrays(
const char **dest,
const char **first,
const char **second);
367 static Point parsePoint(
const char *s);
368 static Rectangle parseRectangle(
const char *s);
369 static Transform parseTransform(
const char *s);
370 static Font parseFont(
const char *s);
371 static Color parseColor(
const char *s);
372 static bool parseBool(
const char *s);
373 static LineStyle parseLineStyle(
const char *s);
374 static CapStyle parseCapStyle(
const char *s);
375 static JoinStyle parseJoinStyle(
const char *s);
376 static FillRule parseFillRule(
const char *s);
377 static Arrowhead parseArrowhead(
const char *s);
378 static Interpolation parseInterpolation(
const char *s);
379 static Anchor parseAnchor(
const char *s);
380 static Alignment parseAlignment(
const char *s);
384 virtual void updateParentTransform(Transform& transform) {transform.rightMultiply(getTransform());}
385 virtual void callRefreshDisplay();
386 uint8_t getLocalChangeFlags()
const {
return localChanges;}
387 uint8_t getSubtreeChangeFlags()
const {
return subtreeChanges;}
388 void clearChangeFlags();
389 void refreshTagBitsRec(cCanvas *ownerCanvas);
390 int64_t getTagBits()
const {
return tagBits;}
391 void setTagBits(uint64_t tagBits) {this->tagBits = tagBits;}
392 uint32_t getHash()
const ;
393 void clearCachedHash();
396 void copy(
const cFigure& other);
404 explicit cFigure(
const char *name=
nullptr );
437 virtual void forEachChild(
cVisitor *v)
override ;
442 virtual std::string str()
const override ;
463 virtual void setVisible(
bool visible);
476 virtual void setTransform(
const Transform& transform);
501 virtual void setZIndex(
double zIndex);
509 virtual double getEffectiveZIndex()
const ;
514 virtual const char *
getTooltip ()
const {
return hasTooltip ? tooltip.c_str() :
nullptr ;}
522 virtual void setTooltip(
const char *tooltip);
537 virtual void setAssociatedObject(
cObject *obj);
544 virtual const char *
getTags ()
const {
return tags.c_str();}
551 virtual void setTags(
const char *tags);
566 virtual cCanvas *getCanvas()
const ;
578 virtual cFigure *getFigure(
int pos)
const ;
584 virtual cFigure *getFigure(
const char *name)
const ;
590 virtual int findFigure(
const char *name)
const ;
596 virtual int findFigure(
const cFigure *figure)
const ;
607 virtual cFigure *findFigureRecursively(
const char *name)
const ;
627 virtual cFigure *getFigureByPath(
const char *path)
const ;
635 virtual void addFigure(
cFigure *figure);
643 virtual void addFigure(
cFigure *figure,
int pos);
659 virtual cFigure *removeFigure(
int pos);
665 virtual cFigure *removeFromParent();
676 virtual bool isAbove(
const cFigure *figure)
const ;
684 virtual bool isBelow(
const cFigure *figure)
const ;
698 virtual void insertAbove(
cFigure *referenceFigure);
712 virtual void insertBelow(
cFigure *referenceFigure);
719 virtual void insertAfter(
const cFigure *referenceFigure);
726 virtual void insertBefore(
const cFigure *referenceFigure);
734 virtual void raiseAbove(
cFigure *figure);
742 virtual void lowerBelow(
cFigure *figure);
750 virtual void raiseToTop();
758 virtual void lowerToBottom();
763 virtual cFigure *dupTree()
const ;
768 virtual void translate(
double dx,
double dy) {transform.translate(dx,dy); fireTransformChange();}
769 virtual void scale(
double s) {transform.scale(s); fireTransformChange();}
770 virtual void scale(
double sx,
double sy) {transform.scale(sx,sy); fireTransformChange();}
771 virtual void scale(
double sx,
double sy,
double cx,
double cy) {transform.scale(sx,sy,cx,cy); fireTransformChange();}
772 virtual void scale(
double sx,
double sy,
const Point& c) {scale(sx, sy, c.x, c.y);}
773 virtual void rotate(
double phi) {transform.rotate(phi); fireTransformChange();}
774 virtual void rotate(
double phi,
double cx,
double cy) {transform.rotate(phi,cx,cy); fireTransformChange();}
775 virtual void rotate(
double phi,
const Point& c) {rotate(phi, c.x, c.y);}
776 virtual void skewx(
double coeff) {transform.skewx(coeff); fireTransformChange();}
777 virtual void skewy(
double coeff) {transform.skewy(coeff); fireTransformChange();}
778 virtual void skewx(
double coeff,
double cy) {transform.skewx(coeff,cy); fireTransformChange();}
779 virtual void skewy(
double coeff,
double cx) {transform.skewy(coeff,cx); fireTransformChange();}
794 virtual void parse(cProperty *property);
806 virtual const char **getAllowedPropertyKeys()
const ;
812 virtual void moveLocal(
double dx,
double dy) = 0;
820 virtual void move(
double dx,
double dy);
836 virtual const char *getRendererClassName()
const = 0;
841 namespace canvas_stream_ops {
842 #define STREAMOP(CLASS) inline std::ostream& operator<<(std::ostream& os, const CLASS& x) { return os << x.str(); }
843 STREAMOP(cFigure::Point);
844 STREAMOP(cFigure::Rectangle);
845 STREAMOP(cFigure::Color);
846 STREAMOP(cFigure::Font);
847 STREAMOP(cFigure::Transform);
848 STREAMOP(cFigure::RGBA);
849 STREAMOP(cFigure::Pixmap);
879 virtual std::string str()
const override ;
881 virtual void moveLocal (
double dx,
double dy)
override {}
904 virtual const char **getAllowedPropertyKeys()
const override ;
905 virtual void parse(
cProperty *property)
override ;
906 virtual void hashTo(
cHasher & hasher)
const override ;
921 virtual std::string str()
const override ;
923 virtual void updateParentTransform(Transform& transform)
override ;
924 virtual void move (
double dx,
double dy)
override { moveLocal(dx, dy); }
925 virtual void moveLocal (
double dx,
double dy)
override {position.x += dx; position.y += dy; fireTransformChange();}
930 virtual const Point& getPosition()
const {
return position;}
931 virtual void setPosition(
const Point& position) {this->position = position; fireTransformChange();}
943 virtual void setAnchorPoint(
const Point& anchorPoint) {this->anchorPoint = anchorPoint; fireTransformChange();}
968 LineStyle lineStyle = LINE_SOLID;
969 double lineWidth = 1;
970 double lineOpacity = 1;
971 CapStyle capStyle = CAP_BUTT;
972 Arrowhead startArrowhead = ARROW_NONE, endArrowhead = ARROW_NONE;
973 bool zoomLineWidth =
false ;
977 virtual const char **getAllowedPropertyKeys()
const override ;
978 virtual void hashTo(
cHasher & hasher)
const override ;
990 virtual std::string str()
const override ;
991 virtual void parse(
cProperty *property)
override ;
1004 virtual void setLineColor(
const Color& lineColor);
1018 virtual void setLineWidth(
double lineWidth);
1029 virtual void setLineOpacity(
double lineOpacity);
1040 virtual void setLineStyle(LineStyle lineStyle);
1051 virtual void setCapStyle(CapStyle capStyle);
1062 virtual void setStartArrowhead(Arrowhead startArrowhead);
1073 virtual void setEndArrowhead(Arrowhead endArrowhead);
1086 virtual void setZoomLineWidth(
bool zoomLineWidth);
1105 virtual const char **getAllowedPropertyKeys()
const override ;
1106 virtual void hashTo(
cHasher & hasher)
const override ;
1118 virtual std::string str()
const override ;
1119 virtual void parse(
cProperty *property)
override ;
1120 virtual void moveLocal(
double dx,
double dy)
override ;
1134 virtual void setStart(
const Point& start);
1139 virtual const Point&
getEnd ()
const {
return end;}
1144 virtual void setEnd(
const Point& end);
1171 double startAngle = 0, endAngle = 0;
1175 virtual const char **getAllowedPropertyKeys()
const override ;
1176 virtual void hashTo(
cHasher & hasher)
const override ;
1188 virtual std::string str()
const override ;
1189 virtual void parse(
cProperty *property)
override ;
1190 virtual void moveLocal(
double dx,
double dy)
override ;
1206 virtual void setBounds(
const Rectangle& bounds);
1212 virtual void setPosition(
const Point& position, Anchor anchor);
1224 virtual void setStartAngle(
double startAngle);
1236 virtual void setEndAngle(
double endAngle);
1260 std::vector<Point> points;
1261 bool smooth =
false ;
1262 JoinStyle joinStyle = JOIN_MITER;
1265 void checkIndex(
int i)
const ;
1266 void checkInsIndex(
int i)
const ;
1268 virtual const char **getAllowedPropertyKeys()
const override ;
1269 virtual void hashTo(
cHasher & hasher)
const override ;
1281 virtual std::string str()
const override ;
1282 virtual void parse(
cProperty *property)
override ;
1283 virtual void moveLocal(
double dx,
double dy)
override ;
1292 virtual const std::vector<Point>&
getPoints ()
const {
return points;}
1297 virtual void setPoints(
const std::vector<Point>& points);
1314 virtual void setNumPoints(
int size);
1319 virtual void setPoint(
int i,
const Point& point);
1324 virtual void addPoint(
const Point& point);
1329 virtual void removePoint(
int i);
1335 virtual void insertPoint(
int i,
const Point& point);
1351 virtual void setSmooth(
bool smooth);
1365 virtual void setJoinStyle(JoinStyle joinStyle);
1392 bool outlined =
true ;
1393 bool filled =
false ;
1396 LineStyle lineStyle = LINE_SOLID;
1397 double lineWidth = 1;
1398 double lineOpacity = 1;
1399 double fillOpacity = 1;
1400 bool zoomLineWidth =
false ;
1404 virtual const char **getAllowedPropertyKeys()
const override ;
1405 virtual void hashTo(
cHasher & hasher)
const override ;
1417 virtual std::string str()
const override ;
1418 virtual void parse(
cProperty *property)
override ;
1432 virtual void setFilled(
bool filled);
1443 virtual void setOutlined(
bool outlined);
1454 virtual void setLineColor(
const Color& lineColor);
1466 virtual void setFillColor(
const Color& fillColor);
1477 virtual void setLineStyle(LineStyle lineStyle);
1491 virtual void setLineWidth(
double lineWidth);
1503 virtual void setLineOpacity(
double lineOpacity);
1515 virtual void setFillOpacity(
double fillOpacity);
1528 virtual void setZoomLineWidth(
bool zoomLineWidth);
1545 double cornerRx = 0, cornerRy = 0;
1547 virtual const char **getAllowedPropertyKeys()
const override ;
1548 virtual void hashTo(
cHasher & hasher)
const override ;
1562 virtual std::string str()
const override ;
1563 virtual void parse(
cProperty *property)
override ;
1564 virtual void moveLocal(
double dx,
double dy)
override ;
1578 virtual void setBounds(
const Rectangle& bounds);
1584 virtual void setPosition(
const Point& position, Anchor anchor);
1601 virtual void setCornerRx(
double rx);
1612 virtual void setCornerRy(
double ry);
1632 virtual const char **getAllowedPropertyKeys()
const override ;
1633 virtual void hashTo(
cHasher & hasher)
const override ;
1645 virtual std::string str()
const override ;
1646 virtual void parse(
cProperty *property)
override ;
1647 virtual void moveLocal(
double dx,
double dy)
override ;
1661 virtual void setBounds(
const Rectangle& bounds);
1667 virtual void setPosition(
const Point& position, Anchor anchor);
1685 double innerRx = 0, innerRy = 0;
1689 virtual const char **getAllowedPropertyKeys()
const override ;
1690 virtual void hashTo(
cHasher & hasher)
const override ;
1702 virtual std::string str()
const override ;
1703 virtual void parse(
cProperty *property)
override ;
1704 virtual void moveLocal(
double dx,
double dy)
override ;
1718 virtual void setBounds(
const Rectangle& bounds);
1724 virtual void setPosition(
const Point& position, Anchor anchor);
1741 virtual void setInnerRx(
double rx);
1751 virtual void setInnerRy(
double ry);
1786 double startAngle = 0, endAngle = 0;
1790 virtual const char **getAllowedPropertyKeys()
const override ;
1791 virtual void hashTo(
cHasher & hasher)
const override ;
1803 virtual std::string str()
const override ;
1804 virtual void parse(
cProperty *property)
override ;
1805 virtual void moveLocal(
double dx,
double dy)
override ;
1821 virtual void setBounds(
const Rectangle& bounds);
1827 virtual void setPosition(
const Point& position, Anchor anchor);
1839 virtual void setStartAngle(
double startAngle);
1851 virtual void setEndAngle(
double endAngle);
1871 std::vector<Point> points;
1872 bool smooth =
false ;
1877 void checkIndex(
int i)
const ;
1878 void checkInsIndex(
int i)
const ;
1880 virtual const char **getAllowedPropertyKeys()
const override ;
1881 virtual void hashTo(
cHasher & hasher)
const override ;
1893 virtual std::string str()
const override ;
1894 virtual void parse(
cProperty *property)
override ;
1895 virtual void moveLocal(
double dx,
double dy)
override ;
1904 virtual const std::vector<Point>&
getPoints ()
const {
return points;}
1909 virtual void setPoints(
const std::vector<Point>& points);
1920 virtual const Point&
getPoint (
int i)
const {checkIndex(i);
return points[i];}
1926 virtual void setNumPoints(
int size);
1931 virtual void setPoint(
int i,
const Point& point);
1936 virtual void addPoint(
const Point& point);
1941 virtual void removePoint(
int i);
1947 virtual void insertPoint(
int i,
const Point& point);
1960 virtual void setSmooth(
bool smooth);
1974 virtual void setJoinStyle(JoinStyle joinStyle);
1991 virtual void setFillRule(FillRule fillRule);
2014 struct PathItem {
char code; };
2015 struct MoveTo : PathItem {
double x;
double y; };
2016 struct MoveRel : PathItem {
double dx;
double dy; };
2017 struct LineTo : PathItem {
double x;
double y; };
2018 struct LineRel : PathItem {
double dx;
double dy; };
2019 struct HorizontalLineTo : PathItem {
double x; };
2020 struct HorizontalLineRel : PathItem {
double dx; };
2021 struct VerticalLineTo : PathItem {
double y; };
2022 struct VerticalLineRel : PathItem {
double dy; };
2023 struct ArcTo : PathItem {
double rx;
double ry;
double phi;
bool largeArc;
bool sweep;
double x;
double y; };
2024 struct ArcRel : PathItem {
double rx;
double ry;
double phi;
bool largeArc;
bool sweep;
double dx;
double dy; };
2025 struct CurveTo : PathItem {
double x1;
double y1;
double x;
double y; };
2026 struct CurveRel : PathItem {
double dx1;
double dy1;
double dx;
double dy; };
2027 struct SmoothCurveTo : PathItem {
double x;
double y; };
2028 struct SmoothCurveRel : PathItem {
double dx;
double dy; };
2029 struct CubicBezierCurveTo : PathItem {
double x1;
double y1;
double x2;
double y2;
double x;
double y; };
2030 struct CubicBezierCurveRel : PathItem {
double dx1;
double dy1;
double dx2;
double dy2;
double dx;
double dy; };
2031 struct SmoothCubicBezierCurveTo : PathItem {
double x2;
double y2;
double x;
double y; };
2032 struct SmoothCubicBezierCurveRel : PathItem {
double dx2;
double dy2;
double dx;
double dy; };
2033 struct ClosePath : PathItem { };
2036 std::vector<PathItem*> path;
2037 mutable std::string cachedPathString;
2045 void addItem(PathItem *item);
2049 virtual const char **getAllowedPropertyKeys()
const override ;
2050 virtual void hashTo(
cHasher & hasher)
const override ;
2064 virtual std::string str()
const override ;
2065 virtual void parse(
cProperty *property)
override ;
2069 virtual void moveLocal(
double dx,
double dy)
override ;
2084 virtual void setJoinStyle(JoinStyle joinStyle);
2095 virtual void setCapStyle(CapStyle capStyle);
2113 virtual void setFillRule(FillRule fillRule);
2132 virtual void setOffset(
const Point& offset);
2140 virtual const char *getPath()
const ;
2147 virtual void setPath(
const char *path);
2164 virtual void clearPath();
2172 virtual void addMoveTo(
double x,
double y);
2181 virtual void addMoveRel(
double dx,
double dy);
2189 virtual void addLineTo(
double x,
double y);
2197 virtual void addLineRel(
double dx,
double dy);
2205 virtual void addHorizontalLineTo(
double x);
2213 virtual void addHorizontalLineRel(
double dx);
2221 virtual void addVerticalLineTo(
double y);
2229 virtual void addVerticalLineRel(
double dy);
2245 virtual void addArcTo(
double rx,
double ry,
double phi,
bool largeArc,
bool sweep,
double x,
double y);
2262 virtual void addArcRel(
double rx,
double ry,
double phi,
bool largeArc,
bool sweep,
double dx,
double dy);
2270 virtual void addCurveTo(
double x1,
double y1,
double x,
double y);
2279 virtual void addCurveRel(
double dx1,
double dy1,
double dx,
double dy);
2292 virtual void addSmoothCurveTo(
double x,
double y);
2305 virtual void addSmoothCurveRel(
double dx,
double dy);
2315 virtual void addCubicBezierCurveTo(
double x1,
double y1,
double x2,
double y2,
double x,
double y);
2326 virtual void addCubicBezierCurveRel(
double dx1,
double dy1,
double dx2,
double dy2,
double dx,
double dy);
2340 virtual void addSmoothCubicBezierCurveTo(
double x2,
double y2,
double x,
double y);
2354 virtual void addSmoothCubicBezierCurveRel(
double dx2,
double dy2,
double dx,
double dy);
2363 virtual void addClosePath();
2395 Anchor anchor = ANCHOR_NW;
2396 Alignment alignment = ALIGN_LEFT;
2400 virtual const char **getAllowedPropertyKeys()
const override ;
2401 virtual void hashTo(
cHasher & hasher)
const override ;
2413 virtual std::string str()
const override ;
2414 virtual void parse(
cProperty *property)
override ;
2418 virtual void moveLocal(
double dx,
double dy)
override ;
2435 virtual void setPosition(
const Point& position);
2449 virtual void setAnchor(Anchor anchor);
2467 virtual void setAlignment(Alignment alignment);
2483 virtual Rectangle getBounds()
const ;
2496 virtual void setColor(
const Color& color);
2507 virtual void setOpacity(
double opacity);
2525 virtual void setHalo(
bool enabled);
2537 virtual void setFont(Font font);
2545 virtual const char *
getText ()
const {
return text.c_str();}
2551 virtual void setText(
const char * text);
2598 virtual const char **getAllowedPropertyKeys()
const override ;
2599 virtual void hashTo(
cHasher & hasher)
const override ;
2611 virtual void parse(
cProperty *property)
override ;
2617 virtual double getAngle()
const {
return angle;}
2618 virtual void setAngle(
double angle);
2651 Anchor anchor = ANCHOR_CENTER;
2652 double width = 0, height = 0;
2653 Interpolation interpolation = INTERPOLATION_FAST;
2656 double tintAmount = 0;
2660 virtual const char **getAllowedPropertyKeys()
const override ;
2661 virtual void hashTo(
cHasher & hasher)
const override ;
2662 virtual Point getDefaultSize()
const = 0;
2674 virtual void parse(
cProperty *property)
override ;
2678 virtual void moveLocal(
double dx,
double dy)
override ;
2695 virtual void setPosition(
const Point& position);
2709 virtual void setAnchor(Anchor anchor);
2723 virtual void setWidth(
double width);
2737 virtual void setHeight(
double height);
2743 virtual void setSize (
double width,
double height) {setWidth(width); setHeight(height);}
2756 virtual Rectangle getBounds()
const ;
2773 virtual void setInterpolation(Interpolation interpolation);
2784 virtual void setOpacity(
double opacity);
2798 virtual void setTintColor(
const Color& tintColor);
2814 virtual void setTintAmount(
double tintAmount);
2830 std::string imageName;
2834 virtual const char **getAllowedPropertyKeys()
const override ;
2835 virtual void hashTo(
cHasher & hasher)
const override ;
2836 virtual Point getDefaultSize()
const override ;
2848 virtual std::string str()
const override ;
2849 virtual void parse(
cProperty *property)
override ;
2866 virtual void setImageName(
const char * imageName);
2939 virtual const char **getAllowedPropertyKeys()
const override ;
2940 virtual void hashTo(
cHasher & hasher)
const override ;
2941 virtual Point getDefaultSize()
const override ;
2954 virtual std::string str()
const override ;
2955 virtual void parse(
cProperty *property)
override ;
2974 virtual void setPixmap(
const Pixmap& pixmap);
2981 virtual void setPixmapSize(
int width,
int height,
const RGBA& fill);
2983 virtual void setPixmapSize(
int width,
int height,
const Color& color,
double opacity);
2985 virtual void fillPixmap(
const RGBA& fill);
2987 virtual void fillPixmap(
const Color& color,
double opacity);
2989 virtual const RGBA getPixel (
int x,
int y)
const {
return pixmap.pixel(x, y);}
2991 virtual void setPixel(
int x,
int y,
const RGBA& argb);
2993 virtual void setPixel(
int x,
int y,
const Color& color,
double opacity = 1.0);
2997 virtual void setPixelColor(
int x,
int y,
const Color& color);
3001 virtual void setPixelOpacity(
int x,
int y,
double opacity);
3028 std::map<std::string,int> tagBitIndex;
3029 static std::map<std::string,cObjectFactory*> figureFactories;
3030 std::map<const cObject*,double> animationSpeedMap;
3031 double minAnimationSpeed = DBL_MAX;
3032 double animationHoldEndTime = 0;
3036 virtual cFigure *createFigure(
const char *type)
const ;
3037 static bool containsCanvasItems(
cProperties *properties);
3038 virtual void addFiguresFrom(
cProperties *properties);
3039 virtual uint64_t parseTags(
const char *s);
3040 virtual std::string getTags(uint64_t tagBits);
3041 const std::map<const cObject*,double>& getAnimationSpeedMap()
const {
return animationSpeedMap;}
3042 double getMinAnimationSpeed()
const {
return minAnimationSpeed;}
3043 double getAnimationHoldEndTime()
const {
return animationHoldEndTime;}
3045 void copy(
const cCanvas & other);
3049 explicit cCanvas (
const char *name =
nullptr );
3058 virtual void forEachChild(
cVisitor *v)
override ;
3059 virtual std::string str()
const override ;
3078 virtual uint32_t getHash()
const ;
3161 virtual cFigure *getSubmodulesLayer()
const ;
3182 virtual std::string getAllTags()
const ;
3188 virtual std::vector<std::string> getAllTagsAsVector()
const ;
3208 virtual void setAnimationSpeed(
double animationSpeed,
const cObject *source);
3214 virtual double getAnimationSpeed(
const cObject *source);
3234 virtual void holdSimulationFor(
double animationTimeDelta);
CapStyle
Line cap style constants: CAP_BUTT, CAP_SQUARE, etc.
Definition: ccanvas.h:186
virtual cAbstractTextFigure * dup() const override
Definition: ccanvas.h:2412
cObject is a lightweight class which serves as the root of the OMNeT++ class hierarchy....
Definition: cobject.h:92
virtual Anchor getAnchor() const
Definition: ccanvas.h:2442
virtual cFigure * getFigure(const char *name) const
Definition: ccanvas.h:3149
virtual bool getHalo() const
Definition: ccanvas.h:2512
Utility class to calculate the hash of some data.
Definition: chasher.h:40
virtual int findFigure(cFigure *figure) const
Definition: ccanvas.h:3125
Abstract base class for figures that display text. Text may be multi-line.
Definition: ccanvas.h:2386
Alignment
Text alignment mode constants: ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER.
Definition: ccanvas.h:204
virtual cFigure * removeFigure(cFigure *figure)
Definition: ccanvas.h:3106
Enables traversing the tree of (cObject-rooted) simulation objects.
Definition: cvisitor.h:56
virtual double getOpacity() const
Definition: ccanvas.h:2501
virtual cFigure * getFigure(int pos) const
Definition: ccanvas.h:3143
Provides a scene graph based 2D drawing API for modules.
Definition: ccanvas.h:3023
A figure that displays text which is affected by zooming and transformations.
Definition: ccanvas.h:2563
virtual cFigure * getRootFigure() const
Definition: ccanvas.h:3087
virtual int getNumFigures() const
Definition: ccanvas.h:3136
virtual int findFigure(const char *name) const
Definition: ccanvas.h:3119
A collection of properties (cProperty).
Definition: cproperties.h:34
virtual const Point & getPosition() const
Definition: ccanvas.h:2428
virtual cCanvas * dup() const override
Definition: ccanvas.h:3057
virtual cTextFigure * dup() const override
Definition: ccanvas.h:2577
virtual void addFigure(cFigure *figure, int pos)
Definition: ccanvas.h:3100
virtual const char * getRendererClassName() const override
Definition: ccanvas.h:2578
virtual cFigure * getFigureByPath(const char *path) const
Definition: ccanvas.h:3173
virtual Alignment getAlignment() const
Definition: ccanvas.h:2458
virtual cFigure * removeFigure(int pos)
Definition: ccanvas.h:3112
Definition: opp_pooledstring.h:63
virtual const Font & getFont() const
Definition: ccanvas.h:2530
FontStyle
Font style constants: FONT_NONE, FONT_BOLD, etc.
Definition: ccanvas.h:180
virtual const cFigure::Color & getBackgroundColor() const
Definition: ccanvas.h:3067
Thrown when the simulation kernel or other components detect a runtime error.
Definition: cexception.h:286
virtual void setBackgroundColor(const cFigure::Color &color)
Definition: ccanvas.h:3072
virtual const char * getText() const
Definition: ccanvas.h:2545
Interpolation
Image interpolation mode constants: INTERPOLATION_NONE, INTERPOLATION_FAST, etc.
Definition: ccanvas.h:198
Arrowhead
Arrowhead style constants: ARROW_NONE, ARROW_SIMPLE, etc.
Definition: ccanvas.h:195
LineStyle
Line style constants: LINE_SOLID, LINE_DOTTED, etc.
Definition: ccanvas.h:183
virtual bool hasFigures() const
Definition: ccanvas.h:3131
Stores a (NED) property with its (possibly compound) value.
Definition: cproperty.h:38
virtual const Color & getColor() const
Definition: ccanvas.h:2491
Anchor
Anchoring mode constants: ANCHOR_CENTER, ANCHOR_N, etc.
Definition: ccanvas.h:201
virtual void addFigure(cFigure *figure)
Definition: ccanvas.h:3092
virtual cFigure * findFigureRecursively(const char *name) const
Definition: ccanvas.h:3167
JoinStyle
Line join style constants: JOIN_BEVEL, JOIN_MITER, etc.
Definition: ccanvas.h:189
A cObject that keeps track of its owner. It serves as base class for many classes in the OMNeT++ libr...
Definition: cownedobject.h:105
FillRule
Fill rule constants: FILL_EVENODD, FILL_NONZERO.
Definition: ccanvas.h:192