QGIS API Documentation  2.5.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
QgsComposition Class Reference

Graphics scene for map printing. More...

#include <qgscomposition.h>

Inheritance diagram for QgsComposition:
Inheritance graph
[legend]
Collaboration diagram for QgsComposition:
Collaboration graph
[legend]

Public Types

enum  PlotStyle { Preview = 0, Print, Postscript }
 Plot type. More...
 
enum  GridStyle { Solid, Dots, Crosses }
 Style to draw the snapping grid. More...
 
enum  ZValueDirection { ZValueBelow, ZValueAbove }
 
enum  PaperOrientation { Portrait, Landscape }
 
enum  AtlasMode { AtlasOff, PreviewAtlas, ExportAtlas }
 Composition atlas modes. More...
 

Public Slots

void sendItemAddedSignal (QgsComposerItem *item)
 Casts object to the proper subclass type and calls corresponding itemAdded signal. More...
 
void updateBounds ()
 Updates the scene bounds of the composition. More...
 
void refreshItems ()
 Forces items in the composition to refresh. More...
 
void setSelectedItem (QgsComposerItem *item)
 Clears any selected items and sets an item as the current selection. More...
 
void refreshDataDefinedProperty (const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties)
 Refreshes a data defined property for the composition by reevaluating the property's value and redrawing the composition with this new value. More...
 

Signals

void paperSizeChanged ()
 
void nPagesChanged ()
 
void printResolutionChanged ()
 Is emitted when the compositions print resolution changes. More...
 
void selectedItemChanged (QgsComposerItem *selected)
 Is emitted when selected item changed. More...
 
void composerArrowAdded (QgsComposerArrow *arrow)
 Is emitted when new composer arrow has been added to the view. More...
 
void composerHtmlFrameAdded (QgsComposerHtml *html, QgsComposerFrame *frame)
 Is emitted when a new composer html has been added to the view. More...
 
void composerLabelAdded (QgsComposerLabel *label)
 Is emitted when new composer label has been added to the view. More...
 
void composerMapAdded (QgsComposerMap *map)
 Is emitted when new composer map has been added to the view. More...
 
void composerScaleBarAdded (QgsComposerScaleBar *scalebar)
 Is emitted when new composer scale bar has been added. More...
 
void composerLegendAdded (QgsComposerLegend *legend)
 Is emitted when a new composer legend has been added. More...
 
void composerPictureAdded (QgsComposerPicture *picture)
 Is emitted when a new composer picture has been added. More...
 
void composerShapeAdded (QgsComposerShape *shape)
 Is emitted when a new composer shape has been added. More...
 
void composerTableAdded (QgsComposerAttributeTable *table)
 Is emitted when a new composer table has been added. More...
 
void itemRemoved (QgsComposerItem *)
 Is emitted when a composer item has been removed from the scene. More...
 
void refreshItemsTriggered ()
 Is emitted when item in the composition must be refreshed. More...
 
void statusMsgChanged (QString message)
 Is emitted when the composition has an updated status bar message for the composer window. More...
 

Public Member Functions

Q_DECL_DEPRECATED QgsComposition (QgsMapRenderer *mapRenderer)
 
 QgsComposition (const QgsMapSettings &mapSettings)
 
 ~QgsComposition ()
 
void setPaperSize (const double width, const double height)
 Changes size of paper item. More...
 
double paperHeight () const
 Returns height of paper item. More...
 
double paperWidth () const
 Returns width of paper item. More...
 
double spaceBetweenPages () const
 
void setNumPages (const int pages)
 Note: added in version 1.9. More...
 
int numPages () const
 Note: added in version 1.9. More...
 
void setPageStyleSymbol (QgsFillSymbolV2 *symbol)
 Note: added in version 2.1. More...
 
QgsFillSymbolV2pageStyleSymbol ()
 Note: added in version 2.1. More...
 
QPointF positionOnPage (const QPointF &position) const
 Returns the position within a page of a point in the composition. More...
 
int pageNumberForPoint (const QPointF &position) const
 Returns the page number corresponding to a point in the composition. More...
 
void setStatusMessage (const QString &message)
 Sets the status bar message for the composer window. More...
 
void updateSettings ()
 Refreshes the composition when composer related options change Note: added in version 2.1. More...
 
void setSnapToGridEnabled (const bool b)
 
bool snapToGridEnabled () const
 
void setGridVisible (const bool b)
 
bool gridVisible () const
 
void setSnapLinesVisible (const bool visible)
 Hides / shows custom snap lines. More...
 
bool snapLinesVisible () const
 
void setAlignmentSnap (const bool s)
 
bool alignmentSnap () const
 
void setSmartGuidesEnabled (const bool b)
 
bool smartGuidesEnabled () const
 
void clearSnapLines ()
 Removes all snap lines. More...
 
void setSnapGridResolution (const double r)
 
double snapGridResolution () const
 
void setSnapGridOffsetX (const double offset)
 
double snapGridOffsetX () const
 
void setSnapGridOffsetY (const double offset)
 
double snapGridOffsetY () const
 
void setGridPen (const QPen &p)
 
const QPen & gridPen () const
 
void setGridStyle (const GridStyle s)
 
GridStyle gridStyle () const
 
Q_DECL_DEPRECATED void setSnapGridTolerance (double tolerance)
 Sets the snap tolerance to use when automatically snapping items during movement and resizing to the composition grid. More...
 
Q_DECL_DEPRECATED double snapGridTolerance () const
 Returns the snap tolerance to use when automatically snapping items during movement and resizing to the composition grid. More...
 
Q_DECL_DEPRECATED void setAlignmentSnapTolerance (double t)
 Sets the snap tolerance to use when automatically snapping items during movement and resizing to guides and the edges and centers of other items. More...
 
Q_DECL_DEPRECATED double alignmentSnapTolerance () const
 Returns the snap tolerance to use when automatically snapping items during movement and resizing to guides and the edges and centers of other items. More...
 
void setSnapTolerance (const int snapTolerance)
 Sets the snap tolerance to use when automatically snapping items during movement and resizing to guides and the edges and centers of other items. More...
 
int snapTolerance () const
 Returns the snap tolerance to use when automatically snapping items during movement and resizing to guides and the edges and centers of other items. More...
 
QUndoStack * undoStack ()
 Returns pointer to undo/redo command storage. More...
 
QgsComposerItemcomposerItemAt (const QPointF &position) const
 Returns the topmost composer item. More...
 
QgsComposerItemcomposerItemAt (const QPointF &position, const QgsComposerItem *belowItem) const
 Returns the highest composer item at a specified position which is below a specified item. More...
 
int pageNumberAt (const QPointF &position) const
 Returns the page number (0-based) given a coordinate. More...
 
int itemPageNumber (const QgsComposerItem *) const
 Returns on which page number (0-based) is displayed an item. More...
 
QList< QgsComposerItem * > selectedComposerItems ()
 
QList< const QgsComposerMap * > composerMapItems () const
 Returns pointers to all composer maps in the scene. More...
 
template<class T >
void composerItems (QList< T * > &itemList)
 Return composer items of a specific type. More...
 
const QgsComposerMapgetComposerMapById (const int id) const
 Returns the composer map with specified id. More...
 
Q_DECL_DEPRECATED const
QgsComposerHtml
getComposerHtmlByItem (QgsComposerItem *item) const
 Returns the composer html with specified id (a string as named in the composer user interface item properties). More...
 
const QgsComposerItemgetComposerItemById (const QString theId) const
 Returns a composer item given its text identifier. More...
 
const QgsComposerItemgetComposerItemByUuid (const QString theUuid) const
 Returns a composer item given its unique identifier. More...
 
int printResolution () const
 
void setPrintResolution (const int dpi)
 
bool printAsRaster () const
 
void setPrintAsRaster (const bool enabled)
 
bool generateWorldFile () const
 
void setGenerateWorldFile (const bool enabled)
 
QgsComposerMapworldFileMap () const
 
void setWorldFileMap (QgsComposerMap *map)
 
bool useAdvancedEffects () const
 Returns true if a composition should use advanced effects such as blend modes. More...
 
void setUseAdvancedEffects (const bool effectsEnabled)
 Used to enable or disable advanced effects such as blend modes in a composition. More...
 
Q_DECL_DEPRECATED QgsMapRenderermapRenderer ()
 Returns pointer to map renderer of qgis map canvas. More...
 
const QgsMapSettingsmapSettings () const
 Return setting of QGIS map canvas. More...
 
QgsComposition::PlotStyle plotStyle () const
 
void setPlotStyle (const QgsComposition::PlotStyle style)
 
Q_DECL_DEPRECATED int pixelFontSize (double pointSize) const
 Returns the mm font size for a font that has point size set. More...
 
Q_DECL_DEPRECATED double pointFontSize (int pixelSize) const
 Does the inverse calculation and returns points for mm. More...
 
bool writeXML (QDomElement &composerElem, QDomDocument &doc)
 Writes settings to xml (paper dimension) More...
 
bool readXML (const QDomElement &compositionElem, const QDomDocument &doc)
 Reads settings from xml file. More...
 
