QGIS API Documentation  2.99.0-Master (8ec3eaf)
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
QgsComposerItem Class Reference

A item that forms part of a map composition. More...

#include <qgscomposeritem.h>

Inheritance diagram for QgsComposerItem:
Inheritance graph
[legend]

Public Types

enum  ItemPositionMode {
  UpperLeft, UpperMiddle, UpperRight, MiddleLeft,
  Middle, MiddleRight, LowerLeft, LowerMiddle,
  LowerRight
}
 
enum  ItemType {
  ComposerItem = UserType + 100, ComposerArrow, ComposerItemGroup, ComposerLabel,
  ComposerLegend, ComposerMap, ComposerPaper, ComposerPicture,
  ComposerScaleBar, ComposerShape, ComposerPolygon, ComposerPolyline,
  ComposerTable, ComposerAttributeTable, ComposerTextTable, ComposerFrame
}
 
enum  MouseMoveAction {
  MoveItem, ResizeUp, ResizeDown, ResizeLeft,
  ResizeRight, ResizeLeftUp, ResizeRightUp, ResizeLeftDown,
  ResizeRightDown, NoAction
}
 Describes the action (move or resize in different directon) to be done during mouse move. More...
 
enum  ZoomMode { Zoom = 0, ZoomRecenter, ZoomToPoint, NoZoom }
 Modes for zooming item content. More...
 
- Public Types inherited from QgsComposerObject
enum  DataDefinedProperty {
  NoProperty = 0, AllProperties, TestProperty, PresetPaperSize,
  PaperWidth, PaperHeight, NumPages, PaperOrientation,
  PageNumber, PositionX, PositionY, ItemWidth,
  ItemHeight, ItemRotation, Transparency, BlendMode,
  ExcludeFromExports, MapRotation, MapScale, MapXMin,
  MapYMin, MapXMax, MapYMax, MapAtlasMargin,
  MapLayers, MapStylePreset, PictureSource, SourceUrl
}
 Data defined properties for different item types. More...
 
enum  PropertyValueType { EvaluatedValue = 0, OriginalValue }
 Specifies whether the value returned by a function should be the original, user set value, or the current evaluated value for the property. More...
 

Public Slots

virtual void refreshDataDefinedProperty (const QgsComposerObject::DataDefinedProperty property=QgsComposerObject::AllProperties, const QgsExpressionContext *context=nullptr) override
 Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value. More...
 
void repaint () override
 
virtual void setItemRotation (const double r, const bool adjustPosition=false)
 Sets the item rotation. More...
 
- Public Slots inherited from QgsComposerObject
virtual void refreshDataDefinedProperty (const DataDefinedProperty property=AllProperties, const QgsExpressionContext *context=nullptr)
 Refreshes a data defined property for the item by reevaluating the property's value and redrawing the item with this new value. More...
 
virtual void repaint ()
 Triggers a redraw for the item. More...
 

Signals

void frameChanged ()
 Emitted if the item's frame style changes. More...
 
void itemRotationChanged (double newRotation)
 Is emitted on item rotation change. More...
 
void lockChanged ()
 Emitted if the item's lock status changes. More...
 
void sizeChanged ()
 Emitted if the rectangle changes. More...
 
- Signals inherited from QgsComposerObject
void itemChanged ()
 Emitted when the item changes. More...
 

Public Member Functions

 QgsComposerItem (QgsComposition *composition, bool manageZValue=true)
 Constructor. More...
 
 QgsComposerItem (qreal x, qreal y, qreal width, qreal height, QgsComposition *composition, bool manageZValue=true)
 Constructor with box position and composer object. More...
 
virtual ~QgsComposerItem ()
 
bool _readXml (const QDomElement &itemElem, const QDomDocument &doc)
 Reads parameter that are not subclass specific in document. Usually called from readXml methods of subclasses. More...
 
bool _writeXml (QDomElement &itemElem, QDomDocument &doc) const
 Writes parameter that are not subclass specific in document. Usually called from writeXml methods of subclasses. More...
 
virtual void addItem (QgsComposerItem *item)
 Composite operations for item groups do nothing per default. More...
 
QColor backgroundColor () const
 Gets the background color for this item. More...
 
void beginCommand (const QString &commandText, QgsComposerMergeCommand::Context c=QgsComposerMergeCommand::Unknown)
 Starts new composer undo command. More...
 
virtual void beginItemCommand (const QString &text)
 
QPainter::CompositionMode blendMode () const
 Returns the item's composition blending mode. More...
 
void cancelCommand ()
 
virtual QgsExpressionContext createExpressionContext () const override
 Creates an expression context relating to the item's current state. More...
 
virtual QString displayName () const
 Get item display name. More...
 
bool effectsEnabled () const
 Returns whether effects (eg blend modes) are enabled for the item. More...
 
void endCommand ()
 Finish current command and push it onto the undo stack. More...
 
virtual void endItemCommand ()
 
virtual double estimatedFrameBleed () const
 Returns the estimated amount the item's frame bleeds outside the item's actual rectangle. More...
 
bool excludeFromExports (const QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue)
 Returns whether the item should be excluded from composer exports and prints. More...
 
Qt::PenJoinStyle frameJoinStyle () const
 Returns the join style used for drawing the item's frame. More...
 
QColor frameOutlineColor () const
 Returns the frame's outline color. More...
 
double frameOutlineWidth () const
 Returns the frame's outline width. More...
 
bool hasBackground () const
 Whether this item has a Background or not. More...
 
bool hasFrame () const
 Whether this item has a frame or not. More...
 
QString id () const
 Get item's id (which is not necessarly unique) More...
 
bool isGroupMember () const
 Returns whether this item is part of a group. More...
 
virtual bool isRemoved () const
 Returns whether this item has been removed from the composition. More...
 
