Mapper  0.9.0
API documentation
Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | List of all members
OpenOrienteering::OgrTemplate Class Reference

A Template which displays a file supported by OGR (geospatial vector data). More...

#include <ogr_template.h>

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

Public Member Functions

 OgrTemplate (const QString &path, Map *map)
 
 ~OgrTemplate () override
 
const char * getTemplateType () const override
 Returns a string which should identify the type of the template uniquely: the class name. More...
 
std::unique_ptr< GeoreferencingmakeOrthographicGeoreferencing (const QString &path)
 
bool preLoadConfiguration (QWidget *dialog_parent) override
 Does configuration before the actual template is loaded. More...
 
bool loadTemplateFileImpl (bool configuring) override
 Loads the geospatial vector data into the template_map. More...
 
bool postLoadConfiguration (QWidget *dialog_parent, bool &out_center_in_view) override
 Does configuration after the actual template is loaded. More...
 
- Public Member Functions inherited from OpenOrienteering::TemplateMap
 TemplateMap (const QString &path, Map *map)
 
 ~TemplateMap () override
 
const char * getTemplateType () const override
 Returns a string which should identify the type of the template uniquely: the class name. More...
 
bool isRasterGraphics () const override
 Returns true if the template is raster graphics. More...
 
bool loadTemplateFileImpl (bool configuring) override
 Hook for loading the actual template file non-interactively. More...
 
bool postLoadConfiguration (QWidget *dialog_parent, bool &out_center_in_view) override
 Does configuration after the actual template is loaded. More...
 
void unloadTemplateFileImpl () override
 Hook for unloading the template file. More...
 
void drawTemplate (QPainter *painter, const QRectF &clip_rect, double scale, bool on_screen, float opacity) const override
 Draws the template using the given painter with the given opacity. More...
 
QRectF getTemplateExtent () const override
 Returns the extent of the template in template coordinates. More...
 
bool hasAlpha () const override
 Returns true if the template has elements which are not opaque. More...
 
const MaptemplateMap () const
 
- Public Member Functions inherited from OpenOrienteering::Template
 ~Template () override
 
Templateduplicate () const
 Creates a duplicate of the template. More...
 
QString errorString () const
 Returns a description of the last error that occurred. 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...
 
bool loadTemplateFile (bool configuring)
 Loads the template file. More...
 
void unloadTemplateFile ()
 Unloads the template file. 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...
 
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)
 
- 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 const std::vector< QByteArray > & supportedExtensions ()
 
- Static Public Member Functions inherited from OpenOrienteering::TemplateMap
static const std::vector< QByteArray > & supportedExtensions ()
 Returns the filename extensions supported by this template class. More...
 
- Static Public Member Functions inherited from OpenOrienteering::Template
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)
 

Protected Slots

void reload ()
 
void applySettings ()
 

Protected Member Functions

void reloadLater ()
 
void updateView (Map &template_map)
 
void mapProjectionChanged ()
 
void mapTransformationChanged ()
 
OgrTemplateduplicateImpl () const override
 Derived classes must create a duplicate and transfer. More...
 
bool loadTypeSpecificTemplateConfiguration (QXmlStreamReader &xml) override
 Hook for loading parameters needed by the actual template type. More...
 
void saveTypeSpecificTemplateConfiguration (QXmlStreamWriter &xml) const override
 Hook for saving parameters needed by the actual template type. More...
 
- Protected Member Functions inherited from OpenOrienteering::TemplateMap
TemplateduplicateImpl () const override
 Derived classes must create a duplicate and transfer. More...
 
MaptemplateMap ()
 
void setTemplateMap (std::unique_ptr< Map > &&map)
 
void calculateTransformation ()
 
- Protected Member Functions inherited from OpenOrienteering::Template
 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 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)
 

Additional Inherited Members

- Public Types inherited from OpenOrienteering::Template
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 inherited from OpenOrienteering::Template
void templateStateChanged ()
 Emitted whenever template_state was changed. More...
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Static Public Attributes inherited from OpenOrienteering::Template
static bool suppressAbsolutePaths = false
 A flag which disables the writing of absolute paths for template files. More...
 
- Protected Attributes inherited from OpenOrienteering::Template
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
 
- Properties inherited from QObject
 objectName
 

Detailed Description

A Template which displays a file supported by OGR (geospatial vector data).

Constructor & Destructor Documentation

◆ OgrTemplate()

OpenOrienteering::OgrTemplate::OgrTemplate ( const QString path,
Map map 
)

◆ ~OgrTemplate()

OpenOrienteering::OgrTemplate::~OgrTemplate ( )
override

Member Function Documentation

◆ applySettings

void OpenOrienteering::OgrTemplate::applySettings ( )
protectedslot

◆ duplicateImpl()

OgrTemplate * OpenOrienteering::OgrTemplate::duplicateImpl ( ) const
overrideprotectedvirtual

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

Implements OpenOrienteering::Template.

◆ getTemplateType()

const char * OpenOrienteering::OgrTemplate::getTemplateType ( ) const
overridevirtual

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

Very simple RTTI feature.

Implements OpenOrienteering::Template.

◆ loadTemplateFileImpl()

bool OpenOrienteering::OgrTemplate::loadTemplateFileImpl ( bool  configuring)
overridevirtual

Loads the geospatial vector data into the template_map.

If is_georereferenced is true, the template_map will be configured to use the georeferencing of the map given in the constructor, and OgrFileImportFormat will let OGR do coordinate transformations as needed.

If is_georeferenced is false and an explicit_georef is defined, the template_map will be configured to use this particular georeferencing to produce a projection of the original data.

Otherwise, the data will be handled as raw map or paper data, depending on use_real_coords.

Implements OpenOrienteering::Template.

◆ loadTypeSpecificTemplateConfiguration()

bool OpenOrienteering::OgrTemplate::loadTypeSpecificTemplateConfiguration ( QXmlStreamReader xml)
overrideprotectedvirtual

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 from OpenOrienteering::Template.

◆ makeOrthographicGeoreferencing()

std::unique_ptr< Georeferencing > OpenOrienteering::OgrTemplate::makeOrthographicGeoreferencing ( const QString path)
Todo:
Use the template's datum etc. instead of WGS84?

◆ mapProjectionChanged()

void OpenOrienteering::OgrTemplate::mapProjectionChanged ( )
protected

◆ mapTransformationChanged()

void OpenOrienteering::OgrTemplate::mapTransformationChanged ( )
protected

◆ postLoadConfiguration()

bool OpenOrienteering::OgrTemplate::postLoadConfiguration ( QWidget dialog_parent,
bool out_center_in_view 
)
overridevirtual

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 from OpenOrienteering::Template.

◆ preLoadConfiguration()

bool OpenOrienteering::OgrTemplate::preLoadConfiguration ( QWidget dialog_parent)
overridevirtual

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 from OpenOrienteering::Template.

◆ reload

void OpenOrienteering::OgrTemplate::reload ( )
protectedslot

◆ reloadLater()

void OpenOrienteering::OgrTemplate::reloadLater ( )
protected

◆ saveTypeSpecificTemplateConfiguration()

void OpenOrienteering::OgrTemplate::saveTypeSpecificTemplateConfiguration ( QXmlStreamWriter xml) const
overrideprotectedvirtual

Hook for saving parameters needed by the actual template type.

The default implementation does nothing.

Reimplemented from OpenOrienteering::Template.

◆ supportedExtensions()

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

◆ updateView()

void OpenOrienteering::OgrTemplate::updateView ( Map template_map)
protected

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