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

MapPrinter provides an interface to print a map (to a printer or file). More...

#include <map_printer.h>

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

Public Slots

void setTarget (const QPrinterInfo *new_target)
 Sets the target QPrinterInfo. More...
 
void setPrintArea (const QRectF &area)
 Sets the map area which is to be printed. More...
 
void setPageSize (QPageSize::PageSizeId size)
 Sets the page size ID to be used. More...
 
void setCustomPageSize (const QSizeF &dimensions)
 Sets a custom paper size with the given dimensions. More...
 
void setPageOrientation (MapPrinterPageFormat::Orientation orientation)
 Sets the page orientation. More...
 
void setOverlap (qreal h_overlap, qreal v_overlap)
 Sets the overlapping of the pages at the margins. More...
 
void setResolution (int dpi)
 Sets the desired printing resolution in dpi. More...
 
void setScale (unsigned int value)
 Sets the denominator of the map scale for printing. More...
 
void setMode (MapPrinterOptions::MapPrinterMode mode)
 Sets the printing mode. More...
 
void setPrintTemplates (bool visible)
 Controls whether to print templates. More...
 
void setPrintGrid (bool visible)
 Controls whether to print the map grid. More...
 
void setSimulateOverprinting (bool enabled)
 Controls whether to print in overprinting simulation mode. More...
 
void setColorMode (MapPrinterOptions::ColorMode color_mode)
 Controls the color mode. More...
 
void saveConfig () const
 Saves the print parameter (to the map). More...
 
void cancelPrintMap ()
 Cancels a running printMap(), if possible. More...
 

Signals

void targetChanged (const QPrinterInfo *target) const
 Indicates a new target printer. More...
 
void printAreaChanged (const QRectF &area) const
 Indicates a change in the map area. More...
 
void pageFormatChanged (const OpenOrienteering::MapPrinterPageFormat &format) const
 Indicates a change in the page format. More...
 
void optionsChanged (const OpenOrienteering::MapPrinterOptions &options) const
 Indicates a change in the rendering options. More...
 
void printProgress (int value, const QString &status) const
 Emitted during printMap() to indicate progress. More...
 

Public Member Functions

 MapPrinter (Map &map, const MapView *view, QObject *parent=nullptr)
 Constructs a new MapPrinter for the given map and (optional) view. More...
 
 MapPrinter (const MapPrinter &)=delete
 
 MapPrinter (MapPrinter &&)=delete
 
MapPrinteroperator= (const MapPrinter &)=delete
 
MapPrinteroperator= (MapPrinter &&)=delete
 
 ~MapPrinter () override
 Destructor. More...
 
const QPrinterInfogetTarget () const
 Returns the configured target printer in terms of QPrinterInfo. More...
 
bool isPrinter () const
 Returns true if a real printer is configured. More...
 
const MapPrinterPageFormatgetPageFormat () const
 Returns the page format specification. More...
 
const QRectFgetPrintArea () const
 Returns the map area to be printed. More...
 
const MapPrinterOptionsgetOptions () const
 Returns the rendering options. More...
 
bool isOutputEmpty () const
 Returns true if the current print area and rendering options will result in empty pages. More...
 
qreal getScaleAdjustment () const
 Returns the quotient of map scale denominator and print scale denominator. More...
 
QSizeF getPrintAreaPaperSize () const
 Returns the paper size which is required by the current print area and scale. More...
 
QSizeF getPageRectPrintAreaSize () const
 Returns the print area size which is possible with the current page rect size. More...
 
const std::vector< qreal > & horizontalPagePositions () const
 Returns a list of horizontal page positions on the map. More...
 
const std::vector< qreal > & verticalPagePositions () const
 Returns a list of vertical page positions on the map. More...
 
bool engineMayRasterize () const
 Returns true when the Qt print engine may rasterize non-opaque data. More...
 
bool engineWillRasterize () const
 Returns true when the Qt print engine will have to rasterize the map. More...
 
bool hasAlpha (const Template *temp) const
 Returns true when the template will be printed non-opaquely. More...
 
std::unique_ptr< QPrintermakePrinter () const
 Creates a printer configured according to the current settings. More...
 
void takePrinterSettings (const QPrinter *printer)
 Takes the settings from the given printer, and generates signals for changing properties. More...
 
bool printMap (QPrinter *printer)
 Prints the map to the given printer. More...
 
void drawPage (QPainter *device_painter, const QRectF &page_extent, QImage *page_buffer=nullptr) const
 Draws a single page to the painter. More...
 
void drawSeparationPages (QPrinter *printer, QPainter *device_painter, const QRectF &page_extent) const
 Draws the separations as distinct pages to the printer. More...
 
