src/linetypes/object.h

Wed, 26 Feb 2020 22:26:05 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 26 Feb 2020 22:26:05 +0200
changeset 56
fad4a5dd8dee
parent 35
98906a94732f
child 73
97df974b5ed5
permissions
-rw-r--r--

PartRenderer::modelToScreenCoordinates FINALLY WORKS

3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
1 #pragma once
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
2 #include <QPointF>
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
3 #include <QString>
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
4 #include <QStringView>
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
5 #include "main.h"
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
6 #include "colors.h"
21
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
7 #include "gl/common.h"
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
8
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
9 namespace ldraw
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
10 {
21
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
11 struct GetPolygonsContext;
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
12 enum class Property;
13
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
13 class Object;
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
14 class ColoredObject;
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
15 class Empty;
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
16 }
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
17
21
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
18 class DocumentManager;
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
19
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
20 struct ldraw::GetPolygonsContext
21
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
21 {
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
22 ::DocumentManager* documents;
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
23 };
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
24
13
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
25 /**
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
26 * @brief Different properties that can be queried with getProperty
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
27 */
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
28 enum class ldraw::Property
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
29 {
13
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
30 Color, // Color of the object
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
31 Text, // Text contained in a comment
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
32 Point1, // First vertex in a polygon or edge line
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
33 Point2, // Second vertex in a polygon or edge line
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
34 Point3, // Third vertex in a polygon
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
35 Point4, // Fourth vertex in a quadrilateral
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
36 ControlPoint1, // First control point in a conditional edge line
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
37 ControlPoint2, // Second control point in a conditional edge line
21
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
38 Transformation, // 4x4 transformation matrix of a subfile reference
13
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
39 ReferenceName, // Subfile reference name
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
40 IsInverted, // Whether or not the object has been inverted with BFC INVERTNEXT
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
41 ErrorMessage // For error lines, why parsing failed
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
42 };
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
43
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
44 class ldraw::Object
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
45 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
46 public:
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
47 enum class SetPropertyResult
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 Success = 0,
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
50 PropertyNotHandled,
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
51 InvalidValue
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
52 };
13
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
53 Object();
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
54 Object(const Object&) = delete;
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
55 virtual ~Object();
17
a5111f4e6412 added teapot rendering
Teemu Piippo <teemu@hecknology.net>
parents: 14
diff changeset
56 const Id id;
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
57 //virtual void toString(QTextStream &out) = 0;
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
58 virtual bool hasColor() const;
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
59 virtual QVariant getProperty(Property id) const;
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
60 virtual SetPropertyResult setProperty(Property id, const QVariant& value);
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
61 virtual QString textRepresentation() const = 0;
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
62 virtual QBrush textRepresentationForeground() const;
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
63 virtual QBrush textRepresentationBackground() const;
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
64 virtual QFont textRepresentationFont() const;
21
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
65 virtual void getPolygons(std::vector<gl::Polygon>& polygons, GetPolygonsContext* context) const;
26
3a9e761e4faa at least VAOs work now
Teemu Piippo <teemu@hecknology.net>
parents: 21
diff changeset
66 virtual void invert() {}
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
67 };
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
68
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
69 class ldraw::ColoredObject : public Object
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
70 {
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
71 public:
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
72 ColoredObject(const Color colorIndex = ldraw::mainColor);
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
73 bool hasColor() const override final;
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
74 QVariant getProperty(Property id) const override;
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
75 SetPropertyResult setProperty(Property id, const QVariant& value) override;
21
Teemu Piippo <teemu@hecknology.net>
parents: 17
diff changeset
76 protected:
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
77 Color colorIndex = ldraw::mainColor;
3
55a55a9ec2c2 Added lots of code
Teemu Piippo <teemu@hecknology.net>
parents:
diff changeset
78 };
6
73e448b2943d language support
Teemu Piippo <teemu@hecknology.net>
parents: 3
diff changeset
79
13
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
80 /**
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
81 * @brief Represents an empty line.
6e838748867b renamings
Teemu Piippo <teemu@hecknology.net>
parents: 8
diff changeset
82 */
35
98906a94732f renamed the linetypes namespace to ldraw namespace and added more structures to it
Teemu Piippo <teemu@hecknology.net>
parents: 33
diff changeset
83 class ldraw::Empty : public Object
8
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
84 {
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
85 QString textRepresentation() const override;
44679e468ba9 major update with many things
Teemu Piippo <teemu@hecknology.net>
parents: 6
diff changeset
86 };

mercurial