src/editmodes/abstracteditmode.h

changeset 827
82469b40567e
parent 825
f7649c9bfd9a
child 829
bb903e89e23c
equal deleted inserted replaced
826:d7a21e4a4ec3 827:82469b40567e
1 #pragma once 1 #pragma once
2 #include "../main.h" 2 #include "../main.h"
3 #include "../glRenderer.h"
4 3
5 class QPainter; 4 class QPainter;
6 class GLRenderer; 5 class GLRenderer;
6 class QMouseEvent;
7 7
8 enum class EditModeType 8 enum class EditModeType
9 { 9 {
10 Select, 10 Select,
11 Draw, 11 Draw,
14 }; 14 };
15 15
16 class AbstractEditMode 16 class AbstractEditMode
17 { 17 {
18 GLRenderer* _renderer; 18 GLRenderer* _renderer;
19 QBrush _polybrush;
20 19
21 public: 20 public:
22 struct MouseEventData 21 struct MouseEventData
23 { 22 {
24 QMouseEvent* ev; 23 QMouseEvent* ev;
26 bool mouseMoved; 25 bool mouseMoved;
27 Qt::MouseButtons releasedButtons; 26 Qt::MouseButtons releasedButtons;
28 }; 27 };
29 28
30 AbstractEditMode (GLRenderer* renderer); 29 AbstractEditMode (GLRenderer* renderer);
30 virtual ~AbstractEditMode();
31 31
32 virtual bool allowFreeCamera() const = 0; 32 virtual bool allowFreeCamera() const = 0;
33 virtual void render (QPainter& painter) const {}; 33 virtual void render (QPainter&) const {};
34 GLRenderer* renderer() const; 34 GLRenderer* renderer() const;
35 virtual EditModeType type() const = 0; 35 virtual EditModeType type() const = 0;
36 virtual bool mousePressed (QMouseEvent*) { return false; } 36 virtual bool mousePressed (QMouseEvent*) { return false; }
37 virtual bool mouseReleased (MouseEventData const&) { return false; } 37 virtual bool mouseReleased (MouseEventData const&) { return false; }
38 virtual bool mouseDoubleClicked (QMouseEvent*) { return false; } 38 virtual bool mouseDoubleClicked (QMouseEvent*) { return false; }
39 virtual bool mouseMoved (QMouseEvent*) { return false; } 39 virtual bool mouseMoved (QMouseEvent*) { return false; }
40 void finishDraw (LDObjectList& objs);
41 40
42 static AbstractEditMode* createByType (GLRenderer* renderer, EditModeType type); 41 static AbstractEditMode* createByType (GLRenderer* renderer, EditModeType type);
43 }; 42 };
44 43
45 // 44 //
46 // Base class for draw-like edit modes 45 // Base class for draw-like edit modes
47 // 46 //
48 class AbstractDrawMode : public AbstractEditMode 47 class AbstractDrawMode : public AbstractEditMode
49 { 48 {
49 DEFINE_CLASS (AbstractDrawMode, AbstractEditMode)
50
51 protected:
50 QList<Vertex> _drawedVerts; 52 QList<Vertex> _drawedVerts;
51 Vertex m_rectverts[4]; 53 Vertex _rectverts[4];
52 54 QBrush _polybrush;
53 DEFINE_CLASS (AbstractDrawMode, AbstractEditMode)
54 55
55 public: 56 public:
56 AbstractDrawMode (GLRenderer* renderer); 57 AbstractDrawMode (GLRenderer* renderer);
57 58
58 virtual bool allowFreeCamera() const override 59 virtual bool allowFreeCamera() const override
60 return false; 61 return false;
61 } 62 }
62 63
63 bool mouseReleased (const AbstractEditMode::MouseEventData& data) override; 64 bool mouseReleased (const AbstractEditMode::MouseEventData& data) override;
64 void addDrawnVertex (const Vertex& pos); 65 void addDrawnVertex (const Vertex& pos);
66 void finishDraw (LDObjectList& objs);
65 67
66 virtual bool preAddVertex (Vertex const&) 68 virtual bool preAddVertex (Vertex const&)
67 { 69 {
68 return false; 70 return false;
69 } 71 }

mercurial