00001 #ifndef ARENASCENE_H 00002 #define ARENASCENE_H 00003 00004 #include <QGraphicsScene> 00005 #include <QGraphicsSceneDragDropEvent> 00006 #include <QGraphicsSceneDragDropEvent> 00007 #include <QMap> 00008 00009 class Arena; 00010 class ArenaElement; 00011 class ArenaSceneElement; 00012 00013 const int ITEM_SIZE = 80; 00014 const int SPACING = 15; 00015 const int CELL_SIZE = ITEM_SIZE + SPACING; 00016 00017 class ArenaScene : public QGraphicsScene 00018 { 00019 Q_OBJECT 00020 00021 public: 00022 explicit ArenaScene(Arena* arena); 00023 00024 static QPoint sceneToGrid(QPointF scenePos); 00025 static QPointF sceneToGridF(QPointF scenePos); 00026 static QPointF gridToScene(QPointF gridPos); 00027 00028 static QPointF nearestGridPoint(QPointF scenePos); 00029 00030 ArenaSceneElement *sceneElementFor(ArenaElement* element); 00031 00032 QList<ArenaSceneElement*> selectedElements(); 00033 00034 private slots: 00035 void slotElementAdded(ArenaElement *element); 00036 void slotElementRemoved(ArenaElement *element); 00037 void updateViewMargin(); 00038 00039 private: 00040 void createGround(); 00041 00042 Arena * const m_arena; 00043 QMap<ArenaElement*, ArenaSceneElement*> m_elements; 00044 }; 00045 00046 #endif // ARENASCENE_H