]> git.sven.stormbind.net Git - sven/vym.git/blob - src/mapobj.h
Replace Pierre as the maintainer
[sven/vym.git] / src / mapobj.h
1 #ifndef MAPOBJ_H
2 #define MAPOBJ_H
3
4 #include <QGraphicsItem>
5
6 #include "xmlobj.h"
7
8 #define dZ_BBOX 0 // testing
9 #define dZ_SELBOX 5
10 #define dZ_FRAME_LOW 10
11 #define dZ_LINK 20
12 #define dZ_XLINK 40
13 #define dZ_FLOATIMG 70
14 #define dZ_ICON 80
15 #define dZ_TEXT 90
16 #define dZ_DEPTH 100
17 #define Z_SNOW 2000
18 #define Z_INIT 9999
19 #define Z_LINEEDIT 10000
20
21 class ConvexPolygon;
22
23 #include "treeitem.h"
24
25 /*! \brief Base class for all objects visible on a map
26  */
27
28 class MapObj : public XMLObj, public QGraphicsItem {
29   public:
30     MapObj(QGraphicsItem *parent = NULL, TreeItem *ti = NULL);
31     virtual ~MapObj();
32     virtual void init();
33     virtual void copy(MapObj *);
34
35     virtual void setTreeItem(TreeItem *);
36     virtual TreeItem *getTreeItem() const;
37
38     virtual qreal x();
39     virtual qreal y();
40     virtual qreal width();
41     virtual qreal height();
42     virtual QPointF getAbsPos();
43     virtual QString getPos();              //! Return position as string (x,y)
44     virtual void move(double x, double y); //! move to absolute Position
45     virtual void move(QPointF p);
46     virtual void moveBy(double x, double y); //! move to relative Position
47
48     virtual QRectF boundingRect() const;
49     virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
50
51     virtual QRectF getBBox(); //! returns bounding box
52     virtual ConvexPolygon
53     getBoundingPolygon();                    //! return bounding convex polygon
54     virtual QPolygonF getClickPoly();        //! returns polygon to click
55     virtual QPainterPath getSelectionPath(); //! returns path for selection
56     virtual bool isInClickBox(const QPointF &p); //! Checks if p is in clickBox
57     virtual QSizeF getSize(); //! returns size of bounding box
58
59     virtual void setRotation(const qreal &a);
60     virtual qreal getRotation();
61     virtual bool isVisibleObj();
62     virtual void setVisibility(bool);
63     virtual void positionBBox();
64     virtual void calcBBoxSize();
65
66   protected:
67     QRectF bbox;         // bounding box of MO itself
68     QPolygonF clickPoly; // area where mouseclicks are found
69     QPointF absPos;      // Position on canvas
70     bool visible;
71
72     qreal angle; //! Rotation angle
73
74     TreeItem *treeItem; //! Crossrefence to treemodel
75 };
76
77 #endif