Mapper  0.9.0
API documentation
Classes | Public Types | Signals | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
OpenOrienteering::Template Class Referenceabstract

Abstract base class for templates. More...

#include <template.h>

Inheritance diagram for OpenOrienteering::Template:
Inheritance graph
[legend]
Collaboration diagram for OpenOrienteering::Template:
Collaboration graph
[legend]

Classes

class  ScopedOffsetReversal
 

Public Types

enum  State { Loaded = 0, Unloaded, Invalid }
 States in the lifetime of a template. More...
 
enum  LookupResult { NotFound = 0, FoundInMapDir = 1, FoundByRelPath = 2, FoundByAbsPath = 3 }
 The result of template file lookup attempts. More...
 
template<typename T >
using not_null = T
 Indicates arguments which must not be nullptr. More...
 

Signals

void templateStateChanged ()
 Emitted whenever template_state was changed. More...
 

Public Member Functions

 ~Template () override
 
Templateduplicate () const
 Creates a duplicate of the template. More...
 
virtual const char * getTemplateType () const =0
 Returns a string which should identify the type of the template uniquely: the class name. More...
 
QString errorString () const
 Returns a description of the last error that occurred. More...
 
virtual bool isRasterGraphics () const =0
 Returns true if the template is raster graphics. More...
 
void saveTemplateConfiguration (QXmlStreamWriter &xml, bool open, const QDir *map_dir=nullptr) const
 Saves template parameters. More...
 
virtual bool saveTemplateFile () const
 Saves the template itself, returns true if successful. More...
 
void switchTemplateFile (const QString &new_path, bool load_file)
 Changes a template's file without changing the parameters. More...
 
bool execSwitchTemplateFileDialog (QWidget *dialog_parent)
 Shows the dialog to find a moved template. More...
 
bool configureAndLoad (QWidget *dialog_parent, MapView *view)
 Does everything needed to load a template. More...
 
LookupResult tryToFindTemplateFile (const QString &map_path)
 Tries to find the template file non-interactively. More...
 
bool tryToFindAndReloadTemplateFile (const QString &map_path)
 Tries to find and load the template file non-interactively. More...
 
virtual bool preLoadConfiguration (QWidget *dialog_parent)
 Does configuration before the actual template is loaded. More...
 
bool loadTemplateFile (bool configuring)
 Loads the template file. More...
 
virtual bool postLoadConfiguration (QWidget *dialog_parent, bool &out_center_in_view)
 Does configuration after the actual template is loaded. More...
 
void unloadTemplateFile ()
 Unloads the template file. More...
 
virtual void drawTemplate (QPainter *painter, const QRectF &clip_rect, double scale, bool on_screen, float opacity) const =0
 Draws the template using the given painter with the given opacity. More...
 
virtual QRectF calculateTemplateBoundingBox () const
 Calculates the template's bounding box in map coordinates. More...
 
virtual int getTemplateBoundingBoxPixelBorder ()
 Returns the extra extent of the template out of the bounding box. More...
 
virtual void setTemplateAreaDirty ()
 Marks the whole area of the template as needing a redraw. More...
 
virtual bool canBeDrawnOnto () const
 Must return if freehand drawing onto the template is possible. More...
 
void drawOntoTemplate (not_null< MapCoordF *> coords, int num_coords, QColor color, float width, QRectF map_bbox)
 Draws onto the template. More...
 
virtual void drawOntoTemplateUndo (bool redo)
 Triggers an undo or redo action for template freehand drawing. More...
 
void applyTemplateTransform (QPainter *painter) const
 Changes the painter's transformation so it can be used to draw in template coordinates. More...
 
virtual QRectF getTemplateExtent () const
 Returns the extent of the template in template coordinates. More...
 
void scale (double factor, const MapCoord &center)
 Scales the template with the given scaling center. More...
 
void rotate (double rotation, const MapCoord &center)
 Rotates the template around the given point. More...
 
MapCoordF mapToTemplate (const MapCoordF &coords) const
 
MapCoordF mapToTemplateOther (const MapCoordF &coords) const
 
MapCoordF templateToMap (const QPointF &coords) const
 
MapCoordF templateToMapOther (const QPointF &coords) const
 
const PassPointListgetPassPointList () const
 
PassPointListgetPassPointList ()
 
