Quantum GIS API Documentation
1.7.4
|
Graphics scene for map printing. More...
#include <qgscomposition.h>
Public Types | |
enum | PlotStyle { Preview = 0, Print, Postscript } |
Plot type. More... | |
enum | GridStyle { Solid, Dots, Crosses } |
Style to draw the snapping grid. More... | |
Signals | |
void | paperSizeChanged () |
Public Member Functions | |
QgsComposition (QgsMapRenderer *mapRenderer) | |
~QgsComposition () | |
void | setPaperSize (double width, double height) |
Changes size of paper item. | |
double | paperHeight () const |
Returns height of paper item. | |
double | paperWidth () const |
Returns width of paper item. | |
void | setSnapToGridEnabled (bool b) |
bool | snapToGridEnabled () const |
void | setSnapGridResolution (double r) |
double | snapGridResolution () const |
void | setSnapGridOffsetX (double offset) |
double | snapGridOffsetX () const |
void | setSnapGridOffsetY (double offset) |
double | snapGridOffsetY () const |
void | setGridPen (const QPen &p) |
const QPen & | gridPen () const |
void | setGridStyle (GridStyle s) |
GridStyle | gridStyle () const |
QUndoStack * | undoStack () |
Returns pointer to undo/redo command storage. | |
QgsComposerItem * | composerItemAt (const QPointF &position) |
Returns the topmost composer item. | |
QList< QgsComposerItem * > | selectedComposerItems () |
QList< const QgsComposerMap * > | composerMapItems () const |
Returns pointers to all composer maps in the scene. | |
const QgsComposerMap * | getComposerMapById (int id) const |
Returns the composer map with specified id. | |
int | printResolution () const |
void | setPrintResolution (int dpi) |
bool | printAsRaster () const |
void | setPrintAsRaster (bool enabled) |
QgsMapRenderer * | mapRenderer () |
Returns pointer to map renderer of qgis map canvas. | |
QgsComposition::PlotStyle | plotStyle () const |
void | setPlotStyle (QgsComposition::PlotStyle style) |
int | pixelFontSize (double pointSize) const |
Returns the pixel font size for a font that has point size set. | |
double | pointFontSize (int pixelSize) const |
Does the inverse calculation and returns points for pixels (equals to mm in QgsComposition) | |
bool | writeXML (QDomElement &composerElem, QDomDocument &doc) |
Writes settings to xml (paper dimension) | |
bool | readXML (const QDomElement &compositionElem, const QDomDocument &doc) |
Reads settings from xml file. | |
void | addItemToZList (QgsComposerItem *item) |
Adds item to z list. | |
void | removeItemFromZList (QgsComposerItem *item) |
Removes item from z list. | |
void | raiseSelectedItems () |
void | raiseItem (QgsComposerItem *item) |
void | lowerSelectedItems () |
void | lowerItem (QgsComposerItem *item) |
void | moveSelectedItemsToTop () |
void | moveItemToTop (QgsComposerItem *item) |
void | moveSelectedItemsToBottom () |
void | moveItemToBottom (QgsComposerItem *item) |
void | alignSelectedItemsLeft () |
void | alignSelectedItemsHCenter () |
void | alignSelectedItemsRight () |
void | alignSelectedItemsTop () |
void | alignSelectedItemsVCenter () |
void | alignSelectedItemsBottom () |
void | sortZList () |
Sorts the zList. | |
QPointF | snapPointToGrid (const QPointF &scenePoint) const |
Snaps a scene coordinate point to grid. | |
void | beginCommand (QgsComposerItem *item, const QString &commandText, QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown) |
Allocates new item command and saves initial state in it. | |
void | endCommand () |
Saves end state of item and pushes command to the undo history. | |
void | cancelCommand () |
Deletes current command. | |
Private Member Functions | |
QgsComposition () | |
void | updateZValues () |
Reset z-values of items based on position in z list. | |
int | boundingRectOfSelectedItems (QRectF &bRect) |
Returns the bounding rectangle of the selected items in scene coordinates. | |
void | loadGridAppearanceSettings () |
void | saveGridAppearanceSettings () |
Private Attributes | |
QgsMapRenderer * | mMapRenderer |
Pointer to map renderer of QGIS main map. | |
QgsComposition::PlotStyle | mPlotStyle |
QgsPaperItem * | mPaperItem |
QLinkedList< QgsComposerItem * > | mItemZList |
Maintains z-Order of items. | |
int | mPrintResolution |
Dpi for printout. | |
bool | mPrintAsRaster |
Flag if map should be printed as a raster (via QImage). | |
bool | mSnapToGrid |
Parameters for snap to grid function. | |
double | mSnapGridResolution |
double | mSnapGridOffsetX |
double | mSnapGridOffsetY |
QPen | mGridPen |
GridStyle | mGridStyle |
QUndoStack | mUndoStack |
QgsComposerItemCommand * | mActiveCommand |
Graphics scene for map printing.
The class manages the paper item which always is the item in the back (z-value 0). It maintains the z-Values of the items and stores them in a list in ascending z-Order. This list can be changed to lower/raise items one position or to bring them to front/back.
Definition at line 40 of file qgscomposition.h.
Style to draw the snapping grid.
Definition at line 54 of file qgscomposition.h.
QgsComposition::QgsComposition | ( | QgsMapRenderer * | mapRenderer | ) |
Definition at line 27 of file qgscomposition.cpp.
References loadGridAppearanceSettings(), mPaperItem, and mPrintResolution.
Definition at line 49 of file qgscomposition.cpp.
References mPaperItem.
QgsComposition::QgsComposition | ( | ) | [private] |
Definition at line 42 of file qgscomposition.cpp.
References loadGridAppearanceSettings().
void QgsComposition::addItemToZList | ( | QgsComposerItem * | item | ) |
Adds item to z list.
Usually called from constructor of QgsComposerItem
Definition at line 245 of file qgscomposition.cpp.
References mItemZList, and QgsDebugMsg.
Referenced by QgsComposerItem::QgsComposerItem().
Definition at line 527 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), mUndoStack, QgsComposerItemCommand::saveAfterState(), QgsComposerItemCommand::savePreviousState(), and selectedComposerItems().
Definition at line 406 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), mUndoStack, QgsComposerItemCommand::saveAfterState(), QgsComposerItemCommand::savePreviousState(), and selectedComposerItems().
Definition at line 375 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), mUndoStack, QgsComposerItemCommand::saveAfterState(), QgsComposerItemCommand::savePreviousState(), and selectedComposerItems().
Definition at line 437 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), mUndoStack, QgsComposerItemCommand::saveAfterState(), QgsComposerItemCommand::savePreviousState(), and selectedComposerItems().
Definition at line 468 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), mUndoStack, QgsComposerItemCommand::saveAfterState(), QgsComposerItemCommand::savePreviousState(), and selectedComposerItems().
Definition at line 498 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), mUndoStack, QgsComposerItemCommand::saveAfterState(), QgsComposerItemCommand::savePreviousState(), and selectedComposerItems().
void QgsComposition::beginCommand | ( | QgsComposerItem * | item, |
const QString & | commandText, | ||
QgsComposerMergeCommand::Context | c = QgsComposerMergeCommand::Unknown |
||
) |
Allocates new item command and saves initial state in it.
item | target item |
commandText | descriptive command text |
c | context for merge commands (unknown for non-mergeable commands) |
Definition at line 769 of file qgscomposition.cpp.
References mActiveCommand, QgsComposerItemCommand::savePreviousState(), and QgsComposerMergeCommand::Unknown.
Referenced by QgsComposerItem::beginCommand(), and QgsComposerView::mouseReleaseEvent().
int QgsComposition::boundingRectOfSelectedItems | ( | QRectF & | bRect | ) | [private] |
Returns the bounding rectangle of the selected items in scene coordinates.
Definition at line 618 of file qgscomposition.cpp.
References selectedComposerItems().
Referenced by alignSelectedItemsBottom(), alignSelectedItemsHCenter(), alignSelectedItemsLeft(), alignSelectedItemsRight(), alignSelectedItemsTop(), and alignSelectedItemsVCenter().
void QgsComposition::cancelCommand | ( | ) |
Deletes current command.
Definition at line 806 of file qgscomposition.cpp.
References mActiveCommand.
Referenced by QgsComposerItem::cancelCommand().
QgsComposerItem * QgsComposition::composerItemAt | ( | const QPointF & | position | ) |
Returns the topmost composer item.
Ignores mPaperItem
Definition at line 78 of file qgscomposition.cpp.
References mPaperItem.
Referenced by QgsComposerView::mousePressEvent(), and QgsComposerView::wheelEvent().
QList< const QgsComposerMap * > QgsComposition::composerMapItems | ( | ) | const |
Returns pointers to all composer maps in the scene.
Definition at line 113 of file qgscomposition.cpp.
Referenced by QgsComposerView::addComposerLegend(), QgsComposerView::addComposerScaleBar(), and QgsComposerMap::QgsComposerMap().
void QgsComposition::endCommand | ( | ) |
Saves end state of item and pushes command to the undo history.
Definition at line 789 of file qgscomposition.cpp.
References QgsComposerItemCommand::containsChange(), mActiveCommand, mUndoStack, and QgsComposerItemCommand::saveAfterState().
Referenced by QgsComposerItem::endCommand(), and QgsComposerView::mouseReleaseEvent().
const QgsComposerMap * QgsComposition::getComposerMapById | ( | int | id | ) | const |
Returns the composer map with specified id.
Definition at line 131 of file qgscomposition.cpp.
References QgsComposerMap::id().
Referenced by QgsComposerAttributeTable::readXML(), QgsComposerPicture::readXML(), QgsComposerLegend::readXML(), QgsComposerScaleBar::readXML(), and QgsComposerPicture::setRotationMap().
const QPen& QgsComposition::gridPen | ( | ) | const [inline] |
Definition at line 86 of file qgscomposition.h.
Referenced by QgsPaperItem::paint().
GridStyle QgsComposition::gridStyle | ( | ) | const [inline] |
Definition at line 89 of file qgscomposition.h.
Referenced by QgsPaperItem::paint().
void QgsComposition::loadGridAppearanceSettings | ( | ) | [private] |
Definition at line 714 of file qgscomposition.cpp.
References Crosses, Dots, mGridPen, mGridStyle, and Solid.
Referenced by QgsComposition().
void QgsComposition::lowerItem | ( | QgsComposerItem * | item | ) |
Definition at line 308 of file qgscomposition.cpp.
References mItemZList.
Referenced by lowerSelectedItems().
void QgsComposition::lowerSelectedItems | ( | ) |
Definition at line 294 of file qgscomposition.cpp.
References lowerItem(), selectedComposerItems(), and updateZValues().
QgsMapRenderer* QgsComposition::mapRenderer | ( | ) | [inline] |
Returns pointer to map renderer of qgis map canvas.
Definition at line 113 of file qgscomposition.h.
Referenced by QgsComposerLegend::layerIdList(), and QgsComposerMap::QgsComposerMap().
void QgsComposition::moveItemToBottom | ( | QgsComposerItem * | item | ) |
Definition at line 364 of file qgscomposition.cpp.
References mItemZList.
Referenced by moveSelectedItemsToBottom().
void QgsComposition::moveItemToTop | ( | QgsComposerItem * | item | ) |
Definition at line 339 of file qgscomposition.cpp.
References mItemZList.
Referenced by moveSelectedItemsToTop().
Definition at line 350 of file qgscomposition.cpp.
References moveItemToBottom(), selectedComposerItems(), and updateZValues().
Definition at line 324 of file qgscomposition.cpp.
References moveItemToTop(), selectedComposerItems(), and updateZValues().
double QgsComposition::paperHeight | ( | ) | const |
Returns height of paper item.
Definition at line 68 of file qgscomposition.cpp.
References mPaperItem.
Referenced by readXML().
void QgsComposition::paperSizeChanged | ( | ) | [signal] |
Referenced by setPaperSize().
double QgsComposition::paperWidth | ( | ) | const |
Returns width of paper item.
Definition at line 73 of file qgscomposition.cpp.
References mPaperItem.
Referenced by readXML().
int QgsComposition::pixelFontSize | ( | double | pointSize | ) | const |
Returns the pixel font size for a font that has point size set.
The result depends on the resolution (dpi) and of the preview mode. Each item that sets a font should call this function before drawing text
Definition at line 152 of file qgscomposition.cpp.
QgsComposition::PlotStyle QgsComposition::plotStyle | ( | ) | const [inline] |
Definition at line 115 of file qgscomposition.h.
Referenced by QgsComposerItemGroup::drawFrame(), QgsComposerItem::drawSelectionBoxes(), QgsComposerArrow::drawSVGMarker(), QgsPaperItem::paint(), and QgsComposerMap::paint().
double QgsComposition::pointFontSize | ( | int | pixelSize | ) | const |
Does the inverse calculation and returns points for pixels (equals to mm in QgsComposition)
Definition at line 159 of file qgscomposition.cpp.
bool QgsComposition::printAsRaster | ( | ) | const [inline] |
Definition at line 109 of file qgscomposition.h.
int QgsComposition::printResolution | ( | ) | const [inline] |
Definition at line 106 of file qgscomposition.h.
void QgsComposition::raiseItem | ( | QgsComposerItem * | item | ) |
Definition at line 279 of file qgscomposition.cpp.
References mItemZList.
Referenced by raiseSelectedItems().
void QgsComposition::raiseSelectedItems | ( | ) |
Definition at line 265 of file qgscomposition.cpp.
References raiseItem(), selectedComposerItems(), and updateZValues().
bool QgsComposition::readXML | ( | const QDomElement & | compositionElem, |
const QDomDocument & | doc | ||
) |
Reads settings from xml file.
Definition at line 200 of file qgscomposition.cpp.
References mPaperItem, mPrintAsRaster, mPrintResolution, mSnapGridOffsetX, mSnapGridOffsetY, mSnapGridResolution, mSnapToGrid, paperHeight(), and paperWidth().
void QgsComposition::removeItemFromZList | ( | QgsComposerItem * | item | ) |
Removes item from z list.
Usually called from destructor of QgsComposerItem
Definition at line 256 of file qgscomposition.cpp.
References mItemZList.
Referenced by QgsComposerItem::~QgsComposerItem().
void QgsComposition::saveGridAppearanceSettings | ( | ) | [private] |
Definition at line 746 of file qgscomposition.cpp.
References Crosses, Dots, mGridPen, mGridStyle, and Solid.
Referenced by setGridPen(), and setGridStyle().
QList< QgsComposerItem * > QgsComposition::selectedComposerItems | ( | ) |
Definition at line 94 of file qgscomposition.cpp.
Referenced by alignSelectedItemsBottom(), alignSelectedItemsHCenter(), alignSelectedItemsLeft(), alignSelectedItemsRight(), alignSelectedItemsTop(), alignSelectedItemsVCenter(), boundingRectOfSelectedItems(), QgsComposerView::groupItems(), QgsComposerView::keyPressEvent(), lowerSelectedItems(), moveSelectedItemsToBottom(), moveSelectedItemsToTop(), raiseSelectedItems(), and QgsComposerView::ungroupItems().
void QgsComposition::setGridPen | ( | const QPen & | p | ) |
Definition at line 694 of file qgscomposition.cpp.
References mGridPen, mPaperItem, and saveGridAppearanceSettings().
void QgsComposition::setGridStyle | ( | GridStyle | s | ) |
Definition at line 704 of file qgscomposition.cpp.
References mGridStyle, mPaperItem, and saveGridAppearanceSettings().
void QgsComposition::setPaperSize | ( | double | width, |
double | height | ||
) |
Changes size of paper item.
Definition at line 59 of file qgscomposition.cpp.
References mPaperItem, and paperSizeChanged().
void QgsComposition::setPlotStyle | ( | QgsComposition::PlotStyle | style | ) | [inline] |
Definition at line 116 of file qgscomposition.h.
void QgsComposition::setPrintAsRaster | ( | bool | enabled | ) | [inline] |
Definition at line 110 of file qgscomposition.h.
void QgsComposition::setPrintResolution | ( | int | dpi | ) | [inline] |
Definition at line 107 of file qgscomposition.h.
void QgsComposition::setSnapGridOffsetX | ( | double | offset | ) |
Definition at line 676 of file qgscomposition.cpp.
References mPaperItem, and mSnapGridOffsetX.
void QgsComposition::setSnapGridOffsetY | ( | double | offset | ) |
Definition at line 685 of file qgscomposition.cpp.
References mPaperItem, and mSnapGridOffsetY.
void QgsComposition::setSnapGridResolution | ( | double | r | ) |
Definition at line 667 of file qgscomposition.cpp.
References mPaperItem, and mSnapGridResolution.
void QgsComposition::setSnapToGridEnabled | ( | bool | b | ) |
Definition at line 658 of file qgscomposition.cpp.
References mPaperItem, and mSnapToGrid.
double QgsComposition::snapGridOffsetX | ( | ) | const [inline] |
Definition at line 80 of file qgscomposition.h.
Referenced by QgsPaperItem::paint().
double QgsComposition::snapGridOffsetY | ( | ) | const [inline] |
Definition at line 83 of file qgscomposition.h.
Referenced by QgsPaperItem::paint().
double QgsComposition::snapGridResolution | ( | ) | const [inline] |
Definition at line 77 of file qgscomposition.h.
Referenced by QgsPaperItem::paint().
QPointF QgsComposition::snapPointToGrid | ( | const QPointF & | scenePoint | ) | const |
Snaps a scene coordinate point to grid.
Definition at line 604 of file qgscomposition.cpp.
References mSnapGridOffsetX, mSnapGridOffsetY, mSnapGridResolution, and mSnapToGrid.
Referenced by QgsComposerItem::changeItemRectangle(), QgsComposerView::mousePressEvent(), and QgsComposerView::mouseReleaseEvent().
bool QgsComposition::snapToGridEnabled | ( | ) | const [inline] |
Definition at line 74 of file qgscomposition.h.
Referenced by QgsPaperItem::paint().
void QgsComposition::sortZList | ( | ) |
Sorts the zList.
The only time where this function needs to be called is from QgsComposer after reading all the items from xml file
Definition at line 578 of file qgscomposition.cpp.
References mItemZList.
QUndoStack* QgsComposition::undoStack | ( | ) | [inline] |
Returns pointer to undo/redo command storage.
Definition at line 92 of file qgscomposition.h.
Referenced by QgsComposerView::keyPressEvent(), and QgsComposerView::pushAddRemoveCommand().
void QgsComposition::updateZValues | ( | ) | [private] |
Reset z-values of items based on position in z list.
Definition at line 556 of file qgscomposition.cpp.
References mItemZList, mUndoStack, QgsComposerItemCommand::saveAfterState(), and QgsComposerItemCommand::savePreviousState().
Referenced by lowerSelectedItems(), moveSelectedItemsToBottom(), moveSelectedItemsToTop(), and raiseSelectedItems().
bool QgsComposition::writeXML | ( | QDomElement & | composerElem, |
QDomDocument & | doc | ||
) |
Writes settings to xml (paper dimension)
Definition at line 165 of file qgscomposition.cpp.
References mPaperItem, mPrintAsRaster, mPrintResolution, mSnapGridOffsetX, mSnapGridOffsetY, mSnapGridResolution, and mSnapToGrid.
Definition at line 199 of file qgscomposition.h.
Referenced by beginCommand(), cancelCommand(), and endCommand().
QPen QgsComposition::mGridPen [private] |
Definition at line 194 of file qgscomposition.h.
Referenced by loadGridAppearanceSettings(), saveGridAppearanceSettings(), and setGridPen().
GridStyle QgsComposition::mGridStyle [private] |
Definition at line 195 of file qgscomposition.h.
Referenced by loadGridAppearanceSettings(), saveGridAppearanceSettings(), and setGridStyle().
QLinkedList<QgsComposerItem*> QgsComposition::mItemZList [private] |
Maintains z-Order of items.
Starts with item at position 1 (position 0 is always paper item)
Definition at line 181 of file qgscomposition.h.
Referenced by addItemToZList(), lowerItem(), moveItemToBottom(), moveItemToTop(), raiseItem(), removeItemFromZList(), sortZList(), and updateZValues().
QgsMapRenderer* QgsComposition::mMapRenderer [private] |
Pointer to map renderer of QGIS main map.
Definition at line 176 of file qgscomposition.h.
QgsPaperItem* QgsComposition::mPaperItem [private] |
Definition at line 178 of file qgscomposition.h.
Referenced by composerItemAt(), paperHeight(), paperWidth(), QgsComposition(), readXML(), setGridPen(), setGridStyle(), setPaperSize(), setSnapGridOffsetX(), setSnapGridOffsetY(), setSnapGridResolution(), setSnapToGridEnabled(), writeXML(), and ~QgsComposition().
Definition at line 177 of file qgscomposition.h.
bool QgsComposition::mPrintAsRaster [private] |
Flag if map should be printed as a raster (via QImage).
False by default
Definition at line 187 of file qgscomposition.h.
Referenced by readXML(), and writeXML().
int QgsComposition::mPrintResolution [private] |
Dpi for printout.
Definition at line 184 of file qgscomposition.h.
Referenced by QgsComposition(), readXML(), and writeXML().
double QgsComposition::mSnapGridOffsetX [private] |
Definition at line 192 of file qgscomposition.h.
Referenced by readXML(), setSnapGridOffsetX(), snapPointToGrid(), and writeXML().
double QgsComposition::mSnapGridOffsetY [private] |
Definition at line 193 of file qgscomposition.h.
Referenced by readXML(), setSnapGridOffsetY(), snapPointToGrid(), and writeXML().
double QgsComposition::mSnapGridResolution [private] |
Definition at line 191 of file qgscomposition.h.
Referenced by readXML(), setSnapGridResolution(), snapPointToGrid(), and writeXML().
bool QgsComposition::mSnapToGrid [private] |
Parameters for snap to grid function.
Definition at line 190 of file qgscomposition.h.
Referenced by readXML(), setSnapToGridEnabled(), snapPointToGrid(), and writeXML().
QUndoStack QgsComposition::mUndoStack [private] |
Definition at line 197 of file qgscomposition.h.
Referenced by alignSelectedItemsBottom(), alignSelectedItemsHCenter(), alignSelectedItemsLeft(), alignSelectedItemsRight(), alignSelectedItemsTop(), alignSelectedItemsVCenter(), endCommand(), and updateZValues().