const MapPrinterConfigconfig () const
 Returns the current configuration. 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 const QPrinterInfopdfTarget ()
 Returns a QPrinterInfo pointer which signals printing to a PDF file. More...
 
static const QPrinterInfoimageTarget ()
 Returns a QPrinterInfo pointer which signals printing to a raster file. More...
 
static const QHash< int, const char *> & paperSizeNames ()
 Returns a reference to a hash which maps paper sizes to names as C strings. 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 Member Functions

bool vectorModeSelected () const
 Returns true if vector mode is set. More...
 
bool rasterModeSelected () const
 Returns true if raster mode is set. More...
 
bool separationsModeSelected () const
 Returns true if separations mode is set. More...
 
void updatePaperDimensions ()
 Updates the paper dimensions from paper format and orientation. More...
 
void updatePageBreaks ()
 Updates the page breaks from map area and page format. More...
 
void mapScaleChanged ()
 Updates the scale adjustment and page breaks. 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 Member Functions inherited from OpenOrienteering::MapPrinterConfig
 MapPrinterConfig (const Map &map)
 Constructs a default config for the given map. More...
 
 MapPrinterConfig (const Map &map, QXmlStreamReader &xml)
 Constructs a config and loads the map print parameters from an XML stream. More...
 
void save (QXmlStreamWriter &xml, const QLatin1String &element_name) const
 Saves the map print parameters to an XML stream. More...
 

Protected Attributes

Mapmap
 
const MapViewview
 
const QPrinterInfotarget = nullptr
 
QPrinterInfo target_copy
 
qreal scale_adjustment
 
std::vector< qreal > h_page_pos
 
std::vector< qreal > v_page_pos
 
bool cancel_print_map = false
 
- Protected Attributes inherited from OpenOrienteering::MapPrinterConfig
QString printer_name
 The name of the printer. More...
 
QRectF print_area
 The print area. More...
 
MapPrinterPageFormat page_format
 The page format. More...
 
MapPrinterOptions options
 Printing options. More...
 
bool center_print_area
 A flag which indicates to the UI whether to maintain a centered print area when the size of the map or the page changes. More...
 
bool single_page_print_area
 A flag which indicates to the UI whether to adjust the print area size to the current page size. More...
 
std::shared_ptr< void > native_data
 Platform-dependent data. More...
 

Additional Inherited Members

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

Detailed Description

MapPrinter provides an interface to print a map (to a printer or file).

It may render a page on any QPaintDevice, such as an QImage.

Constructor & Destructor Documentation

◆ MapPrinter() [1/3]

OpenOrienteering::MapPrinter::MapPrinter ( Map map,
const MapView view,
QObject parent = nullptr 
)

Constructs a new MapPrinter for the given map and (optional) view.

◆ MapPrinter() [2/3]

OpenOrienteering::MapPrinter::MapPrinter ( const MapPrinter )
delete

◆ MapPrinter() [3/3]

OpenOrienteering::MapPrinter::MapPrinter ( MapPrinter &&  )
delete

◆ ~MapPrinter()

OpenOrienteering::MapPrinter::~MapPrinter ( )
overridedefault

Destructor.

Member Function Documentation

◆ cancelPrintMap

void OpenOrienteering::MapPrinter::cancelPrintMap ( )
slot

Cancels a running printMap(), if possible.

This can only be used during handlers of the printMapProgress() signal.

◆ config()

const MapPrinterConfig& OpenOrienteering::MapPrinter::config ( ) const
inline

Returns the current configuration.

◆ drawPage()

void OpenOrienteering::MapPrinter::drawPage ( QPainter device_painter,
const QRectF page_extent,
QImage page_buffer = nullptr 
) const

Draws a single page to the painter.

In case of an error, the painter will be inactive when returning from this function.

When the actual paint device is a QImage, pass it as page_buffer. This helps to determine the exact dimensions and to avoid the allocation of another buffer. Otherwise, drawPage() may allocate a buffer with this map printer's resolution and size. Parameter units_per_inch has no influence on this buffer but refers to the logical coordinates of device_painter.

◆ drawSeparationPages()

void OpenOrienteering::MapPrinter::drawSeparationPages ( QPrinter printer,
QPainter device_painter,
const QRectF page_extent 
) const

Draws the separations as distinct pages to the printer.

◆ engineMayRasterize()

bool OpenOrienteering::MapPrinter::engineMayRasterize ( ) const

Returns true when the Qt print engine may rasterize non-opaque data.

Drawing non-opaque data might cause rasterization with some Qt print engines. This function is used to detect configurations where such rasterization may happen. The result can be comined with tests for the data actually having alpha.

◆ engineWillRasterize()

bool OpenOrienteering::MapPrinter::engineWillRasterize ( ) const

