![]() |
Mapper
0.9.0
API documentation
|
MapPrinter provides an interface to print a map (to a printer or file). More...
#include <map_printer.h>
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 | |
MapPrinter & | operator= (const MapPrinter &)=delete |
MapPrinter & | operator= (MapPrinter &&)=delete |
~MapPrinter () override | |
Destructor. More... | |
const QPrinterInfo * | getTarget () const |
Returns the configured target printer in terms of QPrinterInfo. More... | |
bool | isPrinter () const |
Returns true if a real printer is configured. More... | |
const MapPrinterPageFormat & | getPageFormat () const |
Returns the page format specification. More... | |
const QRectF & | getPrintArea () const |
Returns the map area to be printed. More... | |
const MapPrinterOptions & | getOptions () 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< QPrinter > | makePrinter () 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 MapPrinterConfig & | config () const |
Returns the current configuration. More... | |
![]() | |
virtual const QMetaObject * | metaObject () 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) |
QThread * | thread () 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) |
T | 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 ®Exp, Qt::FindChildOptions options) const const |
QList< T > | findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const |
const QObjectList & | children () 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< QByteArray > | dynamicPropertyNames () const const |
void | destroyed (QObject *obj) |
void | objectNameChanged (const QString &objectName) |
QObject * | parent () const const |
bool | inherits (const char *className) const const |
void | deleteLater () |
Q_DISABLE_COPY (Class) | |
Q_DISABLE_MOVE (Class) | |
Q_DISABLE_COPY_MOVE (Class) | |
T | qobject_cast (QObject *object) |
T | qobject_cast (const QObject *object) |
T | qFindChild (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QString &name) |
QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
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 QPrinterInfo * | pdfTarget () |
Returns a QPrinterInfo pointer which signals printing to a PDF file. More... | |
static const QPrinterInfo * | imageTarget () |
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... | |
![]() | |
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... | |
![]() | |
QObject * | sender () 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) |
![]() | |
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 | |
Map & | map |
const MapView * | view |
const QPrinterInfo * | target = nullptr |
QPrinterInfo | target_copy |
qreal | scale_adjustment |
std::vector< qreal > | h_page_pos |
std::vector< qreal > | v_page_pos |
bool | cancel_print_map = false |
![]() | |
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 | |
![]() | |
typedef | QObjectList |
![]() | |
objectName | |
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.
OpenOrienteering::MapPrinter::MapPrinter | ( | Map & | map, |
const MapView * | view, | ||
QObject * | parent = nullptr |
||
) |
Constructs a new MapPrinter for the given map and (optional) view.
|
delete |
|
delete |
|
overridedefault |
Destructor.
|
slot |
Cancels a running printMap(), if possible.
This can only be used during handlers of the printMapProgress() signal.
|
inline |
Returns the current configuration.
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.
void OpenOrienteering::MapPrinter::drawSeparationPages | ( | QPrinter * | printer, |
QPainter * | device_painter, | ||
const QRectF & | page_extent | ||
) | const |
Draws the separations as distinct pages to the printer.
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.
bool OpenOrienteering::MapPrinter::engineWillRasterize | ( | ) | const |
|
inline |
Returns the rendering options.
|
inline |
Returns the page format specification.
QSizeF OpenOrienteering::MapPrinter::getPageRectPrintAreaSize | ( | ) | const |
Returns the print area size which is possible with the current page rect size.
|
inline |
Returns the map area to be printed.
QSizeF OpenOrienteering::MapPrinter::getPrintAreaPaperSize | ( | ) | const |
Returns the paper size which is required by the current print area and scale.
|
inline |
Returns the quotient of map scale denominator and print scale denominator.
|
inline |
Returns the configured target printer in terms of QPrinterInfo.
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.
|
inline |
Returns a list of horizontal page positions on the map.
|
static |
Returns a QPrinterInfo pointer which signals printing to a raster file.
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.)
bool OpenOrienteering::MapPrinter::isPrinter | ( | ) | const |
Returns true if a real printer is configured.
std::unique_ptr< QPrinter > OpenOrienteering::MapPrinter::makePrinter | ( | ) | const |
Creates a printer configured according to the current settings.
|
protected |
Updates the scale adjustment and page breaks.
|
delete |
|
delete |
|
signal |
Indicates a change in the rendering options.
|
signal |
Indicates a change in the page format.
|
static |
Returns a reference to a hash which maps paper sizes to names as C strings.
These strings are not translated.
|
static |
Returns a QPrinterInfo pointer which signals printing to a PDF file.
|
signal |
Indicates a change in the map area.
Prints the map to the given printer.
This will first update this object's properties from the printer's properties.
|
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).
value | Reflects the progress in the range from 1 (just started) to 100 (finished). |
status | A verbal representation of what printMap() is doing. |
|
inlineprotected |
Returns true if raster mode is set.
|
slot |
Saves the print parameter (to the map).
|
inlineprotected |
Returns true if separations mode is set.
|
slot |
Controls the color mode.
|
slot |
Sets a custom paper size with the given dimensions.
|
slot |
Sets the printing mode.
|
slot |
Sets the overlapping of the pages at the margins.
|
slot |
Sets the page orientation.
|
slot |
Sets the page size ID to be used.
|
slot |
Sets the map area which is to be printed.
|
slot |
Controls whether to print the map grid.
|
slot |
Controls whether to print templates.
If a MapView is given when enabling template printing, it will determine the visibility of map and templates.
|
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.
|
slot |
Sets the denominator of the map scale for printing.
|
slot |
Controls whether to print in overprinting simulation mode.
|
slot |
Sets the target QPrinterInfo.
Ownership is not taken over! Target may even be nullptr.
void OpenOrienteering::MapPrinter::takePrinterSettings | ( | const QPrinter * | printer | ) |
Takes the settings from the given printer, and generates signals for changing properties.
|
signal |
Indicates a new target printer.
|
protected |
Updates the page breaks from map area and page format.
|
protected |
Updates the paper dimensions from paper format and orientation.
|
inlineprotected |
Returns true if vector mode is set.
|
inline |
Returns a list of vertical page positions on the map.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |