src/linetypes/object.h

Wed, 22 Jan 2020 22:41:17 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Wed, 22 Jan 2020 22:41:17 +0200
changeset 28
c92c1daf735f
parent 26
3a9e761e4faa
child 33
4c41bfe2ec6e
permissions
-rw-r--r--

modelview matrix set up

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

mercurial