Returns true when the Qt print engine will have to rasterize the map.

Drawing a map with non-opaque colors will cause rasterization with some Qt print engines. This functions signals when this rasterization must take place (i.e. even when we try to avoid rasterization for templates and grid).

◆ getOptions()

const MapPrinterOptions& OpenOrienteering::MapPrinter::getOptions ( ) const
inline

Returns the rendering options.

◆ getPageFormat()

const MapPrinterPageFormat& OpenOrienteering::MapPrinter::getPageFormat ( ) const
inline

Returns the page format specification.

◆ getPageRectPrintAreaSize()

QSizeF OpenOrienteering::MapPrinter::getPageRectPrintAreaSize ( ) const

Returns the print area size which is possible with the current page rect size.

◆ getPrintArea()

const QRectF& OpenOrienteering::MapPrinter::getPrintArea ( ) const
inline

Returns the map area to be printed.

◆ getPrintAreaPaperSize()

QSizeF OpenOrienteering::MapPrinter::getPrintAreaPaperSize ( ) const

Returns the paper size which is required by the current print area and scale.

◆ getScaleAdjustment()

qreal OpenOrienteering::MapPrinter::getScaleAdjustment ( ) const
inline

Returns the quotient of map scale denominator and print scale denominator.

◆ getTarget()

const QPrinterInfo* OpenOrienteering::MapPrinter::getTarget ( ) const
inline

Returns the configured target printer in terms of QPrinterInfo.

◆ hasAlpha()

bool OpenOrienteering::MapPrinter::hasAlpha ( const Template temp) const

Returns true when the template will be printed non-opaquely.

Drawing non-opaque templates might cause rasterization with some Qt print engines. This function is used to detect this case. It considers the template's state and hasAlpha() property as well the view's visibility configuration for the given template.

◆ horizontalPagePositions()

const std::vector< qreal >& OpenOrienteering::MapPrinter::horizontalPagePositions ( ) const
inline

Returns a list of horizontal page positions on the map.

◆ imageTarget()

const QPrinterInfo * OpenOrienteering::MapPrinter::imageTarget ( )
static

Returns a QPrinterInfo pointer which signals printing to a raster file.

◆ isOutputEmpty()

bool OpenOrienteering::MapPrinter::isOutputEmpty ( ) const

Returns true if the current print area and rendering options will result in empty pages.

(The grid is not considered.)

◆ isPrinter()

bool OpenOrienteering::MapPrinter::isPrinter ( ) const

Returns true if a real printer is configured.

◆ makePrinter()

std::unique_ptr< QPrinter > OpenOrienteering::MapPrinter::makePrinter ( ) const

Creates a printer configured according to the current settings.

◆ mapScaleChanged()

void OpenOrienteering::MapPrinter::mapScaleChanged ( )
protected

Updates the scale adjustment and page breaks.

◆ operator=() [1/2]

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

◆ operator=() [2/2]

MapPrinter& OpenOrienteering::MapPrinter::operator= ( MapPrinter &&  )
delete

◆ optionsChanged

void OpenOrienteering::MapPrinter::optionsChanged ( const OpenOrienteering::MapPrinterOptions options) const
signal

Indicates a change in the rendering options.

◆ pageFormatChanged

void OpenOrienteering::MapPrinter::pageFormatChanged ( const OpenOrienteering::MapPrinterPageFormat format) const
signal

Indicates a change in the page format.

◆ paperSizeNames()

const QHash< int, const char *> & OpenOrienteering::MapPrinter::paperSizeNames ( )
static

Returns a reference to a hash which maps paper sizes to names as C strings.

These strings are not translated.

Deprecated:
Use QPageSize::key() instead.
Todo:
Remove MapPrinter::paperSizeNames() in Mapper 1.0.

◆ pdfTarget()

const QPrinterInfo * OpenOrienteering::MapPrinter::pdfTarget ( )
static

Returns a QPrinterInfo pointer which signals printing to a PDF file.

◆ printAreaChanged

void OpenOrienteering::MapPrinter::printAreaChanged ( const QRectF area) const
signal

Indicates a change in the map area.

◆ printMap()

bool OpenOrienteering::MapPrinter::printMap ( QPrinter printer)

Prints the map to the given printer.

This will first update this object's properties from the printer's properties.

Returns
true on success, false on error.

◆ printProgress

void OpenOrienteering::MapPrinter::printProgress ( int  value,
const QString status 
) const
signal

Emitted during printMap() to indicate progress.

You can expect this signal to be emitted at the start of the print process (value = 1), after each page printed, and at the end of the process (value = 100).

Parameters
valueReflects the progress in the range from 1 (just started) to 100 (finished).
statusA verbal representation of what printMap() is doing.