double itemRotation (const QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue) const
 Returns the current rotation for the composer item. More...
 
ItemPositionMode lastUsedPositionMode ()
 Returns item's last used position mode. More...
 
void move (double dx, double dy)
 Moves item in canvas coordinates. More...
 
virtual void moveContent (double dx, double dy)
 Move Content of item. More...
 
virtual int numberExportLayers () const
 Get the number of layers that this item requires for exporting as layers. More...
 
int page () const
 Gets the page the item is currently on. More...
 
QPointF pagePos () const
 Returns the item's position relative to its current page. More...
 
bool positionLock () const
 Returns whether position lock for mouse drags is enabled returns true if item is locked for mouse movement and resizing. More...
 
virtual QRectF rectWithFrame () const
 Returns the item's rectangular bounds, including any bleed caused by the item's frame. More...
 
virtual void removeItems ()
 
virtual bool selected () const
 Is selected. More...
 
void setBackgroundColor (const QColor &backgroundColor)
 Sets the background color for this item. More...
 
void setBackgroundEnabled (const bool drawBackground)
 Set whether this item has a Background drawn around it or not. More...
 
void setBlendMode (const QPainter::CompositionMode blendMode)
 Sets the item's composition blending mode. More...
 
virtual void setCurrentExportLayer (const int layerIdx=-1)
 Sets the current layer to draw for exporting. More...
 
void setEffectsEnabled (const bool effectsEnabled)
 Sets whether effects (eg blend modes) are enabled for the item. More...
 
virtual void setExcludeFromExports (const bool exclude)
 Sets whether the item should be excluded from composer exports and prints. More...
 
virtual void setFrameEnabled (const bool drawFrame)
 Set whether this item has a frame drawn around it or not. More...
 
void setFrameJoinStyle (const Qt::PenJoinStyle style)
 Sets join style used when drawing the item's frame. More...
 
virtual void setFrameOutlineColor (const QColor &color)
 Sets frame outline color. More...
 
virtual void setFrameOutlineWidth (const double outlineWidth)
 Sets frame outline width. More...
 
virtual void setId (const QString &id)
 Set item's id (which is not necessarly unique) More...
 
void setIsGroupMember (const bool isGroupMember)
 Sets whether this item is part of a group. More...
 
void setIsRemoved (const bool removed)
 Sets whether this item has been removed from the composition. More...
 
void setItemPosition (double x, double y, ItemPositionMode itemPoint=UpperLeft, int page=-1)
 Moves the item to a new position (in canvas coordinates) More...
 
void setItemPosition (double x, double y, double width, double height, ItemPositionMode itemPoint=UpperLeft, bool posIncludesFrame=false, int page=-1)
 Sets item position and width / height in one go. More...
 
void setPositionLock (const bool lock)
 Locks / unlocks the item position for mouse drags. More...
 
virtual void setSceneRect (const QRectF &rectangle)
 Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size unit. More...
 
virtual void setSelected (bool s)
 Set selected, selected item should be highlighted. More...
 
void setTransparency (const int transparency)
 Sets the item's transparency. More...
 
virtual void setVisibility (const bool visible)
 Sets visibility for item. More...
 
int transparency () const
 Returns the item's transparency. More...
 
virtual int type () const override
 Return correct graphics item type. More...
 
virtual void updateItem ()
 Updates item, with the possibility to do custom update for subclasses. More...
 
void updatePagePos (double newPageWidth, double newPageHeight)
 Moves the item so that it retains its relative position on the page when the paper size changes. More...
 
QString uuid () const
 Get item identification name. More...
 
virtual void zoomContent (const double factor, const QPointF point, const ZoomMode mode=QgsComposerItem::Zoom)
 Zoom content of item. More...
 
- Public Member Functions inherited from QgsComposerObject
 QgsComposerObject (QgsComposition *composition)
 Constructor. More...
 
virtual ~QgsComposerObject ()
 
const QgsCompositioncomposition () const
 Returns the composition the item is attached to. More...
 
QgsCompositioncomposition ()
 
QStringList customProperties () const
 Return list of keys stored in custom properties for the object. More...
 
QVariant customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const
 Read a custom property from the object. More...
 
QgsDataDefineddataDefinedProperty (const DataDefinedProperty property) const
 Returns a reference to the data defined settings for one of the item's data defined properties. More...
 
virtual bool readXml (const QDomElement &itemElem, const QDomDocument &doc)
 Sets item state from DOM element. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from the object. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for the object. More...
 
void setDataDefinedProperty (const DataDefinedProperty property, const bool active, const bool useExpression, const QString &expression, const QString &field)
 Sets parameters for a data defined property for the item. More...
 
virtual bool writeXml (QDomElement &elem, QDomDocument &doc) const
 Stores item state in DOM element. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()
 

Protected Member Functions

void deleteAlignItems ()
 
void deleteHAlignSnapItem ()
 
void deleteVAlignSnapItem ()
 
virtual void drawBackground (QPainter *p)
 Draw background. More...
 
virtual void drawFrame (QPainter *p)
 Draw black frame around item. More...
 
virtual void drawSelectionBoxes (QPainter *p)
 Draws additional graphics on selected items. More...
 
QRectF evalItemRect (const QRectF &newRect, const bool resizeOnly=false, const QgsExpressionContext *context=nullptr)
 Evaluates an item's bounding rect to consider data defined position and size of item and reference point. More...
 
QGraphicsLineItem * hAlignSnapItem ()
 Return horizontal align snap item. Creates a new graphics line if 0. More...
 
double horizontalViewScaleFactor () const
 Returns the zoom factor of the graphics view. More...
 
double rectHandlerBorderTolerance () const
 Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the item border for resizing. More...
 
bool shouldDrawItem () const
 Returns whether the item should be drawn in the current context. More...
 
