-
Notifications
You must be signed in to change notification settings - Fork 105
/
point_symbol.h
167 lines (135 loc) · 5.83 KB
/
point_symbol.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
* Copyright 2012, 2013 Thomas Schöps
* Copyright 2012-2019 Kai Pastor
*
* This file is part of OpenOrienteering.
*
* OpenOrienteering is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* OpenOrienteering is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenOrienteering. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPENORIENTEERING_POINT_SYMBOL_H
#define OPENORIENTEERING_POINT_SYMBOL_H
#include <memory>
#include <vector>
#include <Qt>
#include <QtGlobal>
#include "symbol.h"
// IWYU pragma: no_include "core/objects/object.h"
class QPainterPath;
class QXmlStreamReader;
class QXmlStreamWriter;
namespace OpenOrienteering {
class Map;
class MapColor;
class MapColorMap;
class MapCoordF;
class ObjectRenderables;
class SymbolPropertiesWidget;
class SymbolSettingDialog;
class VirtualCoordVector;
/**
* Symbol for PointObjects.
*
* Apart from its own settings which are presented to the user as "[Midpoint
* symbol]" in the point symbol editor, this class can contain a list of
* elements together with a symbol for each element. All elements and the
* PointObject's own settings make up the appearance of the point symbol.
* The reason the own settings are left in is just efficiency, as for some
* symbols like crop land, a really huge number of point objects may be generated.
*/
class PointSymbol : public Symbol
{
friend class PointSymbolSettings;
friend class PointSymbolEditorWidget;
friend class OCAD8FileImport;
friend class XMLImportExport;
public:
/** Constructs an empty point symbol. */
PointSymbol() noexcept;
~PointSymbol() override;
protected:
explicit PointSymbol(const PointSymbol& proto);
PointSymbol* duplicate() const override;
public:
bool validate() const override;
void createRenderables(
const Object *object,
const VirtualCoordVector &coords,
ObjectRenderables &output,
RenderableOptions options ) const override;
void createRenderablesScaled(const MapCoordF& coord, qreal rotation, ObjectRenderables& output, qreal coord_scale = 1) const;
void createRenderablesIfCenterInside(const MapCoordF& point_coord, qreal rotation, const QPainterPath* outline, ObjectRenderables& output) const;
void createPrimitivesIfCompletelyInside(const MapCoordF& point_coord, const QPainterPath* outline, ObjectRenderables& output) const;
void createRenderablesIfCompletelyInside(const MapCoordF& point_coord, qreal rotation, const QPainterPath* outline, ObjectRenderables& output) const;
void createPrimitivesIfPartiallyInside(const MapCoordF& point_coord, const QPainterPath* outline, ObjectRenderables& output) const;
void createRenderablesIfPartiallyInside(const MapCoordF& point_coord, qreal rotation, const QPainterPath* outline, ObjectRenderables& output) const;
void colorDeletedEvent(const MapColor* color) override;
bool containsColor(const MapColor* color) const override;
const MapColor* guessDominantColor() const override;
void replaceColors(const MapColorMap& color_map) override;
void scale(double factor) override;
qreal dimensionForIcon() const override;
// Contained objects and symbols (elements)
/** Returns the number of contained elements. */
int getNumElements() const;
/** Adds a new element consisting of object and symbol at the given index. */
void addElement(int pos, Object* object, Symbol* symbol);
/** Returns the object of the i-th element. */
Object* getElementObject(int pos);
/** Returns the object of the i-th element. */
const Object* getElementObject(int pos) const;
/** Returns the symbol of the i-th element. */
Symbol* getElementSymbol(int pos);
/** Returns the symbol of the i-th element. */
const Symbol* getElementSymbol(int pos) const;
/** Deletes the i-th element. */
void deleteElement(int pos);
/**
* Returns true if the point contains no elements and does not create
* renderables itself. Useful to check if it can be deleted.
*/
bool isEmpty() const;
/**
* Checks if the contained elements are rotationally symmetrical around
* the origin (this means, only point elements at (0,0) are allowed).
*/
bool isSymmetrical() const;
// Getters / Setters
using Symbol::setRotatable; /* public visibility */
inline int getInnerRadius() const {return inner_radius;}
inline void setInnerRadius(int value) {inner_radius = value;}
inline const MapColor* getInnerColor() const {return inner_color;}
inline void setInnerColor(const MapColor* color) {inner_color = color;}
inline int getOuterWidth() const {return outer_width;}
inline void setOuterWidth(int value) {outer_width = value;}
inline const MapColor* getOuterColor() const {return outer_color;}
inline void setOuterColor(const MapColor* color) {outer_color = color;}
SymbolPropertiesWidget* createPropertiesWidget(SymbolSettingDialog* dialog) override;
protected:
void saveImpl(QXmlStreamWriter& xml, const Map& map) const override;
bool loadImpl(QXmlStreamReader& xml, const Map& map, SymbolDictionary& symbol_dict, int version) override;
bool equalsImpl(const Symbol* other, Qt::CaseSensitivity case_sensitivity) const override;
/// \todo Expose elements more directly in PointSymbol API.
struct Element
{
std::unique_ptr<Symbol> symbol;
std::unique_ptr<Object> object;
};
std::vector<Element> elements;
const MapColor* inner_color;
const MapColor* outer_color;
int inner_radius; // in 1/1000 mm
int outer_width; // in 1/1000 mm
};
} // namespace OpenOrienteering
#endif