◆ rasterModeSelected()

bool OpenOrienteering::MapPrinter::rasterModeSelected ( ) const
inlineprotected

Returns true if raster mode is set.

◆ saveConfig

void OpenOrienteering::MapPrinter::saveConfig ( ) const
slot

Saves the print parameter (to the map).

◆ separationsModeSelected()

bool OpenOrienteering::MapPrinter::separationsModeSelected ( ) const
inlineprotected

Returns true if separations mode is set.

◆ setColorMode

void OpenOrienteering::MapPrinter::setColorMode ( MapPrinterOptions::ColorMode  color_mode)
slot

Controls the color mode.

◆ setCustomPageSize

void OpenOrienteering::MapPrinter::setCustomPageSize ( const QSizeF dimensions)
slot

Sets a custom paper size with the given dimensions.

◆ setMode

void OpenOrienteering::MapPrinter::setMode ( MapPrinterOptions::MapPrinterMode  mode)
slot

Sets the printing mode.

◆ setOverlap

void OpenOrienteering::MapPrinter::setOverlap ( qreal  h_overlap,
qreal  v_overlap 
)
slot

Sets the overlapping of the pages at the margins.

◆ setPageOrientation

void OpenOrienteering::MapPrinter::setPageOrientation ( MapPrinterPageFormat::Orientation  orientation)
slot

Sets the page orientation.

◆ setPageSize

void OpenOrienteering::MapPrinter::setPageSize ( QPageSize::PageSizeId  size)
slot

Sets the page size ID to be used.

◆ setPrintArea

void OpenOrienteering::MapPrinter::setPrintArea ( const QRectF area)
slot

Sets the map area which is to be printed.

◆ setPrintGrid

void OpenOrienteering::MapPrinter::setPrintGrid ( bool  visible)
slot

Controls whether to print the map grid.

◆ setPrintTemplates

void OpenOrienteering::MapPrinter::setPrintTemplates ( bool  visible)
slot

Controls whether to print templates.

If a MapView is given when enabling template printing, it will determine the visibility of map and templates.

◆ setResolution

void OpenOrienteering::MapPrinter::setResolution ( int  dpi)
slot

Sets the desired printing resolution in dpi.

The actual resolution will be set by the printer.

Does nothing if dpi is 0 or less.

◆ setScale

void OpenOrienteering::MapPrinter::setScale ( unsigned int  value)
slot

Sets the denominator of the map scale for printing.

◆ setSimulateOverprinting

void OpenOrienteering::MapPrinter::setSimulateOverprinting ( bool  enabled)
slot

Controls whether to print in overprinting simulation mode.

◆ setTarget

void OpenOrienteering::MapPrinter::setTarget ( const QPrinterInfo new_target)
slot

Sets the target QPrinterInfo.

Ownership is not taken over! Target may even be nullptr.

◆ takePrinterSettings()

void OpenOrienteering::MapPrinter::takePrinterSettings ( const QPrinter printer)

Takes the settings from the given printer, and generates signals for changing properties.

◆ targetChanged

void OpenOrienteering::MapPrinter::targetChanged ( const QPrinterInfo target) const
signal

Indicates a new target printer.

◆ updatePageBreaks()

void OpenOrienteering::MapPrinter::updatePageBreaks ( )
protected

Updates the page breaks from map area and page format.

◆ updatePaperDimensions()

void OpenOrienteering::MapPrinter::updatePaperDimensions ( )
protected

Updates the paper dimensions from paper format and orientation.

◆ vectorModeSelected()

bool OpenOrienteering::MapPrinter::vectorModeSelected ( ) const
inlineprotected

Returns true if vector mode is set.

◆ verticalPagePositions()

const std::vector< qreal >& OpenOrienteering::MapPrinter::verticalPagePositions ( ) const
inline

Returns a list of vertical page positions on the map.

Member Data Documentation

◆ cancel_print_map

bool OpenOrienteering::MapPrinter::cancel_print_map = false
protected

◆ h_page_pos

std::vector<qreal> OpenOrienteering::MapPrinter::h_page_pos
protected

◆ map

Map& OpenOrienteering::MapPrinter::map
protected

◆ scale_adjustment

qreal OpenOrienteering::MapPrinter::scale_adjustment
protected

◆ target

const QPrinterInfo* OpenOrienteering::MapPrinter::target = nullptr
protected

◆ target_copy

QPrinterInfo OpenOrienteering::MapPrinter::target_copy
protected

◆ v_page_pos

std::vector<qreal> OpenOrienteering::MapPrinter::v_page_pos
protected

◆ view

const MapView* OpenOrienteering::MapPrinter::view
protected

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