![]() |
Mapper
0.9.0
API documentation
|
A text object. More...
#include <text_object.h>
Public Types | |
enum | HorizontalAlignment { AlignLeft = 0, AlignHCenter = 1, AlignRight = 2 } |
enum | VerticalAlignment { AlignBaseline = 0, AlignTop = 1, AlignVCenter = 2, AlignBottom = 3 } |
typedef std::vector< TextObjectLineInfo > | LineInfoContainer |
A sequence container of TextObjectLineInfo objects. More... | |
![]() | |
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 | |
TextObject (const Symbol *symbol=nullptr) | |
Construct a new text object. More... | |
TextObject * | duplicate () const override |
Creates a duplicate of the text object. More... | |
TextObject & | operator= (const TextObject &)=delete |
void | copyFrom (const Object &other) override |
bool | hasSingleAnchor () const |
Returns true if the text object has a single anchor, false if it has as word wrap box. More... | |
void | setAnchorPosition (qint32 x, qint32 y) |
Sets the position of the anchor point to (x,y). More... | |
void | setAnchorPosition (const MapCoord &coord) |
Sets the position of the anchor point to coord. More... | |
void | setAnchorPosition (const MapCoordF &coord) |
Sets the position of the anchor point to coord. More... | |
MapCoordF | getAnchorCoordF () const |
Returns the coordinates of the anchor point or midpoint. More... | |
void | transform (const QTransform &t) override |
Apply a transformation to all coordinates. More... | |
void | setBox (qint32 mid_x, qint32 mid_y, qreal width, qreal height) |
Set position and size. More... | |
void | setBoxSize (const MapCoord &size) |
Set size. More... | |
MapCoord | getBoxSize () const |
Returns the size as a MapCoord. More... | |
qreal | getBoxWidth () const |
Returns the width of the word wrap box. More... | |
qreal | getBoxHeight () const |
Returns the height of the word wrap box. More... | |
std::vector< QPointF > | controlPoints () const |
Returns the positions of the control points. More... | |
void | scale (const MapCoordF ¢er, double factor) override |
Scales position and box, with the given scaling center. More... | |
void | scale (double factor_x, double factor_y) override |
Scales position and box, with the center (0, 0). More... | |
void | setText (const QString &text) |
Sets the text of the object. More... | |
const QString & | getText () const |
Returns the text of the object. More... | |
void | setHorizontalAlignment (HorizontalAlignment h_align) |
Sets the horizontal alignment of the text. More... | |
HorizontalAlignment | getHorizontalAlignment () const |
Returns the horizontal alignment of the text. More... | |
void | setVerticalAlignment (VerticalAlignment v_align) |
Sets the vertical alignment of the text. More... | |
VerticalAlignment | getVerticalAlignment () const |
Returns the vertical alignment of the text. More... | |
bool | intersectsBox (const QRectF &box) const override |
Checks if a path point (excluding curve control points) is included in the given box. More... | |
QTransform | calcTextToMapTransform () const |
Returns a QTransform from text coordinates to map coordinates. More... | |
QTransform | calcMapToTextTransform () const |
Returns a QTransform from map coordinates to text coordinates. More... | |
int | getNumLines () const |
Return the number of rendered lines. More... | |
TextObjectLineInfo * | getLineInfo (int i) |
Returns the layout information about a particular line. More... | |
const TextObjectLineInfo * | getLineInfo (int i) const |
Returns the layout information about a particular line. More... | |
int | calcTextPositionAt (const MapCoordF &coord, bool find_line_only) const |
Return the index of the character or the line number corresponding to a particular map coordinate. More... | |
int | calcTextPositionAt (const QPointF &coord, bool find_line_only) const |
Return the index of the character or the line number corresponding to a particular text coordinate. More... | |
int | findLineForIndex (int index) const |
Returns the line number for a particular index in the text. More... | |
const TextObjectLineInfo & | findLineInfoForIndex (int index) const |
Returns the line layout information for particular index. More... | |
void | prepareLineInfos () const |
Prepare the text layout information. More... | |
![]() | |
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 |
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... | |
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... | |
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... | |
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... | |
Protected Member Functions | |
TextObject (const TextObject &proto) | |
Constructs a TextObject, initialized from the given prototype. More... | |
![]() | |
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 |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
Type | type |
const Symbol * | symbol = nullptr |
MapCoordVector | coords |
Map * | map = nullptr |
Tags | object_tags |
A text object.
A text object is an instance of a text symbol. Its position may be specified by a single coordinate (the anchor point) or by two coordinates (word wrap box: first coordinate specifies the coordinate of the midpoint, second coordinates specifies the width and height).
TODO: the way of defining word wrap boxes is inconvenient, as the second coordinate does not specify a real coordinate in this case, but is misused as extent. Change this?
typedef std::vector<TextObjectLineInfo> OpenOrienteering::TextObject::LineInfoContainer |
A sequence container of TextObjectLineInfo objects.
|
explicit |
Construct a new text object.
If a symbol is specified, it must be a text symbol.
symbol | the text symbol (optional) |
|
explicitprotected |
Constructs a TextObject, initialized from the given prototype.
QTransform OpenOrienteering::TextObject::calcMapToTextTransform | ( | ) | const |
Returns a QTransform from map coordinates to text coordinates.
int OpenOrienteering::TextObject::calcTextPositionAt | ( | const MapCoordF & | coord, |
bool | find_line_only | ||
) | const |
Return the index of the character or the line number corresponding to a particular map coordinate.
Returns -1 if the coordinate is not at a text position. If find_line_only is true, the line number is returned, otherwise the index of the character.
int OpenOrienteering::TextObject::calcTextPositionAt | ( | const QPointF & | coord, |
bool | find_line_only | ||
) | const |
Return the index of the character or the line number corresponding to a particular text coordinate.
Returns -1 if the coordinate is not at a text position. If find_line_only is true, the line number is returned, otherwise the index of the character.
QTransform OpenOrienteering::TextObject::calcTextToMapTransform | ( | ) | const |
Returns a QTransform from text coordinates to map coordinates.
std::vector< QPointF > OpenOrienteering::TextObject::controlPoints | ( | ) | const |
Returns the positions of the control points.
The returned vector may have one or four members, depending on the type of object.
|
overridevirtual |
Reimplemented from OpenOrienteering::Object.
|
overridevirtual |
Creates a duplicate of the text object.
Implements OpenOrienteering::Object.
int OpenOrienteering::TextObject::findLineForIndex | ( | int | index | ) | const |
Returns the line number for a particular index in the text.
const TextObjectLineInfo & OpenOrienteering::TextObject::findLineInfoForIndex | ( | int | index | ) | const |
Returns the line layout information for particular index.
MapCoordF OpenOrienteering::TextObject::getAnchorCoordF | ( | ) | const |
Returns the coordinates of the anchor point or midpoint.
|
inline |
Returns the height of the word wrap box.
The text object must have a specified size.
|
inline |
Returns the width of the word wrap box.
The text object must have a specified size.
|
inline |
Returns the horizontal alignment of the text.
|
inline |
Returns the layout information about a particular line.
|
inline |
Returns the layout information about a particular line.
|
inline |
Return the number of rendered lines.
For a text object with a word wrap box, the number of rendered lines may be higher than the number of explicit line breaks in the original text.
|
inline |
Returns the text of the object.
|
inline |
Returns the vertical alignment of the text.
|
inline |
Returns true if the text object has a single anchor, false if it has as word wrap box.
Checks if a path point (excluding curve control points) is included in the given box.
Implements OpenOrienteering::Object.
|
delete |
void OpenOrienteering::TextObject::prepareLineInfos | ( | ) | const |
Prepare the text layout information.
|
overridevirtual |
Scales position and box, with the given scaling center.
Reimplemented from OpenOrienteering::Object.
|
overridevirtual |
Scales position and box, with the center (0, 0).
Reimplemented from OpenOrienteering::Object.
void OpenOrienteering::TextObject::setAnchorPosition | ( | qint32 | x, |
qint32 | y | ||
) |
Sets the position of the anchor point to (x,y).
This will drop an existing word wrap box.
void OpenOrienteering::TextObject::setAnchorPosition | ( | const MapCoord & | coord | ) |
Sets the position of the anchor point to coord.
This will drop an existing word wrap box.
void OpenOrienteering::TextObject::setAnchorPosition | ( | const MapCoordF & | coord | ) |
Sets the position of the anchor point to coord.
This will drop an existing word wrap box.
void OpenOrienteering::TextObject::setBox | ( | qint32 | mid_x, |
qint32 | mid_y, | ||
qreal | width, | ||
qreal | height | ||
) |
Set position and size.
The midpoint is set to (mid_x, mid_y), the size is specified by the parameters width and height.
void OpenOrienteering::TextObject::setBoxSize | ( | const MapCoord & | size | ) |
Set size.
void OpenOrienteering::TextObject::setHorizontalAlignment | ( | TextObject::HorizontalAlignment | h_align | ) |
Sets the horizontal alignment of the text.
void OpenOrienteering::TextObject::setText | ( | const QString & | text | ) |
Sets the text of the object.
void OpenOrienteering::TextObject::setVerticalAlignment | ( | TextObject::VerticalAlignment | v_align | ) |
Sets the vertical alignment of the text.
|
overridevirtual |
Apply a transformation to all coordinates.
Implements OpenOrienteering::Object.