Mapper  0.9.0
API documentation
Public Member Functions | Static Public Member Functions | Friends | List of all members
OpenOrienteering::MapPart Class Reference

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...
 
MapPartoperator= (const MapPart &)=delete
 
void save (QXmlStreamWriter &xml) const
 Saves the map part in xml format to the given stream. More...
 
const QStringgetName () 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 ObjectgetObject (int i) const
 Returns the i-th object from the part. More...
 
ObjectgetObject (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< UndoStepimportPart (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 MapPartload (QXmlStreamReader &xml, Map &map, SymbolDictionary &symbol_dict)
 Loads the map part in xml format from the given stream. More...
 

Friends

class OCAD8FileImport
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ MapPart() [1/2]

OpenOrienteering::MapPart::MapPart ( const QString name,
Map map 
)

Creates a new map part with the given name for a map.

◆ MapPart() [2/2]

OpenOrienteering::MapPart::MapPart ( const MapPart )
delete

◆ ~MapPart()

OpenOrienteering::MapPart::~MapPart ( )

Destroys the map part.

Member Function Documentation

◆ addObject() [1/2]

void OpenOrienteering::MapPart::addObject ( Object object)

Adds the object as new object at the end.

◆ addObject() [2/2]

void OpenOrienteering::MapPart::addObject ( Object object,
int  pos 
)

Adds the object as new object at the given index.

◆ applyOnAllObjects() [1/3]

void OpenOrienteering::MapPart::applyOnAllObjects ( const std::function< void(Object *)> &  operation)

Applies an operation on all objects.

◆ applyOnAllObjects() [2/3]

void OpenOrienteering::MapPart::applyOnAllObjects ( const std::function< void(const Object *)> &  operation) const

Applies an operation on all objects.

◆ applyOnAllObjects() [3/3]

void OpenOrienteering::MapPart::applyOnAllObjects ( const std::function< void(Object *, MapPart *, int)> &  operation)

Applies an operation on all objects.

◆ applyOnMatchingObjects() [1/3]

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.

◆ applyOnMatchingObjects() [2/3]

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.

◆ applyOnMatchingObjects() [3/3]

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.

◆ calculateExtent()

QRectF OpenOrienteering::MapPart::calculateExtent ( bool  include_helper_symbols) const

Calculates and returns the bounding box of all objects in this map part.

◆ countObjectsInRect()

int OpenOrienteering::MapPart::countObjectsInRect ( const QRectF map_coord_rect,
bool  include_hidden_objects 
) const

◆ deleteObject() [1/2]

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".

Todo:
Make a separate method "removeObject()", this is misleading!

◆ deleteObject() [2/2]

bool OpenOrienteering::MapPart::deleteObject ( Object object,
bool  remove_only 
)

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.

Todo:
Make a separate method "removeObject()", this is misleading!

◆ existsObject()

bool OpenOrienteering::MapPart::existsObject ( const std::function< bool(const Object *)> &  condition) const

Applies a condition on all objects (until the first match is found).

Returns
True if there is an object matching the condition, false otherwise.

◆ findObjectIndex()

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).

◆ findObjectsAt()

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

◆ findObjectsAtBox()

void OpenOrienteering::MapPart::findObjectsAtBox ( const MapCoordF corner1,
const MapCoordF corner2,
bool  include_hidden_objects,
bool  include_protected_objects,
std::vector< Object *> &  out 
) const

◆ getName()

const QString & OpenOrienteering::MapPart::getName ( ) const
inline

Returns the part's name.

◆ getNumObjects()

int OpenOrienteering::MapPart::getNumObjects ( ) const
inline

Returns the number of objects in the part.

◆ getObject() [1/2]

const Object * OpenOrienteering::MapPart::getObject ( int  i) const
inline

Returns the i-th object from the part.

◆ getObject() [2/2]

Object * OpenOrienteering::MapPart::getObject ( int  i)
inline

Returns the i-th object from the part.

◆ importPart()

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.

◆ load()

MapPart * OpenOrienteering::MapPart::load ( QXmlStreamReader xml,
Map map,
SymbolDictionary symbol_dict 
)
static

Loads the map part in xml format from the given stream.

Needs a dictionary to map symbol ids to symbol pointers.

◆ operator=()

MapPart& OpenOrienteering::MapPart::operator= ( const MapPart )
delete

◆ save()

void OpenOrienteering::MapPart::save ( QXmlStreamWriter xml) const

Saves the map part in xml format to the given stream.

◆ setName()

void OpenOrienteering::MapPart::setName ( const QString new_name)

Sets the part's name.

◆ setObject()

void OpenOrienteering::MapPart::setObject ( Object object,
int  pos,
bool  delete_old 
)

Replaces the object at the given index with another.

If delete_old is set, calls "delete old_object".

Friends And Related Function Documentation

◆ OCAD8FileImport

friend class OCAD8FileImport
friend

The documentation for this class was generated from the following files: