Sun, 10 Jun 2018 17:17:42 +0300
added the disc and disc negative to the circular primitive type
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 |
1326 | 3 | * Copyright (C) 2013 - 2018 Teemu Piippo |
1103
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" |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
22 | #include "geometry/plane.h" |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
23 | |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
24 | 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
|
25 | { |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
26 | public: |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
27 | 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
|
28 | ~Canvas(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
29 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
30 | EditModeType currentEditModeType() const; |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
31 | const Plane& drawPlane() const; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
32 | int depthNegateFactor() const; |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
33 | 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
|
34 | 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
|
35 | 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
|
36 | void drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos) const; |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
37 | void clearCurrentCullValue(); |
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
38 | double currentCullValue() const; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
39 | void getRelativeAxes(Axis& relX, Axis& relY) const; |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
40 | 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
|
41 | QPen linePen() const; |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
42 | const Vertex& position3D() const; |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
43 | void setDrawPlane(const Plane& plane); |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
44 | void setCullValue(double value); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
45 | void setEditMode(EditModeType type); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
46 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
47 | 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
|
48 | 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
|
49 | 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
|
50 | void drawFixedCameraBackdrop() override; |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
51 | void dropEvent(QDropEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
52 | bool freeCameraAllowed() const override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
53 | void keyReleaseEvent(QKeyEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
54 | void mouseDoubleClickEvent(QMouseEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
55 | void mouseMoveEvent(QMouseEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
56 | void mousePressEvent(QMouseEvent *event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
57 | void mouseReleaseEvent(QMouseEvent* event) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
58 | void overpaint(QPainter& painter) override; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
59 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
60 | private: |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
61 | LDDocument& m_document; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
62 | AbstractEditMode* m_currentEditMode = nullptr; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
63 | Vertex m_position3D; |
1390
3eace926af7f
added draw plane feature (doesn't work with circle draw quite right yet)
Teemu Piippo <teemu@hecknology.net>
parents:
1369
diff
changeset
|
64 | Plane m_drawPlane; |
1369
1e2391b78d17
added cull depth support
Teemu Piippo <teemu@hecknology.net>
parents:
1326
diff
changeset
|
65 | double cullValues[6] = {0}; |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
66 | }; |