int getNumPassPoints () const
 
PassPointgetPassPoint (int i)
 
void addPassPoint (const PassPoint &point, int pos)
 
void deletePassPoint (int pos)
 
void clearPassPoints ()
 
void switchTransforms ()
 Change from adjusted into original state or the other way round. More...
 
void getTransform (TemplateTransform &out) const
 
void setTransform (const TemplateTransform &transform)
 
void getOtherTransform (TemplateTransform &out) const
 
void setOtherTransform (const TemplateTransform &transform)
 
MapgetMap () const
 
const QStringgetTemplateFilename () const
 
void setTemplateFileInfo (const QFileInfo &file_info)
 Changes the path and filename only. Does not do any reloading etc. More...
 
const QStringgetTemplatePath () const
 
void setTemplatePath (const QString &value)
 Changes the path and filename only. Does not do any reloading etc. More...
 
const QStringgetTemplateRelativePath () const
 
void setTemplateRelativePath (const QString &value)
 
State getTemplateState () const
 
void setTemplateState (State state)
 
int getTemplateGroup () const
 
void setTemplateGroup (int value)
 
bool hasUnsavedChanges () const
 
void setHasUnsavedChanges (bool value)
 
bool isTemplateGeoreferenced () const
 
virtual bool canChangeTemplateGeoreferenced ()
 Returns if the template allows the georefencing state to be changed at all. More...
 
virtual bool trySetTemplateGeoreferenced (bool value, QWidget *dialog_parent)
 Tries to change the usage of georeferencing data. More...
 
MapCoord templatePosition () const
 
void setTemplatePosition (const MapCoord &coord)
 
MapCoord templatePositionOffset () const
 
void setTemplatePositionOffset (const MapCoord &offset)
 
void applyTemplatePositionOffset ()
 
void resetTemplatePositionOffset ()
 
qint64 getTemplateX () const
 
void setTemplateX (qint64 x)
 
qint64 getTemplateY () const
 
void setTemplateY (qint64 y)
 
double getTemplateScaleX () const
 
void setTemplateScaleX (double scale_x)
 
double getTemplateScaleY () const
 
void setTemplateScaleY (double scale_y)
 
double getTemplateShear () const
 
void setTemplateShear (double shear)
 
double getTemplateRotation () const
 
void setTemplateRotation (double rotation)
 
bool isAdjustmentApplied () const
 
bool isAdjustmentDirty () const
 
void setAdjustmentDirty (bool value)
 
virtual bool hasAlpha () const
 Returns true if the template has elements which are not opaque. More...
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 QObject (QObject *parent)
 
virtual ~QObject ()
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectListchildren () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

Static Public Member Functions

static std::unique_ptr< TemplateloadTemplateConfiguration (QXmlStreamReader &xml, Map &map, bool &open)
 Creates and returns a template from the configuration in the XML stream. More...
 
static const std::vector< QByteArray > & supportedExtensions ()
 Returns the filename extensions supported by known subclasses. More...
 
static std::unique_ptr< TemplatetemplateForFile (const QString &path, Map *map)
 Creates a Template instance for the given path. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 

Static Public Attributes

static bool suppressAbsolutePaths = false
 A flag which disables the writing of absolute paths for template files. More...
 

Protected Member Functions

 Template (const QString &path, not_null< Map *> map)
 Initializes the template as "Unloaded". More...
 
void setErrorString (const QString &text)
 Sets the error description which will be returned by errorString(). More...
 
virtual TemplateduplicateImpl () const =0
 Derived classes must create a duplicate and transfer. More...
 
virtual void saveTypeSpecificTemplateConfiguration (QXmlStreamWriter &xml) const
 Hook for saving parameters needed by the actual template type. More...
 
virtual bool loadTypeSpecificTemplateConfiguration (QXmlStreamReader &xml)
 Hook for loading parameters needed by the actual template type. More...
 
virtual bool loadTemplateFileImpl (bool configuring)=0
 Hook for loading the actual template file non-interactively. More...
 
virtual void unloadTemplateFileImpl ()=0
 Hook for unloading the template file. More...
 
virtual void drawOntoTemplateImpl (MapCoordF *coords, int num_coords, QColor color, float width)
 Hook for drawing on the template. More...
 
void updateTransformationMatrices ()
 Must be called after direct changes to transform or other_transform. More...
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Protected Attributes