bool loadFromTemplate (const QDomDocument &doc, QMap< QString, QString > *substitutionMap=0, bool addUndoCommands=false)
 Load a template document. More...
 
void addItemsFromXML (const QDomElement &elem, const QDomDocument &doc, QMap< QgsComposerMap *, int > *mapsToRestore=0, bool addUndoCommands=false, QPointF *pos=0, bool pasteInPlace=false)
 Add items from XML representation to the graphics scene (for project file reading, pasting items from clipboard) More...
 
void addItemToZList (QgsComposerItem *item)
 Adds item to z list. More...
 
void removeItemFromZList (QgsComposerItem *item)
 Removes item from z list. More...
 
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 selectNextByZOrder (const ZValueDirection direction)
 
QgsComposerItemgetComposerItemBelow (QgsComposerItem *item) const
 
QgsComposerItemgetComposerItemAbove (QgsComposerItem *item) const
 
void alignSelectedItemsLeft ()
 
void alignSelectedItemsHCenter ()
 
void alignSelectedItemsRight ()
 
void alignSelectedItemsTop ()
 
void alignSelectedItemsVCenter ()
 
void alignSelectedItemsBottom ()
 
void lockSelectedItems ()
 Lock the selected items. More...
 
void unlockAllItems ()
 Unlock all items. More...
 
void sortZList ()
 Sorts the zList. More...
 
void refreshZList ()
 Rebuilds the z order list based on current order of items in scene. More...
 
QPointF snapPointToGrid (const QPointF &scenePoint) const
 Snaps a scene coordinate point to grid. More...
 
QList< QGraphicsLineItem * > * snapLines ()
 Returns pointer to snap lines collection. More...
 
QgsComposerMouseHandlesselectionHandles ()
 Returns pointer to selection handles. More...
 
QGraphicsLineItem * addSnapLine ()
 Add a custom snap line (can be horizontal or vertical) More...
 
void removeSnapLine (QGraphicsLineItem *line)
 Remove custom snap line (and delete the object) More...
 
QGraphicsLineItem * nearestSnapLine (const bool horizontal, const double x, const double y, const double tolerance, QList< QPair< QgsComposerItem *, QgsComposerItem::ItemPositionMode > > &snappedItems) const
 Get nearest snap line. More...
 