QGraphicsLineItem * vAlignSnapItem ()
 Return vertical align snap item. Creates a new graphics line if 0. More...
 
- Protected Member Functions inherited from QgsComposerObject
bool dataDefinedEvaluate (const QgsComposerObject::DataDefinedProperty property, QVariant &expressionValue, const QgsExpressionContext &context=QgsExpressionContext()) const
 Evaluate a data defined property and return the calculated value. More...
 

Protected Attributes

bool mBackground
 True if item background needs to be painted. More...
 
QColor mBackgroundColor
 Background color. More...
 
QPainter::CompositionMode mBlendMode
 Composition blend mode for item. More...
 
QGraphicsRectItem * mBoundingResizeRectangle
 Rectangle used during move and resize actions. More...
 
int mCurrentExportLayer
 The layer that needs to be exported. More...
 
QgsComposerItem::MouseMoveAction mCurrentMouseMoveAction
 
QgsComposerEffectmEffect
 
bool mEffectsEnabled
 
bool mEvaluatedExcludeFromExports
 Temporary evaluated item exclusion. More...
 
double mEvaluatedItemRotation
 Temporary evaluated item rotation in degrees, clockwise. More...
 
bool mExcludeFromExports
 Whether item should be excluded in exports. More...
 
bool mFrame
 True if item fram needs to be painted. More...
 
Qt::PenJoinStyle mFrameJoinStyle
 Frame join style. More...
 
QGraphicsLineItem * mHAlignSnapItem
 
bool mIsGroupMember
 Whether or not this item is part of a group. More...
 
bool mItemPositionLocked
 True if item position and size cannot be changed with mouse move. More...
 
double mItemRotation
 Item rotation in degrees, clockwise. More...
 
QPointF mLastMouseEventPos
 Position of the last mouse move event (in scene coordinates) More...
 
ItemPositionMode mLastUsedPositionMode
 The item's position mode. More...
 
double mLastValidViewScaleFactor
 Backup to restore item appearance if no view scale factor is available. More...
 
QPointF mMouseMoveStartPos
 Start point of the last mouse move action (in scene coordinates) More...
 
bool mRemovedFromComposition
 True if item has been removed from the composition. More...
 
int mTransparency
 Item transparency. More...
 
QGraphicsLineItem * mVAlignSnapItem
 
- Protected Attributes inherited from QgsComposerObject
QgsCompositionmComposition
 
QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QMap< QgsComposerObject::DataDefinedProperty, QString > mDataDefinedNames
 Map of data defined properties for the item to string name to use when exporting item to xml. More...
 

Friends

class QgsComposerItemGroup
 

Detailed Description

A item that forms part of a map composition.

Definition at line 39 of file qgscomposeritem.h.

Member Enumeration Documentation

§ ItemPositionMode

Enumerator
UpperLeft 
UpperMiddle 
UpperRight 
MiddleLeft 
Middle 
MiddleRight 
LowerLeft 
LowerMiddle 
LowerRight 

Definition at line 82 of file qgscomposeritem.h.

§ ItemType

Enumerator
ComposerItem 
ComposerArrow 
ComposerItemGroup 
ComposerLabel 
ComposerLegend 
ComposerMap 
ComposerPaper 
ComposerPicture 
ComposerScaleBar 
ComposerShape 
ComposerPolygon 
ComposerPolyline 
ComposerTable 
ComposerAttributeTable 
ComposerTextTable 
ComposerFrame 

Definition at line 44 of file qgscomposeritem.h.

§ MouseMoveAction

Describes the action (move or resize in different directon) to be done during mouse move.

Enumerator
MoveItem 
ResizeUp 
ResizeDown 
ResizeLeft 
ResizeRight 
ResizeLeftUp 
ResizeRightUp 
ResizeLeftDown 
ResizeRightDown 
NoAction 

Definition at line 68 of file qgscomposeritem.h.

§ ZoomMode

Modes for zooming item content.

Enumerator
Zoom 

Zoom to center of content.

ZoomRecenter 

Zoom and recenter content to point.

ZoomToPoint 

Zoom while maintaining relative position of point.

NoZoom 

No zoom.

Definition at line 100 of file qgscomposeritem.h.

Constructor & Destructor Documentation

§ QgsComposerItem() [1/2]

QgsComposerItem::QgsComposerItem ( QgsComposition composition,
bool  manageZValue = true 
)

Constructor.

Parameters
compositionparent composition
manageZValuetrue if the z-Value of this object should be managed by mComposition

Definition at line 48 of file qgscomposeritem.cpp.

§ QgsComposerItem() [2/2]

QgsComposerItem::QgsComposerItem ( qreal  x,
qreal  y,
qreal  width,
qreal  height,
QgsComposition composition,
bool  manageZValue = true 
)

Constructor with box position and composer object.

Parameters
xx coordinate of item
yy coordinate of item
widthwidth of item
heightheight of item
compositionparent composition
manageZValuetrue if the z-Value of this object should be managed by mComposition

Definition at line 77 of file qgscomposeritem.cpp.

§ ~QgsComposerItem()

QgsComposerItem::~QgsComposerItem ( )
virtual

Definition at line 143 of file qgscomposeritem.cpp.

Member Function Documentation

§ _readXml()

bool QgsComposerItem::_readXml ( const QDomElement &  itemElem,
const QDomDocument &  doc 
)

Reads parameter that are not subclass specific in document. Usually called from readXml methods of subclasses.

Definition at line 257 of file qgscomposeritem.cpp.

§ _writeXml()

bool QgsComposerItem::_writeXml ( QDomElement &  itemElem,
QDomDocument &  doc 
) const

Writes parameter that are not subclass specific in document. Usually called from writeXml methods of subclasses.

Definition at line 167 of file qgscomposeritem.cpp.

§ addItem()

