src/ui/canvas.h

Thu, 27 Feb 2020 12:23:42 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 27 Feb 2020 12:23:42 +0200
changeset 58
b7841cd31fb7
parent 57
5c0005f63319
child 61
4585d8d7a7ec
permissions
-rw-r--r--

use glm::project instead of figuring out the conversion manually...

47
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #include "gl/partrenderer.h"
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 class Canvas : public PartRenderer
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 {
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 Q_OBJECT
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
7 public:
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 Canvas(
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 Model* model,
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 DocumentManager* documents,
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 const ldraw::ColorTable& colorTable,
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 QWidget* parent = nullptr);
51
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
13 public slots:
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
14 void handleSelectionChange(const QSet<ldraw::Id>& selectedIds, const QSet<ldraw::Id>& deselectedIds);
47
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
15 protected:
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 void mouseMoveEvent(QMouseEvent* event) override;
51
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
17 void mousePressEvent(QMouseEvent* event) override;
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
18 void mouseReleaseEvent(QMouseEvent* event) override;
57
5c0005f63319 use glm::unProject to implement screenToModelCoordinates
Teemu Piippo <teemu@hecknology.net>
parents: 51
diff changeset
19 void paintGL() override;
47
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
20 signals:
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
21 void newStatusText(const QString& newStatusText);
51
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
22 void selectionChanged(const QSet<ldraw::Id>& newSelection);
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
23 private:
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
24 QPoint lastMousePosition;
57
5c0005f63319 use glm::unProject to implement screenToModelCoordinates
Teemu Piippo <teemu@hecknology.net>
parents: 51
diff changeset
25 std::optional<glm::vec3> worldPosition;
51
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
26 int totalMouseMove = 0;
1a9eac27698d selection works now
Teemu Piippo <teemu@hecknology.net>
parents: 47
diff changeset
27 QSet<ldraw::Id> selection;
47
cd6704009eb9 picking works now
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 };

mercurial