Mapmap
 Map containing this template. More...
 
QString template_file
 The filename of the template file (e.g. "map.bmp") More...
 
QString template_path
 The complete path to the template file including the filename (e.g. "/home/me/map.bmp") More...
 
QString template_relative_path
 The template path relative to the map file (e.g. More...
 
State template_state
 The template lifetime state. More...
 
QString error_string
 The description of the last error. More...
 
bool has_unsaved_changes
 Does the template itself (not its transformation) have unsaved changes (e.g. GPS track has changed, image has been painted on) More...
 
bool is_georeferenced
 Is the template in georeferenced mode? More...
 
TemplateTransform transform
 Currently active transformation. NOTE: after direct changes here call updateTransformationMatrices() More...
 
TemplateTransform other_transform
 Currently inactive transformation (adjusted or original). NOTE: after direct changes here call updateTransformationMatrices() More...
 
bool adjusted
 If true, transform is the adjusted transformation, otherwise it is the original one. More...
 
bool adjustment_dirty
 If true, the adjusted transformation has to be recalculated. More...
 
PassPointList passpoints
 List of pass points for position adjustment. More...
 
int template_group
 Number of the template group. If the template is not grouped, this is set to -1. More...
 
Matrix map_to_template
 
Matrix template_to_map
 
Matrix template_to_map_other
 

Additional Inherited Members

- Public Attributes inherited from QObject
typedef QObjectList
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Abstract base class for templates.

Member Typedef Documentation

◆ not_null

template<typename T >
using OpenOrienteering::Template::not_null = T

Indicates arguments which must not be nullptr.

Todo:
Use the Guideline Support Library

Member Enumeration Documentation

◆ LookupResult

The result of template file lookup attempts.

Enumerator
NotFound 

File not found at all.

FoundInMapDir 

File name found in the map's directory.

FoundByRelPath 

File found by relative path from the map's directory.

FoundByAbsPath 

File found by absolute path.

◆ State

States in the lifetime of a template.

Enumerator
Loaded 

The template data is loaded and ready to be displayed.

Unloaded 

The template data is not yet loaded or has been unloaded.

It is assumed to be available, so it can be (re-)loaded if needed.

Invalid 

A required resource cannot be found (e.g.

missing image or font), so the template data cannot be loaded.

Constructor & Destructor Documentation

◆ Template()

OpenOrienteering::Template::Template ( const QString path,
not_null< Map *>  map 
)
protected

Initializes the template as "Unloaded".

◆ ~Template()

OpenOrienteering::Template::~Template ( )
override

Member Function Documentation

◆ addPassPoint()

void OpenOrienteering::Template::addPassPoint ( const PassPoint point,
int  pos 
)

◆ applyTemplatePositionOffset()

void OpenOrienteering::Template::applyTemplatePositionOffset ( )

◆ applyTemplateTransform()

void OpenOrienteering::Template::applyTemplateTransform ( QPainter painter) const

Changes the painter's transformation so it can be used to draw in template coordinates.

The previous transformation of the painter must be the map transformation.

Note
For non-georeferenced templates only, or if the template transformation has been set by the template nevertheless.

◆ calculateTemplateBoundingBox()

QRectF OpenOrienteering::Template::calculateTemplateBoundingBox ( ) const
virtual

Calculates the template's bounding box in map coordinates.

Reimplemented in OpenOrienteering::TemplateTrack.

◆ canBeDrawnOnto()

bool OpenOrienteering::Template::canBeDrawnOnto ( ) const
virtual

Must return if freehand drawing onto the template is possible.

Reimplemented in OpenOrienteering::TemplateImage.

◆ canChangeTemplateGeoreferenced()

bool OpenOrienteering::Template::canChangeTemplateGeoreferenced ( )
virtual

Returns if the template allows the georefencing state to be changed at all.

The default implementation returns false.

Reimplemented in OpenOrienteering::TemplateImage.

◆ clearPassPoints()

void OpenOrienteering::Template::clearPassPoints ( )

◆ configureAndLoad()

bool OpenOrienteering::Template::configureAndLoad ( QWidget dialog_parent,
MapView view 
)

Does everything needed to load a template.

Calls preLoadConfiguration(), loadTemplateFile() and postLoadConfiguration(). Returns if the process was successful.

The passed-in view is used to center the template if needed.

◆ deletePassPoint()

void OpenOrienteering::Template::deletePassPoint ( int  pos)

◆ drawOntoTemplate()

void OpenOrienteering::Template::drawOntoTemplate ( not_null< MapCoordF *>  coords,
int  num_coords,
QColor  color,
float  width,
QRectF  map_bbox 
)

Draws onto the template.

This only works for templates for which canBeDrawnOnto() returns true.

coords is an array of points with which the drawn line is defined and must contain at least 2 points.

If map_bbox is an invalid rect, then the method will calculate it itself.

Todo:
Rewrite using a range of MapCoordF.

◆ drawOntoTemplateImpl()

void OpenOrienteering::Template::drawOntoTemplateImpl ( MapCoordF coords,
int  num_coords,
QColor  color,
float  width 
)
protectedvirtual

Hook for drawing on the template.

Draws the polyline given by the points onto the template. Required if canBeDrawnOnto() returns true.

Reimplemented in OpenOrienteering::TemplateImage.

◆ drawOntoTemplateUndo()

void OpenOrienteering::Template::drawOntoTemplateUndo ( bool  redo)
virtual

Triggers an undo or redo action for template freehand drawing.

This only works for templates for which canBeDrawnOnto() returns true.

Reimplemented in OpenOrienteering::TemplateImage.

◆ drawTemplate()

virtual void OpenOrienteering::Template::drawTemplate ( QPainter painter,
const QRectF clip_rect,
double  scale,
bool  on_screen,
float  opacity 
) const
pure virtual

Draws the template using the given painter with the given opacity.

The painter transformation is set to use template coordinates. The clip rect is in template coordinates. The scale is the combined view & template scale. It can be used to give a minimum size to elements.

Implemented in OpenOrienteering::TemplateImage, OpenOrienteering::TemplateMap, and OpenOrienteering::TemplateTrack.

◆ duplicate()

Template * OpenOrienteering::Template::duplicate ( ) const

Creates a duplicate of the template.

Todo:
Rewrite as virtual function, using protected copy constructor.

◆ duplicateImpl()

virtual Template* OpenOrienteering::Template::duplicateImpl ( ) const
protectedpure virtual

Derived classes must create a duplicate and transfer.

type specific information over to the copy here. This includes the content of the template file if it is loaded.

Todo:
Rewrite together with duplicate().

Implemented in OpenOrienteering::TemplateImage, OpenOrienteering::TemplateTrack, OpenOrienteering::OgrTemplate, and OpenOrienteering::TemplateMap.

◆ errorString()

QString OpenOrienteering::Template::errorString ( ) const

Returns a description of the last error that occurred.

◆ execSwitchTemplateFileDialog()

bool OpenOrienteering::Template::execSwitchTemplateFileDialog ( QWidget dialog_parent)

Shows the dialog to find a moved template.

If the user selects a new file, tries to switch to the selected template file using switchTemplateFile() and by trying to load the new file. Returns true if this succeeds; if not, reverts the switch and returns false. Also returns false if the dialog is aborted.

◆ getMap()

Map* OpenOrienteering::Template::getMap ( ) const
inline

◆ getNumPassPoints()

int OpenOrienteering::Template::getNumPassPoints ( ) const
inline

◆ getOtherTransform()

void OpenOrienteering::Template::getOtherTransform ( TemplateTransform out) const

◆ getPassPoint()

PassPoint* OpenOrienteering::Template::getPassPoint ( int  i)
inline

◆ getPassPointList() [1/2]

const PassPointList& OpenOrienteering::Template::getPassPointList ( ) const
inline

◆ getPassPointList() [2/2]

PassPointList& OpenOrienteering::Template::getPassPointList ( )
inline

◆ getTemplateBoundingBoxPixelBorder()

virtual int OpenOrienteering::Template::getTemplateBoundingBoxPixelBorder ( )
inlinevirtual

Returns the extra extent of the template out of the bounding box.

While the bounding box is defined in map coordinates, this border is given in pixels. This is useful for elements which stay the same size regardless of the zoom level so that a bounding box in map coords cannot be calculated.

Reimplemented in OpenOrienteering::TemplateTrack.

◆ getTemplateExtent()

QRectF OpenOrienteering::Template::getTemplateExtent ( ) const
virtual

Returns the extent of the template in template coordinates.

The default implementation returns a "very big" rectangle.

Note
For non-georeferenced templates only!

Reimplemented in OpenOrienteering::TemplateImage, OpenOrienteering::TemplateMap, and OpenOrienteering::TemplateTrack.

◆ getTemplateFilename()

const QString& OpenOrienteering::Template::getTemplateFilename ( ) const
inline

◆ getTemplateGroup()

int OpenOrienteering::Template::getTemplateGroup ( ) const
inline

◆ getTemplatePath()

const QString& OpenOrienteering::Template::getTemplatePath ( ) const
inline

◆ getTemplateRelativePath()

const QString& OpenOrienteering::Template::getTemplateRelativePath ( ) const
inline

◆ getTemplateRotation()

double OpenOrienteering::Template::getTemplateRotation ( ) const
inline

◆ getTemplateScaleX()

double OpenOrienteering::Template::getTemplateScaleX ( ) const
inline

◆ getTemplateScaleY()

double OpenOrienteering::Template::getTemplateScaleY ( ) const
inline

◆ getTemplateShear()

double OpenOrienteering::Template::getTemplateShear ( ) const
inline

◆ getTemplateState()

State OpenOrienteering::Template::getTemplateState ( ) const
inline

◆ getTemplateType()

virtual const char* OpenOrienteering::Template::getTemplateType ( ) const
pure virtual

Returns a string which should identify the type of the template uniquely: the class name.

Very simple RTTI feature.

Implemented in OpenOrienteering::TemplateImage, OpenOrienteering::TemplateTrack, OpenOrienteering::TemplateMap, and OpenOrienteering::OgrTemplate.

◆ getTemplateX()

qint64 OpenOrienteering::Template::getTemplateX ( ) const
inline

◆ getTemplateY()

qint64 OpenOrienteering::Template::getTemplateY ( ) const
inline

◆ getTransform()

void OpenOrienteering::Template::getTransform ( TemplateTransform out) const

◆ hasAlpha()

bool OpenOrienteering::Template::hasAlpha ( ) const
virtual

Returns true if the template has elements which are not opaque.

The default implementation returns true when the template is loaded.

Reimplemented in OpenOrienteering::TemplateMap, and OpenOrienteering::TemplateTrack.

◆ hasUnsavedChanges()

bool OpenOrienteering::Template::hasUnsavedChanges ( ) const
inline

◆ isAdjustmentApplied()

bool OpenOrienteering::Template::isAdjustmentApplied ( ) const
inline

◆ isAdjustmentDirty()

bool OpenOrienteering::Template::isAdjustmentDirty ( ) const
inline

◆ isRasterGraphics()

virtual bool OpenOrienteering::Template::isRasterGraphics ( ) const
pure virtual

Returns true if the template is raster graphics.

Raster graphics cannot be printed in the foreground in vector mode.

Implemented in OpenOrienteering::TemplateImage, OpenOrienteering::TemplateTrack, and OpenOrienteering::TemplateMap.

◆ isTemplateGeoreferenced()

bool OpenOrienteering::Template::isTemplateGeoreferenced ( ) const
inline

◆ loadTemplateConfiguration()

std::unique_ptr< Template > OpenOrienteering::Template::loadTemplateConfiguration ( QXmlStreamReader xml,
Map map,
bool open 
)
static

Creates and returns a template from the configuration in the XML stream.

Returns a null pointer in the case of error.

◆ loadTemplateFile()

bool OpenOrienteering::Template::loadTemplateFile ( bool  configuring)

Loads the template file.

This function can be called if the template state is Invalid or Unloaded. It must not be called if the template file is already loaded. It returns true if the template is loaded successfully.

Set the configuring parameter to true if the template is currently being configured by the user (in contrast to the case where it is reloaded, e.g. when loaded while reopening an existing map file).

◆ loadTemplateFileImpl()

virtual bool OpenOrienteering::Template::loadTemplateFileImpl ( bool  configuring)
protectedpure virtual

Hook for loading the actual template file non-interactively.

Returns true if successful.

If configuring is true, a call to postLoadConfiguration() will follow if this returns true.

Implemented in OpenOrienteering::TemplateImage, OpenOrienteering::OgrTemplate, OpenOrienteering::TemplateTrack, and OpenOrienteering::TemplateMap.

◆ loadTypeSpecificTemplateConfiguration()

bool OpenOrienteering::Template::loadTypeSpecificTemplateConfiguration ( QXmlStreamReader xml)
protectedvirtual

Hook for loading parameters needed by the actual template type.

Note
The default implementation calls xml.skipCurrentElement(). Implementations must do the same if they do not parse it.

Returns true on success.

Reimplemented in OpenOrienteering::TemplateTrack, OpenOrienteering::OgrTemplate, and OpenOrienteering::TemplateImage.

◆ mapToTemplate()

MapCoordF OpenOrienteering::Template::mapToTemplate ( const MapCoordF coords) const
inline

◆ mapToTemplateOther()

MapCoordF OpenOrienteering::Template::mapToTemplateOther ( const MapCoordF coords) const
inline

◆ postLoadConfiguration()

bool OpenOrienteering::Template::postLoadConfiguration ( QWidget dialog_parent,
bool out_center_in_view 
)
virtual

Does configuration after the actual template is loaded.

This function is called after the user chose the template file and after the chosen file was successfully loaded. Derived classes can show dialogs here to get user input which is needed to interpret the template file.

If the implementation returns false, loading the template is aborted.

By setting out_center_in_view, the implementation can decide if the template should be centered in the active view (only if it is not georeferenced.)

Reimplemented in OpenOrienteering::TemplateImage, OpenOrienteering::OgrTemplate, OpenOrienteering::TemplateTrack, and OpenOrienteering::TemplateMap.

◆ preLoadConfiguration()

bool OpenOrienteering::Template::preLoadConfiguration ( QWidget dialog_parent)
virtual

Does configuration before the actual template is loaded.

This function is called after the user chooses the template file, but before it is loaded. Derived classes can show dialogs here to get user input which is needed to interpret the template file.

If the implementation returns false, loading the template is aborted.

Note
Derived classes should set is_georeferenced either here or in postLoadConfiguration(). By default templates are loaded as non-georeferenced.

Reimplemented in OpenOrienteering::OgrTemplate.

◆ resetTemplatePositionOffset()

void OpenOrienteering::Template::resetTemplatePositionOffset ( )

◆ rotate()

void OpenOrienteering::Template::rotate ( double  rotation,
const MapCoord center 
)

Rotates the template around the given point.

Note
For non-georeferenced templates only!

◆ saveTemplateConfiguration()

void OpenOrienteering::Template::saveTemplateConfiguration ( QXmlStreamWriter xml,
bool  open,
const QDir map_dir = nullptr 
) const

Saves template parameters.

This method saves common properties such as filename, transformation, adjustment, etc., and it calls saveTypeSpecificTemplateConfiguration for saving type-specific parameters (e.g. filtering mode for images).

If a target directory is given via map_dir, the relative template path is determined for this directory.

◆ saveTemplateFile()

bool OpenOrienteering::Template::saveTemplateFile ( ) const
virtual

Saves the template itself, returns true if successful.

This is called when saving the map if the template's hasUnsavedChanges() is true.

Reimplemented in OpenOrienteering::TemplateImage, and OpenOrienteering::TemplateTrack.

◆ saveTypeSpecificTemplateConfiguration()

void OpenOrienteering::Template::saveTypeSpecificTemplateConfiguration ( QXmlStreamWriter xml) const
protectedvirtual

Hook for saving parameters needed by the actual template type.

The default implementation does nothing.

Reimplemented in OpenOrienteering::TemplateTrack, OpenOrienteering::OgrTemplate, and OpenOrienteering::TemplateImage.

◆ scale()

void OpenOrienteering::Template::scale ( double  factor,
const MapCoord center 
)

Scales the template with the given scaling center.

Note
For non-georeferenced templates only!

◆ setAdjustmentDirty()

void OpenOrienteering::Template::setAdjustmentDirty ( bool  value)

◆ setErrorString()

void OpenOrienteering::Template::setErrorString ( const QString text)
protected

Sets the error description which will be returned by errorString().

◆ setHasUnsavedChanges()

void OpenOrienteering::Template::setHasUnsavedChanges ( bool  value)

◆ setOtherTransform()

void OpenOrienteering::Template::setOtherTransform ( const TemplateTransform transform)

◆ setTemplateAreaDirty()

void OpenOrienteering::Template::setTemplateAreaDirty ( )
virtual

Marks the whole area of the template as needing a redraw.

Use this before and after modifications to the template transformation.

The default implementation marks everything as "to be redrawn" for georeferenced templates and uses the reported extent otherwise.

◆ setTemplateFileInfo()

void OpenOrienteering::Template::setTemplateFileInfo ( const QFileInfo file_info)

Changes the path and filename only. Does not do any reloading etc.

◆ setTemplateGroup()

void OpenOrienteering::Template::setTemplateGroup ( int  value)
inline

◆ setTemplatePath()

void OpenOrienteering::Template::setTemplatePath ( const QString value)

Changes the path and filename only. Does not do any reloading etc.

◆ setTemplatePosition()

void OpenOrienteering::Template::setTemplatePosition ( const MapCoord coord)

◆ setTemplatePositionOffset()

void OpenOrienteering::Template::setTemplatePositionOffset ( const MapCoord offset)

◆ setTemplateRelativePath()

void OpenOrienteering::Template::setTemplateRelativePath ( const QString value)
inline

◆ setTemplateRotation()

void OpenOrienteering::Template::setTemplateRotation ( double  rotation)
inline

◆ setTemplateScaleX()

void OpenOrienteering::Template::setTemplateScaleX ( double  scale_x)
inline

◆ setTemplateScaleY()

void OpenOrienteering::Template::setTemplateScaleY ( double  scale_y)
inline

◆ setTemplateShear()

void OpenOrienteering::Template::setTemplateShear ( double  shear)
inline

◆ setTemplateState()

void OpenOrienteering::Template::setTemplateState ( State  state)
inline

◆ setTemplateX()

void OpenOrienteering::Template::setTemplateX ( qint64  x)
inline

◆ setTemplateY()

void OpenOrienteering::Template::setTemplateY ( qint64  y)
inline

◆ setTransform()

void OpenOrienteering::Template::setTransform ( const TemplateTransform transform)

◆ supportedExtensions()

const std::vector< QByteArray > & OpenOrienteering::Template::supportedExtensions ( )
static

Returns the filename extensions supported by known subclasses.

◆ switchTemplateFile()

void OpenOrienteering::Template::switchTemplateFile ( const QString new_path,
bool  load_file 
)

Changes a template's file without changing the parameters.

Useful when a template file has been moved. If load_file is true, tries to load the given file.

◆ switchTransforms()

void OpenOrienteering::Template::switchTransforms ( )

Change from adjusted into original state or the other way round.

◆ templateForFile()

std::unique_ptr< Template > OpenOrienteering::Template::templateForFile ( const QString path,
Map map 
)
static

Creates a Template instance for the given path.

This function tries to find a matching template subclass by looking at the file extension. It may return nullptr if no subclass supports the extension.

◆ templatePosition()

MapCoord OpenOrienteering::Template::templatePosition ( ) const

◆ templatePositionOffset()

MapCoord OpenOrienteering::Template::templatePositionOffset ( ) const

◆ templateStateChanged

void OpenOrienteering::Template::templateStateChanged ( )
signal

Emitted whenever template_state was changed.

◆ templateToMap()

MapCoordF OpenOrienteering::Template::templateToMap ( const QPointF coords) const
inline

◆ templateToMapOther()

MapCoordF OpenOrienteering::Template::templateToMapOther ( const QPointF coords) const
inline

◆ trySetTemplateGeoreferenced()

bool OpenOrienteering::Template::trySetTemplateGeoreferenced ( bool  value,
QWidget dialog_parent 
)
virtual

Tries to change the usage of georeferencing data.

If supported by the actual template, this function tries to switch the state between non-georeferenced and georeferenced. It returns the final state which may be the same as before if the change is not implemented or fails for other reasons.

The default implementation changes nothing, and it just returns the current state.

Reimplemented in OpenOrienteering::TemplateImage.

◆ tryToFindAndReloadTemplateFile()

bool OpenOrienteering::Template::tryToFindAndReloadTemplateFile ( const QString map_path)

Tries to find and load the template file non-interactively.

Returns true if the template was loaded successful.

If out_loaded_from_map_dir is given, it is set to true if the template file is found using the template filename in the map's directory.

See also
tryToFindTemplateFile

◆ tryToFindTemplateFile()

Template::LookupResult OpenOrienteering::Template::tryToFindTemplateFile ( const QString map_path)

Tries to find the template file non-interactively.

Thus function updates the path and name variables, and the template state. If successful, changes the state from Invalid to Unloaded if necessary, and returns true. Otherwise, changes the state from Unloaded to Invalid if necessary, and returns false. (If the state is Loaded, it is left unchanged.) It returns an indication of its success.

This function searches for the template in the following locations:

  1. The relative path with regard to the map directory, if both are valid. This alternative has precedence because it should always work, especially after coyping or moving a whole working directory on the same computer or to another one.
  2. The absolute path of the template. This is the most explicit alternative. It works on the same computer when the map file is copied or moved to another location.
  3. The map directory, if valid, for the filename of the template. This is a fallback for use cases where a map and selected templates are moved to the same flat folder, e.g. when receiving them via individual e-mail attachements.
Parameters
map_pathEither the full filepath of the map, or an arbitrary directory which shall be regarded as the map directory.

◆ unloadTemplateFile()

void OpenOrienteering::Template::unloadTemplateFile ( )

Unloads the template file.

Can be called if the template state is Loaded. Must not be called if the template file is already unloaded, or invalid.

◆ unloadTemplateFileImpl()

virtual void OpenOrienteering::Template::unloadTemplateFileImpl ( )
protectedpure virtual

Hook for unloading the template file.

Implemented in OpenOrienteering::TemplateImage, OpenOrienteering::TemplateMap, and OpenOrienteering::TemplateTrack.

◆ updateTransformationMatrices()

void OpenOrienteering::Template::updateTransformationMatrices ( )
protected

Must be called after direct changes to transform or other_transform.

Member Data Documentation

◆ adjusted

bool OpenOrienteering::Template::adjusted
protected

If true, transform is the adjusted transformation, otherwise it is the original one.

◆ adjustment_dirty

bool OpenOrienteering::Template::adjustment_dirty
protected

If true, the adjusted transformation has to be recalculated.

◆ error_string

QString OpenOrienteering::Template::error_string
protected

The description of the last error.

◆ has_unsaved_changes

bool OpenOrienteering::Template::has_unsaved_changes
protected

Does the template itself (not its transformation) have unsaved changes (e.g. GPS track has changed, image has been painted on)

◆ is_georeferenced

bool OpenOrienteering::Template::is_georeferenced
protected

Is the template in georeferenced mode?

◆ map

Map* OpenOrienteering::Template::map
protected

Map containing this template.

◆ map_to_template

Matrix OpenOrienteering::Template::map_to_template
protected

◆ other_transform

TemplateTransform OpenOrienteering::Template::other_transform
protected

Currently inactive transformation (adjusted or original). NOTE: after direct changes here call updateTransformationMatrices()

◆ passpoints

PassPointList OpenOrienteering::Template::passpoints
protected

List of pass points for position adjustment.

◆ suppressAbsolutePaths

bool OpenOrienteering::Template::suppressAbsolutePaths = false
static

A flag which disables the writing of absolute paths for template files.

By default, class Template saves absolute paths. This behavior can be changed by setting this flag to true. This allows to hide local (or private) directory names.

This flag defaults to false.

◆ template_file

QString OpenOrienteering::Template::template_file
protected

The filename of the template file (e.g. "map.bmp")

◆ template_group

int OpenOrienteering::Template::template_group
protected

Number of the template group. If the template is not grouped, this is set to -1.

◆ template_path

QString OpenOrienteering::Template::template_path
protected

The complete path to the template file including the filename (e.g. "/home/me/map.bmp")

◆ template_relative_path

QString OpenOrienteering::Template::template_relative_path
protected

The template path relative to the map file (e.g.

"../me/map.bmp"). Can be empty as long as the map file has not been saved yet.

◆ template_state

State OpenOrienteering::Template::template_state
protected

The template lifetime state.

◆ template_to_map

Matrix OpenOrienteering::Template::template_to_map
protected

◆ template_to_map_other

Matrix OpenOrienteering::Template::template_to_map_other
protected

◆ transform

TemplateTransform OpenOrienteering::Template::transform
protected

Currently active transformation. NOTE: after direct changes here call updateTransformationMatrices()


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