virtual void QgsComposerItem::addItem ( QgsComposerItem item)
inlinevirtual

Composite operations for item groups do nothing per default.

Reimplemented in QgsComposerItemGroup.

Definition at line 395 of file qgscomposeritem.h.

§ backgroundColor()

QColor QgsComposerItem::backgroundColor ( ) const
inline

Gets the background color for this item.

Returns
background color
See also
setBackgroundColor
hasBackground

Definition at line 344 of file qgscomposeritem.h.

§ beginCommand()

void QgsComposerItem::beginCommand ( const QString &  commandText,
QgsComposerMergeCommand::Context  c = QgsComposerMergeCommand::Unknown 
)

Starts new composer undo command.

Parameters
commandTextcommand title
ccontext for mergeable commands (unknown for non-mergeable commands

Definition at line 477 of file qgscomposeritem.cpp.

§ beginItemCommand()

virtual void QgsComposerItem::beginItemCommand ( const QString &  text)
inlinevirtual

Reimplemented in QgsComposerFrame.

Definition at line 398 of file qgscomposeritem.h.

§ blendMode()

QPainter::CompositionMode QgsComposerItem::blendMode ( ) const
inline

Returns the item's composition blending mode.

Returns
item blending mode
See also
setBlendMode

Definition at line 358 of file qgscomposeritem.h.

§ cancelCommand()

void QgsComposerItem::cancelCommand ( )

Definition at line 493 of file qgscomposeritem.cpp.

§ createExpressionContext()

QgsExpressionContext QgsComposerItem::createExpressionContext ( ) const
overridevirtual

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

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

Note
added in QGIS 2.12

Reimplemented from QgsComposerObject.

Reimplemented in QgsComposerMap, and QgsComposerFrame.

Definition at line 855 of file qgscomposeritem.cpp.

§ deleteAlignItems()

void QgsComposerItem::deleteAlignItems ( )
protected

Definition at line 1099 of file qgscomposeritem.cpp.

§ deleteHAlignSnapItem()

void QgsComposerItem::deleteHAlignSnapItem ( )
protected

Definition at line 1079 of file qgscomposeritem.cpp.

§ deleteVAlignSnapItem()

void QgsComposerItem::deleteVAlignSnapItem ( )
protected

Definition at line 1089 of file qgscomposeritem.cpp.

§ displayName()

QString QgsComposerItem::displayName ( ) const
virtual

Get item display name.

This is the item's id if set, and if not, a user-friendly string identifying item type.

Returns
display name for item
See also
id
setId
Note
added in version 2.5

Reimplemented in QgsComposerMap, QgsComposerLegend, QgsComposerLabel, QgsComposerShape, QgsComposerPolygon, QgsComposerPolyline, and QgsComposerFrame.

Definition at line 1181 of file qgscomposeritem.cpp.

§ drawBackground()

void QgsComposerItem::drawBackground ( QPainter *  p)
protectedvirtual

Draw background.

Reimplemented in QgsComposerShape.

Definition at line 862 of file qgscomposeritem.cpp.

§ drawFrame()

void QgsComposerItem::drawFrame ( QPainter *  p)
protectedvirtual

Draw black frame around item.

Reimplemented in QgsComposerShape, and QgsComposerItemGroup.

Definition at line 540 of file qgscomposeritem.cpp.

§ drawSelectionBoxes()

void QgsComposerItem::drawSelectionBoxes ( QPainter *  p)
protectedvirtual

Draws additional graphics on selected items.

The base implementation has no effect.

Definition at line 501 of file qgscomposeritem.cpp.

§ effectsEnabled()

bool QgsComposerItem::effectsEnabled ( ) const
inline

Returns whether effects (eg blend modes) are enabled for the item.

Returns
true if effects are enabled
See also
setEffectsEnabled
transparency
blendMode

Definition at line 384 of file qgscomposeritem.h.

§ endCommand()

void QgsComposerItem::endCommand ( )

Finish current command and push it onto the undo stack.

Definition at line 485 of file qgscomposeritem.cpp.

§ endItemCommand()

virtual void QgsComposerItem::endItemCommand ( )
inlinevirtual

Reimplemented in QgsComposerFrame.

Definition at line 405 of file qgscomposeritem.h.

§ estimatedFrameBleed()

double QgsComposerItem::estimatedFrameBleed ( ) const
virtual

Returns the estimated amount the item's frame bleeds outside the item's actual rectangle.

For instance, if the item has a 2mm frame outline, then 1mm of this frame is drawn outside the item's rect. In this case the return value will be 1.0

Note
introduced in 2.2
See also
rectWithFrame

Reimplemented in QgsComposerShape.

Definition at line 461 of file qgscomposeritem.cpp.

§ evalItemRect()

QRectF QgsComposerItem::evalItemRect ( const QRectF &  newRect,
const bool  resizeOnly = false,
const QgsExpressionContext context = nullptr 
)
protected

Evaluates an item's bounding rect to consider data defined position and size of item and reference point.

Parameters
newRecttarget bouding rect for item
resizeOnlyset to true if the item is only being resized. If true then the position of the returned rect will be adjusted to account for the item's position mode
contextexpression context for evaluating data defined expressions
Returns
bounding box rectangle for item after data defined size and position have been set and position mode has been accounted for
Note
added in QGIS 2.5

Definition at line 712 of file qgscomposeritem.cpp.

§ excludeFromExports()

bool QgsComposerItem::excludeFromExports ( const QgsComposerObject::PropertyValueType  valueType = QgsComposerObject::EvaluatedValue)

Returns whether the item should be excluded from composer exports and prints.

Parameters
valueTypecontrols whether the returned value is the user specified vaule, or the current evaluated value (which may be affected by data driven settings).
Returns
true if item should be excluded
Note
added in version 2.5
See also
setExcludeFromExports

Definition at line 1239 of file qgscomposeritem.cpp.

§ frameChanged

void QgsComposerItem::frameChanged ( )
signal

Emitted if the item's frame style changes.

Note
: this function was introduced in version 2.2

§ frameJoinStyle()

Qt::PenJoinStyle QgsComposerItem::frameJoinStyle ( ) const
inline

Returns the join style used for drawing the item's frame.

Returns
Join style for outline frame
Note
introduced in 2.3
See also
hasFrame
setFrameJoinStyle
frameOutlineWidth
frameOutlineColor

Definition at line 293 of file qgscomposeritem.h.

§ frameOutlineColor()

QColor QgsComposerItem::frameOutlineColor ( ) const
inline

Returns the frame's outline color.

Only used if hasFrame is true.

Returns
frame outline color
Note
introduced in 2.6
See also
hasFrame
setFrameOutlineColor
frameJoinStyle
setFrameOutlineColor

Definition at line 263 of file qgscomposeritem.h.

§ frameOutlineWidth()

double QgsComposerItem::frameOutlineWidth ( ) const
inline

Returns the frame's outline width.

Only used if hasFrame is true.

Returns
Frame outline width
Note
introduced in 2.3
See also
hasFrame
setFrameOutlineWidth
frameJoinStyle
frameOutlineColor

Definition at line 283 of file qgscomposeritem.h.

§ hAlignSnapItem()

QGraphicsLineItem * QgsComposerItem::hAlignSnapItem ( )
protected

Return horizontal align snap item. Creates a new graphics line if 0.

Definition at line 1051 of file qgscomposeritem.cpp.

§ hasBackground()

bool QgsComposerItem::hasBackground ( ) const
inline

Whether this item has a Background or not.

Returns
true if there is a Background around this item, otherwise false.
See also
setBackgroundEnabled
backgroundColor

Definition at line 329 of file qgscomposeritem.h.

§ hasFrame()

bool QgsComposerItem::hasFrame ( ) const
inline

Whether this item has a frame or not.

Returns
true if there is a frame around this item, otherwise false.
See also
setFrameEnabled
frameOutlineWidth
frameJoinStyle
frameOutlineColor

Definition at line 234 of file qgscomposeritem.h.

§ horizontalViewScaleFactor()

double QgsComposerItem::horizontalViewScaleFactor ( ) const
protected

Returns the zoom factor of the graphics view.

Returns
the factor or -1 in case of error (e.g. graphic view does not exist)

Definition at line 948 of file qgscomposeritem.cpp.

§ id()

QString QgsComposerItem::id ( ) const
inline

Get item's id (which is not necessarly unique)

Returns
item id
See also
setId

Definition at line 442 of file qgscomposeritem.h.

§ isGroupMember()

bool QgsComposerItem::isGroupMember ( ) const
inline

Returns whether this item is part of a group.

Returns
true if item is in a group
Note
added in version 2.5
See also
setIsGroupMember

Definition at line 497 of file qgscomposeritem.h.

§ isRemoved()

virtual bool QgsComposerItem::isRemoved ( ) const
inlinevirtual

Returns whether this item has been removed from the composition.

Items removed from the composition are not deleted so that they can be restored via an undo command.

Returns
true if the item has been removed from the composition
Note
added in QGIS 2.5
See also
setIsRemoved

Definition at line 133 of file qgscomposeritem.h.

§ itemRotation()

double QgsComposerItem::itemRotation ( const QgsComposerObject::PropertyValueType  valueType = QgsComposerObject::EvaluatedValue) const

Returns the current rotation for the composer item.

Returns
rotation for composer item
Parameters
valueTypecontrols whether the returned value is the user specified rotation, or the current evaluated rotation (which may be affected by data driven rotation settings).
Note
this method was added in version 2.1
See also
setItemRotation

Definition at line 571 of file qgscomposeritem.cpp.

§ itemRotationChanged

void QgsComposerItem::itemRotationChanged ( double  newRotation)
signal

Is emitted on item rotation change.

§ lastUsedPositionMode()

ItemPositionMode QgsComposerItem::lastUsedPositionMode ( )
inline

Returns item's last used position mode.

Note
: This property has no effect on actual's item position, which is always the top-left corner.

Definition at line 215 of file qgscomposeritem.h.

§ lockChanged

void QgsComposerItem::lockChanged ( )
signal

Emitted if the item's lock status changes.

Note
: this function was introduced in version 2.5

§ move()

void QgsComposerItem::move ( double  dx,
double  dy 
)

Moves item in canvas coordinates.

Definition at line 576 of file qgscomposeritem.cpp.

§ moveContent()

virtual void QgsComposerItem::moveContent ( double  dx,
double  dy 
)
inlinevirtual

Move Content of item.

Does nothing per default (but implemented in composer map)

Parameters
dxmove in x-direction (canvas coordinates)
dymove in y-direction(canvas coordinates)

Reimplemented in QgsComposerMap.

Definition at line 156 of file qgscomposeritem.h.

§ numberExportLayers()

virtual int QgsComposerItem::numberExportLayers ( ) const
inlinevirtual

Get the number of layers that this item requires for exporting as layers.

Returns
0 if this item is to be placed on the same layer as the previous item, 1 if it should be placed on its own layer, and >1 if it requires multiple export layers
Note
this method was added in version 2.4
See also
setCurrentExportLayer

Reimplemented in QgsComposerMap.

Definition at line 512 of file qgscomposeritem.h.

§ page()

int QgsComposerItem::page ( ) const

Gets the page the item is currently on.

Returns
page number for item, beginning on page 1
See also
pagePos
updatePagePos
Note
this method was added in version 2.4

Definition at line 582 of file qgscomposeritem.cpp.

§ pagePos()

QPointF QgsComposerItem::pagePos ( ) const

Returns the item's position relative to its current page.

Returns
position relative to the page's top left corner.
See also
page
updatePagePos
Note
this method was added in version 2.4

Definition at line 595 of file qgscomposeritem.cpp.

§ positionLock()

bool QgsComposerItem::positionLock ( ) const
inline

Returns whether position lock for mouse drags is enabled returns true if item is locked for mouse movement and resizing.

See also
setPositionLock

Definition at line 423 of file qgscomposeritem.h.

§ rectHandlerBorderTolerance()

double QgsComposerItem::rectHandlerBorderTolerance ( ) const
protected

Returns the current (zoom level dependent) tolerance to decide if mouse position is close enough to the item border for resizing.

Definition at line 967 of file qgscomposeritem.cpp.

§ rectWithFrame()

QRectF QgsComposerItem::rectWithFrame ( ) const
virtual

Returns the item's rectangular bounds, including any bleed caused by the item's frame.

The bounds are returned in the item's coordinate system (see Qt's QGraphicsItem docs for more details about QGraphicsItem coordinate systems). The results differ from Qt's rect() function, as rect() makes no allowances for the portion of outlines which are drawn outside of the item.

