QGIS API Documentation  2.99.0-Master (b058df7)
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QgsComposition Class Reference

Graphics scene for map printing. More...

#include <qgscomposition.h>

Inheritance diagram for QgsComposition:
Inheritance graph
[legend]

Public Types

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

Public Slots

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

Signals

void composerItemGroupAdded (QgsComposerItemGroup *group)
 Is emitted when a new item group has been added to the view. More...
 
void itemAdded (QgsComposerItem *item)
 Is emitted when a new composer item has been added to the composition. More...
 
void itemRemoved (QgsComposerItem *)
 Is emitted when a composer item has been removed from the scene. More...
 
void nameChanged (const QString &name)
 Emitted when the composition's name is changed. More...
 
void nPagesChanged ()
 
void paperSizeChanged ()
 
void printResolutionChanged ()
 Is emitted when the compositions print resolution changes. More...
 
void refreshItemsTriggered ()
 Is emitted when item in the composition must be refreshed. More...
 
void selectedItemChanged (QgsComposerItem *selected)
 Is emitted when selected item changed. If 0, no item is selected. More...
 
void statusMsgChanged (const QString &message)
 Is emitted when the composition has an updated status bar message for the composer window. More...
 
void variablesChanged ()
 Emitted whenever the expression variables stored in the composition have been changed. More...
 

Public Member Functions

 QgsComposition (QgsProject *project)
 Construct a new composition linked to the specified project. More...
 
 ~QgsComposition ()
 
void addComposerArrow (QgsComposerArrow *arrow)
 Adds an arrow item to the graphics scene and advises composer to create a widget for it (through signal) More...
 
void addComposerHtmlFrame (QgsComposerHtml *html, QgsComposerFrame *frame)
 Adds composer html frame and advises composer to create a widget for it (through signal) More...
 
void addComposerLabel (QgsComposerLabel *label)
 Adds label to the graphics scene and advises composer to create a widget for it (through signal) More...
 
void addComposerLegend (QgsComposerLegend *legend)
 Adds legend to the graphics scene and advises composer to create a widget for it (through signal) More...
 
void addComposerMap (QgsComposerMap *map)
 Adds map to the graphics scene and advises composer to create a widget for it (through signal) More...
 
void addComposerPicture (QgsComposerPicture *picture)
 Adds picture to the graphics scene and advises composer to create a widget for it (through signal) More...
 
void addComposerPolygon (QgsComposerPolygon *polygon)
 Adds a composer polygon and advises composer to create a widget for it (through signal) More...
 
void addComposerPolyline (QgsComposerPolyline *polyline)
 Adds a composer polyline and advises composer to create a widget for it (through signal) More...
 
void addComposerScaleBar (QgsComposerScaleBar *scaleBar)
 Adds scale bar to the graphics scene and advises composer to create a widget for it (through signal) More...
 
void addComposerShape (QgsComposerShape *shape)
 Adds a composer shape to the graphics scene and advises composer to create a widget for it (through signal) More...
 
void addComposerTableFrame (QgsComposerAttributeTableV2 *table, QgsComposerFrame *frame)
 Adds composer tablev2 frame and advises composer to create a widget for it (through signal) More...
 
