src/linetypes/conditionaledge.cpp

Thu, 27 Feb 2020 11:56:41 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Thu, 27 Feb 2020 11:56:41 +0200
changeset 57
5c0005f63319
parent 35
98906a94732f
child 77
028798a72591
permissions
-rw-r--r--

use glm::unProject to implement screenToModelCoordinates

3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #include "conditionaledge.h"
55a55a9ec2c2 Added lots of code
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 ldraw::ConditionalEdge::ConditionalEdge(
33
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
4 const glm::vec3& point_1,
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
5 const glm::vec3& point_2,
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
6 const glm::vec3& controlPoint_1,
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
7 const glm::vec3& controlPoint_2,
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8 const Color color_index) :
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
9 Edge{point_1, point_2, color_index},
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 controlPoint_1{controlPoint_1},
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
11 controlPoint_2{controlPoint_2}
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
13 }
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
14
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
15 ldraw::ConditionalEdge::ConditionalEdge(const QVector<glm::vec3>& vertices, const Color color) :
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
16 Edge{vertices[0], vertices[1], color},
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
17 controlPoint_1{vertices[2]},
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
18 controlPoint_2{vertices[3]}
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
19 {
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
20 }
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
21
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
22 QVariant ldraw::ConditionalEdge::getProperty(Property property) const
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
23 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
24 switch (property)
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
25 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
26 case Property::ControlPoint1:
33
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
27 return QVariant::fromValue(controlPoint_1);
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
28 case Property::ControlPoint2:
33
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
29 return QVariant::fromValue(controlPoint_2);
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
30 default:
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
31 return Edge::getProperty(property);
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
32 }
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
33 }
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
34
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
35 auto ldraw::ConditionalEdge::setProperty(
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
36 Property property,
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
37 const QVariant& value)
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
38 -> SetPropertyResult
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
39 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
40 switch (property)
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
41 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
42 case Property::ControlPoint1:
33
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
43 controlPoint_1 = value.value<glm::vec3>();
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
44 case Property::ControlPoint2:
33
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
45 controlPoint_2 = value.value<glm::vec3>();
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46 default:
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
47 return Edge::setProperty(property, value);
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
48 }
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
49 }
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
50
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
51 QString ldraw::ConditionalEdge::textRepresentation() const
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
52 {
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
53 return Edge::textRepresentation() + utility::format("%1 %2",
33
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
54 utility::vertexToStringParens(controlPoint_1),
4c41bfe2ec6e replaced matrix and vertex classes with glm
Teemu Piippo <teemu@hecknology.net>
parents: 18
diff changeset
55 utility::vertexToStringParens(controlPoint_2));
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
56 }

mercurial