]> git.sven.stormbind.net Git - sven/vym.git/blobdiff - src/mapobj.h
New upstream version 2.9.22
[sven/vym.git] / src / mapobj.h
diff --git a/src/mapobj.h b/src/mapobj.h
new file mode 100644 (file)
index 0000000..66dee77
--- /dev/null
@@ -0,0 +1,77 @@
+#ifndef MAPOBJ_H
+#define MAPOBJ_H
+
+#include <QGraphicsItem>
+
+#include "xmlobj.h"
+
+#define dZ_BBOX 0 // testing
+#define dZ_SELBOX 5
+#define dZ_FRAME_LOW 10
+#define dZ_LINK 20
+#define dZ_XLINK 40
+#define dZ_FLOATIMG 70
+#define dZ_ICON 80
+#define dZ_TEXT 90
+#define dZ_DEPTH 100
+#define Z_SNOW 2000
+#define Z_INIT 9999
+#define Z_LINEEDIT 10000
+
+class ConvexPolygon;
+
+#include "treeitem.h"
+
+/*! \brief Base class for all objects visible on a map
+ */
+
+class MapObj : public XMLObj, public QGraphicsItem {
+  public:
+    MapObj(QGraphicsItem *parent = NULL, TreeItem *ti = NULL);
+    virtual ~MapObj();
+    virtual void init();
+    virtual void copy(MapObj *);
+
+    virtual void setTreeItem(TreeItem *);
+    virtual TreeItem *getTreeItem() const;
+
+    virtual qreal x();
+    virtual qreal y();
+    virtual qreal width();
+    virtual qreal height();
+    virtual QPointF getAbsPos();
+    virtual QString getPos();              //! Return position as string (x,y)
+    virtual void move(double x, double y); //! move to absolute Position
+    virtual void move(QPointF p);
+    virtual void moveBy(double x, double y); //! move to relative Position
+
+    virtual QRectF boundingRect() const;
+    virtual void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *);
+
+    virtual QRectF getBBox(); //! returns bounding box
+    virtual ConvexPolygon
+    getBoundingPolygon();                    //! return bounding convex polygon
+    virtual QPolygonF getClickPoly();        //! returns polygon to click
+    virtual QPainterPath getSelectionPath(); //! returns path for selection
+    virtual bool isInClickBox(const QPointF &p); //! Checks if p is in clickBox
+    virtual QSizeF getSize(); //! returns size of bounding box
+
+    virtual void setRotation(const qreal &a);
+    virtual qreal getRotation();
+    virtual bool isVisibleObj();
+    virtual void setVisibility(bool);
+    virtual void positionBBox();
+    virtual void calcBBoxSize();
+
+  protected:
+    QRectF bbox;         // bounding box of MO itself
+    QPolygonF clickPoly; // area where mouseclicks are found
+    QPointF absPos;      // Position on canvas
+    bool visible;
+
+    qreal angle; //! Rotation angle
+
+    TreeItem *treeItem; //! Crossrefence to treemodel
+};
+
+#endif