Note
introduced in 2.2
See also
estimatedFrameBleed

Definition at line 471 of file qgscomposeritem.cpp.

§ refreshDataDefinedProperty

void QgsComposerItem::refreshDataDefinedProperty ( const QgsComposerObject::DataDefinedProperty  property = QgsComposerObject::AllProperties,
const QgsExpressionContext context = nullptr 
)
overridevirtualslot

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

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

Definition at line 1110 of file qgscomposeritem.cpp.

§ removeItems()

virtual void QgsComposerItem::removeItems ( )
inlinevirtual

Reimplemented in QgsComposerItemGroup.

Definition at line 396 of file qgscomposeritem.h.

§ repaint

void QgsComposerItem::repaint ( )
overrideslot

Definition at line 1105 of file qgscomposeritem.cpp.

§ selected()

virtual bool QgsComposerItem::selected ( ) const
inlinevirtual

Is selected.

Definition at line 148 of file qgscomposeritem.h.

§ setBackgroundColor()

void QgsComposerItem::setBackgroundColor ( const QColor &  backgroundColor)

Sets the background color for this item.

Parameters
backgroundColornew background color
Returns
nothing
See also
backgroundColor
setBackgroundEnabled

Definition at line 875 of file qgscomposeritem.cpp.

§ setBackgroundEnabled()

