src/canvas.h

Sun, 12 Feb 2017 16:59:35 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sun, 12 Feb 2017 16:59:35 +0200
changeset 1125
d8f94e56d42e
parent 1110
ec3ee7da7806
child 1129
2b20261dc511
permissions
-rw-r--r--

Moved the definitions of all configuration options into a new text file and made the configuration collector read that.

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
ac7db4c076c3 Created a new GLRenderer derivative class "Canvas" and made MainWindow use it
Teemu Piippo <teemu@hecknology.net>
parents:
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
1108
90d6f4b7782e Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents: 1106
diff changeset
29 Vertex convert2dTo3d(const QPoint& pos2d, bool snap) const;
90d6f4b7782e Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents: 1106
diff changeset
30 QPoint convert3dTo2d(const Vertex& pos3d) const;
1104
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
31 EditModeType currentEditModeType() 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;
1108
90d6f4b7782e Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents: 1106
diff changeset
37 double getDepthValue() const;
90d6f4b7782e Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents: 1106
diff changeset
38 void getRelativeAxes(Axis& relX, Axis& relY) const;
90d6f4b7782e Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents: 1106
diff changeset
39 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
40 QPen linePen() const;
1104
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
41 const Vertex& position3D() const;
1108
90d6f4b7782e Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents: 1106
diff changeset
42 void setDepthValue(double depth);
1104
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
43 void setEditMode(EditModeType type);
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
44
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
45 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
46 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
47 void dragEnterEvent(QDragEnterEvent* event) override;
1104
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
48 void dropEvent(QDropEvent* event) override;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
49 bool freeCameraAllowed() const override;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
50 void keyReleaseEvent(QKeyEvent* event) override;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
51 void mouseDoubleClickEvent(QMouseEvent* event) override;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
52 void mouseMoveEvent(QMouseEvent* event) override;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
53 void mousePressEvent(QMouseEvent *event) override;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
54 void mouseReleaseEvent(QMouseEvent* event) override;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
55 void overpaint(QPainter& painter) override;
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 private:
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
58 LDDocument& m_document;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
59 AbstractEditMode* m_currentEditMode = nullptr;
edddb9b0db9e Moved document editing methods from GLRenderer to Canvas
Teemu Piippo <teemu@hecknology.net>
parents: 1103
diff changeset
60 Vertex m_position3D;
1108
90d6f4b7782e Moved more editing-related methods to Canvas.
Teemu Piippo <teemu@hecknology.net>
parents: 1106
diff changeset
61 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
62 };

mercurial