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

Class for displaying a grid on a map. More...

#include <map_grid.h>

Public Types

enum  Alignment { MagneticNorth = 0, GridNorth = 1, TrueNorth = 2 }
 Options for aligning the grid with different north concepts. More...
 
enum  Unit { MillimetersOnMap = 0, MetersInTerrain = 1 }
 Different units for specifying the grid interval. More...
 
enum  DisplayMode { AllLines = 0, HorizontalLines = 1, VerticalLines = 2 }
 Different display modes for map grids. More...
 

Public Member Functions

 MapGrid ()
 Creates a new map grid with default settings. More...
 
void save (QXmlStreamWriter &xml) const
 Saves the grid in xml format to the given stream. More...
 
const MapGridload (QXmlStreamReader &xml)
 Loads the grid in xml format from the given stream. More...
 
void draw (QPainter *painter, const QRectF &bounding_box, Map *map, qreal scale_adjustment=0) const
 Draws the map grid. More...
 
void draw (QPainter *painter, const QRectF &bounding_box, Map *map, bool) const =delete
 
void calculateFinalParameters (double &final_horz_spacing, double &final_vert_spacing, double &final_horz_offset, double &final_vert_offset, double &final_rotation, Map *map) const
 Calculates the "final" parameters with the following properties: More...
 
MapCoordF getClosestPointOnGrid (MapCoordF position, Map *map) const
 Returns the grid point which is closest to the given position. More...
 
bool isSnappingEnabled () const
 
void setSnappingEnabled (bool enable)
 
QRgb getColor () const
 
void setColor (QRgb color)
 
bool hasAlpha () const
 Returns true if the grid is not opaque. More...
 
DisplayMode getDisplayMode () const
 
void setDisplayMode (DisplayMode mode)
 
Alignment getAlignment () const
 
void setAlignment (Alignment alignment)
 
double getAdditionalRotation () const
 
void setAdditionalRotation (double rotation)
 
Unit getUnit () const
 
void setUnit (Unit unit)
 
double getHorizontalSpacing () const
 
void setHorizontalSpacing (double spacing)
 
double getVerticalSpacing () const
 
void setVerticalSpacing (double spacing)
 
double getHorizontalOffset () const
 
void setHorizontalOffset (double offset)
 
double getVerticalOffset () const
 
void setVerticalOffset (double offset)
 

Friends

bool operator== (const MapGrid &lhs, const MapGrid &rhs)
 Compares two map grid objects. More...
 

Detailed Description

Class for displaying a grid on a map.

Each map has an instance of this class which can be retrieved with map->getGrid(). The grid's visibility is defined per MapView.

Grid lines are thin. They are either drawn using a cosmetic pen (usually on screen) or with 0.1 mm (usually on paper).

Member Enumeration Documentation

◆ Alignment

Options for aligning the grid with different north concepts.

Enumerator
MagneticNorth 
GridNorth 
TrueNorth 

◆ DisplayMode

Different display modes for map grids.

Enumerator
AllLines 
HorizontalLines 
VerticalLines 

◆ Unit

Different units for specifying the grid interval.

Enumerator
MillimetersOnMap 
MetersInTerrain 

Constructor & Destructor Documentation

◆ MapGrid()

OpenOrienteering::MapGrid::MapGrid ( )

Creates a new map grid with default settings.

Member Function Documentation

◆ calculateFinalParameters()

void OpenOrienteering::MapGrid::calculateFinalParameters ( double &  final_horz_spacing,
double &  final_vert_spacing,
double &  final_horz_offset,
double &  final_vert_offset,
double &  final_rotation,
Map map 
) const

Calculates the "final" parameters with the following properties:

  • spacings and offsets are in millimeters on the map
  • rotation is relative to the vector (1, 0) and counterclockwise

◆ draw() [1/2]

void OpenOrienteering::MapGrid::draw ( QPainter painter,
const QRectF bounding_box,
Map map,
qreal  scale_adjustment = 0 
) const

Draws the map grid.

Parameters
painterThe QPainter used for drawing.
bounding_boxBounding box of the area to draw the grid for, in map coordinates.
mapMap to draw the grid for.
scale_adjustmentIf zero, uses a cosmetic pen (one pixel wide), otherwise this is the divisor used to create a 0.1 mm wide pen.

◆ draw() [2/2]

void OpenOrienteering::MapGrid::draw ( QPainter painter,
const QRectF bounding_box,
Map map,
bool   
) const
delete

◆ getAdditionalRotation()

double OpenOrienteering::MapGrid::getAdditionalRotation ( ) const
inline

◆ getAlignment()

Alignment OpenOrienteering::MapGrid::getAlignment ( ) const
inline

◆ getClosestPointOnGrid()

MapCoordF OpenOrienteering::MapGrid::getClosestPointOnGrid ( MapCoordF  position,
Map map 
) const

Returns the grid point which is closest to the given position.

◆ getColor()

QRgb OpenOrienteering::MapGrid::getColor ( ) const
inline

◆ getDisplayMode()

DisplayMode OpenOrienteering::MapGrid::getDisplayMode ( ) const
inline

◆ getHorizontalOffset()

double OpenOrienteering::MapGrid::getHorizontalOffset ( ) const
inline

◆ getHorizontalSpacing()

double OpenOrienteering::MapGrid::getHorizontalSpacing ( ) const
inline

◆ getUnit()

Unit OpenOrienteering::MapGrid::getUnit ( ) const
inline

◆ getVerticalOffset()

double OpenOrienteering::MapGrid::getVerticalOffset ( ) const
inline

◆ getVerticalSpacing()

double OpenOrienteering::MapGrid::getVerticalSpacing ( ) const
inline

◆ hasAlpha()

bool OpenOrienteering::MapGrid::hasAlpha ( ) const

Returns true if the grid is not opaque.

◆ isSnappingEnabled()

bool OpenOrienteering::MapGrid::isSnappingEnabled ( ) const
inline

◆ load()

const MapGrid & OpenOrienteering::MapGrid::load ( QXmlStreamReader xml)

Loads the grid in xml format from the given stream.

◆ save()

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

Saves the grid in xml format to the given stream.

◆ setAdditionalRotation()

void OpenOrienteering::MapGrid::setAdditionalRotation ( double  rotation)
inline

◆ setAlignment()

void OpenOrienteering::MapGrid::setAlignment ( Alignment  alignment)
inline

◆ setColor()

void OpenOrienteering::MapGrid::setColor ( QRgb  color)
inline

◆ setDisplayMode()

void OpenOrienteering::MapGrid::setDisplayMode ( DisplayMode  mode)
inline

◆ setHorizontalOffset()

void OpenOrienteering::MapGrid::setHorizontalOffset ( double  offset)
inline

◆ setHorizontalSpacing()

void OpenOrienteering::MapGrid::setHorizontalSpacing ( double  spacing)
inline

◆ setSnappingEnabled()

void OpenOrienteering::MapGrid::setSnappingEnabled ( bool  enable)
inline

◆ setUnit()

void OpenOrienteering::MapGrid::setUnit ( Unit  unit)
inline

◆ setVerticalOffset()

void OpenOrienteering::MapGrid::setVerticalOffset ( double  offset)
inline

◆ setVerticalSpacing()

void OpenOrienteering::MapGrid::setVerticalSpacing ( double  spacing)
inline

Friends And Related Function Documentation

◆ operator==

bool operator== ( const MapGrid lhs,
const MapGrid rhs 
)
friend

Compares two map grid objects.

Returns
true if the objects are equal, false otherwise

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