void QgsComposerItem::setBackgroundEnabled ( const bool  drawBackground)
inline

Set whether this item has a Background drawn around it or not.

Parameters
drawBackgrounddraw Background
Returns
nothing
See also
hasBackground
setBackgroundColor

Definition at line 337 of file qgscomposeritem.h.

§ setBlendMode()

void QgsComposerItem::setBlendMode ( const QPainter::CompositionMode  blendMode)

Sets the item's composition blending mode.

Parameters
blendModeblending mode for item
See also
blendMode

Definition at line 881 of file qgscomposeritem.cpp.

§ setCurrentExportLayer()

virtual void QgsComposerItem::setCurrentExportLayer ( const int  layerIdx = -1)
inlinevirtual

Sets the current layer to draw for exporting.

Parameters
layerIdxcan be set to -1 to draw all item layers, and must be less than numberExportLayers()
Note
this method was added in version 2.4
See also
numberExportLayers

Definition at line 519 of file qgscomposeritem.h.

§ setEffectsEnabled()

void QgsComposerItem::setEffectsEnabled ( const bool  effectsEnabled)

Sets whether effects (eg blend modes) are enabled for the item.

Parameters
effectsEnabledset to true to enable effects
See also
effectsEnabled
setTransparency
setBlendMode

Definition at line 941 of file qgscomposeritem.cpp.

§ setExcludeFromExports()

void QgsComposerItem::setExcludeFromExports ( const bool  exclude)
virtual

Sets whether the item should be excluded from composer exports and prints.

Parameters
excludeset to true to exclude the item from exports
Note
added in version 2.5
See also
excludeFromExports

Definition at line 1244 of file qgscomposeritem.cpp.

§ setFrameEnabled()

void QgsComposerItem::setFrameEnabled ( const bool  drawFrame)
virtual

Set whether this item has a frame drawn around it or not.

Parameters
drawFramedraw frame
See also
hasFrame
setFrameOutlineWidth
setFrameJoinStyle
setFrameOutlineColor

Reimplemented in QgsComposerLabel.

Definition at line 408 of file qgscomposeritem.cpp.

§ setFrameJoinStyle()

void QgsComposerItem::setFrameJoinStyle ( const Qt::PenJoinStyle  style)

Sets join style used when drawing the item's frame.

Parameters
styleJoin style for outline frame
Note
introduced in 2.3
See also
setFrameEnabled
frameJoinStyle
setFrameOutlineWidth
setFrameOutlineColor

Definition at line 446 of file qgscomposeritem.cpp.

§ setFrameOutlineColor()

void QgsComposerItem::setFrameOutlineColor ( const QColor &  color)
virtual

Sets frame outline color.

Parameters
colornew color for outline frame
Note
introduced in 2.6
See also
frameOutlineColor
setFrameEnabled
setFrameJoinStyle
setFrameOutlineWidth

Definition at line 420 of file qgscomposeritem.cpp.

§ setFrameOutlineWidth()

void QgsComposerItem::setFrameOutlineWidth ( const double  outlineWidth)
virtual

Sets frame outline width.

Parameters
outlineWidthnew width for outline frame
Note
introduced in 2.2
See also
frameOutlineWidth
setFrameEnabled
setFrameJoinStyle
setFrameOutlineColor

Reimplemented in QgsComposerMap, and QgsComposerLabel.

