src/linetypes/object.h

Sat, 14 Dec 2019 23:00:01 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Sat, 14 Dec 2019 23:00:01 +0200
changeset 20
cef43609a374
parent 17
a5111f4e6412
child 21
0133e565e072
permissions
-rw-r--r--

fixed build

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

mercurial