void addItemsFromXml (const QDomElement &elem, const QDomDocument &doc, bool addUndoCommands=false, QPointF *pos=nullptr, 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. Usually called from constructor of QgsComposerItem. More...
 
void addMultiFrame (QgsComposerMultiFrame *multiFrame)
 Adds multiframe. The object is owned by QgsComposition until removeMultiFrame is called. More...
 
QGraphicsLineItem * addSnapLine ()
 Add a custom snap line (can be horizontal or vertical) More...
 
bool alignmentSnap () const
 
void alignSelectedItemsBottom ()
 
void alignSelectedItemsHCenter ()
 
void alignSelectedItemsLeft ()
 
void alignSelectedItemsRight ()
 
void alignSelectedItemsTop ()
 
void alignSelectedItemsVCenter ()
 
QgsAtlasCompositionatlasComposition ()
 
QgsComposition::AtlasMode atlasMode () const
 Returns the current atlas mode of the composition. 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 beginMultiFrameCommand (QgsComposerMultiFrame *multiFrame, const QString &text, const QgsComposerMultiFrameMergeCommand::Context c=QgsComposerMultiFrameMergeCommand::Unknown)
 
void beginPrint (QPrinter &printer, const bool evaluateDDPageSize=false)
 Prepare the printer for printing. More...
 
void beginPrintAsPDF (QPrinter &printer, const QString &file)
 Prepare the printer for printing in a PDF. More...
 
bool boundingBoxesVisible () const
 Returns whether selection bounding boxes should be shown in the composition. More...
 
void cancelCommand ()
 Deletes current command. More...
 
void cancelMultiFrameCommand ()
 Deletes current multi frame command. More...
 
void clearSnapLines ()
 Removes all snap lines. More...
 
QgsComposerItemcomposerItemAt (QPointF position, const bool ignoreLocked=false) const
 Returns the topmost composer item at a specified position. More...
 
QgsComposerItemcomposerItemAt (QPointF position, const QgsComposerItem *belowItem, const bool ignoreLocked=false) const
 Returns the topmost composer item at a specified position which is below a specified item. More...
 
template<class T >
void composerItems (QList< T *> &itemList)
 Return composer items of a specific type. More...
 
template<class T >
void composerItemsOnPage (QList< T *> &itemList, const int pageNumber) const
 Return composer items of a specific type on a specified page. More...
 
QList< const QgsComposerMap * > composerMapItems () const
 Returns pointers to all composer maps in the scene. More...
 
QRectF compositionBounds (bool ignorePages=false, double margin=0.0) const
 Calculates the bounds of all non-gui items in the composition. More...
 
void computeWorldFileParameters (double &a, double &b, double &c, double &d, double &e, double &f) const
 Compute world file parameters. More...
 
void computeWorldFileParameters (const QRectF &exportRegion, double &a, double &b, double &c, double &d, double &e, double &f) const
 Computes the world file parameters for a specified region of the composition. More...
 
QgsExpressionContext createExpressionContext () const override
 Creates an expression context relating to the compositions's current state. More...
 
QStringList customProperties () const
 Return list of keys stored in custom properties for composition. More...
 
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from the composition. More...
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the composition's property collection, used for data defined overrides. More...
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the composition's property collection, used for data defined overrides. More...
 
void doPrint (QPrinter &printer, QPainter &painter, bool startNewPage=false)
 Print on a preconfigured printer. More...
 
void endCommand ()
 Saves end state of item and pushes command to the undo history. More...
 
void endMultiFrameCommand ()
 
bool exportAsPDF (const QString &file)
 Convenience function that prepares the printer for printing in PDF and prints. More...
 
bool generateWorldFile () const
 Returns true if the composition will generate corresponding world files when pages are exported. More...
 
void georeferenceOutput (const QString &file, QgsComposerMap *referenceMap=nullptr, const QRectF &exportRegion=QRectF(), double dpi=-1) const
 Georeferences a file (image of PDF) exported from the composition. More...
 
QgsComposerItemgetComposerItemAbove (QgsComposerItem *item) const
 
QgsComposerItemgetComposerItemBelow (QgsComposerItem *item) const
 
const QgsComposerItemgetComposerItemById (const QString &id) const
 Returns a composer item given its text identifier. More...
 
const QgsComposerItemgetComposerItemByUuid (const QString &uuid) const
 Returns a composer item given its unique identifier. More...
 
const QgsComposerMapgetComposerMapById (const int id) const
 Returns the composer map with specified id. More...
 
QPen gridPen () const
 
GridStyle gridStyle () const
 
bool gridVisible () const
 
QgsComposerItemGroupgroupItems (QList< QgsComposerItem *> items)
 Creates a new group from a list of composer items and adds it to the composition. More...
 
int itemPageNumber (const QgsComposerItem *) const
 Returns on which page number (0-based) is displayed an item. More...
 
QgsComposerModelitemsModel ()
 Returns the items model attached to the composition. More...
 
bool loadFromTemplate (const QDomDocument &doc, QMap< QString, QString > *substitutionMap=nullptr, bool addUndoCommands=false, const bool clearComposition=true)
 Load a template document. More...
 
void lockSelectedItems ()
 Lock the selected items. More...
 
bool lowerItem (QgsComposerItem *item)
 
void lowerSelectedItems ()
 
bool moveItemToBottom (QgsComposerItem *item)
 
bool moveItemToTop (QgsComposerItem *item)
 
void moveSelectedItemsToBottom ()
 
void moveSelectedItemsToTop ()
 
QString name () const
 Returns the composition's name. 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...
 
int numPages () const
 Returns the number of pages in the composition. More...
 
bool pageIsEmpty (const int page) const
 Returns whether a page is empty, ie, it contains no items except for the background paper item. More...
 
QRectF pageItemBounds (int pageNumber, bool visibleOnly=false) const
 Returns the bounding box of the items contained on a specified page. More...
 
int pageNumberAt (QPointF position) const
 Returns the page number (0-based) given a coordinate. More...
 
int pageNumberForPoint (QPointF position) const
 Returns the page number corresponding to a point in the composition. More...
 
QList< QgsPaperItem *> pages ()
 Return pages in the correct order. More...
 
QgsFillSymbolpageStyleSymbol ()
 Note: added in version 2.1. More...
 
bool pagesVisible () const
 Returns whether the page items are be visible in the composition. More...
 
double paperHeight () const
 Height of paper item. More...
 
double paperWidth () const
 Width of paper item. More...
 
QgsComposition::PlotStyle plotStyle () const
 
QPointF positionOnPage (QPointF position) const
 Returns the position within a page of a point in the composition. More...
 
bool preventCursorChange () const
 
bool print (QPrinter &printer, const bool evaluateDDPageSize=false)
 Convenience function that prepares the printer and prints. More...
 
bool printAsRaster () const
 
QImage printPageAsRaster (int page, QSize imageSize=QSize(), int dpi=0)
 Renders a composer page to an image. More...
 
int printResolution () const
 
QgsProjectproject () const
 The project associated with the composition. 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...
 
bool raiseItem (QgsComposerItem *item)
 
void raiseSelectedItems ()
 
bool readXml (const QDomElement &compositionElem, const QDomDocument &doc)
 Reads settings from xml file. More...
 
QgsComposerMapreferenceMap () const
 Returns the map item which will be used to generate corresponding world files when the composition is exported. More...
 
void refreshZList ()
 Rebuilds the z order list by adding any item which are present in the composition but missing from the z order list. More...
 
void removeComposerItem (QgsComposerItem *item, const bool createCommand=true, const bool removeGroupItems=true)
 Remove item from the graphics scene. Additionally to QGraphicsScene::removeItem, this function considers undo/redo command. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from the composition. More...
 
void removeItemFromZList (QgsComposerItem *item)
 Removes item from z list. Usually called from destructor of QgsComposerItem. More...
 
void removeMultiFrame (QgsComposerMultiFrame *multiFrame)
 Removes multi frame (but does not delete it) More...
 
void removeSnapLine (QGraphicsLineItem *line)
 Remove custom snap line (and delete the object) More...
 
void renderPage (QPainter *p, int page)
 Renders a full page to a paint device. More...
 
void renderRect (QPainter *p, const QRectF &rect)
 Renders a portion of the composition to a paint device. More...
 
QImage renderRectAsRaster (const QRectF &rect, QSize imageSize=QSize(), int dpi=0)
 Renders a portion of the composition to an image. More...
 
void resizePageToContents (double marginTop=0.0, double marginRight=0.0, double marginBottom=0.0, double marginLeft=0.0)
 Resizes the composition page to fit the current contents of the composition. More...
 
void resizeToContentsMargins (double &marginTop, double &marginRight, double &marginBottom, double &marginLeft) const
 Returns the resize to contents margins. More...
 
QList< QgsComposerItem * > selectedComposerItems (const bool includeLockedItems=true)
 Returns list of selected composer items. More...
 
QgsComposerMouseHandlesselectionHandles ()
 Returns pointer to selection handles. More...
 
void selectNextByZOrder (const ZValueDirection direction)
 
void setAlignmentSnap (const bool s)
 
bool setAtlasMode (const QgsComposition::AtlasMode mode)
 Sets the current atlas mode of the composition. More...
 
void setBoundingBoxesVisible (const bool boundsVisible)
 Sets whether selection bounding boxes should be shown in the composition. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the composition. More...
 
void setGenerateWorldFile (bool enabled)
 Sets whether the composition will generate corresponding world files when pages are exported. More...
 
void setGridPen (const QPen &p)
 
void setGridStyle (const GridStyle s)
 
void setGridVisible (const bool b)
 
void setName (const QString &name)
 Sets the composition's name. More...
 
void setNumPages (const int pages)
 Sets the number of pages for the composition. More...
 
void setPageStyleSymbol (QgsFillSymbol *symbol)
 Note: added in version 2.1. More...
 
void setPagesVisible (bool visible)
 Sets whether the page items should be visible in the composition. More...
 
void setPaperSize (double width, double height, bool keepRelativeItemPosition=true)
 Changes size of paper item. More...
 
void setPlotStyle (const QgsComposition::PlotStyle style)
 
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...
 
void setPrintAsRaster (const bool enabled)
 
void setPrintResolution (const int dpi)
 
void setReferenceMap (QgsComposerMap *map)
 Sets the map item which will be used to generate corresponding world files when the composition is exported. More...
 
void setResizeToContentsMargins (double marginTop, double marginRight, double marginBottom, double marginLeft)
 Sets the resize to contents margins. More...
 
void setSmartGuidesEnabled (const bool b)
 
void setSnapGridOffsetX (const double offset)
 
void setSnapGridOffsetY (const double offset)
 
void setSnapGridResolution (const double r)
 
void setSnapLinesVisible (const bool visible)
 Hides / shows custom snap lines. More...
 
void setSnapToGridEnabled (const bool b)
 
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...
 
void setStatusMessage (const QString &message)
 Sets the status bar message for the composer window. More...
 
void setUseAdvancedEffects (const bool effectsEnabled)
 Used to enable or disable advanced effects such as blend modes in a composition. More...
 
bool shouldExportPage (const int page) const
 Returns whether a specified page number should be included in exports of the composition. More...
 
bool smartGuidesEnabled () const
 
double snapGridOffsetX () const
 
double snapGridOffsetY () const
 
double snapGridResolution () const
 
QList< QGraphicsLineItem *> * snapLines ()
 Returns pointer to snap lines collection. More...
 
bool snapLinesVisible () const
 
QPointF snapPointToGrid (QPointF scenePoint) const
 Snaps a scene coordinate point to grid. More...
 
bool snapToGridEnabled () const
 
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...
 
double spaceBetweenPages () const
 Returns the vertical space between pages in a composer view. More...
 
QUndoStack * undoStack ()
 Returns pointer to undo/redo command storage. More...
 
QList< QgsComposerItem * > ungroupItems (QgsComposerItemGroup *group)
 Ungroups items by removing them from an item group and removing the group from the composition. More...
 
void unlockAllItems ()
 Unlock all items. More...
 
void updateSettings ()
 Refreshes the composition when composer related options change. More...
 
bool useAdvancedEffects () const
 Returns true if a composition should use advanced effects such as blend modes. More...
 
bool writeXml (QDomElement &composerElem, QDomDocument &doc)
 Writes settings to xml (paper dimension) More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

Protected Member Functions

void init ()
 

Properties

QString name
 

Friends

class QgsComposerModel
 
class TestQgsComposition
 

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

Member Enumeration Documentation

◆ AtlasMode

Composition atlas modes.

Enumerator
AtlasOff 
PreviewAtlas 
ExportAtlas 

Definition at line 118 of file qgscomposition.h.

◆ GridStyle

Style to draw the snapping grid.

Enumerator
Solid 
Dots 
Crosses 

Definition at line 93 of file qgscomposition.h.

◆ PaperOrientation

Enumerator
Portrait 
Landscape 

Definition at line 106 of file qgscomposition.h.

◆ PlotStyle

Plot type.

Enumerator
Preview 
Print 
Postscript 

Definition at line 85 of file qgscomposition.h.

◆ ZValueDirection

Enumerator
ZValueBelow 
ZValueAbove 

Definition at line 100 of file qgscomposition.h.

Constructor & Destructor Documentation

◆ QgsComposition()

QgsComposition::QgsComposition ( QgsProject project)
explicit

Construct a new composition linked to the specified project.

Definition at line 67 of file qgscomposition.cpp.

◆ ~QgsComposition()

QgsComposition::~QgsComposition ( )

Definition at line 144 of file qgscomposition.cpp.

Member Function Documentation

◆ addComposerArrow()

void QgsComposition::addComposerArrow ( QgsComposerArrow arrow)

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

Definition at line 2438 of file qgscomposition.cpp.

◆ addComposerHtmlFrame()

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

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

Definition at line 2527 of file qgscomposition.cpp.

◆ addComposerLabel()

void QgsComposition::addComposerLabel ( QgsComposerLabel label)

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

Definition at line 2468 of file qgscomposition.cpp.

◆ addComposerLegend()

void QgsComposition::addComposerLegend ( QgsComposerLegend legend)

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

Definition at line 2497 of file qgscomposition.cpp.

◆ addComposerMap()

void QgsComposition::addComposerMap ( QgsComposerMap map)

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

Definition at line 2478 of file qgscomposition.cpp.

◆ addComposerPicture()

void QgsComposition::addComposerPicture ( QgsComposerPicture picture)

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

Definition at line 2507 of file qgscomposition.cpp.

◆ addComposerPolygon()

void QgsComposition::addComposerPolygon ( QgsComposerPolygon polygon)

Adds a composer polygon and advises composer to create a widget for it (through signal)

Definition at line 2448 of file qgscomposition.cpp.

◆ addComposerPolyline()

void QgsComposition::addComposerPolyline ( QgsComposerPolyline polyline)

Adds a composer polyline and advises composer to create a widget for it (through signal)

Definition at line 2458 of file qgscomposition.cpp.

◆ addComposerScaleBar()

void QgsComposition::addComposerScaleBar ( QgsComposerScaleBar scaleBar)

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

Definition at line 2487 of file qgscomposition.cpp.

◆ addComposerShape()

void QgsComposition::addComposerShape ( QgsComposerShape shape)

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

Definition at line 2517 of file qgscomposition.cpp.

◆ addComposerTableFrame()

void QgsComposition::addComposerTableFrame ( QgsComposerAttributeTableV2 table,
QgsComposerFrame frame 
)

Adds composer tablev2 frame and advises composer to create a widget for it (through signal)

Definition at line 2537 of file qgscomposition.cpp.

◆ addItemsFromXml()

void QgsComposition::addItemsFromXml ( const QDomElement &  elem,
const QDomDocument &  doc,
bool  addUndoCommands = false,
QPointF *  pos = nullptr,
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
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)

Definition at line 1134 of file qgscomposition.cpp.

◆ addItemToZList()

void QgsComposition::addItemToZList ( QgsComposerItem item)

Adds item to z list. Usually called from constructor of QgsComposerItem.

Definition at line 1514 of file qgscomposition.cpp.

◆ addMultiFrame()

void QgsComposition::addMultiFrame ( QgsComposerMultiFrame multiFrame)

Adds multiframe. The object is owned by QgsComposition until removeMultiFrame is called.

Definition at line 2424 of file qgscomposition.cpp.

◆ addSnapLine()

QGraphicsLineItem * QgsComposition::addSnapLine ( )

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

Definition at line 2065 of file qgscomposition.cpp.

◆ alignmentSnap()

bool QgsComposition::alignmentSnap ( ) const
inline

Definition at line 304 of file qgscomposition.h.

◆ alignSelectedItemsBottom()

void QgsComposition::alignSelectedItemsBottom ( )

Definition at line 1838 of file qgscomposition.cpp.

◆ alignSelectedItemsHCenter()

void QgsComposition::alignSelectedItemsHCenter ( )

Definition at line 1721 of file qgscomposition.cpp.

◆ alignSelectedItemsLeft()

void QgsComposition::alignSelectedItemsLeft ( )

Definition at line 1691 of file qgscomposition.cpp.

◆ alignSelectedItemsRight()

void QgsComposition::alignSelectedItemsRight ( )

Definition at line 1751 of file qgscomposition.cpp.

◆ alignSelectedItemsTop()

void QgsComposition::alignSelectedItemsTop ( )

Definition at line 1781 of file qgscomposition.cpp.

◆ alignSelectedItemsVCenter()

void QgsComposition::alignSelectedItemsVCenter ( )

Definition at line 1810 of file qgscomposition.cpp.

◆ atlasComposition()

QgsAtlasComposition& QgsComposition::atlasComposition ( )
inline

Definition at line 788 of file qgscomposition.h.

◆ atlasMode()

QgsComposition::AtlasMode QgsComposition::atlasMode ( ) const
inline

Returns the current atlas mode of the composition.

Returns
current atlas mode
See also
setAtlasMode

Definition at line 795 of file qgscomposition.h.

◆ beginCommand()

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

◆ beginMultiFrameCommand()

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

Definition at line 2379 of file qgscomposition.cpp.

◆ beginPrint()

void QgsComposition::beginPrint ( QPrinter &  printer,
const bool  evaluateDDPageSize = false 
)

Prepare the printer for printing.

Definition at line 2838 of file qgscomposition.cpp.

◆ beginPrintAsPDF()

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

Prepare the printer for printing in a PDF.

Definition at line 2712 of file qgscomposition.cpp.

◆ boundingBoxesVisible()

bool QgsComposition::boundingBoxesVisible ( ) const
inline

Returns whether selection bounding boxes should be shown in the composition.

Returns
true if selection bounding boxes should be shown
See also
setBoundingBoxesVisible
Since
QGIS 2.7

Definition at line 378 of file qgscomposition.h.

◆ cancelCommand()

void QgsComposition::cancelCommand ( )

Deletes current command.

Definition at line 2373 of file qgscomposition.cpp.

◆ cancelMultiFrameCommand()

void QgsComposition::cancelMultiFrameCommand ( )

Deletes current multi frame command.

Definition at line 2418 of file qgscomposition.cpp.

◆ clearSnapLines()

void QgsComposition::clearSnapLines ( )

Removes all snap lines.

Definition at line 2088 of file qgscomposition.cpp.

◆ composerItemAt() [1/2]

QgsComposerItem * QgsComposition::composerItemAt ( QPointF  position,
const bool  ignoreLocked = false 
) const

Returns the topmost composer item at a specified position.

Ignores paper items.

Parameters
positionpoint to search for item at
ignoreLockedset to true to ignore locked items
Returns
composer item at position

Definition at line 587 of file qgscomposition.cpp.

◆ composerItemAt() [2/2]

QgsComposerItem * QgsComposition::composerItemAt ( QPointF  position,
const QgsComposerItem belowItem,
const bool  ignoreLocked = false 
) const

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

Ignores paper items.

Parameters
positionpoint to search for item at
belowItemitem to search below
ignoreLockedset to true to ignore locked items
Returns
composer item at position which is below specified item

Definition at line 592 of file qgscomposition.cpp.

◆ composerItemGroupAdded

void QgsComposition::composerItemGroupAdded ( QgsComposerItemGroup group)
signal

Is emitted when a new item group has been added to the view.

◆ composerItems()

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

Return composer items of a specific type.

Parameters
itemListlist of item type to store matching items in
Note
not available in Python bindings

Definition at line 1136 of file qgscomposition.h.

◆ composerItemsOnPage()

template<class T >
void QgsComposition::composerItemsOnPage ( QList< T *> &  itemList,
const int  pageNumber 
) const

Return composer items of a specific type on a specified page.

Parameters
itemListlist of item type to store matching items in
pageNumberpage number (0 based)
Note
not available in Python bindings
Since
QGIS 2.5

Definition at line 1151 of file qgscomposition.h.

◆ composerMapItems()

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

◆ compositionBounds()

QRectF QgsComposition::compositionBounds ( bool  ignorePages = false,
double  margin = 0.0 
) const

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

Ignores snap lines and mouse handles.

Parameters
ignorePagesset to true to ignore page items
marginoptional marginal (in percent, e.g., 0.05 = 5% ) to add around items

Definition at line 245 of file qgscomposition.cpp.

◆ computeWorldFileParameters() [1/2]

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

Compute world file parameters.

Assumes the whole page containing the associated map item will be exported.

Definition at line 3087 of file qgscomposition.cpp.

◆ computeWorldFileParameters() [2/2]

void QgsComposition::computeWorldFileParameters ( const QRectF &  exportRegion,
double &  a,
double &  b,
double &  c,
double &  d,
double &  e,
double &  f 
) const

Computes the world file parameters for a specified region of the composition.

Parameters
exportRegionregion of the composition which will be associated with world file
a
b
c
d
e
f
Since
QGIS 2.12

Definition at line 3101 of file qgscomposition.cpp.

◆ createExpressionContext()

QgsExpressionContext QgsComposition::createExpressionContext ( ) const
overridevirtual

Creates an expression context relating to the compositions's current state.

The context includes scopes for global, project, composition and atlas properties.

Since
QGIS 2.12

Implements QgsExpressionContextGenerator.

Definition at line 3279 of file qgscomposition.cpp.

◆ customProperties()

QStringList QgsComposition::customProperties ( ) const

Return list of keys stored in custom properties for composition.

See also
setCustomProperty()
customProperty()
removeCustomProperty()
Since
QGIS 2.12

Definition at line 3274 of file qgscomposition.cpp.

◆ customProperty()

QVariant QgsComposition::customProperty ( const QString &  key,
const QVariant &  defaultValue = QVariant() 
) const

Read a custom property from the composition.

Parameters
keyproperty key
defaultValuedefault value to return if property with matching key does not exist
Returns
value of matching property
See also
setCustomProperty()
removeCustomProperty()
customProperties()
Since
QGIS 2.12

Definition at line 3264 of file qgscomposition.cpp.

◆ dataDefinedProperties() [1/2]

QgsPropertyCollection& QgsComposition::dataDefinedProperties ( )
inline

Returns a reference to the composition's property collection, used for data defined overrides.

Since
QGIS 3.0
See also
setDataDefinedProperties()

Definition at line 888 of file qgscomposition.h.

◆ dataDefinedProperties() [2/2]

const QgsPropertyCollection& QgsComposition::dataDefinedProperties ( ) const
inline

Returns a reference to the composition's property collection, used for data defined overrides.

Since
QGIS 3.0
See also
setDataDefinedProperties()

Definition at line 895 of file qgscomposition.h.

◆ doPrint()

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

◆ endCommand()

void QgsComposition::endCommand ( )

Saves end state of item and pushes command to the undo history.

Definition at line 2355 of file qgscomposition.cpp.

◆ endMultiFrameCommand()

void QgsComposition::endMultiFrameCommand ( )

Definition at line 2400 of file qgscomposition.cpp.

◆ exportAsPDF()

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

◆ generateWorldFile()

bool QgsComposition::generateWorldFile ( ) const
inline

Returns true if the composition will generate corresponding world files when pages are exported.

See also
setGenerateWorldFile()
referenceMap()

Definition at line 467 of file qgscomposition.h.

◆ georeferenceOutput()

void QgsComposition::georeferenceOutput ( const QString &  file,
QgsComposerMap referenceMap = nullptr,
const QRectF &  exportRegion = QRectF(),
double  dpi = -1 
) const

Georeferences a file (image of PDF) exported from the composition.

Parameters
filefilename of exported file
referenceMapmap item to use for georeferencing, or leave as nullptr to use the currently defined referenceMap().
exportRegionset to a valid rectangle to indicate that only part of the composition was exported
dpiset to DPI of exported file, or leave as -1 to use composition's DPI.
Since
QGIS 2.16

Definition at line 2745 of file qgscomposition.cpp.

◆ getComposerItemAbove()

QgsComposerItem * QgsComposition::getComposerItemAbove ( QgsComposerItem item) const

Definition at line 1563 of file qgscomposition.cpp.

◆ getComposerItemBelow()

QgsComposerItem * QgsComposition::getComposerItemBelow ( QgsComposerItem item) const

Definition at line 1568 of file qgscomposition.cpp.

◆ getComposerItemById()

const QgsComposerItem * QgsComposition::getComposerItemById ( const QString &  id) const

Returns a composer item given its text identifier.

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

Parameters
id- A QString representing the identifier of the item to retrieve.
Returns
QgsComposerItem pointer or 0 pointer if no such item exists.

Definition at line 690 of file qgscomposition.cpp.

◆ getComposerItemByUuid()

const QgsComposerItem * QgsComposition::getComposerItemByUuid ( const QString &  uuid) const

Returns a composer item given its unique identifier.

Parameters
uuidA QString representing the UUID of the item to

Definition at line 745 of file qgscomposition.cpp.

◆ getComposerMapById()

const QgsComposerMap * QgsComposition::getComposerMapById ( const int  id) const

Returns the composer map with specified id.

Returns
QgsComposerMap or 0 pointer if the composer map item does not exist

Definition at line 672 of file qgscomposition.cpp.

◆ gridPen()

QPen QgsComposition::gridPen ( ) const
inline

Definition at line 341 of file qgscomposition.h.

◆ gridStyle()

GridStyle QgsComposition::gridStyle ( ) const
inline

Definition at line 344 of file qgscomposition.h.

◆ gridVisible()

bool QgsComposition::gridVisible ( ) const
inline

Definition at line 297 of file qgscomposition.h.

◆ groupItems()

QgsComposerItemGroup * QgsComposition::groupItems ( QList< QgsComposerItem *>  items)

Creates a new group from a list of composer items and adds it to the composition.

Parameters
itemsitems to include in group
Returns
QgsComposerItemGroup of grouped items, if grouping was possible
Since
QGIS 2.6

Definition at line 1913 of file qgscomposition.cpp.

◆ init()

void QgsComposition::init ( )
protected

Definition at line 75 of file qgscomposition.cpp.

◆ itemAdded

void QgsComposition::itemAdded ( QgsComposerItem item)
signal

Is emitted when a new composer item has been added to the composition.

Since
QGIS 3.0

◆ itemPageNumber()

int QgsComposition::itemPageNumber ( const QgsComposerItem item) const

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

Definition at line 630 of file qgscomposition.cpp.

◆ itemRemoved

void QgsComposition::itemRemoved ( QgsComposerItem )
signal

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

◆ itemsModel()

QgsComposerModel* QgsComposition::itemsModel ( )
inline

Returns the items model attached to the composition.

Returns
QgsComposerModel for composition
Since
QGIS 2.5

Definition at line 817 of file qgscomposition.h.

◆ loadFromTemplate()

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

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
clearCompositionset to true to clear the existing composition and read all composition and atlas properties from the template. Set to false to only add new items from the template, without overwriting the existing items or composition settings.

Definition at line 1018 of file qgscomposition.cpp.

◆ lockSelectedItems()

void QgsComposition::lockSelectedItems ( )

Lock the selected items.

Definition at line 1866 of file qgscomposition.cpp.

◆ lowerItem()

bool QgsComposition::lowerItem ( QgsComposerItem item)

Definition at line 1631 of file qgscomposition.cpp.

◆ lowerSelectedItems()

void QgsComposition::lowerSelectedItems ( )

Definition at line 1610 of file qgscomposition.cpp.

◆ moveItemToBottom()

bool QgsComposition::moveItemToBottom ( QgsComposerItem item)

Definition at line 1685 of file qgscomposition.cpp.

◆ moveItemToTop()

bool QgsComposition::moveItemToTop ( QgsComposerItem item)

Definition at line 1658 of file qgscomposition.cpp.

◆ moveSelectedItemsToBottom()

void QgsComposition::moveSelectedItemsToBottom ( )

Definition at line 1664 of file qgscomposition.cpp.

◆ moveSelectedItemsToTop()

void QgsComposition::moveSelectedItemsToTop ( )

Definition at line 1637 of file qgscomposition.cpp.

◆ name()

QString QgsComposition::name ( ) const
inline

Returns the composition's name.

See also
setName()
Since
QGIS 3.0

Definition at line 140 of file qgscomposition.h.

◆ nameChanged

void QgsComposition::nameChanged ( const QString &  name)
signal

Emitted when the composition's name is changed.

Since
QGIS 3.0
See also
setName()

◆ nearestSnapLine()

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

Get nearest snap line.

Note
not available in Python bindings

Definition at line 2113 of file qgscomposition.cpp.

◆ nPagesChanged

void QgsComposition::nPagesChanged ( )
signal

◆ numPages()

int QgsComposition::numPages ( ) const

Returns the number of pages in the composition.

Returns
number of pages
See also
setNumPages

Definition at line 487 of file qgscomposition.cpp.

◆ pageIsEmpty()

bool QgsComposition::pageIsEmpty ( const int  page) const

Returns whether a page is empty, ie, it contains no items except for the background paper item.

Parameters
pagepage number, starting with 1
Returns
true if page is empty
Since
QGIS 2.5
See also
numPages
setNumPages
shouldExportPage

Definition at line 492 of file qgscomposition.cpp.

◆ pageItemBounds()

QRectF QgsComposition::pageItemBounds ( int  pageNumber,
bool  visibleOnly = false 
) const

Returns the bounding box of the items contained on a specified page.

Parameters
pageNumberpage number, where 0 is the first page
visibleOnlyset to true to only include visible items
Since
QGIS 2.12

Definition at line 276 of file qgscomposition.cpp.

◆ pageNumberAt()

int QgsComposition::pageNumberAt ( QPointF  position) const

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

Definition at line 625 of file qgscomposition.cpp.

◆ pageNumberForPoint()

int QgsComposition::pageNumberForPoint ( QPointF  position) const

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

Since
QGIS 2.1

Definition at line 574 of file qgscomposition.cpp.

◆ pages()

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

Return pages in the correct order.

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

Definition at line 810 of file qgscomposition.h.

◆ pageStyleSymbol()

QgsFillSymbol* QgsComposition::pageStyleSymbol ( )
inline

Note: added in version 2.1.

Definition at line 267 of file qgscomposition.h.

◆ pagesVisible()

bool QgsComposition::pagesVisible ( ) const
inline

Returns whether the page items are be visible in the composition.

This setting effects both display of the page boundaries in composer views and whether they will be rendered in composition exports.

Since
QGIS 2.12
See also
setPagesVisible()

Definition at line 326 of file qgscomposition.h.

◆ paperHeight()

double QgsComposition::paperHeight ( ) const

Height of paper item.

Returns
height in mm
See also
paperWidth
setPaperSize

Definition at line 370 of file qgscomposition.cpp.

◆ paperSizeChanged

void QgsComposition::paperSizeChanged ( )
signal

◆ paperWidth()

double QgsComposition::paperWidth ( ) const

Width of paper item.

Returns
width in mm
See also
paperHeight
setPaperSize

Definition at line 375 of file qgscomposition.cpp.

◆ plotStyle()

QgsComposition::PlotStyle QgsComposition::plotStyle ( ) const
inline

Definition at line 501 of file qgscomposition.h.

◆ positionOnPage()

QPointF QgsComposition::positionOnPage ( QPointF  position) const

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

Since
QGIS 2.1

Definition at line 557 of file qgscomposition.cpp.

◆ preventCursorChange()

bool QgsComposition::preventCursorChange ( ) const
inline

Definition at line 676 of file qgscomposition.h.

◆ print()

bool QgsComposition::print ( QPrinter &  printer,
const bool  evaluateDDPageSize = false 
)

Convenience function that prepares the printer and prints.

Returns
true if print was successful

Definition at line 2858 of file qgscomposition.cpp.

◆ printAsRaster()

bool QgsComposition::printAsRaster ( ) const
inline

Definition at line 458 of file qgscomposition.h.

◆ printPageAsRaster()

QImage QgsComposition::printPageAsRaster ( int  page,
QSize  imageSize = QSize(),
int  dpi = 0 
)

Renders a composer page to an image.

Parameters
pagepage number, 0 based such that the first page is page 0
imageSizeoptional target image size, in pixels. It is the caller's responsibility to ensure that the ratio of the target image size matches the ratio of the composition page size.
dpioptional dpi override, or 0 to use default composition print resolution. This parameter has no effect if imageSize is specified.
Returns
rendered image, or null image if image does not fit into available memory
See also
renderRectAsRaster()
renderPage()

Definition at line 2875 of file qgscomposition.cpp.

◆ printResolution()

int QgsComposition::printResolution ( ) const
inline

Definition at line 455 of file qgscomposition.h.

◆ printResolutionChanged

void QgsComposition::printResolutionChanged ( )
signal

Is emitted when the compositions print resolution changes.

◆ project()

QgsProject * QgsComposition::project ( ) const

The project associated with the composition.

Used to get access to layers, map themes, relations and various other bits. It is never null.

Since
QGIS 3.0

Definition at line 166 of file qgscomposition.cpp.

◆ pushAddRemoveCommand()

void QgsComposition::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.

Definition at line 2629 of file qgscomposition.cpp.

◆ raiseItem()

bool QgsComposition::raiseItem ( QgsComposerItem item)

Definition at line 1557 of file qgscomposition.cpp.

◆ raiseSelectedItems()

void QgsComposition::raiseSelectedItems ( )

Definition at line 1536 of file qgscomposition.cpp.

◆ readXml()

bool QgsComposition::readXml ( const QDomElement &  compositionElem,
const QDomDocument &  doc 
)

Reads settings from xml file.

Definition at line 922 of file qgscomposition.cpp.

◆ referenceMap()

QgsComposerMap * QgsComposition::referenceMap ( ) const

Returns the map item which will be used to generate corresponding world files when the composition is exported.

If no map was explicitly set via setReferenceMap(), the largest map in the composition will be returned (or nullptr if there are no maps in the composition).

See also
setReferenceMap()
generateWorldFile()

Definition at line 771 of file qgscomposition.cpp.

◆ refreshDataDefinedProperty

void QgsComposition::refreshDataDefinedProperty ( const QgsComposerObject::DataDefinedProperty  property = QgsComposerObject::AllProperties,
const QgsExpressionContext context = nullptr 
)
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.
contextexpression context for evaluating data defined expressions
Since
QGIS 2.5

Definition at line 226 of file qgscomposition.cpp.

◆ refreshItems

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.

Since
QGIS 2.3

Definition at line 191 of file qgscomposition.cpp.

◆ refreshItemsTriggered

void QgsComposition::refreshItemsTriggered ( )
signal

Is emitted when item in the composition must be refreshed.

◆ refreshZList()

void QgsComposition::refreshZList ( )

Rebuilds the z order list by adding any item which are present in the composition but missing from the z order list.

Definition at line 2018 of file qgscomposition.cpp.

◆ removeComposerItem()

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

Remove item from the graphics scene. Additionally to QGraphicsScene::removeItem, this function considers undo/redo command.

Definition at line 2548 of file qgscomposition.cpp.

◆ removeCustomProperty()

void QgsComposition::removeCustomProperty ( const QString &  key)

Remove a custom property from the composition.

Parameters
keyproperty key
See also
setCustomProperty()
customProperty()
customProperties()
Since
QGIS 2.12

Definition at line 3269 of file qgscomposition.cpp.

◆ removeItemFromZList()

void QgsComposition::removeItemFromZList ( QgsComposerItem item)

Removes item from z list. Usually called from destructor of QgsComposerItem.

Definition at line 1525 of file qgscomposition.cpp.

◆ removeMultiFrame()

void QgsComposition::removeMultiFrame ( QgsComposerMultiFrame multiFrame)

Removes multi frame (but does not delete it)

Definition at line 2431 of file qgscomposition.cpp.

◆ removeSnapLine()

void QgsComposition::removeSnapLine ( QGraphicsLineItem *  line)

Remove custom snap line (and delete the object)

Definition at line 2081 of file qgscomposition.cpp.

◆ renderPage()

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

Renders a full page to a paint device.

Parameters
pdestination painter
pagepage number, 0 based such that the first page is page 0
See also
renderRect()
printPageAsRaster()

Definition at line 2943 of file qgscomposition.cpp.

◆ renderRect()

void QgsComposition::renderRect ( QPainter *  p,
const QRectF &  rect 
)

Renders a portion of the composition to a paint device.

This method can be used to render sections of pages rather than full pages.

Parameters
pdestination painter
rectregion of composition to render
Since
QGIS 2.12
See also
renderPage()
renderRectAsRaster()

Definition at line 2960 of file qgscomposition.cpp.

◆ renderRectAsRaster()

QImage QgsComposition::renderRectAsRaster ( const QRectF &  rect,
QSize  imageSize = QSize(),
int  dpi = 0 
)

Renders a portion of the composition to an image.

This method can be used to render sections of pages rather than full pages.

Parameters
rectregion of composition to render
imageSizeoptional target image size, in pixels. It is the caller's responsibility to ensure that the ratio of the target image size matches the ratio of the specified region of the composition.
dpioptional dpi override, or 0 to use default composition print resolution. This parameter has no effect if imageSize is specified.
Returns
rendered image, or null image if image does not fit into available memory
Since
QGIS 2.12
See also
printPageAsRaster()
renderRect()

Definition at line 2909 of file qgscomposition.cpp.

◆ resizePageToContents()

void QgsComposition::resizePageToContents ( double  marginTop = 0.0,
double  marginRight = 0.0,
double  marginBottom = 0.0,
double  marginLeft = 0.0 
)

Resizes the composition page to fit the current contents of the composition.

Calling this method resets the number of pages to 1, with the size set to the minimum size required to fit all existing composer items. Items will also be repositioned so that the new top-left bounds of the composition is at the point (marginLeft, marginTop). An optional margin can be specified.

Parameters
marginToptop margin (millimeters)
marginRightright margin (millimeters)
marginBottombottom margin (millimeters)
marginLeftleft margin (millimeters)
Since
QGIS 2.12
See also
setResizeToContentsMargins()
resizeToContentsMargins()

Definition at line 380 of file qgscomposition.cpp.

◆ resizeToContentsMargins()

void QgsComposition::resizeToContentsMargins ( double &  marginTop,
double &  marginRight,
double &  marginBottom,
double &  marginLeft 
) const

Returns the resize to contents margins.

These margins are saved in the composition so that they can be restored with the composer.

Parameters
marginTopreference for top margin (millimeters)
marginRightreference for right margin (millimeters)
marginBottomreference for bottom margin (millimeters)
marginLeftreference for left margin (millimeters)
Since
QGIS 2.12
See also
resizePageToContents()
setResizeToContentsMargins()

Definition at line 432 of file qgscomposition.cpp.

◆ selectedComposerItems()

QList< QgsComposerItem * > QgsComposition::selectedComposerItems ( const bool  includeLockedItems = true)

Returns list of selected composer items.

Parameters
includeLockedItemsset to true to include locked items in list
Returns
list of selected items

Definition at line 635 of file qgscomposition.cpp.

◆ selectedItemChanged

void QgsComposition::selectedItemChanged ( QgsComposerItem selected)
signal

Is emitted when selected item changed. If 0, no item is selected.

◆ selectionHandles()

QgsComposerMouseHandles* QgsComposition::selectionHandles ( )
inline

Returns pointer to selection handles.

Note
not available in Python bindings

Definition at line 606 of file qgscomposition.h.

◆ selectNextByZOrder()

void QgsComposition::selectNextByZOrder ( const ZValueDirection  direction)

Definition at line 1573 of file qgscomposition.cpp.

◆ sendItemAddedSignal

void QgsComposition::sendItemAddedSignal ( QgsComposerItem item)
slot

Casts object to the proper subclass type and calls corresponding itemAdded signal.

Definition at line 2648 of file qgscomposition.cpp.

◆ setAlignmentSnap()

void QgsComposition::setAlignmentSnap ( const bool  s)
inline

Definition at line 303 of file qgscomposition.h.

◆ setAllDeselected

void QgsComposition::setAllDeselected ( )
slot

Clears any selected items in the composition.

Call this method rather than QGraphicsScene::clearSelection, as the latter does not correctly emit signals to allow the composition's model to update.

Since
QGIS 2.5

Definition at line 206 of file qgscomposition.cpp.

◆ setAtlasMode()

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

◆ setBoundingBoxesVisible()

void QgsComposition::setBoundingBoxesVisible ( const bool  boundsVisible)

Sets whether selection bounding boxes should be shown in the composition.

Parameters
boundsVisibleset to true to show selection bounding box
See also
boundingBoxesVisible
Since
QGIS 2.7

Definition at line 2285 of file qgscomposition.cpp.

◆ setCustomProperty()

void QgsComposition::setCustomProperty ( const QString &  key,
const QVariant &  value 
)

Set a custom property for the composition.

Parameters
keyproperty key. If a property with the same key already exists it will be overwritten.
valueproperty value
See also
customProperty()
removeCustomProperty()
customProperties()
Since
QGIS 2.12

Definition at line 3256 of file qgscomposition.cpp.

◆ setDataDefinedProperties

void QgsComposition::setDataDefinedProperties ( const QgsPropertyCollection collection)
inlineslot

Sets the composition's property collection, used for data defined overrides.

Parameters
collectionproperty collection. Existing properties will be replaced.
Since
QGIS 3.0
See also
dataDefinedProperties()

Definition at line 944 of file qgscomposition.h.

◆ setGenerateWorldFile()

void QgsComposition::setGenerateWorldFile ( bool  enabled)
inline

Sets whether the composition will generate corresponding world files when pages are exported.

Parameters
enabledset to true to generate world files
See also
generateWorldFile()
setReferenceMap()

Definition at line 476 of file qgscomposition.h.

◆ setGridPen()

void QgsComposition::setGridPen ( const QPen &  p)

Definition at line 2271 of file qgscomposition.cpp.

◆ setGridStyle()

void QgsComposition::setGridStyle ( const GridStyle  s)

Definition at line 2279 of file qgscomposition.cpp.

◆ setGridVisible()

void QgsComposition::setGridVisible ( const bool  b)

Definition at line 2247 of file qgscomposition.cpp.

◆ setName()

void QgsComposition::setName ( const QString &  name)

Sets the composition's name.

See also
name()
Since
QGIS 3.0

Definition at line 171 of file qgscomposition.cpp.

◆ setNumPages()

void QgsComposition::setNumPages ( const int  pages)

Sets the number of pages for the composition.

Parameters
pagesnumber of pages
See also
numPages

Definition at line 440 of file qgscomposition.cpp.

◆ setPageStyleSymbol()

void QgsComposition::setPageStyleSymbol ( QgsFillSymbol symbol)

Note: added in version 2.1.

Definition at line 539 of file qgscomposition.cpp.

◆ setPagesVisible()

void QgsComposition::setPagesVisible ( bool  visible)

Sets whether the page items should be visible in the composition.

Removing them will prevent both display of the page boundaries in composer views and will also prevent them from being rendered in composition exports.

Parameters
visibleset to true to show pages, false to hide pages
Since
QGIS 2.12
See also
pagesVisible()

Definition at line 2107 of file qgscomposition.cpp.

◆ setPaperSize()

void QgsComposition::setPaperSize ( double  width,
double  height,
bool  keepRelativeItemPosition = true 
)

Changes size of paper item.

Parameters
widthpage width in mm
heightpage height in mm
keepRelativeItemPositionif true, all items and guides will be moved so that they retain their same relative position to the top left corner of their current page.
See also
paperHeight
paperWidth

Definition at line 304 of file qgscomposition.cpp.

◆ setPlotStyle()

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

Definition at line 502 of file qgscomposition.h.

◆ setPreventCursorChange()

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

◆ setPrintAsRaster()

void QgsComposition::setPrintAsRaster ( const bool  enabled)
inline

Definition at line 459 of file qgscomposition.h.

◆ setPrintResolution()

void QgsComposition::setPrintResolution ( const int  dpi)

Definition at line 764 of file qgscomposition.cpp.

◆ setReferenceMap()

void QgsComposition::setReferenceMap ( QgsComposerMap map)

Sets the map item which will be used to generate corresponding world files when the composition is exported.

Parameters
mapcomposer map item
See also
referenceMap()
setGenerateWorldFile()

Definition at line 793 of file qgscomposition.cpp.

◆ setResizeToContentsMargins()

void QgsComposition::setResizeToContentsMargins ( double  marginTop,
double  marginRight,
double  marginBottom,
double  marginLeft 
)

Sets the resize to contents margins.

These margins are saved in the composition so that they can be restored with the composer.

Parameters
marginToptop margin (millimeters)
marginRightright margin (millimeters)
marginBottombottom margin (millimeters)
marginLeftleft margin (millimeters)
Since
QGIS 2.12
See also
resizePageToContents()
resizeToContentsMargins()

Definition at line 424 of file qgscomposition.cpp.

◆ setSelectedItem

void QgsComposition::setSelectedItem ( QgsComposerItem item)
slot

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

Parameters
itemitem to set as selected
Since
QGIS 2.3

Definition at line 196 of file qgscomposition.cpp.

◆ setSmartGuidesEnabled()

void QgsComposition::setSmartGuidesEnabled ( const bool  b)
inline

Definition at line 306 of file qgscomposition.h.

◆ setSnapGridOffsetX()

void QgsComposition::setSnapGridOffsetX ( const double  offset)

Definition at line 2259 of file qgscomposition.cpp.

◆ setSnapGridOffsetY()

void QgsComposition::setSnapGridOffsetY ( const double  offset)

Definition at line 2265 of file qgscomposition.cpp.

◆ setSnapGridResolution()

void QgsComposition::setSnapGridResolution ( const double  r)

Definition at line 2253 of file qgscomposition.cpp.

◆ setSnapLinesVisible()

void QgsComposition::setSnapLinesVisible ( const bool  visible)

Hides / shows custom snap lines.

Definition at line 2098 of file qgscomposition.cpp.

◆ setSnapToGridEnabled()

void QgsComposition::setSnapToGridEnabled ( const bool  b)

Definition at line 2241 of file qgscomposition.cpp.

◆ setSnapTolerance()

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
Since
QGIS 2.5

Definition at line 353 of file qgscomposition.h.

◆ setStatusMessage()

void QgsComposition::setStatusMessage ( const QString &  message)

Sets the status bar message for the composer window.

Since
QGIS 2.1

Definition at line 582 of file qgscomposition.cpp.

◆ setUseAdvancedEffects()

void QgsComposition::setUseAdvancedEffects ( const bool  effectsEnabled)

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

Definition at line 799 of file qgscomposition.cpp.

◆ shouldExportPage()

bool QgsComposition::shouldExportPage ( const int  page) const

Returns whether a specified page number should be included in exports of the composition.

Parameters
pagepage number, starting with 1
Returns
true if page should be exported
Since
QGIS 2.5
See also
numPages
pageIsEmpty

Definition at line 515 of file qgscomposition.cpp.

◆ smartGuidesEnabled()

bool QgsComposition::smartGuidesEnabled ( ) const
inline

Definition at line 307 of file qgscomposition.h.

◆ snapGridOffsetX()

double QgsComposition::snapGridOffsetX ( ) const
inline

Definition at line 335 of file qgscomposition.h.

◆ snapGridOffsetY()

double QgsComposition::snapGridOffsetY ( ) const
inline

Definition at line 338 of file qgscomposition.h.

◆ snapGridResolution()

double QgsComposition::snapGridResolution ( ) const
inline

Definition at line 332 of file qgscomposition.h.

◆ snapLines()

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

Returns pointer to snap lines collection.

Definition at line 600 of file qgscomposition.h.

◆ snapLinesVisible()

bool QgsComposition::snapLinesVisible ( ) const
inline

Definition at line 301 of file qgscomposition.h.

◆ snapPointToGrid()

QPointF QgsComposition::snapPointToGrid ( QPointF  scenePoint) const

Snaps a scene coordinate point to grid.

Definition at line 2028 of file qgscomposition.cpp.

◆ snapToGridEnabled()

bool QgsComposition::snapToGridEnabled ( ) const
inline

Definition at line 294 of file qgscomposition.h.

◆ snapTolerance()

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
Since
QGIS 2.5

Definition at line 362 of file qgscomposition.h.

◆ spaceBetweenPages()

double QgsComposition::spaceBetweenPages ( ) const
inline

Returns the vertical space between pages in a composer view.

Returns
space between pages in mm

Definition at line 226 of file qgscomposition.h.

◆ statusMsgChanged

void QgsComposition::statusMsgChanged ( const QString &  message)
signal

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

◆ undoStack()

QUndoStack* QgsComposition::undoStack ( )
inline

Returns pointer to undo/redo command storage.

Definition at line 381 of file qgscomposition.h.

◆ ungroupItems()

QList< QgsComposerItem * > QgsComposition::ungroupItems ( QgsComposerItemGroup group)

Ungroups items by removing them from an item group and removing the group from the composition.

Parameters
groupitem group to ungroup
Returns
list of items removed from the group, or an empty list if ungrouping was not successful
Since
QGIS 2.6

Definition at line 1947 of file qgscomposition.cpp.

◆ unlockAllItems()

void QgsComposition::unlockAllItems ( )

Unlock all items.

Definition at line 1884 of file qgscomposition.cpp.

◆ updateBounds

void QgsComposition::updateBounds ( )
slot

Updates the scene bounds of the composition.

Since
QGIS 2.2

Definition at line 186 of file qgscomposition.cpp.

◆ updateSettings()

void QgsComposition::updateSettings ( )

Refreshes the composition when composer related options change.

Since
QGIS 2.1

Definition at line 2295 of file qgscomposition.cpp.

◆ useAdvancedEffects()

bool QgsComposition::useAdvancedEffects ( ) const
inline

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

Definition at line 497 of file qgscomposition.h.

◆ variablesChanged

void QgsComposition::variablesChanged ( )
signal

Emitted whenever the expression variables stored in the composition have been changed.

Since
QGIS 3.0

◆ writeXml()

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

Writes settings to xml (paper dimension)

Definition at line 816 of file qgscomposition.cpp.

Friends And Related Function Documentation

◆ QgsComposerModel

friend class QgsComposerModel
friend

Definition at line 1132 of file qgscomposition.h.

◆ TestQgsComposition

friend class TestQgsComposition
friend

Definition at line 1133 of file qgscomposition.h.

Property Documentation

◆ name

QString QgsComposition::name
readwrite

Definition at line 80 of file qgscomposition.h.


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