Definition at line 433 of file qgscomposeritem.cpp.

§ setId()

void QgsComposerItem::setId ( const QString &  id)
virtual

Set item's id (which is not necessarly unique)

Parameters
idnew id for item
See also
id

Definition at line 1156 of file qgscomposeritem.cpp.

§ setIsGroupMember()

void QgsComposerItem::setIsGroupMember ( const bool  isGroupMember)

Sets whether this item is part of a group.

Parameters
isGroupMemberset to true if item is in a group
Note
added in version 2.5
See also
isGroupMember

Definition at line 1175 of file qgscomposeritem.cpp.

§ setIsRemoved()

void QgsComposerItem::setIsRemoved ( const bool  removed)
inline

Sets whether this item has been removed from the composition.

Items removed from the composition are not deleted so that they can be restored via an undo command.

Parameters
removedset to true if the item has been removed from the composition
Note
added in QGIS 2.5
See also
isRemoved

Definition at line 142 of file qgscomposeritem.h.

§ setItemPosition() [1/2]

void QgsComposerItem::setItemPosition ( double  x,
double  y,
ItemPositionMode  itemPoint = UpperLeft,
int  page = -1 
)

Moves the item to a new position (in canvas coordinates)

Parameters
xitem position x (mm)
yitem position y (mm)
itemPointreference point which coincides with specified position
pageif page > 0, y is interpreted as relative to the origin of the specified page, if page <= 0, y is in absolute canvas coordinates. a page number of 1 corresponds to the first page.

Definition at line 616 of file qgscomposeritem.cpp.

§ setItemPosition() [2/2]

void QgsComposerItem::setItemPosition ( double  x,
double  y,
double  width,
double  height,
ItemPositionMode  itemPoint = UpperLeft,
bool  posIncludesFrame = false,
int  page = -1 
)

Sets item position and width / height in one go.

Parameters
xitem position x (mm)
yitem position y (mm)
widthitem width (mm)
heightitem height (mm)
itemPointreference point which coincides with specified position
posIncludesFrameset to true if the position and size arguments include the item's frame border
pageif page > 0, y is interpreted as relative to the origin of the specified page, if page <= 0, y is in absolute canvas coordinates. a page number of 1 corresponds to the first page.

Definition at line 623 of file qgscomposeritem.cpp.

§ setItemRotation

void QgsComposerItem::setItemRotation ( const double  r,
const bool  adjustPosition = false 
)
virtualslot

Sets the item rotation.

Parameters
ritem rotation in degrees
adjustPositionset to true if item should be shifted so that rotation occurs around item center. If false, rotation occurs around item origin
Note
this method was added in version 2.1
See also
itemRotation

Definition at line 985 of file qgscomposeritem.cpp.

§ setPositionLock()

void QgsComposerItem::setPositionLock ( const bool  lock)

Locks / unlocks the item position for mouse drags.

Parameters
lockset to true to prevent item movement and resizing via the mouse
See also
positionLock

Definition at line 553 of file qgscomposeritem.cpp.

§ setSceneRect()

void QgsComposerItem::setSceneRect ( const QRectF &  rectangle)
virtual

Sets this items bound in scene coordinates such that 1 item size units corresponds to 1 scene size unit.

Reimplemented in QgsComposerScaleBar, QgsComposerMap, QgsComposerPicture, QgsComposerShape, QgsPaperItem, QgsComposerArrow, QgsComposerFrame, and QgsComposerItemGroup.

Definition at line 685 of file qgscomposeritem.cpp.

§ setSelected()

void QgsComposerItem::setSelected ( bool  s)
virtual

Set selected, selected item should be highlighted.

Definition at line 156 of file qgscomposeritem.cpp.

§ setTransparency()

void QgsComposerItem::setTransparency ( const int  transparency)

Sets the item's transparency.

Parameters
transparencyinteger between 0 (transparent) and 255 (opaque)
See also
transparency

Definition at line 908 of file qgscomposeritem.cpp.

§ setVisibility()

void QgsComposerItem::setVisibility ( const bool  visible)
virtual

Sets visibility for item.

Parameters
visibleset to true to show item, false to hide item
Note
QGraphicsItem::setVisible should not be called directly on a QgsComposerItem, as some item types (eg groups) need to override the visibility toggle.
added in version 2.5

Reimplemented in QgsComposerItemGroup.

Definition at line 1222 of file qgscomposeritem.cpp.

§ shouldDrawItem()

bool QgsComposerItem::shouldDrawItem ( ) const
protected

Returns whether the item should be drawn in the current context.

Returns
true if item should be drawn
Note
added in QGIS 2.5

Definition at line 843 of file qgscomposeritem.cpp.

§ sizeChanged

void QgsComposerItem::sizeChanged ( )
signal

Emitted if the rectangle changes.

§ transparency()

int QgsComposerItem::transparency ( ) const
inline

Returns the item's transparency.

Returns
transparency as integer between 0 (transparent) and 255 (opaque)
See also
setTransparency

Definition at line 370 of file qgscomposeritem.h.

§ type()

virtual int QgsComposerItem::type ( ) const
inlineoverridevirtual

§ updateItem()

virtual void QgsComposerItem::updateItem ( )
inlinevirtual

Updates item, with the possibility to do custom update for subclasses.

Reimplemented in QgsComposerMap, and QgsComposerLegend.

Definition at line 436 of file qgscomposeritem.h.

§ updatePagePos()

void QgsComposerItem::updatePagePos ( double  newPageWidth,
double  newPageHeight 
)

Moves the item so that it retains its relative position on the page when the paper size changes.

Parameters
newPageWidthnew width of the page in mm
newPageHeightnew height of the page in mm
See also
page
pagePos
Note
this method was added in version 2.4

Definition at line 603 of file qgscomposeritem.cpp.

