![]() |
Mapper
0.9.0
API documentation
|
Abstract base class for map symbols. More...
#include <symbol.h>
Classes | |
struct | lessByColor |
A functor for comparing symbols by dominant colors. More... | |
Public Types | |
enum | Type { Point = 1, Line = 2, Area = 4, Text = 8, Combined = 16, NoSymbol = 0, AllSymbols = Point | Line | Area | Text | Combined } |
Enumeration of all possible symbol types. More... | |
enum | RenderableOption { RenderBaselines = 1 << 0, RenderAreasHatched = 1 << 1, RenderNormal = 0 } |
RenderableOptions denominate variations in painting symbols. More... | |
Public Member Functions | |
Symbol (Type type) noexcept | |
virtual | ~Symbol () |
Symbol & | operator= (const Symbol &)=delete |
Symbol & | operator= (Symbol &&)=delete |
virtual bool | validate () const |
bool | equals (const Symbol *other, Qt::CaseSensitivity case_sensitivity=Qt::CaseSensitive) const |
Checks for equality to the other symbol. More... | |
bool | stateEquals (const Symbol *other) const |
Checks protected/hidden state for equality to the other symbol. More... | |
Type | getType () const |
Returns the type of the symbol. More... | |
const PointSymbol * | asPoint () const |
Case to PointSymbol with type checking. More... | |
PointSymbol * | asPoint () |
Case to PointSymbol with type checking. More... | |
const LineSymbol * | asLine () const |
Case to LineSymbol with type checking. More... | |
LineSymbol * | asLine () |
Case to LineSymbol with type checking. More... | |
const AreaSymbol * | asArea () const |
Case to AreaSymbol with type checking. More... | |
AreaSymbol * | asArea () |
Case to AreaSymbol with type checking. More... | |
const TextSymbol * | asText () const |
Case to TextSymbol with type checking. More... | |
TextSymbol * | asText () |
Case to TextSymbol with type checking. More... | |
const CombinedSymbol * | asCombined () const |
Case to CombinedSymbol with type checking. More... | |
CombinedSymbol * | asCombined () |
Case to CombinedSymbol with type checking. More... | |
virtual TypeCombination | getContainedTypes () const |
Returns the combined bitmask of all symbol types this symbol contains. More... | |
bool | isTypeCompatibleTo (const Object *object) const |
Checks if the symbol can be applied to the given object. More... | |
bool | numberEquals (const Symbol *other) const |
Returns if the symbol numbers are exactly equal. More... | |
bool | numberEqualsRelaxed (const Symbol *other) const |
Returns if the symbol numbers are equal, ignoring trailing zeros. More... | |
void | save (QXmlStreamWriter &xml, const Map &map) const |
Saves the symbol in xml format. More... | |
virtual bool | loadingFinishedEvent (Map *map) |
Called when loading the map is finished. More... | |
virtual void | createRenderables (const Object *object, const VirtualCoordVector &coords, ObjectRenderables &output, Symbol::RenderableOptions options) const =0 |
Creates renderables for a generic object. More... | |
virtual void | createRenderables (const PathObject *object, const PathPartVector &path_parts, ObjectRenderables &output, Symbol::RenderableOptions options) const |
Creates renderables for a path object. More... | |
virtual void | createBaselineRenderables (const PathObject *object, const PathPartVector &path_parts, ObjectRenderables &output, const MapColor *color) const |
Creates baseline renderables for a path object. More... | |
virtual void | colorDeletedEvent (const MapColor *color)=0 |
Called when a color is removed from the map. More... | |
virtual bool | containsColor (const MapColor *color) const =0 |
Returns if the given color is used by this symbol. More... | |
virtual const MapColor * | guessDominantColor () const =0 |
Returns the dominant color of this symbol. More... | |
virtual void | replaceColors (const MapColorMap &color_map)=0 |
Replaces colors used by this symbol. More... | |
virtual bool | symbolChangedEvent (const Symbol *old_symbol, const Symbol *new_symbol) |
Called when a symbol was changed, replaced, or removed. More... | |
virtual bool | containsSymbol (const Symbol *symbol) const |
Returns true if the given symbol is referenced by this symbol. More... | |
virtual void | scale (double factor)=0 |
Scales the symbol. More... | |
QImage | getCustomIcon () const |
Returns the custom symbol icon. More... | |
void | setCustomIcon (const QImage &image) |
Sets a custom symbol icon. More... | |
QImage | getIcon (const Map *map) const |
Returns the symbol's icon. More... | |
QImage | createIcon (const Map &map, int side_length, bool antialiasing=true, qreal zoom=0) const |
Creates a symbol icon with the given side length (pixels). More... | |
void | resetIcon () |
Clear the symbol's cached icon. More... | |
virtual qreal | dimensionForIcon () const |
Returns the dimension which shall considered when scaling the icon. More... | |
virtual qreal | calculateLargestLineExtent () const |
Returns the largest extent of all primitive lines which are part of the symbol. More... | |
const QString & | getName () const |
Returns the symbol name. More... | |
QString | getPlainTextName () const |
Returns the symbol name with all HTML markup stripped. More... | |
void | setName (const QString &new_name) |
Sets the symbol name. More... | |
QString | getNumberAsString () const |
Returns the symbol number as string. More... | |
int | getNumberComponent (int i) const |
Returns the i-th component of the symbol number as int. More... | |
void | setNumberComponent (int i, int new_number) |
Sets the i-th component of the symbol number. More... | |
const QString & | getDescription () const |
Returns the symbol description. More... | |
void | setDescription (const QString &new_description) |
Sets the symbol description. More... | |
bool | isHelperSymbol () const |
Returns if this is a helper symbol (which is not printed in the final map). More... | |
void | setIsHelperSymbol (bool value) |
Sets if this is a helper symbol, see isHelperSymbol(). More... | |
bool | isHidden () const |
Returns if this symbol is hidden. More... | |
void | setHidden (bool value) |
Sets the hidden state of this symbol. More... | |
bool | isProtected () const |
Returns if this symbol is protected. More... | |
void | setProtected (bool value) |
Sets the protected state of this symbol. More... | |
bool | isRotatable () const |
Returns if objects with this symbol can be rotated in arbitrary directions. More... | |
virtual SymbolPropertiesWidget * | createPropertiesWidget (SymbolSettingDialog *dialog)=0 |
Creates a properties widget for the symbol. More... | |
Static Public Member Functions | |
template<class S > | |
static std::unique_ptr< S > | duplicate (const S &s) |
Duplicates a symbol. More... | |
static std::unique_ptr< Symbol > | load (QXmlStreamReader &xml, const Map &map, SymbolDictionary &symbol_dict, int version) |
Load the symbol in xml format. More... | |
static std::unique_ptr< Symbol > | makeSymbolForType (Type type) |
Returns a newly created symbol of the given type. More... | |
static bool | areTypesCompatible (Type a, Type b) |
Returns if the symbol types can be applied to the same object types. More... | |
static TypeCombination | getCompatibleTypes (Type type) |
Returns a bitmask of all types which can be applied to the same objects as the given type. More... | |
static bool | lessByNumber (const Symbol *s1, const Symbol *s2) |
Compares two symbols by number. More... | |
static bool | lessByColorPriority (const Symbol *s1, const Symbol *s2) |
Compares two symbols by the dominant colors' priorities. More... | |
Static Public Attributes | |
static constexpr auto | number_components = 3u |
Number of components of symbol numbers. More... | |
Protected Member Functions | |
Symbol (const Symbol &proto) | |
virtual Symbol * | duplicate () const =0 |
void | setRotatable (bool value) |
Sets the rotatability state of the symbol. More... | |
virtual void | saveImpl (QXmlStreamWriter &xml, const Map &map) const =0 |
Must be overridden to save type-specific symbol properties. More... | |
virtual bool | loadImpl (QXmlStreamReader &xml, const Map &map, SymbolDictionary &symbol_dict, int version)=0 |
Must be overridden to load type-specific symbol properties. More... | |
virtual bool | equalsImpl (const Symbol *other, Qt::CaseSensitivity case_sensitivity) const =0 |
Must be overridden to compare specific attributes. More... | |
Abstract base class for map symbols.
Provides among other things a symbol number consisting of multiple parts, e.g. "2.4.12". Parts which are not set are assigned the value -1.
|
explicitnoexcept |
|
virtualdefault |
|
explicitprotected |
|
static |
Returns if the symbol types can be applied to the same object types.
const AreaSymbol * OpenOrienteering::Symbol::asArea | ( | ) | const |
Case to AreaSymbol with type checking.
AreaSymbol * OpenOrienteering::Symbol::asArea | ( | ) |
Case to AreaSymbol with type checking.
const CombinedSymbol * OpenOrienteering::Symbol::asCombined | ( | ) | const |
Case to CombinedSymbol with type checking.
CombinedSymbol * OpenOrienteering::Symbol::asCombined | ( | ) |
Case to CombinedSymbol with type checking.
const LineSymbol * OpenOrienteering::Symbol::asLine | ( | ) | const |
Case to LineSymbol with type checking.
LineSymbol * OpenOrienteering::Symbol::asLine | ( | ) |
Case to LineSymbol with type checking.
const PointSymbol * OpenOrienteering::Symbol::asPoint | ( | ) | const |
Case to PointSymbol with type checking.
PointSymbol * OpenOrienteering::Symbol::asPoint | ( | ) |
Case to PointSymbol with type checking.
const TextSymbol * OpenOrienteering::Symbol::asText | ( | ) | const |
Case to TextSymbol with type checking.
TextSymbol * OpenOrienteering::Symbol::asText | ( | ) |
Case to TextSymbol with type checking.
|
virtual |
Returns the largest extent of all primitive lines which are part of the symbol.
Effectively, this is the half line width.
Reimplemented in OpenOrienteering::LineSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
pure virtual |
Called when a color is removed from the map.
Symbols need to remove all references to the given color when this event occurs.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
Returns if the given color is used by this symbol.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
Returns true if the given symbol is referenced by this symbol.
A symbol does not contain itself, so it must return true when the given symbol is identical to the symbol this function is being called for.
Reimplemented in OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
virtual |
Creates baseline renderables for a path object.
Baseline renderables show the coordinate paths with minimum line width.
QImage OpenOrienteering::Symbol::createIcon | ( | const Map & | map, |
int | side_length, | ||
bool | antialiasing = true , |
||
qreal | zoom = 0 |
||
) | const |
Creates a symbol icon with the given side length (pixels).
If the zoom parameter is zero, the map's symbolIconZoom() is used. At a zoom of 1.0 (100%), a square symbol of 1 mm side length would fill 50% of the icon width and height. Larger symbols may be scaled down.
|
pure virtual |
Creates a properties widget for the symbol.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
pure virtual |
Creates renderables for a generic object.
This will create the renderables according to the object's properties and the given coordinates.
Implementations must use the coordinates (coords) instead of the object's coordinates.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
virtual |
Creates renderables for a path object.
This will create the renderables according to the object's properties and the coordinates given by the path_parts. This allows the immediate use of precalculated meta-information on paths.
Reimplemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
virtual |
Returns the dimension which shall considered when scaling the icon.
Reimplemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
protectedpure virtual |
|
inlinestatic |
Duplicates a symbol.
This template function mitigates the incompatibility of std::unique_ptr with covariant return types when duplicating instances of the polymorphic type Symbol.
For convenient use outside of (child class) method implementatations, there is a free template function duplicate(const Derived& d).
bool OpenOrienteering::Symbol::equals | ( | const Symbol * | other, |
Qt::CaseSensitivity | case_sensitivity = Qt::CaseSensitive |
||
) | const |
Checks for equality to the other symbol.
This function does not check the equality of the state (protected/hidden). Use stateEquals(Symbol*) for this comparison.
other | The symbol to compare with. |
case_sensitivity | Comparison mode for strings, e.g. symbol names. |
|
protectedpure virtual |
Must be overridden to compare specific attributes.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
static |
Returns a bitmask of all types which can be applied to the same objects as the given type.
|
virtual |
Returns the combined bitmask of all symbol types this symbol contains.
Reimplemented in OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
inline |
Returns the custom symbol icon.
|
inline |
Returns the symbol description.
Returns the symbol's icon.
This function returns (a scaled version of) the custom symbol icon if it is set and custom icon display is enabled, or a generated one. The icon is cached, making repeated calls cheap.
|
inline |
Returns the symbol name.
QString OpenOrienteering::Symbol::getNumberAsString | ( | ) | const |
Returns the symbol number as string.
|
inline |
Returns the i-th component of the symbol number as int.
QString OpenOrienteering::Symbol::getPlainTextName | ( | ) | const |
Returns the symbol name with all HTML markup stripped.
|
inline |
Returns the type of the symbol.
|
pure virtual |
Returns the dominant color of this symbol.
If it is not possible to efficiently determine this color exactly, an appropriate heuristic should be used.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
inline |
Returns if this is a helper symbol (which is not printed in the final map).
|
inline |
Returns if this symbol is hidden.
|
inline |
Returns if this symbol is protected.
Objects with a protected symbol cannot be selected or edited.
|
inline |
Returns if objects with this symbol can be rotated in arbitrary directions.
Checks if the symbol can be applied to the given object.
Compares two symbols by the dominant colors' priorities.
Compares two symbols by number.
|
static |
Load the symbol in xml format.
This function invokes loadImpl(...) which may be overridden by child classes. It does not add the symbol to the map.
xml | Stream to load from. |
map | Reference to the map which will eventually contain the symbol. |
symbol_dict | Dictionary mapping symbol IDs to symbols. |
|
protectedpure virtual |
Must be overridden to load type-specific symbol properties.
Returns false if the current xml tag does not belong to the symbol and should be skipped, true if the element has been read completely.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, and OpenOrienteering::CombinedSymbol.
Called when loading the map is finished.
This event handler can be overridden in order to do tasks that need to access other symbols or map objects.
Reimplemented in OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
static |
Returns a newly created symbol of the given type.
Returns if the symbol numbers are exactly equal.
Returns if the symbol numbers are equal, ignoring trailing zeros.
|
pure virtual |
Replaces colors used by this symbol.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
void OpenOrienteering::Symbol::resetIcon | ( | ) |
Clear the symbol's cached icon.
Call this function after changes to the symbol definition, custom icon, or general size/zoom/visibility settings. The cached icon will be recreated the next time getIcon() gets called.
void OpenOrienteering::Symbol::save | ( | QXmlStreamWriter & | xml, |
const Map & | map | ||
) | const |
Saves the symbol in xml format.
This function invokes saveImpl(...) which may be overridden by child classes.
xml | Stream to save to. |
map | Reference to the map containing the symbol. |
|
protectedpure virtual |
Must be overridden to save type-specific symbol properties.
The map pointer can be used to get persistent indices to any pointers on map data.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
pure virtual |
Scales the symbol.
Implemented in OpenOrienteering::AreaSymbol, OpenOrienteering::LineSymbol, OpenOrienteering::TextSymbol, OpenOrienteering::PointSymbol, OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
void OpenOrienteering::Symbol::setCustomIcon | ( | const QImage & | image | ) |
Sets a custom symbol icon.
The custom icon takes precedence over the generated one when custom icon display is enabled. Like the generated icon, it is not part of the symbol state which is compared by the equals
functions. However, it is copied when duplicating an icon.
To clear the custom icon, this function can be called with a null QImage.
|
inline |
Sets the symbol description.
|
inline |
Sets the hidden state of this symbol.
|
inline |
Sets if this is a helper symbol, see isHelperSymbol().
|
inline |
Sets the symbol name.
|
inline |
Sets the i-th component of the symbol number.
|
inline |
Sets the protected state of this symbol.
|
protected |
Sets the rotatability state of the symbol.
Symbol implementations which are to support user-defined object rotatability shall import this function into public visibility. They also need to handle saving and loading.
Checks protected/hidden state for equality to the other symbol.
|
virtual |
Called when a symbol was changed, replaced, or removed.
Symbol need top update or remove references to the given old_symbol. If new_symbol is nullptr, the symbol is about to be deleted.
Returns true if this symbol contained the deleted symbol.
Reimplemented in OpenOrienteering::CombinedSymbol, and OpenOrienteering::LineTextSymbol.
|
virtual |
|
static |
Number of components of symbol numbers.