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