#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 |
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. | |
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 |
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 37 of file qgscomposition.h.
QgsComposition::QgsComposition | ( | QgsMapRenderer * | mapRenderer | ) |
Definition at line 27 of file qgscomposition.cpp.
References loadGridAppearanceSettings(), mPaperItem, mPrintAsRaster, and mPrintResolution.
QgsComposition::~QgsComposition | ( | ) |
QgsComposition::QgsComposition | ( | ) | [private] |
Definition at line 44 of file qgscomposition.cpp.
References loadGridAppearanceSettings(), and mPrintAsRaster.
void QgsComposition::setPaperSize | ( | double | width, | |
double | height | |||
) |
Changes size of paper item.
Definition at line 62 of file qgscomposition.cpp.
References mPaperItem, and paperSizeChanged().
double QgsComposition::paperHeight | ( | ) | const |
Returns height of paper item.
Definition at line 71 of file qgscomposition.cpp.
References mPaperItem.
Referenced by readXML().
double QgsComposition::paperWidth | ( | ) | const |
Returns width of paper item.
Definition at line 76 of file qgscomposition.cpp.
References mPaperItem.
Referenced by readXML().
void QgsComposition::setSnapToGridEnabled | ( | bool | b | ) |
bool QgsComposition::snapToGridEnabled | ( | ) | const [inline] |
void QgsComposition::setSnapGridResolution | ( | double | r | ) |
double QgsComposition::snapGridResolution | ( | ) | const [inline] |
void QgsComposition::setSnapGridOffsetX | ( | double | offset | ) |
double QgsComposition::snapGridOffsetX | ( | ) | const [inline] |
void QgsComposition::setSnapGridOffsetY | ( | double | offset | ) |
double QgsComposition::snapGridOffsetY | ( | ) | const [inline] |
void QgsComposition::setGridPen | ( | const QPen & | p | ) |
Definition at line 680 of file qgscomposition.cpp.
References mGridPen, mPaperItem, and saveGridAppearanceSettings().
const QPen& QgsComposition::gridPen | ( | ) | const [inline] |
void QgsComposition::setGridStyle | ( | GridStyle | s | ) |
Definition at line 690 of file qgscomposition.cpp.
References mGridStyle, mPaperItem, and saveGridAppearanceSettings().
GridStyle QgsComposition::gridStyle | ( | ) | const [inline] |
QgsComposerItem * QgsComposition::composerItemAt | ( | const QPointF & | position | ) |
Returns the topmost composer item.
Ignores mPaperItem
Definition at line 81 of file qgscomposition.cpp.
References mPaperItem.
Referenced by QgsComposerView::mousePressEvent(), and QgsComposerView::wheelEvent().
QList< QgsComposerItem * > QgsComposition::selectedComposerItems | ( | ) |
Definition at line 97 of file qgscomposition.cpp.
Referenced by alignSelectedItemsBottom(), alignSelectedItemsHCenter(), alignSelectedItemsLeft(), alignSelectedItemsRight(), alignSelectedItemsTop(), alignSelectedItemsVCenter(), boundingRectOfSelectedItems(), QgsComposerView::groupItems(), QgsComposerView::keyPressEvent(), lowerSelectedItems(), moveSelectedItemsToBottom(), moveSelectedItemsToTop(), raiseSelectedItems(), and QgsComposerView::ungroupItems().
QList< const QgsComposerMap * > QgsComposition::composerMapItems | ( | ) | const |
Returns pointers to all composer maps in the scene.
Definition at line 116 of file qgscomposition.cpp.
Referenced by QgsComposerView::addComposerScaleBar(), and QgsComposerMap::QgsComposerMap().
const QgsComposerMap * QgsComposition::getComposerMapById | ( | int | id | ) | const |
Returns the composer map with specified id.
Definition at line 134 of file qgscomposition.cpp.
References QgsComposerMap::id().
Referenced by QgsComposerScaleBar::readXML(), QgsComposerPicture::readXML(), QgsComposerAttributeTable::readXML(), and QgsComposerPicture::setRotationMap().
int QgsComposition::printResolution | ( | ) | const [inline] |
Definition at line 100 of file qgscomposition.h.
void QgsComposition::setPrintResolution | ( | int | dpi | ) | [inline] |
Definition at line 101 of file qgscomposition.h.
bool QgsComposition::printAsRaster | ( | ) | const [inline] |
Definition at line 103 of file qgscomposition.h.
void QgsComposition::setPrintAsRaster | ( | bool | enabled | ) |
QgsMapRenderer* QgsComposition::mapRenderer | ( | ) | [inline] |
Returns pointer to map renderer of qgis map canvas.
Definition at line 107 of file qgscomposition.h.
Referenced by QgsComposerLegend::layerIdList(), and QgsComposerMap::QgsComposerMap().
QgsComposition::PlotStyle QgsComposition::plotStyle | ( | ) | const [inline] |
Definition at line 109 of file qgscomposition.h.
Referenced by QgsComposerItemGroup::drawFrame(), QgsComposerItem::drawSelectionBoxes(), QgsComposerArrow::drawSVGMarker(), QgsPaperItem::paint(), QgsComposerPicture::paint(), and QgsComposerMap::paint().
void QgsComposition::setPlotStyle | ( | QgsComposition::PlotStyle | style | ) | [inline] |
Definition at line 110 of file qgscomposition.h.
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 155 of file qgscomposition.cpp.
double QgsComposition::pointFontSize | ( | int | pixelSize | ) | const |
Does the inverse calculation and returns points for pixels (equals to mm in QgsComposition).
Definition at line 162 of file qgscomposition.cpp.
bool QgsComposition::writeXML | ( | QDomElement & | composerElem, | |
QDomDocument & | doc | |||
) |
Writes settings to xml (paper dimension).
Definition at line 168 of file qgscomposition.cpp.
References mPaperItem, mPrintResolution, mSnapGridOffsetX, mSnapGridOffsetY, mSnapGridResolution, and mSnapToGrid.
bool QgsComposition::readXML | ( | const QDomElement & | compositionElem, | |
const QDomDocument & | doc | |||
) |
Reads settings from xml file.
Definition at line 202 of file qgscomposition.cpp.
References mPaperItem, mPrintResolution, mSnapGridOffsetX, mSnapGridOffsetY, mSnapGridResolution, mSnapToGrid, paperHeight(), and paperWidth().
void QgsComposition::addItemToZList | ( | QgsComposerItem * | item | ) |
Adds item to z list.
Usually called from constructor of QgsComposerItem
Definition at line 246 of file qgscomposition.cpp.
References mItemZList, and QgsDebugMsg.
Referenced by QgsComposerItem::QgsComposerItem().
void QgsComposition::removeItemFromZList | ( | QgsComposerItem * | item | ) |
Removes item from z list.
Usually called from destructor of QgsComposerItem
Definition at line 257 of file qgscomposition.cpp.
References mItemZList.
Referenced by QgsComposerItem::~QgsComposerItem().
void QgsComposition::raiseSelectedItems | ( | ) |
Definition at line 266 of file qgscomposition.cpp.
References raiseItem(), selectedComposerItems(), and updateZValues().
void QgsComposition::raiseItem | ( | QgsComposerItem * | item | ) |
Definition at line 280 of file qgscomposition.cpp.
References mItemZList.
Referenced by raiseSelectedItems().
void QgsComposition::lowerSelectedItems | ( | ) |
Definition at line 295 of file qgscomposition.cpp.
References lowerItem(), selectedComposerItems(), and updateZValues().
void QgsComposition::lowerItem | ( | QgsComposerItem * | item | ) |
Definition at line 309 of file qgscomposition.cpp.
References mItemZList.
Referenced by lowerSelectedItems().
void QgsComposition::moveSelectedItemsToTop | ( | ) |
Definition at line 325 of file qgscomposition.cpp.
References moveItemToTop(), selectedComposerItems(), and updateZValues().
void QgsComposition::moveItemToTop | ( | QgsComposerItem * | item | ) |
Definition at line 339 of file qgscomposition.cpp.
References mItemZList.
Referenced by moveSelectedItemsToTop().
void QgsComposition::moveSelectedItemsToBottom | ( | ) |
Definition at line 350 of file qgscomposition.cpp.
References moveItemToBottom(), selectedComposerItems(), and updateZValues().
void QgsComposition::moveItemToBottom | ( | QgsComposerItem * | item | ) |
Definition at line 364 of file qgscomposition.cpp.
References mItemZList.
Referenced by moveSelectedItemsToBottom().
void QgsComposition::alignSelectedItemsLeft | ( | ) |
Definition at line 375 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), and selectedComposerItems().
void QgsComposition::alignSelectedItemsHCenter | ( | ) |
Definition at line 401 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), and selectedComposerItems().
void QgsComposition::alignSelectedItemsRight | ( | ) |
Definition at line 427 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), and selectedComposerItems().
void QgsComposition::alignSelectedItemsTop | ( | ) |
Definition at line 453 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), and selectedComposerItems().
void QgsComposition::alignSelectedItemsVCenter | ( | ) |
Definition at line 477 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), and selectedComposerItems().
void QgsComposition::alignSelectedItemsBottom | ( | ) |
Definition at line 501 of file qgscomposition.cpp.
References boundingRectOfSelectedItems(), and selectedComposerItems().
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 543 of file qgscomposition.cpp.
References mItemZList, and QgsDebugMsg.
QPointF QgsComposition::snapPointToGrid | ( | const QPointF & | scenePoint | ) | const |
Snaps a scene coordinate point to grid.
Definition at line 590 of file qgscomposition.cpp.
References mSnapGridOffsetX, mSnapGridOffsetY, mSnapGridResolution, and mSnapToGrid.
Referenced by QgsComposerItem::changeItemRectangle(), QgsComposerView::mousePressEvent(), and QgsComposerView::mouseReleaseEvent().
void QgsComposition::updateZValues | ( | ) | [private] |
Reset z-values of items based on position in z list.
Definition at line 525 of file qgscomposition.cpp.
References mItemZList, and QgsDebugMsg.
Referenced by lowerSelectedItems(), moveSelectedItemsToBottom(), moveSelectedItemsToTop(), and raiseSelectedItems().
int QgsComposition::boundingRectOfSelectedItems | ( | QRectF & | bRect | ) | [private] |
Returns the bounding rectangle of the selected items in scene coordinates.
Definition at line 604 of file qgscomposition.cpp.
References selectedComposerItems().
Referenced by alignSelectedItemsBottom(), alignSelectedItemsHCenter(), alignSelectedItemsLeft(), alignSelectedItemsRight(), alignSelectedItemsTop(), and alignSelectedItemsVCenter().
void QgsComposition::loadGridAppearanceSettings | ( | ) | [private] |
Definition at line 707 of file qgscomposition.cpp.
References Crosses, Dots, mGridPen, mGridStyle, and Solid.
Referenced by QgsComposition().
void QgsComposition::saveGridAppearanceSettings | ( | ) | [private] |
Definition at line 739 of file qgscomposition.cpp.
References Crosses, Dots, mGridPen, mGridStyle, and Solid.
Referenced by setGridPen(), and setGridStyle().
void QgsComposition::paperSizeChanged | ( | ) | [signal] |
Referenced by setPaperSize().
QgsMapRenderer* QgsComposition::mMapRenderer [private] |
Definition at line 160 of file qgscomposition.h.
QgsPaperItem* QgsComposition::mPaperItem [private] |
Definition at line 161 of file qgscomposition.h.
Referenced by composerItemAt(), paperHeight(), paperWidth(), QgsComposition(), readXML(), setGridPen(), setGridStyle(), setPaperSize(), setSnapGridOffsetX(), setSnapGridOffsetY(), setSnapGridResolution(), setSnapToGridEnabled(), writeXML(), and ~QgsComposition().
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 164 of file qgscomposition.h.
Referenced by addItemToZList(), lowerItem(), moveItemToBottom(), moveItemToTop(), raiseItem(), removeItemFromZList(), sortZList(), and updateZValues().
int QgsComposition::mPrintResolution [private] |
Dpi for printout.
Definition at line 167 of file qgscomposition.h.
Referenced by QgsComposition(), readXML(), and writeXML().
bool QgsComposition::mPrintAsRaster [private] |
Flag if map should be printed as a raster (via QImage).
False by default
Definition at line 170 of file qgscomposition.h.
Referenced by QgsComposition(), and setPrintAsRaster().
bool QgsComposition::mSnapToGrid [private] |
Parameters for snap to grid function.
Definition at line 173 of file qgscomposition.h.
Referenced by readXML(), setSnapToGridEnabled(), snapPointToGrid(), and writeXML().
double QgsComposition::mSnapGridResolution [private] |
Definition at line 174 of file qgscomposition.h.
Referenced by readXML(), setSnapGridResolution(), snapPointToGrid(), and writeXML().
double QgsComposition::mSnapGridOffsetX [private] |
Definition at line 175 of file qgscomposition.h.
Referenced by readXML(), setSnapGridOffsetX(), snapPointToGrid(), and writeXML().
double QgsComposition::mSnapGridOffsetY [private] |
Definition at line 176 of file qgscomposition.h.
Referenced by readXML(), setSnapGridOffsetY(), snapPointToGrid(), and writeXML().
QPen QgsComposition::mGridPen [private] |
Definition at line 177 of file qgscomposition.h.
Referenced by loadGridAppearanceSettings(), saveGridAppearanceSettings(), and setGridPen().
GridStyle QgsComposition::mGridStyle [private] |
Definition at line 178 of file qgscomposition.h.
Referenced by loadGridAppearanceSettings(), saveGridAppearanceSettings(), and setGridStyle().