§ uuid()

QString QgsComposerItem::uuid ( ) const
inline

Get item identification name.

Returns
unique item identification string
Note
there is not setter since one can't manually set the id
See also
id
setId

Definition at line 456 of file qgscomposeritem.h.

§ vAlignSnapItem()

QGraphicsLineItem * QgsComposerItem::vAlignSnapItem ( )
protected

Return vertical align snap item. Creates a new graphics line if 0.

Definition at line 1065 of file qgscomposeritem.cpp.

§ zoomContent()

virtual void QgsComposerItem::zoomContent ( const double  factor,
const QPointF  point,
const ZoomMode  mode = QgsComposerItem::Zoom 
)
inlinevirtual

Zoom content of item.

Does nothing per default (but implemented in composer map)

Parameters
factorzoom factor, where > 1 results in a zoom in and < 1 results in a zoom out
pointitem point for zoom center
modezoom mode
Note
added in QGIS 2.5

Reimplemented in QgsComposerMap.

Definition at line 164 of file qgscomposeritem.h.

Friends And Related Function Documentation

§ QgsComposerItemGroup

friend class QgsComposerItemGroup
friend

Definition at line 716 of file qgscomposeritem.h.

Member Data Documentation

§ mBackground

bool QgsComposerItem::mBackground
protected

True if item background needs to be painted.

Definition at line 568 of file qgscomposeritem.h.

§ mBackgroundColor

QColor QgsComposerItem::mBackgroundColor
protected

Background color.

Definition at line 570 of file qgscomposeritem.h.

§ mBlendMode

QPainter::CompositionMode QgsComposerItem::mBlendMode
protected

Composition blend mode for item.

Definition at line 590 of file qgscomposeritem.h.

§ mBoundingResizeRectangle

QGraphicsRectItem* QgsComposerItem::mBoundingResizeRectangle
protected

Rectangle used during move and resize actions.

Definition at line 561 of file qgscomposeritem.h.

§ mCurrentExportLayer

int QgsComposerItem::mCurrentExportLayer
protected

The layer that needs to be exported.

Note
: if -1, all layers are to be exported
: this member was added in version 2.4

Definition at line 615 of file qgscomposeritem.h.

§ mCurrentMouseMoveAction

QgsComposerItem::MouseMoveAction QgsComposerItem::mCurrentMouseMoveAction
protected

Definition at line 554 of file qgscomposeritem.h.

§ mEffect

QgsComposerEffect* QgsComposerItem::mEffect
protected

Definition at line 592 of file qgscomposeritem.h.

§ mEffectsEnabled

bool QgsComposerItem::mEffectsEnabled
protected

Definition at line 591 of file qgscomposeritem.h.

§ mEvaluatedExcludeFromExports

bool QgsComposerItem::mEvaluatedExcludeFromExports
protected

Temporary evaluated item exclusion.

Data defined properties may mean this value differs from mExcludeFromExports.

Definition at line 603 of file qgscomposeritem.h.

§ mEvaluatedItemRotation

double QgsComposerItem::mEvaluatedItemRotation
protected

Temporary evaluated item rotation in degrees, clockwise.

Data defined rotation may mean this value differs from mItemRotation.

Definition at line 587 of file qgscomposeritem.h.

§ mExcludeFromExports

bool QgsComposerItem::mExcludeFromExports
protected

Whether item should be excluded in exports.

Definition at line 598 of file qgscomposeritem.h.

§ mFrame

bool QgsComposerItem::mFrame
protected

True if item fram needs to be painted.

Definition at line 566 of file qgscomposeritem.h.

§ mFrameJoinStyle

Qt::PenJoinStyle QgsComposerItem::mFrameJoinStyle
protected

Frame join style.

Definition at line 572 of file qgscomposeritem.h.

§ mHAlignSnapItem

QGraphicsLineItem* QgsComposerItem::mHAlignSnapItem
protected

Definition at line 562 of file qgscomposeritem.h.

§ mIsGroupMember

bool QgsComposerItem::mIsGroupMember
protected

Whether or not this item is part of a group.

Definition at line 609 of file qgscomposeritem.h.

§ mItemPositionLocked

bool QgsComposerItem::mItemPositionLocked
protected

True if item position and size cannot be changed with mouse move.

Definition at line 576 of file qgscomposeritem.h.

§ mItemRotation

double QgsComposerItem::mItemRotation
protected

Item rotation in degrees, clockwise.

Definition at line 582 of file qgscomposeritem.h.

§ mLastMouseEventPos

QPointF QgsComposerItem::mLastMouseEventPos
protected

Position of the last mouse move event (in scene coordinates)

Definition at line 558 of file qgscomposeritem.h.

§ mLastUsedPositionMode

ItemPositionMode QgsComposerItem::mLastUsedPositionMode
protected

The item's position mode.

Definition at line 606 of file qgscomposeritem.h.

§ mLastValidViewScaleFactor

double QgsComposerItem::mLastValidViewScaleFactor
mutableprotected

Backup to restore item appearance if no view scale factor is available.

Definition at line 579 of file qgscomposeritem.h.

§ mMouseMoveStartPos

QPointF QgsComposerItem::mMouseMoveStartPos
protected

Start point of the last mouse move action (in scene coordinates)

Definition at line 556 of file qgscomposeritem.h.

§ mRemovedFromComposition

bool QgsComposerItem::mRemovedFromComposition
protected

True if item has been removed from the composition.

Definition at line 552 of file qgscomposeritem.h.

§ mTransparency

int QgsComposerItem::mTransparency
protected

Item transparency.

Definition at line 595 of file qgscomposeritem.h.

§ mVAlignSnapItem

QGraphicsLineItem* QgsComposerItem::mVAlignSnapItem
protected

Definition at line 563 of file qgscomposeritem.h.


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