![]() |
Mapper
0.9.0
API documentation
|
Abstract base class which combines coordinates and a symbol to form an object (in a map, or inside a point symbol as one of its elements). More...
#include <object.h>
Public Types | |
enum | Type { Point = 0, Path = 1, Text = 4 } |
Enumeration of possible object types. More... | |
typedef QHash< QString, QString > | Tags |
Defines a type which maps keys to values, to be used for tagging objects. More... | |
Public Member Functions | |
Object (Type type, const Symbol *symbol=nullptr) | |
Creates an empty object with the given type and (optional) symbol. More... | |
Object (Type type, const Symbol *symbol, const MapCoordVector &coords, Map *map=nullptr) | |
Creates an empty object with the given type, symbol, coords and (optional) map. More... | |
virtual | ~Object () |
Destructs the object. More... | |
Object & | operator= (const Object &other)=delete |
virtual void | copyFrom (const Object &other) |
virtual Object * | duplicate () const =0 |
Creates an identical copy of the object. More... | |
bool | equals (const Object *other, bool compare_symbol) const |
Checks for equality with another object. More... | |
virtual bool | validate () const |
Type | getType () const |
Returns the object type determined by the subclass. More... | |
PointObject * | asPoint () |
Convenience cast to PointObject with type checking. More... | |
const PointObject * | asPoint () const |
Convenience cast to PointObject with type checking. More... | |
PathObject * | asPath () |
Convenience cast to PathObject with type checking. More... | |
const PathObject * | asPath () const |
Convenience cast to PathObject with type checking. More... | |
TextObject * | asText () |
Convenience cast to TextObject with type checking. More... | |
const TextObject * | asText () const |
Convenience cast to TextObject with type checking. More... | |
void | save (QXmlStreamWriter &xml) const |
Saves the object in xml format to the given stream. More... | |
qreal | getRotation () const |
Returns the rotation for this object (in radians). More... | |
void | setRotation (qreal new_rotation) |
Sets the object's rotation (in radians). More... | |
bool | update () const |
If the output_dirty flag is set, regenerates output and extent, and updates the object's map (if set). More... | |
void | forceUpdate () const |
Always regenerates output and extent, and updates the object's map (if set). More... | |
void | move (qint32 dx, qint32 dy) |
Moves the whole object. More... | |
void | move (const MapCoord &offset) |
Moves the whole object by the given offset. More... | |
virtual void | scale (const MapCoordF ¢er, double factor) |
Scales all coordinates, with the given scaling center. More... | |
virtual void | scale (double factor_x, double factor_y) |
Scales all coordinates, with the center (0, 0). More... | |
void | rotateAround (const MapCoordF ¢er, qreal angle) |
Rotates the whole object around the center point. More... | |
void | rotate (qreal angle) |
Rotates the whole object around the center (0, 0). More... | |
virtual void | transform (const QTransform &t)=0 |
Apply a transformation to all coordinates. More... | |
int | isPointOnObject (const MapCoordF &coord, float tolerance, bool treat_areas_as_paths, bool extended_selection) const |
Checks if the given coord, with the given tolerance, is on this object. More... | |
virtual bool | intersectsBox (const QRectF &box) const =0 |
Checks if a path point (excluding curve control points) is included in the given box. More... | |
void | takeRenderables () |
Takes ownership of the renderables. More... | |
void | clearRenderables () |
Deletes the renderables (and extent), undoing update() More... | |
const ObjectRenderables & | renderables () const |
Returns the renderables, read-only. More... | |
const MapCoordVector & | getRawCoordinateVector () const |
Returns the raw MapCoordVector of the object. More... | |
void | setOutputDirty (bool dirty=true) |
Sets the object output's dirty state. More... | |
bool | isOutputDirty () const |
Returns if the object's output must be regenerated. More... | |
bool | setSymbol (const Symbol *new_symbol, bool no_checks) |
Changes the object's symbol, returns if successful. More... | |
const Symbol * | getSymbol () const |
Returns the object's symbol. More... | |
const QRectF & | getExtent () const |
NOTE: The extent is only valid after update() has been called! More... | |
void | setMap (Map *map) |
Sets the object's map pointer. More... | |
Map * | getMap () const |
Returns the object's map pointer. More... | |
const Tags & | tags () const |
Returns a const reference to the object's tags. More... | |
void | setTags (const Tags &tags) |
Replaces the object's tags. More... | |
QString | getTag (const QString &key) const |
Returns the value of the given tag key. More... | |
void | setTag (const QString &key, const QString &value) |
Sets the given tag key to the value. More... | |
void | removeTag (const QString &key) |
Removes the given tag key and its value. More... | |
void | includeControlPointsRect (QRectF &rect) const |
Extends a rectangle to enclose all of the object's control points. More... | |
Static Public Member Functions | |
static Object * | load (QXmlStreamReader &xml, Map *map, const SymbolDictionary &symbol_dict, const Symbol *symbol=nullptr) |
Loads the object in xml format from the given stream. More... | |
static Object * | getObjectForType (Type type, const Symbol *symbol=nullptr) |
Constructs an object of the given type with the given symbol. More... | |
Protected Member Functions | |
Object (const Object &proto) | |
Constructs a Object, initialized from the given prototype. More... | |
virtual void | updateEvent () const |
virtual void | createRenderables (ObjectRenderables &output, Symbol::RenderableOptions options) const |
Protected Attributes | |
Type | type |
const Symbol * | symbol = nullptr |
MapCoordVector | coords |
Map * | map = nullptr |
Tags | object_tags |
Friends | |
class | ObjectRenderables |
class | OCAD8FileImport |
class | XMLImportExport |
Abstract base class which combines coordinates and a symbol to form an object (in a map, or inside a point symbol as one of its elements).
Every object must have a symbol. If the symbol is not known, one of the "undefined" symbols from the Map class can be used.
From the object's data, a call to update() will generate the object's "output", that is a set of renderables and the calculation of the object's extent (bounding box). The renderables can then be inserted into a map where they are used to display the object.
typedef QHash<QString, QString> OpenOrienteering::Object::Tags |
Defines a type which maps keys to values, to be used for tagging objects.
|
explicit |
Creates an empty object with the given type and (optional) symbol.
|
explicit |
Creates an empty object with the given type, symbol, coords and (optional) map.
|
explicitprotected |
Constructs a Object, initialized from the given prototype.
Note that the object is NOT added to a map, and consequently, the map pointer is initialized to nullptr.
|
virtualdefault |
Destructs the object.
PathObject * OpenOrienteering::Object::asPath | ( | ) |
Convenience cast to PathObject with type checking.
const PathObject * OpenOrienteering::Object::asPath | ( | ) | const |
Convenience cast to PathObject with type checking.
PointObject * OpenOrienteering::Object::asPoint | ( | ) |
Convenience cast to PointObject with type checking.
const PointObject * OpenOrienteering::Object::asPoint | ( | ) | const |
Convenience cast to PointObject with type checking.
TextObject * OpenOrienteering::Object::asText | ( | ) |
Convenience cast to TextObject with type checking.
const TextObject * OpenOrienteering::Object::asText | ( | ) | const |
Convenience cast to TextObject with type checking.
void OpenOrienteering::Object::clearRenderables | ( | ) |
Deletes the renderables (and extent), undoing update()
|
virtual |
Reimplemented in OpenOrienteering::PointObject, OpenOrienteering::PathObject, and OpenOrienteering::TextObject.
|
protectedvirtual |
Reimplemented in OpenOrienteering::PathObject.
|
pure virtual |
Creates an identical copy of the object.
This needs to be implemented in non-abstract subclasses. Implementation should use the copy constructor to ensure proper initialization.
Implemented in OpenOrienteering::PointObject, OpenOrienteering::PathObject, and OpenOrienteering::TextObject.
Checks for equality with another object.
If compare_symbol is set, also the symbols are compared for having the same properties. Note that the map property is not compared.
void OpenOrienteering::Object::forceUpdate | ( | ) | const |
Always regenerates output and extent, and updates the object's map (if set).
|
inline |
NOTE: The extent is only valid after update() has been called!
|
inline |
Returns the object's map pointer.
|
static |
Constructs an object of the given type with the given symbol.
|
inline |
Returns the raw MapCoordVector of the object.
It's layout and interpretation depends on the object type.
|
inline |
Returns the rotation for this object (in radians).
The interpretation of this value depends the object's symbol.
|
inline |
Returns the object's symbol.
Returns the value of the given tag key.
|
inline |
Returns the object type determined by the subclass.
void OpenOrienteering::Object::includeControlPointsRect | ( | QRectF & | rect | ) | const |
Extends a rectangle to enclose all of the object's control points.
Checks if a path point (excluding curve control points) is included in the given box.
Implemented in OpenOrienteering::PointObject, OpenOrienteering::PathObject, and OpenOrienteering::TextObject.
|
inline |
Returns if the object's output must be regenerated.
int OpenOrienteering::Object::isPointOnObject | ( | const MapCoordF & | coord, |
float | tolerance, | ||
bool | treat_areas_as_paths, | ||
bool | extended_selection | ||
) | const |
Checks if the given coord, with the given tolerance, is on this object.
With extended_selection, the coord is on point objects always if it is within their extent, otherwise it has to be close to their midpoint. Returns a Symbol::Type which specifies on which symbol type the coord is (important for combined symbols which can have areas and lines).
|
static |
Loads the object in xml format from the given stream.
xml | The stream to load the object from, must be at the correct tag. |
map | The map in which the object will be inserted. This value will be assigned to the object's map pointer It may be nullptr. |
symbol_dict | A dictionary mapping symbol IDs to symbol pointers. |
symbol | If set, this symbol will be assigned to the object, rather than reading the symbol from the stream. |
void OpenOrienteering::Object::move | ( | qint32 | dx, |
qint32 | dy | ||
) |
Moves the whole object.
dx | X offset in native map coordinates. |
dy | Y offset in native map coordinates. |
void OpenOrienteering::Object::move | ( | const MapCoord & | offset | ) |
Moves the whole object by the given offset.
void OpenOrienteering::Object::removeTag | ( | const QString & | key | ) |
Removes the given tag key and its value.
|
inline |
Returns the renderables, read-only.
void OpenOrienteering::Object::rotate | ( | qreal | angle | ) |
Rotates the whole object around the center (0, 0).
The angle must be given in radians.
void OpenOrienteering::Object::rotateAround | ( | const MapCoordF & | center, |
qreal | angle | ||
) |
Rotates the whole object around the center point.
The angle must be given in radians.
void OpenOrienteering::Object::save | ( | QXmlStreamWriter & | xml | ) | const |
Saves the object in xml format to the given stream.
|
virtual |
Scales all coordinates, with the given scaling center.
Reimplemented in OpenOrienteering::TextObject.
|
virtual |
Scales all coordinates, with the center (0, 0).
factor_x | horizontal scaling factor |
factor_y | vertical scaling factor |
Reimplemented in OpenOrienteering::TextObject.
|
inline |
Sets the object's map pointer.
May be nullptr if the object is not in a map.
|
inline |
Sets the object output's dirty state.
void OpenOrienteering::Object::setRotation | ( | qreal | new_rotation | ) |
Sets the object's rotation (in radians).
The interpretation of this value depends the object's symbol. It may have no effect at all. The value must not be NaN.
Changes the object's symbol, returns if successful.
Some conversions are impossible, for example point to line. Normally, this method checks if the types of the old and the new symbol are compatible. If the old symbol pointer is no longer valid, you can use no_checks to disable this.
Sets the given tag key to the value.
void OpenOrienteering::Object::setTags | ( | const Tags & | tags | ) |
Replaces the object's tags.
|
inline |
Returns a const reference to the object's tags.
void OpenOrienteering::Object::takeRenderables | ( | ) |
Takes ownership of the renderables.
|
pure virtual |
Apply a transformation to all coordinates.
Implemented in OpenOrienteering::PointObject, OpenOrienteering::PathObject, and OpenOrienteering::TextObject.
bool OpenOrienteering::Object::update | ( | ) | const |
If the output_dirty flag is set, regenerates output and extent, and updates the object's map (if set).
Returns true if output was dirty.
|
protectedvirtual |
Reimplemented in OpenOrienteering::PathObject.
|
virtual |
Reimplemented in OpenOrienteering::PathObject.
|
friend |
|
friend |
|
friend |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |