![]() |
Mapper
0.9.0
API documentation
|
Represents a part of a map by owning a list of map objects. More...
#include <map_part.h>
Public Member Functions | |
MapPart (const QString &name, Map *map) | |
Creates a new map part with the given name for a map. More... | |
MapPart (const MapPart &)=delete | |
~MapPart () | |
Destroys the map part. More... | |
MapPart & | operator= (const MapPart &)=delete |
void | save (QXmlStreamWriter &xml) const |
Saves the map part in xml format to the given stream. More... | |
const QString & | getName () const |
Returns the part's name. More... | |
void | setName (const QString &new_name) |
Sets the part's name. More... | |
int | getNumObjects () const |
Returns the number of objects in the part. More... | |
const Object * | getObject (int i) const |
Returns the i-th object from the part. More... | |
Object * | getObject (int i) |
Returns the i-th object from the part. More... | |
int | findObjectIndex (const Object *object) const |
Returns the index of the object. More... | |
void | setObject (Object *object, int pos, bool delete_old) |
Replaces the object at the given index with another. More... | |
void | addObject (Object *object) |
Adds the object as new object at the end. More... | |
void | addObject (Object *object, int pos) |
Adds the object as new object at the given index. More... | |
void | deleteObject (int pos, bool remove_only) |
Deleted the object from the given index. More... | |
bool | deleteObject (Object *object, bool remove_only) |
Deleted the object from the given index. More... | |
std::unique_ptr< UndoStep > | importPart (const MapPart *other, const QHash< const Symbol *, Symbol *> &symbol_map, const QTransform &transform, bool select_new_objects) |
Imports the contents another part into this part. More... | |
void | findObjectsAt (const MapCoordF &coord, float tolerance, bool treat_areas_as_paths, bool extended_selection, bool include_hidden_objects, bool include_protected_objects, SelectionInfoVector &out) const |
void | findObjectsAtBox (const MapCoordF &corner1, const MapCoordF &corner2, bool include_hidden_objects, bool include_protected_objects, std::vector< Object *> &out) const |
int | countObjectsInRect (const QRectF &map_coord_rect, bool include_hidden_objects) const |
QRectF | calculateExtent (bool include_helper_symbols) const |
Calculates and returns the bounding box of all objects in this map part. More... | |
bool | existsObject (const std::function< bool(const Object *)> &condition) const |
Applies a condition on all objects (until the first match is found). More... | |
void | applyOnMatchingObjects (const std::function< void(Object *)> &operation, const std::function< bool(const Object *)> &condition) |
Applies an operation on all objects which match a particular condition. More... | |
void | applyOnMatchingObjects (const std::function< void(const Object *)> &operation, const std::function< bool(const Object *)> &condition) const |
Applies an operation on all objects which match a particular condition. More... | |
void | applyOnMatchingObjects (const std::function< void(Object *, MapPart *, int)> &operation, const std::function< bool(const Object *)> &condition) |
Applies an operation on all objects which match a particular condition. More... | |
void | applyOnAllObjects (const std::function< void(Object *)> &operation) |
Applies an operation on all objects. More... | |
void | applyOnAllObjects (const std::function< void(const Object *)> &operation) const |
Applies an operation on all objects. More... | |
void | applyOnAllObjects (const std::function< void(Object *, MapPart *, int)> &operation) |
Applies an operation on all objects. More... | |
Static Public Member Functions | |
static MapPart * | load (QXmlStreamReader &xml, Map &map, SymbolDictionary &symbol_dict) |
Loads the map part in xml format from the given stream. More... | |
Friends | |
class | OCAD8FileImport |
Represents a part of a map by owning a list of map objects.
Dividing maps in parts is e.g. useful to have multiple mappers work on a map: every mapper can do the work in his/her part without getting into conflict with other parts. For display, the objects from all parts are merged.
Another application is in course setting, where it is useful to have a map part for event-specific map objects and parts for course-specific map objects. Then a course can be printed by merging the event-specific part with the part for the course.
Currently, only one map part can be used per map.
Creates a new map part with the given name for a map.
|
delete |
OpenOrienteering::MapPart::~MapPart | ( | ) |
Destroys the map part.
void OpenOrienteering::MapPart::addObject | ( | Object * | object | ) |
Adds the object as new object at the end.
void OpenOrienteering::MapPart::addObject | ( | Object * | object, |
int | pos | ||
) |
Adds the object as new object at the given index.
void OpenOrienteering::MapPart::applyOnAllObjects | ( | const std::function< void(Object *)> & | operation | ) |
Applies an operation on all objects.
void OpenOrienteering::MapPart::applyOnAllObjects | ( | const std::function< void(const Object *)> & | operation | ) | const |
Applies an operation on all objects.
void OpenOrienteering::MapPart::applyOnAllObjects | ( | const std::function< void(Object *, MapPart *, int)> & | operation | ) |
Applies an operation on all objects.
void OpenOrienteering::MapPart::applyOnMatchingObjects | ( | const std::function< void(Object *)> & | operation, |
const std::function< bool(const Object *)> & | condition | ||
) |
Applies an operation on all objects which match a particular condition.
void OpenOrienteering::MapPart::applyOnMatchingObjects | ( | const std::function< void(const Object *)> & | operation, |
const std::function< bool(const Object *)> & | condition | ||
) | const |
Applies an operation on all objects which match a particular condition.
void OpenOrienteering::MapPart::applyOnMatchingObjects | ( | const std::function< void(Object *, MapPart *, int)> & | operation, |
const std::function< bool(const Object *)> & | condition | ||
) |
Applies an operation on all objects which match a particular condition.
Calculates and returns the bounding box of all objects in this map part.
int OpenOrienteering::MapPart::countObjectsInRect | ( | const QRectF & | map_coord_rect, |
bool | include_hidden_objects | ||
) | const |
void OpenOrienteering::MapPart::deleteObject | ( | int | pos, |
bool | remove_only | ||
) |
Deleted the object from the given index.
If remove_only is set, does not call "delete object".
Deleted the object from the given index.
If remove_only is set, does not call "delete object". Returns if the object was found in this part.
bool OpenOrienteering::MapPart::existsObject | ( | const std::function< bool(const Object *)> & | condition | ) | const |
Applies a condition on all objects (until the first match is found).
int OpenOrienteering::MapPart::findObjectIndex | ( | const Object * | object | ) | const |
Returns the index of the object.
Loops over all objects in the part and looks for the given pointer. The object must be contained in this part, otherwise an assert is triggered (in debug builds), or -1 is returned (release builds).
void OpenOrienteering::MapPart::findObjectsAt | ( | const MapCoordF & | coord, |
float | tolerance, | ||
bool | treat_areas_as_paths, | ||
bool | extended_selection, | ||
bool | include_hidden_objects, | ||
bool | include_protected_objects, | ||
SelectionInfoVector & | out | ||
) | const |
void OpenOrienteering::MapPart::findObjectsAtBox | ( | const MapCoordF & | corner1, |
const MapCoordF & | corner2, | ||
bool | include_hidden_objects, | ||
bool | include_protected_objects, | ||
std::vector< Object *> & | out | ||
) | const |
|
inline |
Returns the part's name.
|
inline |
Returns the number of objects in the part.
|
inline |
Returns the i-th object from the part.
|
inline |
Returns the i-th object from the part.
std::unique_ptr< UndoStep > OpenOrienteering::MapPart::importPart | ( | const MapPart * | other, |
const QHash< const Symbol *, Symbol *> & | symbol_map, | ||
const QTransform & | transform, | ||
bool | select_new_objects | ||
) |
Imports the contents another part into this part.
The other part can be from another map. Uses symbol_map to replace all symbols contained there. No replacement is done for symbols which are not in the symbol_map.
|
static |
Loads the map part in xml format from the given stream.
Needs a dictionary to map symbol ids to symbol pointers.
void OpenOrienteering::MapPart::save | ( | QXmlStreamWriter & | xml | ) | const |
Saves the map part in xml format to the given stream.
void OpenOrienteering::MapPart::setName | ( | const QString & | new_name | ) |
Sets the part's name.
Replaces the object at the given index with another.
If delete_old is set, calls "delete old_object".
|
friend |