00001 #ifndef ARENACONTROLLER_H 00002 #define ARENACONTROLLER_H 00003 00004 #include <QPointF> 00005 #include <QRectF> 00006 #include <QList> 00007 #include <QMap> 00008 00009 class QPainter; 00010 class Arena; 00011 class ArenaScene; 00012 class ArenaSceneElement; 00013 00014 class ArenaController 00015 { 00016 public: 00017 ArenaController(Arena *arena, ArenaScene *scene); 00018 00019 void startInsertion(const QString &elementType, const QPointF &pos); 00020 void cancelInsertion(); 00021 00022 void startDrag(ArenaSceneElement *sceneElement); 00023 void startDrag(QList<ArenaSceneElement *> sceneElements); 00024 00025 void dragTo(const QPointF &to); 00026 void dragBy(const QPointF &by); 00027 00028 void setSnapToGrid(bool snap) { m_snapToGrid = snap; } 00031 void setAutoRotateWalls(bool autoRotate) { m_autoRotateWalls = autoRotate; } 00032 00033 void endOperation(); 00034 00035 bool operationInProgress() const; 00036 00037 void draw(QPainter *painter, const QRectF &rect); 00038 00039 private: 00040 void dragTo(ArenaSceneElement *sceneElement, const QPointF &to); 00041 00042 Arena *m_arena; 00043 ArenaScene *m_scene; 00045 QList<ArenaSceneElement*> m_activeElements; 00046 QMap<ArenaSceneElement*, QPointF> m_origPositions; 00047 QPointF m_totalMouseOffset; 00048 00049 bool m_autoRotateWalls; 00050 bool m_snapToGrid; 00051 00053 bool m_lastDragFinished; 00054 }; 00055 00056 #endif // ARENACONTROLLER_H