src/linetypes/quadrilateral.cpp

Wed, 25 May 2022 20:36:34 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 25 May 2022 20:36:34 +0300
changeset 199
6988973515d2
parent 183
97b591813c8b
permissions
-rw-r--r--

Fix pick() picking from weird places on the screen with high DPI scaling

glReadPixels reads data from the frame buffer, which contains data after
high DPI scaling, so any reads to that need to take this scaling into account

15
9e18ec63eec3 split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #include "quadrilateral.h"
9e18ec63eec3 split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
3 QString ldraw::Quadrilateral::textRepresentation() const
15
9e18ec63eec3 split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 {
9e18ec63eec3 split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 return utility::format("%1 %2 %3 %4",
87
93ec4d630346 added PolygonObject and refactored away a lot of boilerplate
Teemu Piippo <teemu@hecknology.net>
parents: 86
diff changeset
6 utility::vertexToStringParens(this->points[0]),
93ec4d630346 added PolygonObject and refactored away a lot of boilerplate
Teemu Piippo <teemu@hecknology.net>
parents: 86
diff changeset
7 utility::vertexToStringParens(this->points[1]),
93ec4d630346 added PolygonObject and refactored away a lot of boilerplate
Teemu Piippo <teemu@hecknology.net>
parents: 86
diff changeset
8 utility::vertexToStringParens(this->points[2]),
93ec4d630346 added PolygonObject and refactored away a lot of boilerplate
Teemu Piippo <teemu@hecknology.net>
parents: 86
diff changeset
9 utility::vertexToStringParens(this->points[3]));
15
9e18ec63eec3 split quadrilateral and triangle into their own source files
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 }
21
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
11
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
12 void ldraw::Quadrilateral::getPolygons(
21
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
13 std::vector<gl::Polygon>& polygons,
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
14 GetPolygonsContext* context) const
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
15 {
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
16 Q_UNUSED(context)
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
17 polygons.push_back(gl::quadrilateral(
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
18 this->points[0],
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
19 this->points[1],
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
20 this->points[2],
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
21 this->points[3],
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
22 this->colorIndex,
87
93ec4d630346 added PolygonObject and refactored away a lot of boilerplate
Teemu Piippo <teemu@hecknology.net>
parents: 86
diff changeset
23 this->id));
21
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
24 }
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
25
183
97b591813c8b - Add editors for string and bool properties
Teemu Piippo <teemu@hecknology.net>
parents: 177
diff changeset
26 void ldraw::Quadrilateral::invert(GetPolygonsContext *)
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
27 {
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
28 // 0 1 2 3
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
29 // -> 2 1 0 3
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
30 std::swap(this->points[0], this->points[2]);
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
31 }
132
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
32
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
33 ldraw::Object::Type ldraw::Quadrilateral::typeIdentifier() const
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
34 {
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
35 return Type::Quadrilateral;
488d0ba6070b Begin work with serialization
Teemu Piippo <teemu@hecknology.net>
parents: 87
diff changeset
36 }
141
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
37
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
38 QString ldraw::Quadrilateral::toLDrawCode() const
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
39 {
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
40 return utility::format(
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
41 "4 %1 %2 %3 %4 %5",
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
42 this->colorIndex.index,
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
43 utility::vertexToString(this->points[0]),
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
44 utility::vertexToString(this->points[1]),
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
45 utility::vertexToString(this->points[2]),
158
5bd755eaa5a8 Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents: 141
diff changeset
46 utility::vertexToString(this->points[3]));
141
185eb297dc1e Saving works now
Teemu Piippo <teemu@hecknology.net>
parents: 132
diff changeset
47 }
158
5bd755eaa5a8 Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents: 141
diff changeset
48
5bd755eaa5a8 Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents: 141
diff changeset
49 QString ldraw::Quadrilateral::iconName() const
5bd755eaa5a8 Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents: 141
diff changeset
50 {
5bd755eaa5a8 Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents: 141
diff changeset
51 return ":/icons/linetype-quadrilateral.png";
5bd755eaa5a8 Add icons from ionicons
Teemu Piippo <teemu@hecknology.net>
parents: 141
diff changeset
52 }
177
f69d53c053df Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents: 158
diff changeset
53
f69d53c053df Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents: 158
diff changeset
54 QString ldraw::Quadrilateral::typeName() const
f69d53c053df Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents: 158
diff changeset
55 {
f69d53c053df Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents: 158
diff changeset
56 return QObject::tr("quadrilateral");
f69d53c053df Show type of object in the object editor
Teemu Piippo <teemu@hecknology.net>
parents: 158
diff changeset
57 }

mercurial