Thu, 15 Mar 2018 10:46:46 +0200
added signal emissions
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
1 | /* |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
2 | * LDForge: LDraw parts authoring CAD |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
3 | * Copyright (C) 2013 - 2017 Teemu Piippo |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
4 | * |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
5 | * This program is free software: you can redistribute it and/or modify |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
7 | * the Free Software Foundation, either version 3 of the License, or |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
9 | * |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
14 | * |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
17 | */ |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
18 | |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
19 | #pragma once |
1144
4f226fd97826
Renamed glRenderer.cpp → glrenderer.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1129
diff
changeset
|
20 | #include "glrenderer.h" |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
21 | #include "editmodes/abstractEditMode.h" |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
22 | |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
23 | class Canvas : public GLRenderer |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
24 | { |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
25 | public: |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
26 | Canvas(LDDocument* document, QWidget* parent = nullptr); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
27 | ~Canvas(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
28 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
29 | EditModeType currentEditModeType() const; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
30 | int depthNegateFactor() const; |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
31 | LDDocument* document() const; |
1106
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
32 | void drawPoint(QPainter& painter, QPointF pos, QColor color = QColor (64, 192, 0)) const; |
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
33 | void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d) const; |
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
34 | void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos) const; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
35 | double getDepthValue() const; |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
36 | void getRelativeAxes(Axis& relX, Axis& relY) const; |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
37 | Axis getRelativeZ() const; |
1106
7541b0209057
Moved more methods only used by canvas code from GLRenderer to Canvas. Thin border pen is now a static constant.
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
38 | QPen linePen() const; |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
39 | const Vertex& position3D() const; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
40 | void setDepthValue(double depth); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
41 | void setEditMode(EditModeType type); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
42 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
43 | protected: |
1110
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1108
diff
changeset
|
44 | void contextMenuEvent(QContextMenuEvent* event) override; |
ec3ee7da7806
Moved more business logic out of GLRenderer into Canvas. GLRenderer::pick(const QRange&) now returns a set of LDObjects without modifying them. Replaced the GLRenderer::pick(int, int) overload with GLRenderer::pickOneObject.
Teemu Piippo <teemu@hecknology.net>
parents:
1108
diff
changeset
|
45 | void dragEnterEvent(QDragEnterEvent* event) override; |
1178
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1144
diff
changeset
|
46 | void drawFixedCameraBackdrop() override; |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
47 | void dropEvent(QDropEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
48 | bool freeCameraAllowed() const override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
49 | void keyReleaseEvent(QKeyEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
50 | void mouseDoubleClickEvent(QMouseEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
51 | void mouseMoveEvent(QMouseEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
52 | void mousePressEvent(QMouseEvent *event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
53 | void mouseReleaseEvent(QMouseEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
54 | void overpaint(QPainter& painter) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
55 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
56 | private: |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
57 | LDDocument& m_document; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
58 | AbstractEditMode* m_currentEditMode = nullptr; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
59 | Vertex m_position3D; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
60 | double m_depthValues[6] = {0}; |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
61 | }; |