mapobj.h
author insilmaril
Wed, 25 Nov 2009 10:58:21 +0000
changeset 807 f9f7922989d8
parent 794 d922fb6ea482
permissions -rw-r--r--
Added demos/vym-contribute.vym, fixes for selecting items
     1 #ifndef MAPOBJ_H
     2 #define MAPOBJ_H
     3 
     4 #include <QGraphicsScene>
     5 #include <QGraphicsItem>
     6 
     7 #include "xmlobj.h"
     8 
     9 #define Z_BBOX       0
    10 #define Z_XLINK     10
    11 #define Z_LINK      20
    12 #define Z_FRAME     50
    13 #define Z_SELBOX    60
    14 #define Z_FLOATIMG  65
    15 #define Z_ICON      80
    16 #define Z_TEXT     100
    17 #define Z_LINEEDIT 110
    18 
    19 class ConvexPolygon;
    20 
    21 class TreeItem;
    22 
    23 /*! \brief Base class for all objects visible on a map
    24 */
    25 
    26 class MapObj:public XMLObj {
    27 public:
    28     MapObj ();
    29     MapObj (QGraphicsScene *scene,TreeItem *ti=NULL);
    30     MapObj (MapObj*);
    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 QGraphicsScene* getScene();
    39     virtual qreal x();
    40     virtual qreal y();
    41 	virtual qreal width();
    42 	virtual qreal height();
    43 	virtual QPointF getAbsPos();
    44 	virtual QString getPos();					//! Return position as string (x,y)
    45     virtual void move (double x,double y);      //! move to absolute Position
    46     virtual void move (QPointF p);
    47     virtual void moveBy (double x,double y);    //! move to relative Position
    48     virtual QRectF getBBox();					//! returns bounding box
    49     virtual ConvexPolygon getBoundingPolygon();	//! return bounding convex polygon
    50     virtual QRectF getClickBox();				//! returns box to click
    51 	virtual bool isInClickBox (const QPointF &p);	//! Checks if p is in clickBox
    52     virtual QSizeF getSize();					//! returns size of bounding box
    53     virtual bool isVisibleObj();
    54     virtual void setVisibility(bool);
    55     virtual void positionBBox()=0;       
    56 	virtual void calcBBoxSize()=0;
    57 protected:  
    58     QGraphicsScene* scene;
    59     QRectF bbox;					// bounding box of MO itself
    60 	QRectF clickBox;				// area where mouseclicks are found
    61     QPointF absPos;				    // Position on canvas
    62     bool visible;
    63 
    64 	TreeItem *treeItem;				//! Crossrefence to treemodel
    65 
    66 	QGraphicsPolygonItem *pi;	//FIXME-3 testing only
    67 };
    68 
    69 #endif