void beginCommand (QgsComposerItem *item, const QString &commandText, const QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
 Allocates new item command and saves initial state in it. More...
 
void endCommand ()
 Saves end state of item and pushes command to the undo history. More...
 
void cancelCommand ()
 Deletes current command. More...
 
void beginMultiFrameCommand (QgsComposerMultiFrame *multiFrame, const QString &text, const QgsComposerMultiFrameMergeCommand::Context c=QgsComposerMultiFrameMergeCommand::Unknown)
 
void endMultiFrameCommand ()
 
void addMultiFrame (QgsComposerMultiFrame *multiFrame)
 Adds multiframe. More...
 
void removeMultiFrame (QgsComposerMultiFrame *multiFrame)
 Removes multi frame (but does not delete it) More...
 
void addComposerArrow (QgsComposerArrow *arrow)
 Adds an arrow item to the graphics scene and advices composer to create a widget for it (through signal) More...
 
void addComposerLabel (QgsComposerLabel *label)
 Adds label to the graphics scene and advices composer to create a widget for it (through signal) More...
 
void addComposerMap (QgsComposerMap *map, const bool setDefaultPreviewStyle=true)
 Adds map to the graphics scene and advices composer to create a widget for it (through signal) More...
 
void addComposerScaleBar (QgsComposerScaleBar *scaleBar)
 Adds scale bar to the graphics scene and advices composer to create a widget for it (through signal) More...
 
void addComposerLegend (QgsComposerLegend *legend)
 Adds legend to the graphics scene and advices composer to create a widget for it (through signal) More...
 
void addComposerPicture (QgsComposerPicture *picture)
 Adds picture to the graphics scene and advices composer to create a widget for it (through signal) More...
 
void addComposerShape (QgsComposerShape *shape)
 Adds a composer shape to the graphics scene and advices composer to create a widget for it (through signal) More...
 
void addComposerTable (QgsComposerAttributeTable *table)
 Adds a composer table to the graphics scene and advices composer to create a widget for it (through signal) More...
 
void addComposerHtmlFrame (QgsComposerHtml *html, QgsComposerFrame *frame)
 Adds composer html frame and advices composer to create a widget for it (through signal) More...
 
void removeComposerItem (QgsComposerItem *item, const bool createCommand=true)
 Remove item from the graphics scene. More...
 
void pushAddRemoveCommand (QgsComposerItem *item, const QString &text, const QgsAddRemoveItemCommand::State state=QgsAddRemoveItemCommand::Added)
 Convenience function to create a QgsAddRemoveItemCommand, connect its signals and push it to the undo stack. More...
 
void setPreventCursorChange (const bool preventChange)
 If true, prevents any mouse cursor changes by the composition or by any composer items Used by QgsComposer and QgsComposerView to prevent unwanted cursor changes. More...
 
bool preventCursorChange () const
 
void beginPrint (QPrinter &printer)
 Prepare the printer for printing. More...
 
void beginPrintAsPDF (QPrinter &printer, const QString &file)
 Prepare the printer for printing in a PDF. More...
 
void doPrint (QPrinter &printer, QPainter &painter, bool startNewPage=false)
 Print on a preconfigured printer. More...
 
bool print (QPrinter &printer)
 Convenience function that prepares the printer and prints. More...
 
bool exportAsPDF (const QString &file)
 Convenience function that prepares the printer for printing in PDF and prints. More...
 
QImage printPageAsRaster (int page)
 print composer page to image If the image does not fit into memory, a null image is returned More...
 
void renderPage (QPainter *p, int page)
 Render a page to a paint device. More...
 
void computeWorldFileParameters (double &a, double &b, double &c, double &d, double &e, double &f) const
 Compute world file parameters. More...
 
QgsAtlasCompositionatlasComposition ()
 
QgsComposition::AtlasMode atlasMode () const
 Returns the current atlas mode of the composition. More...
 
bool setAtlasMode (const QgsComposition::AtlasMode mode)
 Sets the current atlas mode of the composition. More...
 
QList< QgsPaperItem * > pages ()
 Return pages in the correct order. More...
 
QgsDataDefineddataDefinedProperty (const QgsComposerObject::DataDefinedProperty property)
 Returns a reference to the data defined settings for one of the composition's data defined properties. More...
 
void setDataDefinedProperty (const QgsComposerObject::DataDefinedProperty property, bool active, bool useExpression, const QString &expression, const QString &field)
 Sets parameters for a data defined property for the composition. More...
 

Static Public Member Functions

static Q_DECL_DEPRECATED void relativeResizeRect (QRectF &rectToResize, const QRectF &boundsBefore, const QRectF &boundsAfter)
 Resizes a QRectF relative to the change from boundsBefore to boundsAfter. More...
 
static Q_DECL_DEPRECATED double relativePosition (double position, double beforeMin, double beforeMax, double afterMin, double afterMax)
 Returns a scaled position given a before and after range. More...
 

Protected Member Functions

void init ()
 

Private Slots

void prepareAllDataDefinedExpressions ()
 

Private Member Functions

void createDefaultPageStyleSymbol ()
 
 QgsComposition ()
 
QRectF compositionBounds () const
 Calculates the bounds of all non-gui items in the composition. More...
 
void updateZValues (const bool addUndoCommands=true)
 Reset z-values of items based on position in z list. More...
 
int boundingRectOfSelectedItems (QRectF &bRect)
 Returns the bounding rectangle of the selected items in scene coordinates. More...
 
void loadDefaults ()
 Loads default composer settings. More...
 
void loadSettings ()
 Loads composer settings which may change, eg grid color. More...
 
QPointF minPointFromXml (const QDomElement &elem) const
 Calculates the item minimum position from an xml string. More...
 
void connectAddRemoveCommandSignals (QgsAddRemoveItemCommand *c)
 
void updatePaperItems ()
 
void addPaperItem ()
 
void removePaperItems ()
 
void deleteAndRemoveMultiFrames ()
 
QGraphicsView * graphicsView () const
 
void refreshPageSize ()
 
bool dataDefinedEvaluate (QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue, QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *dataDefinedProperties)
 Evaluate a data defined property and return the calculated value. More...
 
QVariant dataDefinedValue (QgsComposerObject::DataDefinedProperty property, const QgsFeature *feature, const QgsFields *fields, QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *dataDefinedProperties)
 Evaluates a data defined property and returns the calculated value. More...
 
void prepareDataDefinedExpression (QgsDataDefined *dd, QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *dataDefinedProperties) const
 Prepares the expression for a data defined property, using the current atlas layer if set. More...
 

Static Private Member Functions

static QString encodeStringForXML (const QString &str)
 

Private Attributes

QgsMapRenderermMapRenderer
 Pointer to map renderer of QGIS main map. More...
 
const QgsMapSettingsmMapSettings
 
QgsComposition::PlotStyle mPlotStyle
 
double mPageWidth
 
double mPageHeight
 
QList< QgsPaperItem * > mPages
 
double mSpaceBetweenPages
 
QgsFillSymbolV2mPageStyleSymbol
 Drawing style for page. More...
 
QLinkedList< QgsComposerItem * > mItemZList
 Maintains z-Order of items. More...
 
QSet< QgsComposerMultiFrame * > mMultiFrames
 List multiframe objects. More...
 
int mPrintResolution
 Dpi for printout. More...
 
bool mPrintAsRaster
 Flag if map should be printed as a raster (via QImage). More...
 
bool mGenerateWorldFile
 Flag if a world file should be generated on raster export. More...
 
QgsComposerMapmWorldFileMap
 Composer map to use for the world file generation. More...
 
bool mUseAdvancedEffects
 Flag if advanced visual effects such as blend modes should be used. More...
 
bool mSnapToGrid
 Parameters for snap to grid function. More...
 
bool mGridVisible
 
double mSnapGridResolution
 
double mSnapGridOffsetX
 
double mSnapGridOffsetY
 
QPen mGridPen
 
GridStyle mGridStyle
 
bool mAlignmentSnap
 Parameters for alignment snap. More...
 
bool mGuidesVisible
 
bool mSmartGuides
 
int mSnapTolerance
 
QList< QGraphicsLineItem * > mSnapLines
 Arbitraty snap lines (horizontal and vertical) More...
 
QgsComposerMouseHandlesmSelectionHandles
 
QUndoStack mUndoStack
 
QgsComposerItemCommandmActiveItemCommand
 
QgsComposerMultiFrameCommandmActiveMultiFrameCommand
 
QgsAtlasComposition mAtlasComposition
 The atlas composition object. More...
 
QgsComposition::AtlasMode mAtlasMode
 
bool mPreventCursorChange
 
QMap
< QgsComposerObject::DataDefinedProperty,
QString > 
mDataDefinedNames
 Map of data defined properties for the composition to string name to use when exporting composition to xml. More...
 
QMap
< QgsComposerObject::DataDefinedProperty,
QgsDataDefined * > 
mDataDefinedProperties
 Map of current data defined properties to QgsDataDefined for the composition. More...
 

Friends

class QgsComposerObject
 

Detailed Description

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 69 of file qgscomposition.h.

Member Enumeration Documentation

Composition atlas modes.

Enumerator
AtlasOff 
PreviewAtlas 
ExportAtlas 

Definition at line 107 of file qgscomposition.h.

Style to draw the snapping grid.

Enumerator
Solid 
Dots 
Crosses 

Definition at line 83 of file qgscomposition.h.

Enumerator
Portrait 
Landscape 

Definition at line 96 of file qgscomposition.h.

Plot type.

Enumerator
Preview 
Print 
Postscript 

Definition at line 75 of file qgscomposition.h.

Enumerator
ZValueBelow 
ZValueAbove 

Definition at line 90 of file qgscomposition.h.

Constructor & Destructor Documentation

QgsComposition::QgsComposition ( QgsMapRenderer mapRenderer)
Deprecated:
since 2.4 - use the constructor with QgsMapSettings

Definition at line 57 of file qgscomposition.cpp.

References init().

QgsComposition::QgsComposition ( const QgsMapSettings mapSettings)
explicit

Definition at line 66 of file qgscomposition.cpp.

References init().

QgsComposition::~QgsComposition ( )
QgsComposition::QgsComposition ( )
private

Member Function Documentation

void QgsComposition::addComposerArrow ( QgsComposerArrow arrow)

Adds an arrow item to the graphics scene and advices composer to create a widget for it (through signal)

Note
not available in python bindings

Definition at line 2191 of file qgscomposition.cpp.

References composerArrowAdded(), and updateBounds().

Referenced by addItemsFromXML(), and QgsComposerView::mouseReleaseEvent().

void QgsComposition::addComposerHtmlFrame ( QgsComposerHtml html,
QgsComposerFrame frame 
)

Adds composer html frame and advices composer to create a widget for it (through signal)

Definition at line 2281 of file qgscomposition.cpp.

References composerHtmlFrameAdded(), and updateBounds().

Referenced by QgsComposerHtml::addFrame().

void QgsComposition::addComposerLabel ( QgsComposerLabel label)

Adds label to the graphics scene and advices composer to create a widget for it (through signal)

Definition at line 2201 of file qgscomposition.cpp.

References composerLabelAdded(), and updateBounds().

Referenced by addItemsFromXML(), and QgsComposerView::mouseReleaseEvent().

void QgsComposition::addComposerLegend ( QgsComposerLegend legend)

Adds legend to the graphics scene and advices composer to create a widget for it (through signal)

Definition at line 2241 of file qgscomposition.cpp.

References composerLegendAdded(), and updateBounds().

Referenced by addItemsFromXML(), and QgsComposerView::mouseReleaseEvent().

void QgsComposition::addComposerMap ( QgsComposerMap map,
const bool  setDefaultPreviewStyle = true 
)

Adds map to the graphics scene and advices composer to create a widget for it (through signal)

Definition at line 2211 of file qgscomposition.cpp.

References QgsComposerMap::Cache, QgsComposerMap::cache(), composerMapAdded(), QgsComposerMap::previewMode(), QgsComposerMap::Rectangle, QgsComposerMap::setPreviewMode(), and updateBounds().

Referenced by addItemsFromXML(), and QgsComposerView::mouseReleaseEvent().

void QgsComposition::addComposerPicture ( QgsComposerPicture picture)

Adds picture to the graphics scene and advices composer to create a widget for it (through signal)

Definition at line 2251 of file qgscomposition.cpp.

References composerPictureAdded(), and updateBounds().

Referenced by addItemsFromXML(), and QgsComposerView::mouseReleaseEvent().

void QgsComposition::addComposerScaleBar ( QgsComposerScaleBar scaleBar)

Adds scale bar to the graphics scene and advices composer to create a widget for it (through signal)

Definition at line 2231 of file qgscomposition.cpp.

References composerScaleBarAdded(), and updateBounds().

Referenced by addItemsFromXML(), and QgsComposerView::mousePressEvent().

void QgsComposition::addComposerShape ( QgsComposerShape shape)

Adds a composer shape to the graphics scene and advices composer to create a widget for it (through signal)

Definition at line 2261 of file qgscomposition.cpp.

References composerShapeAdded(), and updateBounds().

Referenced by addItemsFromXML(), and QgsComposerView::addShape().

void QgsComposition::addComposerTable ( QgsComposerAttributeTable table)

Adds a composer table to the graphics scene and advices composer to create a widget for it (through signal)

Definition at line 2271 of file qgscomposition.cpp.

References composerTableAdded(), and updateBounds().

Referenced by addItemsFromXML(), and QgsComposerView::mouseReleaseEvent().

void QgsComposition::addItemsFromXML ( const QDomElement &  elem,
const QDomDocument &  doc,
QMap< QgsComposerMap *, int > *  mapsToRestore = 0,
bool  addUndoCommands = false,
QPointF *  pos = 0,
bool  pasteInPlace = false 
)

Add items from XML representation to the graphics scene (for project file reading, pasting items from clipboard)

Parameters
elemitems parent element, e.g.
<Composer> 
or
<ComposerItemClipboard> 
docxml document
mapsToRestorefor reading from project file: set preview move 'rectangle' to all maps and save the preview states to show composer maps on demand
addUndoCommandsinsert AddItem commands if true (e.g. for copy/paste)
positem position. Optional, take position from xml if 0
pasteInPlacewhether the position should be kept but mapped to the page origin. (the page is the page under to the mouse cursor)
Note
not available in python bindings

Definition at line 936 of file qgscomposition.cpp.

References addComposerArrow(), addComposerLabel(), addComposerLegend(), addComposerMap(), addComposerPicture(), addComposerScaleBar(), addComposerShape(), addComposerTable(), addMultiFrame(), QgsComposerMap::assignFreeId(), composerItems(), QgsComposerMap::mapOverviews(), minPointFromXml(), mItemZList, QgsComposerItem::move(), mPageHeight, mSpaceBetweenPages, pageNumberAt(), paperHeight(), QgsComposerMap::previewMode(), pushAddRemoveCommand(), QgsComposerItemGroup::readXML(), QgsComposerShape::readXML(), QgsComposerAttributeTable::readXML(), QgsComposerArrow::readXML(), QgsComposerPicture::readXML(), QgsComposerLabel::readXML(), QgsComposerHtml::readXML(), QgsComposerLegend::readXML(), QgsComposerScaleBar::readXML(), QgsComposerMap::readXML(), QgsComposerMap::Rectangle, refreshZList(), selectedItemChanged(), QgsComposerMultiFrame::setCreateUndoCommands(), QgsComposerItem::setItemPosition(), QgsComposerMap::setPreviewMode(), QgsComposerItem::setSelected(), QgsComposerMap::setUpdatesEnabled(), QgsComposerShape::setUseSymbolV2(), spaceBetweenPages(), and tr.

Referenced by loadFromTemplate(), and QgsComposerView::pasteItems().

void QgsComposition::addItemToZList ( QgsComposerItem item)

Adds item to z list.

Usually called from constructor of QgsComposerItem

Definition at line 1269 of file qgscomposition.cpp.

References mItemZList.

Referenced by QgsComposerItem::init().

void QgsComposition::addMultiFrame ( QgsComposerMultiFrame multiFrame)

Adds multiframe.

The object is owned by QgsComposition until removeMultiFrame is called

Definition at line 2177 of file qgscomposition.cpp.

References mMultiFrames, and updateBounds().

Referenced by addItemsFromXML(), QgsComposerMultiFrame::QgsComposerMultiFrame(), and QgsAddRemoveMultiFrameCommand::switchState().

void QgsComposition::addPaperItem ( )
private
QGraphicsLineItem * QgsComposition::addSnapLine ( )

Add a custom snap line (can be horizontal or vertical)

Definition at line 1831 of file qgscomposition.cpp.

References mGuidesVisible, and mSnapLines.

Referenced by QgsComposerRuler::mousePressEvent(), and readXML().

bool QgsComposition::alignmentSnap ( ) const
inline
Q_DECL_DEPRECATED double QgsComposition::alignmentSnapTolerance ( ) const
inline

Returns the snap tolerance to use when automatically snapping items during movement and resizing to guides and the edges and centers of other items.

Returns
snap tolerance in pixels
See also
setAlignmentSnapTolerance
Deprecated:
Use snapTolerance instead

Definition at line 222 of file qgscomposition.h.

void QgsComposition::alignSelectedItemsBottom ( )
void QgsComposition::alignSelectedItemsHCenter ( )
void QgsComposition::alignSelectedItemsLeft ( )
void QgsComposition::alignSelectedItemsRight ( )
void QgsComposition::alignSelectedItemsTop ( )
void QgsComposition::alignSelectedItemsVCenter ( )
QgsAtlasComposition& QgsComposition::atlasComposition ( )
inline
QgsComposition::AtlasMode QgsComposition::atlasMode ( ) const
inline
void QgsComposition::beginCommand ( QgsComposerItem item,
const QString &  commandText,
const QgsComposerMergeCommand::Context  c = QgsComposerMergeCommand::Unknown 
)

Allocates new item command and saves initial state in it.

Parameters
itemtarget item
commandTextdescriptive command text
ccontext for merge commands (unknown for non-mergeable commands)

Definition at line 2094 of file qgscomposition.cpp.

References mActiveItemCommand, QgsComposerItemCommand::savePreviousState(), and QgsComposerMergeCommand::Unknown.

Referenced by QgsComposerItem::beginCommand(), and QgsComposerView::mouseReleaseEvent().

void QgsComposition::beginMultiFrameCommand ( QgsComposerMultiFrame multiFrame,
const QString &  text,
const QgsComposerMultiFrameMergeCommand::Context  c = QgsComposerMultiFrameMergeCommand::Unknown 
)
void QgsComposition::beginPrint ( QPrinter &  printer)

Prepare the printer for printing.

Definition at line 2571 of file qgscomposition.cpp.

References printResolution().

Referenced by print().

void QgsComposition::beginPrintAsPDF ( QPrinter &  printer,
const QString &  file 
)

Prepare the printer for printing in a PDF.

Definition at line 2502 of file qgscomposition.cpp.

References QgsPaintEngineHack::fixEngineFlags(), paperHeight(), paperWidth(), and refreshPageSize().

Referenced by exportAsPDF().

int QgsComposition::boundingRectOfSelectedItems ( QRectF &  bRect)
private

Returns the bounding rectangle of the selected items in scene coordinates.

Returns
0 in case of success

Definition at line 1970 of file qgscomposition.cpp.

References selectedComposerItems().

Referenced by alignSelectedItemsBottom(), alignSelectedItemsHCenter(), alignSelectedItemsLeft(), alignSelectedItemsRight(), alignSelectedItemsTop(), and alignSelectedItemsVCenter().

void QgsComposition::cancelCommand ( )

Deletes current command.

Definition at line 2132 of file qgscomposition.cpp.

References mActiveItemCommand.

Referenced by QgsComposerItem::cancelCommand().

void QgsComposition::clearSnapLines ( )

Removes all snap lines.

Definition at line 1854 of file qgscomposition.cpp.

References mSnapLines.

void QgsComposition::composerArrowAdded ( QgsComposerArrow arrow)
signal

Is emitted when new composer arrow has been added to the view.

Referenced by addComposerArrow(), and sendItemAddedSignal().

void QgsComposition::composerHtmlFrameAdded ( QgsComposerHtml html,
QgsComposerFrame frame 
)
signal

Is emitted when a new composer html has been added to the view.

Referenced by addComposerHtmlFrame(), and sendItemAddedSignal().

QgsComposerItem * QgsComposition::composerItemAt ( const QPointF &  position) const

Returns the topmost composer item.

Ignores mPaperItem

Definition at line 431 of file qgscomposition.cpp.

Referenced by QgsComposerView::mousePressEvent(), and QgsComposerView::wheelEvent().

QgsComposerItem * QgsComposition::composerItemAt ( const QPointF &  position,
const QgsComposerItem belowItem 
) const

Returns the highest composer item at a specified position which is below a specified item.

Ignores mPaperItem

Note
Added in QGIS 2.1

Definition at line 436 of file qgscomposition.cpp.

template<class T >
void QgsComposition::composerItems ( QList< T * > &  itemList)

Return composer items of a specific type.

Note
not available in python bindings

Definition at line 765 of file qgscomposition.h.

Referenced by addItemsFromXML(), QgsAtlasComposition::composerMap(), QgsAtlasComposition::prepareForFeature(), QgsAtlasComposition::readXMLMapSettings(), setAtlasMode(), and QgsAtlasComposition::updateAtlasMaps().

void QgsComposition::composerLabelAdded ( QgsComposerLabel label)
signal

Is emitted when new composer label has been added to the view.

Referenced by addComposerLabel(), and sendItemAddedSignal().

void QgsComposition::composerLegendAdded ( QgsComposerLegend legend)
signal

Is emitted when a new composer legend has been added.

Referenced by addComposerLegend(), and sendItemAddedSignal().

void QgsComposition::composerMapAdded ( QgsComposerMap map)
signal

Is emitted when new composer map has been added to the view.

Referenced by addComposerMap(), and sendItemAddedSignal().

QList< const QgsComposerMap * > QgsComposition::composerMapItems ( ) const

Returns pointers to all composer maps in the scene.

Note
available in python bindings only with PyQt >= 4.8.4

Definition at line 498 of file qgscomposition.cpp.

Referenced by QgsComposerMap::assignFreeId(), QgsComposerView::mousePressEvent(), QgsComposerView::mouseReleaseEvent(), and QgsComposerMap::QgsComposerMap().

void QgsComposition::composerPictureAdded ( QgsComposerPicture picture)
signal

Is emitted when a new composer picture has been added.

Referenced by addComposerPicture(), and sendItemAddedSignal().

void QgsComposition::composerScaleBarAdded ( QgsComposerScaleBar scalebar)
signal

Is emitted when new composer scale bar has been added.

Referenced by addComposerScaleBar(), and sendItemAddedSignal().

void QgsComposition::composerShapeAdded ( QgsComposerShape shape)
signal

Is emitted when a new composer shape has been added.

Referenced by addComposerShape(), and sendItemAddedSignal().

void QgsComposition::composerTableAdded ( QgsComposerAttributeTable table)
signal

Is emitted when a new composer table has been added.

Referenced by addComposerTable(), and sendItemAddedSignal().

QRectF QgsComposition::compositionBounds ( ) const
private

Calculates the bounds of all non-gui items in the composition.

Ignores snap lines and mouse handles

Definition at line 235 of file qgscomposition.cpp.

References mPageWidth.

Referenced by updateBounds().

void QgsComposition::computeWorldFileParameters ( double &  a,
double &  b,
double &  c,
double &  d,
double &  e,
double &  f 
) const
void QgsComposition::connectAddRemoveCommandSignals ( QgsAddRemoveItemCommand c)
private

Definition at line 2373 of file qgscomposition.cpp.

References itemRemoved(), and sendItemAddedSignal().

Referenced by pushAddRemoveCommand(), and removeComposerItem().

void QgsComposition::createDefaultPageStyleSymbol ( )
private

Definition at line 390 of file qgscomposition.cpp.

References QgsFillSymbolV2::createSimple(), and mPageStyleSymbol.

Referenced by init().

bool QgsComposition::dataDefinedEvaluate ( QgsComposerObject::DataDefinedProperty  property,
QVariant &  expressionValue,
QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *  dataDefinedProperties 
)
private

Evaluate a data defined property and return the calculated value.

Returns
true if data defined property could be successfully evaluated
Parameters
propertydata defined property to evaluate
expressionValueQVariant for storing the evaluated value
dataDefinedPropertiesmap of data defined properties to QgsDataDefined
Note
this method was added in version 2.5

Definition at line 2888 of file qgscomposition.cpp.

References QgsComposerObject::AllProperties, AtlasOff, QgsAtlasComposition::coverageLayer(), QgsAtlasComposition::currentFeature(), dataDefinedValue(), QgsAtlasComposition::enabled(), mAtlasComposition, mAtlasMode, QgsComposerObject::NoProperty, and QgsVectorLayer::pendingFields().

Referenced by QgsComposerObject::dataDefinedEvaluate(), refreshPageSize(), and setNumPages().

QgsDataDefined * QgsComposition::dataDefinedProperty ( const QgsComposerObject::DataDefinedProperty  property)

Returns a reference to the data defined settings for one of the composition's data defined properties.

Parameters
propertydata defined property to return
Note
this method was added in version 2.5

Definition at line 2840 of file qgscomposition.cpp.

References QgsComposerObject::AllProperties, mDataDefinedProperties, and QgsComposerObject::NoProperty.

QVariant QgsComposition::dataDefinedValue ( QgsComposerObject::DataDefinedProperty  property,
const QgsFeature feature,
const QgsFields fields,
QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *  dataDefinedProperties 
)
private

Evaluates a data defined property and returns the calculated value.

Parameters
propertydata defined property to evaluate
featurecurrent atlas feature to evaluate property for
fieldsfields from atlas layer
dataDefinedPropertiesmap of data defined properties to QgsDataDefined
Note
this method was added in version 2.5

Definition at line 2927 of file qgscomposition.cpp.

References QgsComposerObject::AllProperties, QgsFeature::attribute(), QgsExpression::evalErrorString(), QgsExpression::evaluate(), QgsDataDefined::expression(), QgsDataDefined::expressionIsPrepared(), QgsDataDefined::field(), QgsExpression::hasEvalError(), QgsFields::indexFromName(), QgsDataDefined::isActive(), QgsComposerObject::NoProperty, prepareDataDefinedExpression(), QgsDebugMsgLevel, and QgsDataDefined::useExpression().

Referenced by dataDefinedEvaluate().

void QgsComposition::deleteAndRemoveMultiFrames ( )
private

Definition at line 2492 of file qgscomposition.cpp.

References mMultiFrames.

Referenced by loadFromTemplate(), and ~QgsComposition().

void QgsComposition::doPrint ( QPrinter &  printer,
QPainter &  painter,
bool  startNewPage = false 
)

Print on a preconfigured printer.

Parameters
printerQPrinter destination
painterQPainter source
startNewPageset to true to begin the print on a new page

Definition at line 2530 of file qgscomposition.cpp.

References mPrintAsRaster, numPages(), paperHeight(), paperWidth(), printPageAsRaster(), refreshPageSize(), and renderPage().

Referenced by print().

QString QgsComposition::encodeStringForXML ( const QString &  str)
staticprivate

Definition at line 2649 of file qgscomposition.cpp.

Referenced by loadFromTemplate().

void QgsComposition::endCommand ( )
void QgsComposition::endMultiFrameCommand ( )
bool QgsComposition::exportAsPDF ( const QString &  file)

Convenience function that prepares the printer for printing in PDF and prints.

Returns
true if export was successful

Definition at line 2523 of file qgscomposition.cpp.

References beginPrintAsPDF(), and print().

bool QgsComposition::generateWorldFile ( ) const
inline

Definition at line 302 of file qgscomposition.h.

const QgsComposerHtml * QgsComposition::getComposerHtmlByItem ( QgsComposerItem item) const

Returns the composer html with specified id (a string as named in the composer user interface item properties).

Note
Added in QGIS 2.0
Parameters
itemthe item.
Returns
QgsComposerHtml pointer or 0 pointer if no such item exists.

Definition at line 534 of file qgscomposition.cpp.

References QgsComposerFrame::multiFrame().

QgsComposerItem * QgsComposition::getComposerItemAbove ( QgsComposerItem item) const

Definition at line 1324 of file qgscomposition.cpp.

References mItemZList.

Referenced by selectNextByZOrder().

QgsComposerItem * QgsComposition::getComposerItemBelow ( QgsComposerItem item) const

Definition at line 1339 of file qgscomposition.cpp.

References mItemZList.

Referenced by selectNextByZOrder().

const QgsComposerItem * QgsComposition::getComposerItemById ( const QString  theId) const

Returns a composer item given its text identifier.

Ids are not necessarely unique, but this function returns only one element.

Note
added in 2.0
Parameters
theId- A QString representing the identifier of the item to retrieve.
Returns
QgsComposerItem pointer or 0 pointer if no such item exists.

Definition at line 553 of file qgscomposition.cpp.

References QgsComposerItem::id().

const QgsComposerItem * QgsComposition::getComposerItemByUuid ( const QString  theUuid) const

Returns a composer item given its unique identifier.

Note
added in 2.0
Parameters
theUuidA QString representing the UUID of the item to

Definition at line 608 of file qgscomposition.cpp.

References QgsComposerItem::uuid().

const QgsComposerMap * QgsComposition::getComposerMapById ( const int  id) const
QGraphicsView * QgsComposition::graphicsView ( ) const
private

Definition at line 2660 of file qgscomposition.cpp.

Referenced by snapPointToGrid().

const QPen& QgsComposition::gridPen ( ) const
inline

Definition at line 187 of file qgscomposition.h.

Referenced by QgsPaperGrid::paint().

GridStyle QgsComposition::gridStyle ( ) const
inline

Definition at line 190 of file qgscomposition.h.

Referenced by QgsPaperGrid::paint().

bool QgsComposition::gridVisible ( ) const
inline

Definition at line 162 of file qgscomposition.h.

Referenced by QgsPaperGrid::paint().

void QgsComposition::init ( )
protected
int QgsComposition::itemPageNumber ( const QgsComposerItem item) const

Returns on which page number (0-based) is displayed an item.

Definition at line 474 of file qgscomposition.cpp.

References pageNumberAt().

Referenced by QgsComposerLabel::displayText().

void QgsComposition::itemRemoved ( QgsComposerItem )
signal

Is emitted when a composer item has been removed from the scene.

Referenced by connectAddRemoveCommandSignals(), loadFromTemplate(), and removeComposerItem().

void QgsComposition::loadDefaults ( )
private

Loads default composer settings.

Definition at line 194 of file qgscomposition.cpp.

References mSnapGridOffsetX, mSnapGridOffsetY, mSnapGridResolution, and mSnapTolerance.

Referenced by init().

bool QgsComposition::loadFromTemplate ( const QDomDocument &  doc,
QMap< QString, QString > *  substitutionMap = 0,
bool  addUndoCommands = false 
)

Load a template document.

Parameters
doctemplate document
substitutionMapmap with text to replace. Text needs to be enclosed by brackets (e.g. '[text]' )
addUndoCommandswhether or not to add undo commands

Definition at line 825 of file qgscomposition.cpp.

References addItemsFromXML(), atlasComposition(), deleteAndRemoveMultiFrames(), encodeStringForXML(), itemRemoved(), mItemZList, mPages, mUndoStack, QgsAtlasComposition::readXML(), readXML(), and QgsAtlasComposition::readXMLMapSettings().

void QgsComposition::loadSettings ( )
private

Loads composer settings which may change, eg grid color.

Definition at line 2062 of file qgscomposition.cpp.

References Crosses, Dots, mGridPen, mGridStyle, and Solid.

Referenced by init(), and updateSettings().

void QgsComposition::lockSelectedItems ( )
void QgsComposition::lowerItem ( QgsComposerItem item)

Definition at line 1407 of file qgscomposition.cpp.

References mItemZList.

Referenced by lowerSelectedItems().

void QgsComposition::lowerSelectedItems ( )

Definition at line 1393 of file qgscomposition.cpp.

References lowerItem(), selectedComposerItems(), and updateZValues().

Q_DECL_DEPRECATED QgsMapRenderer* QgsComposition::mapRenderer ( )
inline

Returns pointer to map renderer of qgis map canvas.

Deprecated:
since 2.4 - use mapSettings() instead. May return null if not initialized with QgsMapRenderer

Definition at line 317 of file qgscomposition.h.

Referenced by QgsComposerMap::mapRenderer().

const QgsMapSettings& QgsComposition::mapSettings ( ) const
inline
QPointF QgsComposition::minPointFromXml ( const QDomElement &  elem) const
private

Calculates the item minimum position from an xml string.

Definition at line 907 of file qgscomposition.cpp.

References pal::max().

Referenced by addItemsFromXML().

void QgsComposition::moveItemToBottom ( QgsComposerItem item)

Definition at line 1469 of file qgscomposition.cpp.

References mItemZList.

Referenced by moveSelectedItemsToBottom().

void QgsComposition::moveItemToTop ( QgsComposerItem item)

Definition at line 1444 of file qgscomposition.cpp.

References mItemZList.

Referenced by moveSelectedItemsToTop().

void QgsComposition::moveSelectedItemsToBottom ( )

Definition at line 1455 of file qgscomposition.cpp.

References moveItemToBottom(), selectedComposerItems(), and updateZValues().

void QgsComposition::moveSelectedItemsToTop ( )

Definition at line 1429 of file qgscomposition.cpp.

References moveItemToTop(), selectedComposerItems(), and updateZValues().

QGraphicsLineItem * QgsComposition::nearestSnapLine ( const bool  horizontal,
const double  x,
const double  y,
const double  tolerance,
QList< QPair< QgsComposerItem *, QgsComposerItem::ItemPositionMode > > &  snappedItems 
) const
void QgsComposition::nPagesChanged ( )
signal

Referenced by setNumPages().

int QgsComposition::numPages ( ) const
int QgsComposition::pageNumberAt ( const QPointF &  position) const

Returns the page number (0-based) given a coordinate.

Definition at line 469 of file qgscomposition.cpp.

References paperHeight(), and spaceBetweenPages().

Referenced by addItemsFromXML(), and itemPageNumber().

int QgsComposition::pageNumberForPoint ( const QPointF &  position) const

Returns the page number corresponding to a point in the composition.

Note
Added in QGIS 2.1

Definition at line 418 of file qgscomposition.cpp.

References mPages, paperHeight(), and spaceBetweenPages().

Referenced by setPaperSize().

QList< QgsPaperItem* > QgsComposition::pages ( )
inline

Return pages in the correct order.

Note
composerItems(QList< QgsPaperItem* > &) may not return pages in the correct order
added in version 2.4

Definition at line 535 of file qgscomposition.h.

Referenced by setNumPages().

QgsFillSymbolV2* QgsComposition::pageStyleSymbol ( )
inline

Note: added in version 2.1.

Definition at line 137 of file qgscomposition.h.

Referenced by QgsPaperItem::calculatePageMargin(), and QgsPaperItem::paint().

double QgsComposition::paperHeight ( ) const
void QgsComposition::paperSizeChanged ( )
signal

Referenced by readXML(), and setPaperSize().

double QgsComposition::paperWidth ( ) const
int QgsComposition::pixelFontSize ( double  pointSize) const

Returns the mm font size for a font that has point size set.

Each item that sets a font should call this function before drawing text

Deprecated:
use QgsComposerUtils::pointsToMM instead

Definition at line 651 of file qgscomposition.cpp.

References QgsComposerUtils::pointsToMM().

QgsComposition::PlotStyle QgsComposition::plotStyle ( ) const
inline
double QgsComposition::pointFontSize ( int  pixelSize) const

Does the inverse calculation and returns points for mm.

Deprecated:
use QgsComposerUtils::mmToPoints instead

Definition at line 656 of file qgscomposition.cpp.

References QgsComposerUtils::mmToPoints().

QPointF QgsComposition::positionOnPage ( const QPointF &  position) const

Returns the position within a page of a point in the composition.

Note
Added in QGIS 2.1

Definition at line 401 of file qgscomposition.cpp.

References mPages, paperHeight(), and spaceBetweenPages().

Referenced by setPaperSize().

void QgsComposition::prepareAllDataDefinedExpressions ( )
privateslot

Definition at line 3018 of file qgscomposition.cpp.

References mDataDefinedProperties, and prepareDataDefinedExpression().

Referenced by init().

void QgsComposition::prepareDataDefinedExpression ( QgsDataDefined dd,
QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined * > *  dataDefinedProperties 
) const
private

Prepares the expression for a data defined property, using the current atlas layer if set.

Parameters
dddata defined to prepare. If no data defined is set, all data defined expressions will be prepared
dataDefinedPropertiesmap of data defined properties to QgsDataDefined
Note
this method was added in version 2.5

Definition at line 2993 of file qgscomposition.cpp.

References QgsAtlasComposition::coverageLayer(), QgsAtlasComposition::enabled(), mAtlasComposition, and QgsDataDefined::prepareExpression().

Referenced by dataDefinedValue(), and prepareAllDataDefinedExpressions().

bool QgsComposition::preventCursorChange ( ) const
inline

Definition at line 470 of file qgscomposition.h.

Referenced by QgsComposerMouseHandles::setViewportCursor().

bool QgsComposition::print ( QPrinter &  printer)

Convenience function that prepares the printer and prints.

Returns
true if print was successful

Definition at line 2581 of file qgscomposition.cpp.

References beginPrint(), and doPrint().

Referenced by exportAsPDF().

bool QgsComposition::printAsRaster ( ) const
inline

Definition at line 299 of file qgscomposition.h.

QImage QgsComposition::printPageAsRaster ( int  page)

print composer page to image If the image does not fit into memory, a null image is returned

Definition at line 2596 of file qgscomposition.cpp.

References paperHeight(), paperWidth(), printResolution(), and renderPage().

Referenced by doPrint().

int QgsComposition::printResolution ( ) const
inline
void QgsComposition::printResolutionChanged ( )
signal

Is emitted when the compositions print resolution changes.

Referenced by setPrintResolution().

void QgsComposition::pushAddRemoveCommand ( QgsComposerItem item,
const QString &  text,
const QgsAddRemoveItemCommand::State  state = QgsAddRemoveItemCommand::Added 
)
void QgsComposition::raiseItem ( QgsComposerItem item)

Definition at line 1302 of file qgscomposition.cpp.

References mItemZList.

Referenced by raiseSelectedItems().

void QgsComposition::raiseSelectedItems ( )

Definition at line 1288 of file qgscomposition.cpp.

References raiseItem(), selectedComposerItems(), and updateZValues().

bool QgsComposition::readXML ( const QDomElement &  compositionElem,
const QDomDocument &  doc 
)
void QgsComposition::refreshDataDefinedProperty ( const QgsComposerObject::DataDefinedProperty  property = QgsComposerObject::AllProperties)
slot

Refreshes a data defined property for the composition by reevaluating the property's value and redrawing the composition with this new value.

Parameters
propertydata defined property to refresh. If property is set to QgsComposerItem::AllProperties then all data defined properties for the composition will be refreshed.
Note
this method was added in version 2.5

Definition at line 220 of file qgscomposition.cpp.

References QgsComposerObject::AllProperties, QgsComposerObject::NumPages, numPages(), QgsComposerObject::PaperHeight, QgsComposerObject::PaperOrientation, QgsComposerObject::PaperWidth, QgsComposerObject::PresetPaperSize, refreshPageSize(), and setNumPages().

Referenced by init().

void QgsComposition::refreshItems ( )
slot

Forces items in the composition to refresh.

For instance, this causes maps to redraw and rebuild cached images, html items to reload their source url, and attribute tables to refresh their contents. Calling this also triggers a recalculation of all data defined attributes within the composition.

Note
added in version 2.3

Definition at line 208 of file qgscomposition.cpp.

References refreshItemsTriggered().

void QgsComposition::refreshItemsTriggered ( )
signal

Is emitted when item in the composition must be refreshed.

Referenced by init(), and refreshItems().

void QgsComposition::refreshPageSize ( )
private
void QgsComposition::refreshZList ( )

Rebuilds the z order list based on current order of items in scene.

Definition at line 1765 of file qgscomposition.cpp.

References QgsComposerItem::ComposerFrame, QgsComposerItem::ComposerPaper, mItemZList, QgsComposerItem::type(), and updateZValues().

Referenced by addItemsFromXML().

double QgsComposition::relativePosition ( double  position,
double  beforeMin,
double  beforeMax,
double  afterMin,
double  afterMax 
)
static

Returns a scaled position given a before and after range.

Deprecated:
use QgsComposerUtils::relativePosition instead

Definition at line 3028 of file qgscomposition.cpp.

References QgsComposerUtils::relativePosition().

void QgsComposition::relativeResizeRect ( QRectF &  rectToResize,
const QRectF &  boundsBefore,
const QRectF &  boundsAfter 
)
static

Resizes a QRectF relative to the change from boundsBefore to boundsAfter.

Deprecated:
use QgsComposerUtils::relativeResizeRect instead

Definition at line 3023 of file qgscomposition.cpp.

References QgsComposerUtils::relativeResizeRect().

void QgsComposition::removeComposerItem ( QgsComposerItem item,
const bool  createCommand = true 
)
void QgsComposition::removeItemFromZList ( QgsComposerItem item)

Removes item from z list.

Usually called from destructor of QgsComposerItem

Definition at line 1279 of file qgscomposition.cpp.

References mItemZList.

Referenced by QgsComposerItem::~QgsComposerItem().

void QgsComposition::removeMultiFrame ( QgsComposerMultiFrame multiFrame)

Removes multi frame (but does not delete it)

Definition at line 2184 of file qgscomposition.cpp.

References mMultiFrames, and updateBounds().

Referenced by removeComposerItem(), and QgsAddRemoveMultiFrameCommand::switchState().

void QgsComposition::removePaperItems ( )
private

Definition at line 2482 of file qgscomposition.cpp.

References mPages, and QgsExpression::setSpecialColumn().

Referenced by readXML(), and ~QgsComposition().

void QgsComposition::removeSnapLine ( QGraphicsLineItem *  line)

Remove custom snap line (and delete the object)

Definition at line 1847 of file qgscomposition.cpp.

References mSnapLines.

Referenced by QgsComposerRuler::mouseReleaseEvent().

void QgsComposition::renderPage ( QPainter *  p,
int  page 
)

Render a page to a paint device.

Note
added in version 1.9

Definition at line 2614 of file qgscomposition.cpp.

References mPages, mPlotStyle, Print, and setSnapLinesVisible().

Referenced by doPrint(), and printPageAsRaster().

QList< QgsComposerItem * > QgsComposition::selectedComposerItems ( )
void QgsComposition::selectedItemChanged ( QgsComposerItem selected)
signal

Is emitted when selected item changed.

If 0, no item is selected

Referenced by addItemsFromXML(), selectNextByZOrder(), sendItemAddedSignal(), setSelectedItem(), and unlockAllItems().

QgsComposerMouseHandles* QgsComposition::selectionHandles ( )
inline

Returns pointer to selection handles.

Note
not available in python bindings

Definition at line 412 of file qgscomposition.h.

Referenced by QgsComposerView::mousePressEvent(), and QgsComposerView::mouseReleaseEvent().

void QgsComposition::selectNextByZOrder ( const ZValueDirection  direction)
void QgsComposition::sendItemAddedSignal ( QgsComposerItem item)
slot
void QgsComposition::setAlignmentSnap ( const bool  s)
inline

Definition at line 168 of file qgscomposition.h.

Q_DECL_DEPRECATED void QgsComposition::setAlignmentSnapTolerance ( double  t)
inline

Sets the snap tolerance to use when automatically snapping items during movement and resizing to guides and the edges and centers of other items.

Parameters
tsnap tolerance in pixels
See also
alignmentSnapTolerance
Deprecated:
Use setSnapTolerance instead

Definition at line 214 of file qgscomposition.h.

bool QgsComposition::setAtlasMode ( const QgsComposition::AtlasMode  mode)

Sets the current atlas mode of the composition.

Parameters
modeatlas mode to switch to
Returns
false if the mode could not be changed.
See also
atlasMode

Definition at line 2735 of file qgscomposition.cpp.

References QgsComposerMap::atlasDriven(), AtlasOff, QgsAtlasComposition::beginRender(), composerItems(), QgsAtlasComposition::endRender(), mAtlasComposition, mAtlasMode, and QgsComposerMap::toggleAtlasPreview().

Referenced by QgsAtlasComposition::setEnabled().

void QgsComposition::setDataDefinedProperty ( const QgsComposerObject::DataDefinedProperty  property,
bool  active,
bool  useExpression,
const QString &  expression,
const QString &  field 
)

Sets parameters for a data defined property for the composition.

Parameters
propertydata defined property to set
activetrue if data defined property is active, false if it is disabled
useExpressiontrue if the expression should be used
expressionexpression for data defined property
fieldfield name if the data defined property should take its value from a field
Note
this method was added in version 2.5

Definition at line 2859 of file qgscomposition.cpp.

References QgsComposerObject::AllProperties, mDataDefinedProperties, QgsComposerObject::NoProperty, QgsDataDefined::setActive(), QgsDataDefined::setExpressionString(), QgsDataDefined::setField(), and QgsDataDefined::setUseExpression().

void QgsComposition::setGenerateWorldFile ( const bool  enabled)
inline

Definition at line 303 of file qgscomposition.h.

void QgsComposition::setGridPen ( const QPen &  p)

Definition at line 2040 of file qgscomposition.cpp.

References mGridPen, and updatePaperItems().

void QgsComposition::setGridStyle ( const GridStyle  s)

Definition at line 2048 of file qgscomposition.cpp.

References mGridStyle, and updatePaperItems().

void QgsComposition::setGridVisible ( const bool  b)

Definition at line 2016 of file qgscomposition.cpp.

References mGridVisible, and updatePaperItems().

void QgsComposition::setNumPages ( const int  pages)
void QgsComposition::setPageStyleSymbol ( QgsFillSymbolV2 symbol)

Note: added in version 2.1.

Definition at line 383 of file qgscomposition.cpp.

References QgsProject::dirty(), QgsProject::instance(), and mPageStyleSymbol.

void QgsComposition::setPaperSize ( const double  width,
const double  height 
)

Changes size of paper item.

Also moves all items so that they retain their same relative position to the top left corner of their current page.

Definition at line 260 of file qgscomposition.cpp.

References QgsProject::dirty(), QgsProject::instance(), mPageHeight, mPages, mPageWidth, mSpaceBetweenPages, numPages(), pageNumberForPoint(), paperSizeChanged(), positionOnPage(), snapLines(), spaceBetweenPages(), updateBounds(), and QgsComposerItem::updatePagePos().

Referenced by refreshPageSize().

void QgsComposition::setPlotStyle ( const QgsComposition::PlotStyle  style)
inline

Definition at line 324 of file qgscomposition.h.

void QgsComposition::setPreventCursorChange ( const bool  preventChange)
inline

If true, prevents any mouse cursor changes by the composition or by any composer items Used by QgsComposer and QgsComposerView to prevent unwanted cursor changes.

Definition at line 469 of file qgscomposition.h.

Referenced by QgsComposerView::keyPressEvent(), QgsComposerView::keyReleaseEvent(), QgsComposerView::mousePressEvent(), QgsComposerView::mouseReleaseEvent(), and QgsComposerView::setCurrentTool().

void QgsComposition::setPrintAsRaster ( const bool  enabled)
inline

Definition at line 300 of file qgscomposition.h.

void QgsComposition::setPrintResolution ( const int  dpi)
void QgsComposition::setSelectedItem ( QgsComposerItem item)
slot

Clears any selected items and sets an item as the current selection.

Parameters
itemitem to set as selected
Note
added in version 2.3

Definition at line 213 of file qgscomposition.cpp.

References selectedItemChanged(), and QgsComposerItem::setSelected().

void QgsComposition::setSmartGuidesEnabled ( const bool  b)
inline

Definition at line 171 of file qgscomposition.h.

void QgsComposition::setSnapGridOffsetX ( const double  offset)

Definition at line 2028 of file qgscomposition.cpp.

References mSnapGridOffsetX, and updatePaperItems().

void QgsComposition::setSnapGridOffsetY ( const double  offset)

Definition at line 2034 of file qgscomposition.cpp.

References mSnapGridOffsetY, and updatePaperItems().

void QgsComposition::setSnapGridResolution ( const double  r)

Definition at line 2022 of file qgscomposition.cpp.

References mSnapGridResolution, and updatePaperItems().

Q_DECL_DEPRECATED void QgsComposition::setSnapGridTolerance ( double  tolerance)
inline

Sets the snap tolerance to use when automatically snapping items during movement and resizing to the composition grid.

Parameters
tolerancesnap tolerance in pixels
See also
snapGridTolerance
Deprecated:
Use setSnapTolerance instead

Definition at line 198 of file qgscomposition.h.

void QgsComposition::setSnapLinesVisible ( const bool  visible)

Hides / shows custom snap lines.

Definition at line 1865 of file qgscomposition.cpp.

References mGuidesVisible, and mSnapLines.

Referenced by renderPage().

void QgsComposition::setSnapToGridEnabled ( const bool  b)

Definition at line 2010 of file qgscomposition.cpp.

References mSnapToGrid, and updatePaperItems().

void QgsComposition::setSnapTolerance ( const int  snapTolerance)
inline

Sets the snap tolerance to use when automatically snapping items during movement and resizing to guides and the edges and centers of other items.

Parameters
snapTolerancesnap tolerance in pixels
See also
alignmentSnapTolerance
Note
Added in QGIS 2.5

Definition at line 230 of file qgscomposition.h.

void QgsComposition::setStatusMessage ( const QString &  message)

Sets the status bar message for the composer window.

Note
Added in QGIS 2.1

Definition at line 426 of file qgscomposition.cpp.

References statusMsgChanged().

Referenced by QgsComposerMouseHandles::dragMouseMove(), QgsComposerMouseHandles::resetStatusBar(), and QgsComposerMouseHandles::resizeMouseMove().

void QgsComposition::setUseAdvancedEffects ( const bool  effectsEnabled)

Used to enable or disable advanced effects such as blend modes in a composition.

Note
: added in version 1.9

Definition at line 634 of file qgscomposition.cpp.

References mUseAdvancedEffects, and QgsComposerItem::setEffectsEnabled().

void QgsComposition::setWorldFileMap ( QgsComposerMap map)
inline

Definition at line 306 of file qgscomposition.h.

bool QgsComposition::smartGuidesEnabled ( ) const
inline
double QgsComposition::snapGridOffsetX ( ) const
inline

Definition at line 181 of file qgscomposition.h.

Referenced by QgsPaperGrid::paint().

double QgsComposition::snapGridOffsetY ( ) const
inline

Definition at line 184 of file qgscomposition.h.

Referenced by QgsPaperGrid::paint().

double QgsComposition::snapGridResolution ( ) const
inline

Definition at line 178 of file qgscomposition.h.

Referenced by QgsPaperGrid::paint().

Q_DECL_DEPRECATED double QgsComposition::snapGridTolerance ( ) const
inline

Returns the snap tolerance to use when automatically snapping items during movement and resizing to the composition grid.

Returns
snap tolerance in pixels
See also
setSnapGridTolerance
Deprecated:
Use snapTolerance instead

Definition at line 206 of file qgscomposition.h.

QList< QGraphicsLineItem* >* QgsComposition::snapLines ( )
inline

Returns pointer to snap lines collection.

Definition at line 407 of file qgscomposition.h.

Referenced by QgsComposerMouseHandles::collectAlignCoordinates(), setNumPages(), and setPaperSize().

bool QgsComposition::snapLinesVisible ( ) const
inline

Definition at line 166 of file qgscomposition.h.

QPointF QgsComposition::snapPointToGrid ( const QPointF &  scenePoint) const
bool QgsComposition::snapToGridEnabled ( ) const
inline

Definition at line 159 of file qgscomposition.h.

int QgsComposition::snapTolerance ( ) const
inline

Returns the snap tolerance to use when automatically snapping items during movement and resizing to guides and the edges and centers of other items.

Returns
snap tolerance in pixels
See also
setAlignmentSnapTolerance
Note
Added in QGIS 2.5

Definition at line 238 of file qgscomposition.h.

Referenced by QgsComposerMouseHandles::alignPos(), and QgsComposerMouseHandles::checkNearestItem().

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 1739 of file qgscomposition.cpp.

References mItemZList.

double QgsComposition::spaceBetweenPages ( ) const
inline
void QgsComposition::statusMsgChanged ( QString  message)
signal

Is emitted when the composition has an updated status bar message for the composer window.

Referenced by setStatusMessage().

QUndoStack* QgsComposition::undoStack ( )
inline

Returns pointer to undo/redo command storage.

Definition at line 241 of file qgscomposition.h.

Referenced by QgsComposerMouseHandles::mouseReleaseEvent(), QgsComposerView::mouseReleaseEvent(), pushAddRemoveCommand(), and removeComposerItem().

void QgsComposition::unlockAllItems ( )
void QgsComposition::updateBounds ( )
slot
void QgsComposition::updatePaperItems ( )
private
void QgsComposition::updateSettings ( )

Refreshes the composition when composer related options change Note: added in version 2.1.

Definition at line 2054 of file qgscomposition.cpp.

References loadSettings(), and updatePaperItems().

void QgsComposition::updateZValues ( const bool  addUndoCommands = true)
private
bool QgsComposition::useAdvancedEffects ( ) const
inline

Returns true if a composition should use advanced effects such as blend modes.

Note
added in 1.9

Definition at line 310 of file qgscomposition.h.

Referenced by QgsComposerMap::draw(), and QgsComposerLegend::paint().

QgsComposerMap* QgsComposition::worldFileMap ( ) const
inline

Definition at line 305 of file qgscomposition.h.

bool QgsComposition::writeXML ( QDomElement &  composerElem,
QDomDocument &  doc 
)

Friends And Related Function Documentation

friend class QgsComposerObject
friend

Definition at line 762 of file qgscomposition.h.

Member Data Documentation

QgsComposerItemCommand* QgsComposition::mActiveItemCommand
private

Definition at line 643 of file qgscomposition.h.

Referenced by beginCommand(), cancelCommand(), endCommand(), init(), and ~QgsComposition().

QgsComposerMultiFrameCommand* QgsComposition::mActiveMultiFrameCommand
private
bool QgsComposition::mAlignmentSnap
private

Parameters for alignment snap.

Definition at line 631 of file qgscomposition.h.

Referenced by init(), readXML(), and writeXML().

QgsAtlasComposition QgsComposition::mAtlasComposition
private

The atlas composition object.

It is held by the QgsComposition

Definition at line 647 of file qgscomposition.h.

Referenced by dataDefinedEvaluate(), init(), prepareDataDefinedExpression(), and setAtlasMode().

QgsComposition::AtlasMode QgsComposition::mAtlasMode
private

Definition at line 649 of file qgscomposition.h.

Referenced by dataDefinedEvaluate(), init(), and setAtlasMode().

QMap< QgsComposerObject::DataDefinedProperty, QString > QgsComposition::mDataDefinedNames
private

Map of data defined properties for the composition to string name to use when exporting composition to xml.

Definition at line 654 of file qgscomposition.h.

Referenced by init(), readXML(), and writeXML().

QMap< QgsComposerObject::DataDefinedProperty, QgsDataDefined* > QgsComposition::mDataDefinedProperties
private

Map of current data defined properties to QgsDataDefined for the composition.

Definition at line 656 of file qgscomposition.h.

Referenced by dataDefinedProperty(), prepareAllDataDefinedExpressions(), readXML(), refreshPageSize(), setDataDefinedProperty(), setNumPages(), writeXML(), and ~QgsComposition().

bool QgsComposition::mGenerateWorldFile
private

Flag if a world file should be generated on raster export.

Definition at line 614 of file qgscomposition.h.

Referenced by init(), readXML(), and writeXML().

QPen QgsComposition::mGridPen
private

Definition at line 627 of file qgscomposition.h.

Referenced by loadSettings(), and setGridPen().

GridStyle QgsComposition::mGridStyle
private

Definition at line 628 of file qgscomposition.h.

Referenced by loadSettings(), and setGridStyle().

bool QgsComposition::mGridVisible
private

Definition at line 623 of file qgscomposition.h.

Referenced by init(), readXML(), setGridVisible(), and writeXML().

bool QgsComposition::mGuidesVisible
private

Definition at line 632 of file qgscomposition.h.

Referenced by addSnapLine(), init(), readXML(), setSnapLinesVisible(), and writeXML().

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 602 of file qgscomposition.h.

Referenced by addItemsFromXML(), addItemToZList(), getComposerItemAbove(), getComposerItemBelow(), loadFromTemplate(), lowerItem(), moveItemToBottom(), moveItemToTop(), raiseItem(), refreshZList(), removeItemFromZList(), sortZList(), and updateZValues().

QgsMapRenderer* QgsComposition::mMapRenderer
private

Pointer to map renderer of QGIS main map.

Definition at line 588 of file qgscomposition.h.

const QgsMapSettings& QgsComposition::mMapSettings
private

Definition at line 589 of file qgscomposition.h.

QSet<QgsComposerMultiFrame*> QgsComposition::mMultiFrames
private

List multiframe objects.

Definition at line 605 of file qgscomposition.h.

Referenced by addMultiFrame(), deleteAndRemoveMultiFrames(), removeMultiFrame(), and writeXML().

double QgsComposition::mPageHeight
private
QList< QgsPaperItem* > QgsComposition::mPages
private
QgsFillSymbolV2* QgsComposition::mPageStyleSymbol
private

Drawing style for page.

Definition at line 598 of file qgscomposition.h.

Referenced by createDefaultPageStyleSymbol(), init(), readXML(), setPageStyleSymbol(), writeXML(), and ~QgsComposition().

double QgsComposition::mPageWidth
private
QgsComposition::PlotStyle QgsComposition::mPlotStyle
private

Definition at line 591 of file qgscomposition.h.

Referenced by init(), and renderPage().

bool QgsComposition::mPreventCursorChange
private

Definition at line 651 of file qgscomposition.h.

Referenced by init().

bool QgsComposition::mPrintAsRaster
private

Flag if map should be printed as a raster (via QImage).

False by default

Definition at line 611 of file qgscomposition.h.

Referenced by doPrint(), init(), readXML(), and writeXML().

int QgsComposition::mPrintResolution
private

Dpi for printout.

Definition at line 608 of file qgscomposition.h.

Referenced by init(), readXML(), setPrintResolution(), and writeXML().

QgsComposerMouseHandles* QgsComposition::mSelectionHandles
private

Definition at line 639 of file qgscomposition.h.

Referenced by init().

bool QgsComposition::mSmartGuides
private

Definition at line 633 of file qgscomposition.h.

Referenced by init(), readXML(), and writeXML().

double QgsComposition::mSnapGridOffsetX
private
double QgsComposition::mSnapGridOffsetY
private
double QgsComposition::mSnapGridResolution
private
QList< QGraphicsLineItem* > QgsComposition::mSnapLines
private

Arbitraty snap lines (horizontal and vertical)

Definition at line 637 of file qgscomposition.h.

Referenced by addSnapLine(), clearSnapLines(), nearestSnapLine(), removeSnapLine(), setSnapLinesVisible(), and writeXML().

bool QgsComposition::mSnapToGrid
private

Parameters for snap to grid function.

Definition at line 622 of file qgscomposition.h.

Referenced by init(), readXML(), setSnapToGridEnabled(), snapPointToGrid(), and writeXML().

int QgsComposition::mSnapTolerance
private

Definition at line 634 of file qgscomposition.h.

Referenced by init(), loadDefaults(), readXML(), snapPointToGrid(), and writeXML().

double QgsComposition::mSpaceBetweenPages
private

Definition at line 595 of file qgscomposition.h.

Referenced by addItemsFromXML(), addPaperItem(), init(), setPaperSize(), and snapPointToGrid().

QUndoStack QgsComposition::mUndoStack
private
bool QgsComposition::mUseAdvancedEffects
private

Flag if advanced visual effects such as blend modes should be used.

True by default

Definition at line 619 of file qgscomposition.h.

Referenced by init(), and setUseAdvancedEffects().

QgsComposerMap* QgsComposition::mWorldFileMap
private

Composer map to use for the world file generation.

Definition at line 616 of file qgscomposition.h.

Referenced by computeWorldFileParameters(), init(), and writeXML().


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