Sat, 17 Mar 2018 11:35:07 +0200
removed the old Add History Line tool
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 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
19 | #include <QMouseEvent> |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
20 | #include "canvas.h" |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
21 | #include "documentmanager.h" |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
22 | #include "glcamera.h" |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
23 | #include "grid.h" |
1145
02264bf0108d
Renamed ldDocument.cpp → lddocument.cpp
Teemu Piippo <teemu@hecknology.net>
parents:
1129
diff
changeset
|
24 | #include "lddocument.h" |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
25 | #include "mainwindow.h" |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
26 | #include "messageLog.h" |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
27 | #include "miscallenous.h" |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
28 | #include "primitives.h" |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
29 | |
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
30 | Canvas::Canvas(LDDocument* document, QWidget* parent) : |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
31 | GLRenderer {document, parent}, |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
32 | m_document {*document}, |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
33 | m_currentEditMode {AbstractEditMode::createByType (this, EditModeType::Select)} {} |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
34 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
35 | Canvas::~Canvas() |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
36 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
37 | delete m_currentEditMode; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
38 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
39 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
40 | void Canvas::overpaint(QPainter& painter) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
41 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
42 | GLRenderer::overpaint(painter); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
43 | QFontMetrics metrics {QFont {}}; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
44 | |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
45 | if (camera() != Camera::Free) |
1104
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 | // Paint the coordinates onto the screen. |
1177
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
48 | Vertex idealized = currentCamera().idealize(m_position3D); |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
49 | QString text = format(tr("X: %1, Y: %2, Z: %3, %4"), m_position3D[X], m_position3D[Y], m_position3D[Z], |
8661b9237ed5
Added support for ideal co-ordinates, which should make writing editing tools a lot easier. For some reason they don't yet work with the back and right cameras.
Teemu Piippo <teemu@hecknology.net>
parents:
1168
diff
changeset
|
50 | idealized.toString(true)); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
51 | QFontMetrics metrics {font()}; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
52 | QRect textSize = metrics.boundingRect (0, 0, width(), height(), Qt::AlignCenter, text); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
53 | painter.setPen(textPen()); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
54 | painter.drawText(width() - textSize.width(), height() - 16, textSize.width(), textSize.height(), Qt::AlignCenter, text); |
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 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
57 | // Draw edit mode HUD |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
58 | m_currentEditMode->render(painter); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
59 | |
1105
4f4d219e527d
Moved triangle count rendering to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
60 | // Render triangle count |
4f4d219e527d
Moved triangle count rendering to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
61 | { |
4f4d219e527d
Moved triangle count rendering to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
62 | QPoint renderPoint {4, height() - 4 - metrics.height() - metrics.descent()}; |
4f4d219e527d
Moved triangle count rendering to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
63 | painter.drawText(renderPoint, format("△ %1", m_document.triangleCount())); |
4f4d219e527d
Moved triangle count rendering to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
64 | } |
4f4d219e527d
Moved triangle count rendering to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1104
diff
changeset
|
65 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
66 | // Message log |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
67 | if (m_window->messageLog()) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
68 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
69 | int y = 0; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
70 | int margin = 2; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
71 | QColor penColor = textPen().color(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
72 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
73 | for (const MessageManager::Line& line : m_window->messageLog()->getLines()) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
74 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
75 | penColor.setAlphaF(line.alpha); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
76 | painter.setPen(penColor); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
77 | painter.drawText(QPoint {margin, y + margin + metrics.ascent()}, line.text); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
78 | y += metrics.height(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
79 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
80 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
81 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
82 | |
1178
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
83 | /* |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
84 | * Assuming we're currently viewing from a fixed camera, draw a backdrop into it. Currently this means drawing the grid. |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
85 | */ |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
86 | void Canvas::drawFixedCameraBackdrop() |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
87 | { |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
88 | // Find the top left corner of the grid |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
89 | Vertex topLeft = currentCamera().idealize(currentCamera().convert2dTo3d({0, 0})); |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
90 | Vertex bottomRight = currentCamera().idealize(currentCamera().convert2dTo3d({width(), height()})); |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
91 | qreal gridSize = grid()->coordinateSnap(); |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
92 | glEnable(GL_LINE_STIPPLE); |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
93 | glBegin(GL_LINES); |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
94 | |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
95 | switch (grid()->type()) |
1178
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
96 | { |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
97 | case Grid::Cartesian: |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
98 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
99 | qreal x0 = sign(topLeft.x()) * (fabs(topLeft.x()) - fmod(fabs(topLeft.x()), gridSize)); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
100 | qreal y0 = sign(topLeft.y()) * (fabs(topLeft.y()) - fmod(fabs(topLeft.y()), gridSize)); |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
101 | |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
102 | static const auto prepareGridLine = [](qreal value) -> bool |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
103 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
104 | if (not isZero(value)) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
105 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
106 | if (isZero(fmod(value, 10.0))) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
107 | glColor4f(0, 0, 0, 0.6); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
108 | else |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
109 | glColor4f(0, 0, 0, 0.25); |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
110 | |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
111 | return true; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
112 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
113 | else |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
114 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
115 | return false; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
116 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
117 | }; |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
118 | |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
119 | for (qreal x = x0; x < bottomRight.x(); x += gridSize) |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
120 | { |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
121 | if (prepareGridLine(x)) |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
122 | { |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
123 | glVertex(currentCamera().realize({x, -10000, 999})); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
124 | glVertex(currentCamera().realize({x, 10000, 999})); |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
125 | } |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
126 | } |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
127 | |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
128 | for (qreal y = y0; y < bottomRight.y(); y += gridSize) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
129 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
130 | if (prepareGridLine(y)) |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
131 | { |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
132 | glVertex(currentCamera().realize({-10000, y, 999})); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
133 | glVertex(currentCamera().realize({10000, y, 999})); |
1181
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
134 | } |
ca6d0ef9aadb
Added polar grid rendering (which is disabled for now).
Teemu Piippo <teemu@hecknology.net>
parents:
1178
diff
changeset
|
135 | } |
1178
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
136 | } |
1184
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
137 | break; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
138 | |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
139 | case Grid::Polar: |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
140 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
141 | const QPointF pole = grid()->pole(); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
142 | const qreal size = grid()->coordinateSnap(); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
143 | Vertex topLeft = currentCamera().idealize(currentCamera().convert2dTo3d({0, 0})); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
144 | Vertex bottomRight = currentCamera().idealize(currentCamera().convert2dTo3d({width(), height()})); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
145 | QPointF topLeft2d {topLeft.x(), topLeft.y()}; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
146 | QPointF bottomLeft2d {topLeft.x(), bottomRight.y()}; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
147 | QPointF bottomRight2d {bottomRight.x(), bottomRight.y()}; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
148 | QPointF topRight2d {bottomRight.x(), topLeft.y()}; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
149 | qreal smallestRadius = distanceFromPointToRectangle(pole, QRectF{topLeft2d, bottomRight2d}); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
150 | qreal largestRadius = max(QLineF {topLeft2d, pole}.length(), |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
151 | QLineF {bottomLeft2d, pole}.length(), |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
152 | QLineF {bottomRight2d, pole}.length(), |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
153 | QLineF {topRight2d, pole}.length()); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
154 | |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
155 | // Snap the radii to the grid. |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
156 | smallestRadius = round(smallestRadius / size) * size; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
157 | largestRadius = round(largestRadius / size) * size; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
158 | |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
159 | // Is the pole at (0, 0)? If so, then don't render the polar axes above the real ones. |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
160 | bool poleIsOrigin = isZero(pole.x()) and isZero(pole.y()); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
161 | glColor4f(0, 0, 0, 0.25); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
162 | |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
163 | // Render the axes |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
164 | for (int i = 0; i < grid()->polarDivisions() / 2; ++i) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
165 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
166 | qreal azimuth = (2.0 * pi) * i / grid()->polarDivisions(); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
167 | |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
168 | if (not poleIsOrigin or not isZero(fmod(azimuth, pi / 2))) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
169 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
170 | QPointF extremum = {cos(azimuth) * 10000, sin(azimuth) * 10000}; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
171 | QPointF A = pole + extremum; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
172 | QPointF B = pole - extremum; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
173 | glVertex(currentCamera().realize({A.x(), A.y(), 999})); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
174 | glVertex(currentCamera().realize({B.x(), B.y(), 999})); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
175 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
176 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
177 | |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
178 | for (qreal radius = smallestRadius; radius <= largestRadius; radius += size) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
179 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
180 | if (not isZero(radius)) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
181 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
182 | Vertex points[48]; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
183 | |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
184 | for (int i = 0; i < grid()->polarDivisions(); ++i) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
185 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
186 | qreal azimuth = (2.0 * pi) * i / grid()->polarDivisions(); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
187 | QPointF point = pole + QPointF {radius * cos(azimuth), radius * sin(azimuth)}; |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
188 | points[i] = currentCamera().realize({point.x(), point.y(), 999}); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
189 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
190 | |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
191 | for (int i = 0; i < grid()->polarDivisions(); ++i) |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
192 | { |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
193 | glVertex(points[i]); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
194 | glVertex(ring(points, grid()->polarDivisions())[i + 1]); |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
195 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
196 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
197 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
198 | } |
393babf1319d
Polar grid is now togglable.
Teemu Piippo <teemu@hecknology.net>
parents:
1182
diff
changeset
|
199 | break; |
1178
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
200 | } |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
201 | |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
202 | glEnd(); |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
203 | glDisable(GL_LINE_STIPPLE); |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
204 | } |
3a88e7a60b63
At long last, the grid is finally now rendered onto the viewport. Woop!
Teemu Piippo <teemu@hecknology.net>
parents:
1177
diff
changeset
|
205 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
206 | bool Canvas::freeCameraAllowed() const |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
207 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
208 | return m_currentEditMode->allowFreeCamera(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
209 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
210 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
211 | void Canvas::setEditMode(EditModeType a) |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
212 | { |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
213 | if (m_currentEditMode and m_currentEditMode->type() == a) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
214 | return; |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
215 | |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
216 | delete m_currentEditMode; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
217 | m_currentEditMode = AbstractEditMode::createByType(this, a); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
218 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
219 | // If we cannot use the free camera, use the top one instead. |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
220 | if (camera() == Camera::Free and not m_currentEditMode->allowFreeCamera()) |
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
221 | setCamera(Camera::Top); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
222 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
223 | m_window->updateEditModeActions(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
224 | update(); |
1103
ac7db4c076c3
Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
diff
changeset
|
225 | } |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
226 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
227 | EditModeType Canvas::currentEditModeType() const |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
228 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
229 | return m_currentEditMode->type(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
230 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
231 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
232 | LDDocument* Canvas::document() const |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
233 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
234 | return &m_document; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
235 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
236 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
237 | void Canvas::mouseDoubleClickEvent(QMouseEvent* event) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
238 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
239 | if (m_currentEditMode->mouseDoubleClicked (event)) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
240 | event->accept(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
241 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
242 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
243 | void Canvas::dropEvent(QDropEvent* event) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
244 | { |
1283
3c3a5eb965f7
added an MVC interface to the primitives tree
Teemu Piippo <teemu@hecknology.net>
parents:
1274
diff
changeset
|
245 | /* |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
246 | if (m_window and event->source() == m_window->getPrimitivesTree()) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
247 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
248 | PrimitiveTreeItem* item = static_cast<PrimitiveTreeItem*> (m_window->getPrimitivesTree()->currentItem()); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
249 | QString primitiveName = item->primitive()->name; |
1257 | 250 | int position = m_window->suggestInsertPoint(); |
1263
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1257
diff
changeset
|
251 | currentDocument()->emplaceAt<LDSubfileReference>( |
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1257
diff
changeset
|
252 | position, |
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1257
diff
changeset
|
253 | primitiveName, |
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1257
diff
changeset
|
254 | Matrix {}, |
0256edecda54
LDSubfileReference now contains the name of the subfile and not a pointer anymore. Some methods now require a DocumentManager* for context on resolving the name.
Santeri Piippo
parents:
1257
diff
changeset
|
255 | Vertex {}); |
1257 | 256 | m_window->select(currentDocument()->index(position)); |
1168
0b450b4559b8
Removed GLRenderer::refresh(), update() does the job just as fine.
Teemu Piippo <teemu@hecknology.net>
parents:
1145
diff
changeset
|
257 | update(); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
258 | event->acceptProposedAction(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
259 | } |
1283
3c3a5eb965f7
added an MVC interface to the primitives tree
Teemu Piippo <teemu@hecknology.net>
parents:
1274
diff
changeset
|
260 | */ |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
261 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
262 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
263 | void Canvas::keyReleaseEvent(QKeyEvent* event) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
264 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
265 | m_currentEditMode->keyReleased(event); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
266 | GLRenderer::keyReleaseEvent(event); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
267 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
268 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
269 | void Canvas::mouseMoveEvent(QMouseEvent* event) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
270 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
271 | // Calculate 3d position of the cursor |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
272 | m_position3D = currentCamera().convert2dTo3d(mousePosition(), grid()); |
1104
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
273 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
274 | if (not m_currentEditMode->mouseMoved(event)) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
275 | GLRenderer::mouseMoveEvent(event); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
276 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
277 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
278 | void Canvas::mouseReleaseEvent(QMouseEvent *event) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
279 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
280 | AbstractEditMode::MouseEventData data; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
281 | data.ev = event; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
282 | data.mouseMoved = mouseHasMoved(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
283 | data.keymods = keyboardModifiers(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
284 | data.releasedButtons = lastButtons() & ~event->buttons(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
285 | m_currentEditMode->mouseReleased(data); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
286 | GLRenderer::mouseReleaseEvent(event); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
287 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
288 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
289 | void Canvas::mousePressEvent(QMouseEvent *event) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
290 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
291 | if (m_currentEditMode->mousePressed(event)) |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
292 | event->accept(); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
293 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
294 | GLRenderer::mousePressEvent(event); |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
295 | } |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
296 | |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
297 | const Vertex& Canvas::position3D() const |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
298 | { |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
299 | return m_position3D; |
edddb9b0db9e
Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents:
1103
diff
changeset
|
300 | } |
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:
1105
diff
changeset
|
301 | |
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:
1105
diff
changeset
|
302 | void Canvas::drawPoint(QPainter& painter, QPointF pos, QColor color) 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:
1105
diff
changeset
|
303 | { |
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:
1105
diff
changeset
|
304 | int pointSize = 8; |
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:
1105
diff
changeset
|
305 | QPen pen = thinBorderPen; |
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:
1105
diff
changeset
|
306 | pen.setWidth(1); |
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:
1105
diff
changeset
|
307 | painter.setPen(pen); |
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:
1105
diff
changeset
|
308 | painter.setBrush(color); |
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:
1105
diff
changeset
|
309 | painter.drawEllipse(pos.x() - pointSize / 2, pos.y() - pointSize / 2, pointSize, pointSize); |
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:
1105
diff
changeset
|
310 | } |
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:
1105
diff
changeset
|
311 | |
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:
1105
diff
changeset
|
312 | void Canvas::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:
1105
diff
changeset
|
313 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
314 | drawBlipCoordinates(painter, pos3d, currentCamera().convert3dTo2d(pos3d)); |
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:
1105
diff
changeset
|
315 | } |
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:
1105
diff
changeset
|
316 | |
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:
1105
diff
changeset
|
317 | void Canvas::drawBlipCoordinates(QPainter& painter, const Vertex& pos3d, QPointF pos) 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:
1105
diff
changeset
|
318 | { |
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:
1105
diff
changeset
|
319 | painter.setPen (textPen()); |
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:
1105
diff
changeset
|
320 | painter.drawText (pos.x(), pos.y() - 8, pos3d.toString (true)); |
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:
1105
diff
changeset
|
321 | } |
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:
1105
diff
changeset
|
322 | |
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:
1105
diff
changeset
|
323 | QPen Canvas::linePen() 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:
1105
diff
changeset
|
324 | { |
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:
1105
diff
changeset
|
325 | QPen linepen = thinBorderPen; |
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:
1105
diff
changeset
|
326 | linepen.setWidth(2); |
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:
1105
diff
changeset
|
327 | linepen.setColor(luma(backgroundColor()) < 40 ? Qt::white : Qt::black); |
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:
1105
diff
changeset
|
328 | return linepen; |
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:
1105
diff
changeset
|
329 | } |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
330 | |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
331 | |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
332 | int Canvas::depthNegateFactor() const |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
333 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
334 | return currentCamera().isAxisNegated(Z) ? -1 : 1; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
335 | } |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
336 | |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
337 | // ============================================================================= |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
338 | // |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
339 | void Canvas::getRelativeAxes(Axis& relativeX, Axis& relativeY) const |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
340 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
341 | relativeX = currentCamera().axisX(); |
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
342 | relativeY = currentCamera().axisY(); |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
343 | } |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
344 | |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
345 | // ============================================================================= |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
346 | // |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
347 | Axis Canvas::getRelativeZ() const |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
348 | { |
1129
2b20261dc511
Exported GLRenderer cameras into a new class, GLCamera.
Teemu Piippo <teemu@hecknology.net>
parents:
1123
diff
changeset
|
349 | return currentCamera().axisZ(); |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
350 | } |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
351 | |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
352 | // ============================================================================= |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
353 | // |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
354 | void Canvas::setDepthValue (double depth) |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
355 | { |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
356 | if (camera() < Camera::Free) |
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
357 | m_depthValues[static_cast<int>(camera())] = depth; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
358 | } |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
359 | |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
360 | // ============================================================================= |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
361 | // |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
362 | double Canvas::getDepthValue() const |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
363 | { |
1123
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
364 | if (camera() < Camera::Free) |
15e46ea3151f
Reworked iterable enums: they all are enum classes now and the end value is marked with "_End"
Teemu Piippo <teemu@hecknology.net>
parents:
1110
diff
changeset
|
365 | return m_depthValues[static_cast<int>(camera())]; |
1108
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
366 | else |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
367 | return 0.0; |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
368 | } |
90d6f4b7782e
Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents:
1106
diff
changeset
|
369 | |
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
|
370 | void Canvas::contextMenuEvent(QContextMenuEvent* event) |
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
|
371 | { |
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
|
372 | m_window->spawnContextMenu(event->globalPos()); |
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
|
373 | } |
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
|
374 | |
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
|
375 | void Canvas::dragEnterEvent(QDragEnterEvent* event) |
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
|
376 | { |
1283
3c3a5eb965f7
added an MVC interface to the primitives tree
Teemu Piippo <teemu@hecknology.net>
parents:
1274
diff
changeset
|
377 | /* |
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
|
378 | if (m_window and event->source() == m_window->getPrimitivesTree() and m_window->getPrimitivesTree()->currentItem()) |
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
|
379 | event->acceptProposedAction(); |
1283
3c3a5eb965f7
added an MVC interface to the primitives tree
Teemu Piippo <teemu@hecknology.net>
parents:
1274
diff
changeset
|
380 | */ |
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
|
381 | } |