46 Qt::KeyboardModifiers keymods; |
46 Qt::KeyboardModifiers keymods; |
47 bool mouseMoved; |
47 bool mouseMoved; |
48 Qt::MouseButtons releasedButtons; |
48 Qt::MouseButtons releasedButtons; |
49 }; |
49 }; |
50 |
50 |
51 AbstractEditMode (GLRenderer* renderer); |
51 AbstractEditMode(GLRenderer* renderer); |
52 virtual ~AbstractEditMode(); |
52 virtual ~AbstractEditMode(); |
53 |
53 |
54 virtual bool allowFreeCamera() const = 0; |
54 virtual bool allowFreeCamera() const = 0; |
55 virtual void render (QPainter&) const {} |
55 virtual void render(QPainter&) const {} |
56 GLRenderer* renderer() const; |
56 GLRenderer* renderer() const; |
57 virtual EditModeType type() const = 0; |
57 virtual EditModeType type() const = 0; |
58 virtual bool mousePressed (QMouseEvent*) { return false; } |
58 virtual bool mousePressed(QMouseEvent*) { return false; } |
59 virtual bool mouseReleased (MouseEventData const&) { return false; } |
59 virtual bool mouseReleased(MouseEventData const&) { return false; } |
60 virtual bool mouseDoubleClicked (QMouseEvent*) { return false; } |
60 virtual bool mouseDoubleClicked(QMouseEvent*) { return false; } |
61 virtual bool mouseMoved (QMouseEvent*) { return false; } |
61 virtual bool mouseMoved(QMouseEvent*) { return false; } |
62 virtual bool keyReleased (QKeyEvent*) { return false; } |
62 virtual bool keyReleased(QKeyEvent*) { return false; } |
63 |
63 |
64 static AbstractEditMode* createByType (GLRenderer* renderer, EditModeType type); |
64 static AbstractEditMode* createByType(GLRenderer* renderer, EditModeType type); |
65 |
65 |
66 private: |
66 private: |
67 GLRenderer* m_renderer; |
67 GLRenderer* m_renderer; |
68 }; |
68 }; |
69 |
69 |
70 // |
70 // |
71 // Base class for draw-like edit modes |
71 // Base class for draw-like edit modes |
72 // |
72 // |
73 class AbstractDrawMode : public AbstractEditMode |
73 class AbstractDrawMode : public AbstractEditMode |
74 { |
74 { |
75 DEFINE_CLASS (AbstractDrawMode, AbstractEditMode) |
75 DEFINE_CLASS(AbstractDrawMode, AbstractEditMode) |
76 |
76 |
77 protected: |
77 protected: |
78 QList<Vertex> m_drawedVerts; |
78 QList<Vertex> m_drawedVerts; |
79 QBrush m_polybrush; |
79 QBrush m_polybrush; |
80 |
80 |
81 public: |
81 public: |
82 AbstractDrawMode (GLRenderer* renderer); |
82 AbstractDrawMode(GLRenderer* renderer); |
83 |
83 |
84 void addDrawnVertex (const Vertex& pos); |
84 void addDrawnVertex(const Vertex& pos); |
85 virtual bool allowFreeCamera() const override final { return false; } |
85 virtual bool allowFreeCamera() const override final { return false; } |
86 virtual void endDraw() {} |
86 virtual void endDraw() {} |
87 void drawLength (QPainter& painter, |
87 void drawLength(QPainter& painter, |
88 const Vertex& v0, const Vertex& v1, |
88 const Vertex& v0, const Vertex& v1, |
89 const QPointF& v0p, const QPointF& v1p) const; |
89 const QPointF& v0p, const QPointF& v1p) const; |
90 void finishDraw (const LDObjectList& objs); |
90 void finishDraw(const LDObjectList& objs); |
91 Vertex getCursorVertex() const; |
91 Vertex getCursorVertex() const; |
92 bool keyReleased (QKeyEvent* ev) override; |
92 bool keyReleased(QKeyEvent* ev) override; |
93 virtual int maxVertices() const { return 0; } |
93 virtual int maxVertices() const { return 0; } |
94 bool mouseReleased (const AbstractEditMode::MouseEventData& data) override; |
94 bool mouseReleased(const AbstractEditMode::MouseEventData& data) override; |
95 virtual bool preAddVertex (Vertex const&) { return false; } |
95 virtual bool preAddVertex(Vertex const&) { return false; } |
96 void renderPolygon (QPainter& painter, const QVector<Vertex>& poly3d, bool withlengths, bool withangles) const; |
96 void renderPolygon(QPainter& painter, const QVector<Vertex>& poly3d, bool withlengths, bool withangles) const; |
97 }; |
97 }; |
98 |
98 |
99 // |
99 // |
100 // Base class for select-like edit modes |
100 // Base class for select-like edit modes |
101 // |
101 // |
102 class AbstractSelectMode : public AbstractEditMode |
102 class AbstractSelectMode : public AbstractEditMode |
103 { |
103 { |
104 DEFINE_CLASS (AbstractSelectMode, AbstractEditMode) |
104 DEFINE_CLASS(AbstractSelectMode, AbstractEditMode) |
105 |
105 |
106 public: |
106 public: |
107 AbstractSelectMode (GLRenderer* renderer); |
107 AbstractSelectMode(GLRenderer* renderer); |
108 |
108 |
109 virtual bool allowFreeCamera() const override |
109 virtual bool allowFreeCamera() const override |
110 { |
110 { |
111 return true; |
111 return true; |
112 } |
112 } |