ccanvas.h

00001 //==========================================================================
00002 //   CCANVAS.H  -  header for
00003 //                     OMNeT++/OMNEST
00004 //            Discrete System Simulation in C++
00005 //
00006 //==========================================================================
00007 
00008 /*--------------------------------------------------------------*
00009   Copyright (C) 1992-2008 Andras Varga
00010   Copyright (C) 2006-2008 OpenSim Ltd.
00011 
00012   This file is distributed WITHOUT ANY WARRANTY. See the file
00013   `license' for details on this and other legal matters.
00014 *--------------------------------------------------------------*/
00015 
00016 #ifndef __CCANVAS_H
00017 #define __CCANVAS_H
00018 
00019 #include "cownedobject.h"
00020 
00021 NAMESPACE_BEGIN
00022 
00023 class cCanvas;
00024 class cProperty;
00025 class cProperties;
00026 
00027 #define OMNETPP_CANVAS_VERSION  0x20140709  //XXX identifies canvas code version until API stabilizes
00028 
00045 class SIM_API cFigure : public cOwnedObject
00046 {
00047     public:
00048         struct Point {
00049             double x, y;
00050             Point() : x(0), y(0) {}
00051             Point(double x, double y) : x(x), y(y) {}
00052         };
00053 
00054         struct Rectangle {
00055             double x, y, width, height;
00056             Rectangle() : x(0), y(0), width(0), height(0) {}
00057             Rectangle(double x, double y, double width, double height) : x(x), y(y), width(width), height(height) {}
00058         };
00059 
00060         struct Color {
00061             uint8_t red, green, blue; // later: alpha
00062             Color() : red(0), green(0), blue(0) {}
00063             Color(uint8_t red, uint8_t green, uint8_t blue) : red(red), green(green), blue(blue) {}
00064             static Color byName(const char *colorName); // throws exception for unknown names
00065         };
00066 
00067         static const Color BLACK;
00068         static const Color WHITE;
00069         static const Color GREY;
00070         static const Color RED;
00071         static const Color GREEN;
00072         static const Color BLUE;
00073         static const Color YELLOW;
00074         static const Color CYAN;
00075         static const Color MAGENTA;
00076 
00077         struct Font {
00078             std::string typeface;
00079             int pointSize;
00080             uint8_t style;
00081             Font() : pointSize(0), style(FONT_NONE) {}
00082             Font(std::string typeface, int pointSize, uint8_t style=FONT_NONE) : typeface(typeface), pointSize(pointSize), style(style) {}
00083         };
00084 
00085         enum FontStyle { FONT_NONE=0, FONT_BOLD=1, FONT_ITALIC=2, FONT_UNDERLINE=4 };
00086         enum LineStyle { LINE_SOLID, LINE_DOTTED, LINE_DASHED };
00087         enum CapStyle { CAP_BUTT, CAP_SQUARE, CAP_ROUND };
00088         enum JoinStyle { JOIN_BEVEL, JOIN_MITER, JOIN_ROUND };
00089         enum ArrowHead { ARROW_NONE, ARROW_SIMPLE, ARROW_TRIANGLE, ARROW_BARBED };
00090         enum Anchor {ANCHOR_CENTER, ANCHOR_N, ANCHOR_E, ANCHOR_S, ANCHOR_W, ANCHOR_NW, ANCHOR_NE, ANCHOR_SE, ANCHOR_SW };
00091         enum Alignment { ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER }; // note: JUSTIFY is not supported by Tk
00092 
00093         // internal:
00094         enum {CHANGE_VISUAL=1, CHANGE_GEOMETRY=2, CHANGE_STRUCTURAL=4};
00095 
00096     private:
00097         static int lastId;
00098         int id;
00099         bool visible; // treated as structural change, for simpler handling
00100         std::vector<cFigure*> children;
00101         opp_string tags; //TODO stringpool
00102         uint64 tagBits;  // bit-to-tagname mapping is stored in cCanvas. Note: change to std::bitset if 64 tags are not enough
00103 
00104         int8_t localChange;
00105         int8_t treeChange;
00106 
00107     protected:
00108         virtual cFigure *getRootFigure();
00109         virtual void doVisualChange() {doChange(CHANGE_VISUAL);}
00110         virtual void doGeometryChange() {doChange(CHANGE_GEOMETRY);}
00111         virtual void doStructuralChange() {doChange(CHANGE_STRUCTURAL);}
00112         virtual void doChange(int flags);
00113         static Point parsePoint(cProperty *property, const char *key, int index);
00114         static std::vector<Point> parsePoints(cProperty *property, const char *key);
00115         static void parseBounds(cProperty *property, Point& p1, Point& p2);
00116         static Rectangle parseBounds(cProperty *property);
00117         static Font parseFont(cProperty *property, const char *key);
00118         static bool parseBool(const char *s);
00119         static Color parseColor(const char *s);
00120         static LineStyle parseLineStyle(const char *s);
00121         static CapStyle parseCapStyle(const char *s);
00122         static JoinStyle parseJoinStyle(const char *s);
00123         static ArrowHead parseArrowHead(const char *s);
00124         static Anchor parseAnchor(const char *s);
00125         static Alignment parseAlignment(const char *s);
00126 
00127     public:
00128         // internal:
00129         int getLocalChangeFlags() const {return localChange;}
00130         int getTreeChangeFlags() const {return treeChange;}
00131         void clearChangeFlags();
00132         void insertChild(cFigure *figure, std::map<cFigure*,double>& orderMap);
00133         void refreshTagBits();
00134         void refreshTagBitsRec();
00135         int64 getTagBits() const {return tagBits;}
00136         void setTagBits(uint64 tagBits) {this->tagBits = tagBits;}
00137 
00138     private:
00139         void copy(const cFigure& other);
00140 
00141     public:
00142         cFigure(const char *name=NULL) : cOwnedObject(name), id(++lastId), visible(true), tagBits(0), localChange(0), treeChange(0) {}
00143         cFigure(const cFigure& other) : cOwnedObject(other) {copy(other);}
00144         virtual ~cFigure();
00145         cFigure& operator=(const cFigure& other);
00146         virtual void forEachChild(cVisitor *v);
00147         virtual std::string info() const;
00148         virtual void parse(cProperty *property);
00149         virtual cFigure *dupTree();
00150         virtual const char *getClassNameForRenderer() const {return getClassName();} // denotes renderer of which figure class to use; override if you want to subclass a figure while reusing renderer of the base class
00151 
00152         int getId() const {return id;}
00153         virtual Point getChildOrigin() const = 0;
00154         virtual void translate(double x, double y) = 0;
00155         virtual cCanvas *getCanvas();
00156         virtual bool isVisible() const {return visible;} // affects figure subtree, not just this very figure
00157         virtual void setVisible(bool visible) {this->visible = visible; doStructuralChange();}
00158         virtual const char *getTags() const {return tags.c_str();} // returns space-separated list of tags
00159         virtual void setTags(const char *tags) {this->tags = tags; refreshTagBits();} // accepts space-separated list of tags
00160 
00161         virtual void addFigure(cFigure *figure);
00162         virtual void addFigure(cFigure *figure, int pos);
00163         virtual void addFigureAbove(cFigure *figure, cFigure *referenceFigure);
00164         virtual void addFigureBelow(cFigure *figure, cFigure *referenceFigure);
00165         virtual cFigure *removeFigure(int pos);
00166         virtual cFigure *removeFigure(cFigure *figure);
00167         virtual int findFigure(const char *name);
00168         virtual int findFigure(cFigure *figure);
00169         virtual bool containsFigures() const {return !children.empty();}
00170         virtual int getNumFigures() const {return children.size();}
00171         virtual cFigure *getFigure(int pos);
00172         virtual cFigure *getFigure(const char *name);
00173         virtual cFigure *getParentFigure()  {return dynamic_cast<cFigure*>(getOwner());}
00174         virtual void raiseAbove(cFigure *figure);
00175         virtual void lowerBelow(cFigure *figure);
00176         virtual void raiseToTop();
00177         virtual void lowerToBottom();
00178 
00179         virtual cFigure *findFigureRecursively(const char *name);
00180         virtual cFigure *getFigureByPath(const char *path);  //NOTE: path has similar syntax to cModule::getModuleByPath()
00181 };
00182 
00188 class SIM_API cGroupFigure : public cFigure
00189 {
00190     private:
00191         Point location;
00192     private:
00193         void copy(const cGroupFigure& other);
00194     public:
00195         cGroupFigure(const char *name=NULL) : cFigure(name) {}
00196         cGroupFigure(const cGroupFigure& other) : cFigure(other) {copy(other);}
00197         cGroupFigure& operator=(const cGroupFigure& other);
00198         virtual cGroupFigure *dup() const  {return new cGroupFigure(*this);}
00199         virtual std::string info() const;
00200         virtual const char *getClassNameForRenderer() const {return "";} // non-visual figure
00201         virtual void translate(double x, double y);
00202         virtual Point getChildOrigin() const  {return location;}
00203         virtual const Point& getLocation() const  {return location;}
00204         virtual void setLocation(const Point& loc)  {this->location = loc; doGeometryChange();}
00205 };
00206 
00213 class SIM_API cAbstractLineFigure : public cFigure
00214 {
00215     private:
00216         Color lineColor;
00217         LineStyle lineStyle;
00218         double lineWidth;
00219         CapStyle capStyle;
00220         ArrowHead startArrowHead, endArrowHead;
00221     private:
00222         void copy(const cAbstractLineFigure& other);
00223     public:
00224         cAbstractLineFigure(const char *name=NULL) : cFigure(name), lineColor(BLACK), lineStyle(LINE_SOLID), lineWidth(1), capStyle(CAP_BUTT), startArrowHead(ARROW_NONE), endArrowHead(ARROW_NONE) {}
00225         cAbstractLineFigure(const cAbstractLineFigure& other) : cFigure(other) {copy(other);}
00226         cAbstractLineFigure& operator=(const cAbstractLineFigure& other);
00227         virtual std::string info() const;
00228         virtual void parse(cProperty *property);
00229         virtual const Color& getLineColor() const  {return lineColor;}
00230         virtual void setLineColor(const Color& lineColor)  {this->lineColor = lineColor; doVisualChange();}
00231         virtual double getLineWidth() const  {return lineWidth;}
00232         virtual void setLineWidth(double lineWidth)  {this->lineWidth = lineWidth; doVisualChange();}
00233         virtual LineStyle getLineStyle() const  {return lineStyle;}
00234         virtual void setLineStyle(LineStyle lineStyle)  {this->lineStyle = lineStyle; doVisualChange();}
00235         virtual CapStyle getCapStyle() const {return capStyle;}
00236         virtual void setCapStyle(CapStyle capStyle) {this->capStyle = capStyle; doVisualChange();}
00237         virtual ArrowHead getStartArrowHead() const  {return startArrowHead;}
00238         virtual void setStartArrowHead(ArrowHead startArrowHead)  {this->startArrowHead = startArrowHead; doVisualChange();}
00239         virtual ArrowHead getEndArrowHead() const  {return endArrowHead;}
00240         virtual void setEndArrowHead(ArrowHead endArrowHead)  {this->endArrowHead = endArrowHead; doVisualChange();}
00241 };
00242 
00248 class SIM_API cLineFigure : public cAbstractLineFigure
00249 {
00250     private:
00251         Point start, end;
00252     private:
00253         void copy(const cLineFigure& other);
00254     public:
00255         cLineFigure(const char *name=NULL) : cAbstractLineFigure(name) {}
00256         cLineFigure(const cLineFigure& other) : cAbstractLineFigure(other) {copy(other);}
00257         cLineFigure& operator=(const cLineFigure& other);
00258         virtual cLineFigure *dup() const  {return new cLineFigure(*this);}
00259         virtual std::string info() const;
00260         virtual void parse(cProperty *property);
00261         virtual Point getChildOrigin() const  {return start;}
00262         virtual void translate(double x, double y);
00263         virtual const Point& getStart() const  {return start;}
00264         virtual void setStart(const Point& start)  {this->start = start; doGeometryChange();}
00265         virtual const Point& getEnd() const  {return end;}
00266         virtual void setEnd(const Point& end)  {this->end = end; doGeometryChange();}
00267 };
00268 
00277 class SIM_API cArcFigure : public cAbstractLineFigure
00278 {
00279     private:
00280         Rectangle bounds; // bounding box of the oval that arc is part of
00281         double startAngle, endAngle; // in degrees, CCW, 0=east
00282     private:
00283         void copy(const cArcFigure& other);
00284     public:
00285         cArcFigure(const char *name=NULL) : cAbstractLineFigure(name), startAngle(0), endAngle(0) {}
00286         cArcFigure(const cArcFigure& other) : cAbstractLineFigure(other) {copy(other);}
00287         cArcFigure& operator=(const cArcFigure& other);
00288         virtual cArcFigure *dup() const  {return new cArcFigure(*this);}
00289         virtual std::string info() const;
00290         virtual void parse(cProperty *property);
00291         virtual void translate(double x, double y);
00292         virtual Point getChildOrigin() const  {return Point(bounds.x, bounds.y);}
00293         virtual const Rectangle& getBounds() const  {return bounds;}
00294         virtual void setBounds(const Rectangle& bounds)  {this->bounds = bounds; doGeometryChange();}
00295         virtual double getStartAngle() const {return startAngle;}
00296         virtual void setStartAngle(double startAngle) {this->startAngle = startAngle; doVisualChange();}
00297         virtual double getEndAngle() const {return endAngle;}
00298         virtual void setEndAngle(double endAngle) {this->endAngle = endAngle; doVisualChange();}
00299 };
00300 
00310 class SIM_API cPolylineFigure : public cAbstractLineFigure
00311 {
00312     private:
00313         std::vector<Point> points;
00314         bool smooth;
00315         JoinStyle joinStyle;
00316     private:
00317         void copy(const cPolylineFigure& other);
00318     public:
00319         cPolylineFigure(const char *name=NULL) : cAbstractLineFigure(name), smooth(false), joinStyle(JOIN_MITER) {}
00320         cPolylineFigure(const cPolylineFigure& other) : cAbstractLineFigure(other) {copy(other);}
00321         cPolylineFigure& operator=(const cPolylineFigure& other);
00322         virtual cPolylineFigure *dup() const  {return new cPolylineFigure(*this);}
00323         virtual std::string info() const;
00324         virtual void parse(cProperty *property);
00325         virtual void translate(double x, double y);
00326         virtual Point getChildOrigin() const  {static Point dummy; return points.empty() ? dummy : points[0];}
00327         virtual const std::vector<Point>& getPoints() const  {return points;}
00328         virtual void setPoints(const std::vector<Point>& points) {this->points = points; doGeometryChange();}
00329         virtual int getNumPoints() const {return points.size();}
00330         virtual const Point& getPoint(int i) const {return points[i];}
00331         virtual bool getSmooth() const {return smooth;}
00332         virtual void setSmooth(bool smooth) {this->smooth = smooth; doVisualChange();}
00333         virtual JoinStyle getJoinStyle() const {return joinStyle;}
00334         virtual void setJoinStyle(JoinStyle joinStyle) {this->joinStyle = joinStyle; doVisualChange();}
00335 };
00336 
00343 class SIM_API cAbstractShapeFigure : public cFigure
00344 {
00345     private:
00346         bool outlined;
00347         bool filled;
00348         Color lineColor;
00349         Color fillColor;
00350         LineStyle lineStyle;
00351         double lineWidth;
00352     private:
00353         void copy(const cAbstractShapeFigure& other);
00354     public:
00355         cAbstractShapeFigure(const char *name=NULL) : cFigure(name), outlined(true), filled(false), lineColor(BLACK), fillColor(BLUE), lineStyle(LINE_SOLID), lineWidth(1) {}
00356         cAbstractShapeFigure(const cAbstractShapeFigure& other) : cFigure(other) {copy(other);}
00357         cAbstractShapeFigure& operator=(const cAbstractShapeFigure& other);
00358         virtual std::string info() const;
00359         virtual void parse(cProperty *property);
00360         virtual bool isFilled() const  {return filled;}
00361         virtual void setFilled(bool filled)  {this->filled = filled; doVisualChange();}
00362         virtual bool isOutlined() const  {return outlined;}
00363         virtual void setOutlined(bool outlined)  {this->outlined = outlined; doVisualChange();}
00364         virtual const Color& getLineColor() const  {return lineColor;}
00365         virtual void setLineColor(const Color& lineColor)  {this->lineColor = lineColor; doVisualChange();}
00366         virtual const Color& getFillColor() const  {return fillColor;}
00367         virtual void setFillColor(const Color& fillColor)  {this->fillColor = fillColor; doVisualChange();}
00368         virtual LineStyle getLineStyle() const  {return lineStyle;}
00369         virtual void setLineStyle(LineStyle lineStyle)  {this->lineStyle = lineStyle; doVisualChange();}
00370         virtual double getLineWidth() const  {return lineWidth;}
00371         virtual void setLineWidth(double lineWidth)  {this->lineWidth = lineWidth; doVisualChange();}
00372 };
00373 
00377 class SIM_API cRectangleFigure : public cAbstractShapeFigure
00378 {
00379     private:
00380         Rectangle bounds;
00381     private:
00382         void copy(const cRectangleFigure& other);
00383     public:
00384         cRectangleFigure(const char *name=NULL) : cAbstractShapeFigure(name) {}
00385         cRectangleFigure(const cRectangleFigure& other) : cAbstractShapeFigure(other) {copy(other);}
00386         cRectangleFigure& operator=(const cRectangleFigure& other);
00387         virtual cRectangleFigure *dup() const  {return new cRectangleFigure(*this);}
00388         virtual std::string info() const;
00389         virtual void parse(cProperty *property);
00390         virtual void translate(double x, double y);
00391         virtual Point getChildOrigin() const  {return Point(bounds.x, bounds.y);}
00392         virtual const Rectangle& getBounds() const  {return bounds;}
00393         virtual void setBounds(const Rectangle& bounds)  {this->bounds = bounds; doGeometryChange();}
00394 };
00395 
00399 class SIM_API cOvalFigure : public cAbstractShapeFigure
00400 {
00401     private:
00402         Rectangle bounds; // bounding box
00403     private:
00404         void copy(const cOvalFigure& other);
00405     public:
00406         cOvalFigure(const char *name=NULL) : cAbstractShapeFigure(name) {}
00407         cOvalFigure(const cOvalFigure& other) : cAbstractShapeFigure(other) {copy(other);}
00408         cOvalFigure& operator=(const cOvalFigure& other);
00409         virtual cOvalFigure *dup() const  {return new cOvalFigure(*this);}
00410         virtual std::string info() const;
00411         virtual void parse(cProperty *property);
00412         virtual void translate(double x, double y);
00413         virtual Point getChildOrigin() const  {return Point(bounds.x, bounds.y);}
00414         virtual const Rectangle& getBounds() const  {return bounds;}
00415         virtual void setBounds(const Rectangle& bounds)  {this->bounds = bounds; doGeometryChange();}
00416 };
00417 
00423 class SIM_API cPieSliceFigure : public cAbstractShapeFigure
00424 {
00425     private:
00426         Rectangle bounds; // bounding box of the oval that the pie slice is part of
00427         double startAngle, endAngle; // in degrees, CCW, 0=east
00428     private:
00429         void copy(const cPieSliceFigure& other);
00430     public:
00431         cPieSliceFigure(const char *name=NULL) : cAbstractShapeFigure(name), startAngle(0), endAngle(45) {}
00432         cPieSliceFigure(const cPieSliceFigure& other) : cAbstractShapeFigure(other) {copy(other);}
00433         cPieSliceFigure& operator=(const cPieSliceFigure& other);
00434         virtual cPieSliceFigure *dup() const  {return new cPieSliceFigure(*this);}
00435         virtual std::string info() const;
00436         virtual void parse(cProperty *property);
00437         virtual void translate(double x, double y);
00438         virtual Point getChildOrigin() const  {return Point(bounds.x, bounds.y);}
00439         virtual const Rectangle& getBounds() const  {return bounds;}
00440         virtual void setBounds(const Rectangle& bounds)  {this->bounds = bounds; doGeometryChange();}
00441         virtual double getStartAngle() const {return startAngle;}
00442         virtual void setStartAngle(double startAngle) {this->startAngle = startAngle; doVisualChange();}
00443         virtual double getEndAngle() const {return endAngle;}
00444         virtual void setEndAngle(double endAngle) {this->endAngle = endAngle; doVisualChange();}
00445 };
00446 
00453 class SIM_API cPolygonFigure : public cAbstractShapeFigure
00454 {
00455     private:
00456         std::vector<Point> points;
00457         bool smooth;
00458         JoinStyle joinStyle;
00459     private:
00460         void copy(const cPolygonFigure& other);
00461     public:
00462         cPolygonFigure(const char *name=NULL) : cAbstractShapeFigure(name), smooth(false), joinStyle(JOIN_MITER) {}
00463         cPolygonFigure(const cPolygonFigure& other) : cAbstractShapeFigure(other) {copy(other);}
00464         cPolygonFigure& operator=(const cPolygonFigure& other);
00465         virtual cPolygonFigure *dup() const  {return new cPolygonFigure(*this);}
00466         virtual std::string info() const;
00467         virtual void parse(cProperty *property);
00468         virtual void translate(double x, double y);
00469         virtual Point getChildOrigin() const  {static Point dummy; return points.empty() ? dummy : points[0];}
00470         virtual const std::vector<Point>& getPoints() const  {return points;}
00471         virtual void setPoints(const std::vector<Point>& points) {this->points = points; doGeometryChange();}
00472         virtual int getNumPoints() const {return points.size();}
00473         virtual const Point& getPoint(int i) const {return points[i];}
00474         virtual bool getSmooth() const {return smooth;}
00475         virtual void setSmooth(bool smooth) {this->smooth = smooth; doVisualChange();}
00476         virtual JoinStyle getJoinStyle() const {return joinStyle;}
00477         virtual void setJoinStyle(JoinStyle joinStyle) {this->joinStyle = joinStyle; doVisualChange();}
00478 };
00479 
00485 class SIM_API cTextFigure : public cFigure
00486 {
00487     private:
00488         Point location;
00489         Color color;
00490         Font font;
00491         std::string text;
00492         Anchor anchor;
00493         Alignment alignment;
00494     private:
00495         void copy(const cTextFigure& other);
00496     public:
00497         cTextFigure(const char *name=NULL) : cFigure(name), color(BLACK), anchor(ANCHOR_NW), alignment(ALIGN_LEFT) {}
00498         cTextFigure(const cTextFigure& other) : cFigure(other) {copy(other);}
00499         cTextFigure& operator=(const cTextFigure& other);
00500         virtual cTextFigure *dup() const  {return new cTextFigure(*this);}
00501         virtual std::string info() const;
00502         virtual void parse(cProperty *property);
00503         virtual void translate(double x, double y);
00504         virtual Point getChildOrigin() const  {return location;}
00505         virtual const Point& getLocation() const  {return location;}
00506         virtual void setLocation(const Point& location)  {this->location = location; doGeometryChange();}
00507         virtual const Color& getColor() const  {return color;}
00508         virtual void setColor(const Color& color)  {this->color = color; doVisualChange();}
00509         virtual const Font& getFont() const  {return font;}
00510         virtual void setFont(Font font)  {this->font = font; doVisualChange();}
00511         virtual const char *getText() const  {return text.c_str();}
00512         virtual void setText(const char *text)  {this->text = text; doVisualChange();}
00513         virtual Anchor getAnchor() const  {return anchor;}
00514         virtual void setAnchor(Anchor anchor)  {this->anchor = anchor; doVisualChange();}
00515         virtual Alignment getAlignment() const  {return alignment;}
00516         virtual void setAlignment(Alignment alignment)  {this->alignment = alignment; doVisualChange();}
00517 };
00518 
00526 class SIM_API cImageFigure : public cFigure
00527 {
00528     private:
00529         Point location;
00530         std::string imageName;
00531         Color tint;  // amount of tinting will come from alpha after it gets added to Color
00532         bool tinting; // temporary -- we'll use tint color's alpha
00533         Anchor anchor;
00534     private:
00535         void copy(const cImageFigure& other);
00536     public:
00537         cImageFigure(const cImageFigure& other) : cFigure(other) {copy(other);}
00538         cImageFigure& operator=(const cImageFigure& other);
00539         virtual cImageFigure *dup() const  {return new cImageFigure(*this);}
00540         cImageFigure(const char *name=NULL) : cFigure(name), tint(BLUE), tinting(false), anchor(ANCHOR_CENTER) {}
00541         virtual std::string info() const;
00542         virtual void parse(cProperty *property);
00543         virtual void translate(double x, double y);
00544         virtual Point getChildOrigin() const  {return location;}
00545         virtual const Point& getLocation() const  {return location;}
00546         virtual void setLocation(const Point& pos)  {this->location = pos; doGeometryChange();}
00547         virtual const char *getImageName() const  {return imageName.c_str();}
00548         virtual void setImageName(const char *imageName)  {this->imageName = imageName; doVisualChange();}
00549         virtual const Color& getTint() const  {return tint;}
00550         virtual void setTint(const Color& tint)  {this->tint = tint; tinting = true; doVisualChange();}
00551         virtual void clearTint() { tinting = false; }
00552         virtual Anchor getAnchor() const  {return anchor;}
00553         virtual void setAnchor(Anchor anchor)  {this->anchor = anchor; doVisualChange();}
00554 };
00555 
00556 
00576 class SIM_API cCanvas : public cOwnedObject
00577 {
00578     private:
00579         cFigure *rootFigure;
00580         std::map<std::string,int> tagBitIndex;  // tag-to-bitindex
00581     protected:
00582         virtual void parseFigure(cProperty *property, std::map<cFigure*,double>& orderMap);
00583         virtual cFigure *createFigure(const char *type);
00584     public:
00585         // internal:
00586         static bool containsCanvasItems(cProperties *properties);
00587         virtual void addFiguresFrom(cProperties *properties);
00588         virtual uint64 parseTags(const char *s);
00589     private:
00590         void copy(const cCanvas& other);
00591     public:
00592         cCanvas(const char *name = NULL);
00593         cCanvas(const cCanvas& other) : cOwnedObject(other) {copy(other);}
00594         virtual ~cCanvas();
00595         cCanvas& operator=(const cCanvas& other);
00596         virtual cCanvas *dup() const  {return new cCanvas(*this);}
00597         virtual void forEachChild(cVisitor *v);
00598         virtual std::string info() const;
00599 
00600         virtual cFigure *getRootFigure() const {return rootFigure;}
00601         virtual void addFigure(cFigure *figure) {rootFigure->addFigure(figure);}
00602         virtual void addFigure(cFigure *figure, int pos) {rootFigure->addFigure(figure, pos);}
00603         virtual void addFigureAbove(cFigure *figure, cFigure *referenceFigure) {rootFigure->addFigureAbove(figure, referenceFigure);}
00604         virtual void addFigureBelow(cFigure *figure, cFigure *referenceFigure) {rootFigure->addFigureBelow(figure, referenceFigure);}
00605         virtual cFigure *removeFigure(int pos) {return rootFigure->removeFigure(pos);}
00606         virtual cFigure *removeFigure(cFigure *figure) {return rootFigure->removeFigure(figure);}
00607         virtual int findFigure(const char *name) {return rootFigure->findFigure(name);}
00608         virtual int findFigure(cFigure *figure) {return rootFigure->findFigure(figure);}
00609         virtual bool hasFigures() const {return rootFigure->containsFigures();}
00610         virtual int getNumFigures() const {return rootFigure->getNumFigures();} // note: returns the number of *child* figures, not the total number
00611         virtual cFigure *getFigure(int pos) {return rootFigure->getFigure(pos);}
00612         virtual cFigure *getFigure(const char *name) {return rootFigure->getFigure(name);}
00613 
00614         virtual cFigure *getSubmodulesLayer() const; // may return NULL (extra canvases don't have submodules)
00615         virtual cFigure *findFigureRecursively(const char *name) {return rootFigure->findFigureRecursively(name);}
00616         virtual cFigure *getFigureByPath(const char *path) {return rootFigure->getFigureByPath(path);}
00617 
00618         virtual std::string getAllTags() const;
00619         virtual std::vector<std::string> getAllTagsAsVector() const;
00620 };
00621 
00622 NAMESPACE_END
00623 
00624 
00625 #endif
00626 
00627 
Generated on Tue Dec 2 11:16:27 2014 for OMNeT++ Simulation Library by  doxygen 1.6.3