QGIS API Documentation  2.99.0-Master (f1c3692)
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, Opacity,
  BlendMode, ExcludeFromExports, FrameColor, BackgroundColor,
  MapRotation, MapScale, MapXMin, MapYMin,
  MapXMax, MapYMax, MapAtlasMargin, MapLayers,
  MapStylePreset, PictureSource, PictureSvgBackgroundColor, PictureSvgStrokeColor,
  PictureSvgStrokeWidth, SourceUrl, LegendTitle, LegendColumnCount,
  ScalebarFillColor, ScalebarFillColor2, ScalebarLineColor, ScalebarLineWidth
}
 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 rotation, const bool adjustPosition=false)
 Sets the item rotation, in degrees clockwise. 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 (e.g., 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 frameStrokeColor () const
 Returns the frame's stroke color. More...
 
double frameStrokeWidth () const
 Returns the frame's stroke 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 itemOpacity () const
 Returns the item's opacity. More...
 
double itemRotation (const QgsComposerObject::PropertyValueType valueType=QgsComposerObject::EvaluatedValue) const
 Returns the current rotation for the composer item, in degrees clockwise. 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 (e.g., 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 setFrameStrokeColor (const QColor &color)
 Sets frame stroke color. More...
 
virtual void setFrameStrokeWidth (const double strokeWidth)
 Sets frame stroke 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 setItemOpacity (const double opacity)
 Sets the item's opacity. 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 setUpdatesEnabled (bool enabled)
 Sets whether updates to the item are enabled. More...
 
virtual void setVisibility (const bool visible)
 Sets visibility for item. More...
 
virtual int type () const override
 Return correct graphics item type. More...
 
virtual void updateItem ()
 Updates (redraws) the 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...
 
bool updatesEnabled () const
 Returns whether updates to the item are enabled. 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 ()=default
 
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...
 
QgsPropertyCollectiondataDefinedProperties ()
 Returns a reference to the object's property collection, used for data defined overrides. More...
 
const QgsPropertyCollectiondataDefinedProperties () const
 Returns a reference to the object's property collection, used for data defined overrides. 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 setDataDefinedProperties (const QgsPropertyCollection &collection)
 Sets the objects's property collection, used for data defined overrides. More...
 
virtual bool writeXml (QDomElement &elem, QDomDocument &doc) const
 Stores item state in DOM element. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 

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 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 = nullptr
 Rectangle used during move and resize actions. More...
 
int mCurrentExportLayer
 The layer that needs to be exported. More...
 
QgsComposerItem::MouseMoveAction mCurrentMouseMoveAction
 
QgsComposerEffectmEffect = nullptr
 
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...
 
QColor mFrameColor
 Item frame color. More...
 
Qt::PenJoinStyle mFrameJoinStyle = Qt::MiterJoin
 Frame join style. More...
 
double mFrameWidth = 0.3
 Item frame width. More...
 
QGraphicsLineItem * mHAlignSnapItem = nullptr
 
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...
 
double mOpacity = 1.0
 Item opacity, between 0 and 1. More...
 
bool mRemovedFromComposition
 True if item has been removed from the composition. More...
 
QGraphicsLineItem * mVAlignSnapItem = nullptr
 
- Protected Attributes inherited from QgsComposerObject
QgsCompositionmComposition = nullptr
 
QgsObjectCustomProperties mCustomProperties
 Custom properties for object. More...
 
QgsPropertyCollection mDataDefinedProperties
 

Friends

class QgsComposerItemGroup
 

Additional Inherited Members

- Static Public Member Functions inherited from QgsComposerObject
static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns the composer object property definitions. More...
 

Detailed Description

A item that forms part of a map composition.

Definition at line 41 of file qgscomposeritem.h.

Member Enumeration Documentation

◆ ItemPositionMode

Enumerator
UpperLeft 
UpperMiddle 
UpperRight 
MiddleLeft 
Middle 
MiddleRight 
LowerLeft 
LowerMiddle 
LowerRight 

Definition at line 185 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 147 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 171 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 204 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 47 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 70 of file qgscomposeritem.cpp.

◆ ~QgsComposerItem()

QgsComposerItem::~QgsComposerItem ( )
virtual

Definition at line 120 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 232 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 144 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 536 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 474 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 472 of file qgscomposeritem.cpp.

◆ beginItemCommand()

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

Reimplemented in QgsComposerFrame.

Definition at line 539 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 490 of file qgscomposeritem.h.

◆ cancelCommand()

void QgsComposerItem::cancelCommand ( )

Definition at line 488 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.

Since
QGIS 2.12

Reimplemented from QgsComposerObject.

Reimplemented in QgsComposerMap, and QgsComposerFrame.

Definition at line 838 of file qgscomposeritem.cpp.

◆ deleteAlignItems()

void QgsComposerItem::deleteAlignItems ( )
protected

Definition at line 1103 of file qgscomposeritem.cpp.

◆ deleteHAlignSnapItem()

void QgsComposerItem::deleteHAlignSnapItem ( )
protected

Definition at line 1083 of file qgscomposeritem.cpp.

◆ deleteVAlignSnapItem()

void QgsComposerItem::deleteVAlignSnapItem ( )
protected

Definition at line 1093 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
Since
QGIS 2.5

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

Definition at line 1189 of file qgscomposeritem.cpp.

◆ drawBackground()

void QgsComposerItem::drawBackground ( QPainter *  p)
protectedvirtual

Draw background.

Reimplemented in QgsComposerShape.

Definition at line 845 of file qgscomposeritem.cpp.

◆ drawFrame()

void QgsComposerItem::drawFrame ( QPainter *  p)
protectedvirtual

Draw black frame around item.

Reimplemented in QgsComposerShape, and QgsComposerItemGroup.

Definition at line 535 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 496 of file qgscomposeritem.cpp.

◆ effectsEnabled()

bool QgsComposerItem::effectsEnabled ( ) const
inline

Returns whether effects (e.g., blend modes) are enabled for the item.

Returns
true if effects are enabled
See also
setEffectsEnabled
itemOpacity()
blendMode

Definition at line 524 of file qgscomposeritem.h.

◆ endCommand()

void QgsComposerItem::endCommand ( )

Finish current command and push it onto the undo stack.

Definition at line 480 of file qgscomposeritem.cpp.

◆ endItemCommand()

virtual void QgsComposerItem::endItemCommand ( )
inlinevirtual

Reimplemented in QgsComposerFrame.

Definition at line 547 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 stroke, then 1mm of this frame is drawn outside the item's rect. In this case the return value will be 1.0

Since
QGIS 2.2
See also
rectWithFrame

Reimplemented in QgsComposerShape.

Definition at line 456 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 bounding 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
Since
QGIS 2.5

Definition at line 715 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 value, or the current evaluated value (which may be affected by data driven settings).
Returns
true if item should be excluded
Since
QGIS 2.5
See also
setExcludeFromExports

Definition at line 1247 of file qgscomposeritem.cpp.

◆ frameChanged

void QgsComposerItem::frameChanged ( )
signal

Emitted if the item's frame style changes.

Since
QGIS 2.2

◆ frameJoinStyle()

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

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

Returns
Join style for stroke frame
Since
QGIS 2.3
See also
hasFrame
setFrameJoinStyle
frameStrokeWidth
frameStrokeColor

Definition at line 417 of file qgscomposeritem.h.

◆ frameStrokeColor()

QColor QgsComposerItem::frameStrokeColor ( ) const
inline

Returns the frame's stroke color.

Only used if hasFrame is true.

Returns
frame stroke color
Since
QGIS 2.6
See also
hasFrame
setFrameStrokeColor
frameJoinStyle
setFrameStrokeColor

Definition at line 384 of file qgscomposeritem.h.

◆ frameStrokeWidth()

double QgsComposerItem::frameStrokeWidth ( ) const
inline

Returns the frame's stroke width.

Only used if hasFrame is true.

Returns
Frame stroke width
Since
QGIS 2.3
See also
hasFrame
setFrameStrokeWidth
frameJoinStyle
frameStrokeColor

Definition at line 406 of file qgscomposeritem.h.

◆ hAlignSnapItem()

QGraphicsLineItem * QgsComposerItem::hAlignSnapItem ( )
protected

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

Definition at line 1055 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 457 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
frameStrokeWidth
frameJoinStyle
frameStrokeColor

Definition at line 352 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 965 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 591 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
Since
QGIS 2.5
See also
setIsGroupMember

Definition at line 653 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
Since
QGIS 2.5
See also
setIsRemoved

Definition at line 240 of file qgscomposeritem.h.

◆ itemOpacity()

double QgsComposerItem::itemOpacity ( ) const
inline

Returns the item's opacity.

This method should be used instead of QGraphicsItem::opacity() as any data defined overrides will be respected.

Returns
opacity as double between 1.0 (opaque) and 0 (transparent).
See also
setItemOpacity()

Definition at line 506 of file qgscomposeritem.h.

◆ itemRotation()

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

Returns the current rotation for the composer item, in degrees clockwise.

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).
Since
QGIS 2.1
See also
setItemRotation()

Definition at line 566 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 331 of file qgscomposeritem.h.

◆ lockChanged

void QgsComposerItem::lockChanged ( )
signal

Emitted if the item's lock status changes.

Since
QGIS 2.5

◆ move()

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

Moves item in canvas coordinates.

Definition at line 579 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 265 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
Since
QGIS 2.4
See also
setCurrentExportLayer

Reimplemented in QgsComposerMap.

Definition at line 670 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
Since
QGIS 2.4

Definition at line 585 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
Since
QGIS 2.4

Definition at line 598 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 567 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 984 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.

Since
QGIS 2.2
See also
estimatedFrameBleed

Definition at line 466 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
Since
QGIS 2.5

Definition at line 1114 of file qgscomposeritem.cpp.

◆ removeItems()

virtual void QgsComposerItem::removeItems ( )
inlinevirtual

Reimplemented in QgsComposerItemGroup.

Definition at line 537 of file qgscomposeritem.h.

◆ repaint

void QgsComposerItem::repaint ( )
overrideslot

Definition at line 1109 of file qgscomposeritem.cpp.

◆ selected()

virtual bool QgsComposerItem::selected ( ) const
inlinevirtual

Is selected.

Definition at line 256 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 858 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 466 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 867 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()
Since
QGIS 2.4
See also
numberExportLayers

Definition at line 678 of file qgscomposeritem.h.

◆ setEffectsEnabled()

void QgsComposerItem::setEffectsEnabled ( const bool  effectsEnabled)

Sets whether effects (e.g., blend modes) are enabled for the item.

Parameters
effectsEnabledset to true to enable effects
See also
effectsEnabled
setItemOpacity()
setBlendMode

Definition at line 958 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
Since
QGIS 2.5
See also
excludeFromExports

Definition at line 1252 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
setFrameStrokeWidth
setFrameJoinStyle
setFrameStrokeColor

Reimplemented in QgsComposerLabel.

Definition at line 398 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 stroke frame
Since
QGIS 2.3
See also
setFrameEnabled
frameJoinStyle
setFrameStrokeWidth
setFrameStrokeColor

Definition at line 441 of file qgscomposeritem.cpp.

◆ setFrameStrokeColor()

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

Sets frame stroke color.

Parameters
colornew color for stroke frame
Since
QGIS 2.6
See also
frameStrokeColor
setFrameEnabled
setFrameJoinStyle
setFrameStrokeWidth

Definition at line 410 of file qgscomposeritem.cpp.

◆ setFrameStrokeWidth()

void QgsComposerItem::setFrameStrokeWidth ( const double  strokeWidth)
virtual

Sets frame stroke width.

Parameters
strokeWidthnew width for stroke frame
Since
QGIS 2.2
See also
frameStrokeWidth
setFrameEnabled
setFrameJoinStyle
setFrameStrokeColor

Reimplemented in QgsComposerMap, and QgsComposerLabel.

Definition at line 427 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 1164 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
Since
QGIS 2.5
See also
isGroupMember

Definition at line 1183 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
Since
QGIS 2.5
See also
isRemoved

Definition at line 250 of file qgscomposeritem.h.

◆ setItemOpacity()

void QgsComposerItem::setItemOpacity ( const double  opacity)

Sets the item's opacity.

This method should be used instead of QGraphicsItem::setOpacity() as any data defined overrides will be respected.

Parameters
opacitydouble between 1.0 (opaque) and 0 (transparent).
See also
itemOpacity()

Definition at line 895 of file qgscomposeritem.cpp.

◆ 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 619 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 stroke
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 626 of file qgscomposeritem.cpp.

◆ setItemRotation

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

Sets the item rotation, in degrees clockwise.

Parameters
rotationitem 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
Since
QGIS 2.1
See also
itemRotation

Definition at line 1002 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 548 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, QgsComposerShape, QgsComposerPicture, QgsPaperItem, QgsComposerArrow, QgsComposerFrame, and QgsComposerItemGroup.

Definition at line 688 of file qgscomposeritem.cpp.

◆ setSelected()

void QgsComposerItem::setSelected ( bool  s)
virtual

Set selected, selected item should be highlighted.

Definition at line 133 of file qgscomposeritem.cpp.

◆ setUpdatesEnabled()

void QgsComposerItem::setUpdatesEnabled ( bool  enabled)
inline

Sets whether updates to the item are enabled.

If false, the item will not be redrawn. This can be used to prevent multiple item updates when many settings for an item are changed sequentially.

Since
QGIS 3.0
See also
updatesEnabled()

Definition at line 695 of file qgscomposeritem.h.

◆ 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 (e.g., groups) need to override the visibility toggle.
Since
QGIS 2.5

Reimplemented in QgsComposerItemGroup.

Definition at line 1230 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
Since
QGIS 2.5

Definition at line 826 of file qgscomposeritem.cpp.

◆ sizeChanged

void QgsComposerItem::sizeChanged ( )
signal

Emitted if the rectangle changes.

◆ type()

virtual int QgsComposerItem::type ( ) const
inlineoverridevirtual

◆ updateItem()

void QgsComposerItem::updateItem ( )
virtual

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

Subclasses should check updatesEnabled() to determine whether updates are currently permitted for the item.

Reimplemented in QgsComposerLegend.

Definition at line 571 of file qgscomposeritem.cpp.

◆ 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
Since
QGIS 2.4

Definition at line 606 of file qgscomposeritem.cpp.

◆ updatesEnabled()

bool QgsComposerItem::updatesEnabled ( ) const
inline

Returns whether updates to the item are enabled.

If false, the item will not be redrawn. This can be used to prevent multiple item updates when many settings for an item are changed sequentially.

Since
QGIS 3.0
See also
setUpdatesEnabled()

Definition at line 705 of file qgscomposeritem.h.

◆ 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 607 of file qgscomposeritem.h.

◆ vAlignSnapItem()

QGraphicsLineItem * QgsComposerItem::vAlignSnapItem ( )
protected

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

Definition at line 1069 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
Since
QGIS 2.5

Reimplemented in QgsComposerMap.

Definition at line 274 of file qgscomposeritem.h.

Friends And Related Function Documentation

◆ QgsComposerItemGroup

friend class QgsComposerItemGroup
friend

Definition at line 939 of file qgscomposeritem.h.

Member Data Documentation

◆ mBackground

bool QgsComposerItem::mBackground
protected

True if item background needs to be painted.

Definition at line 757 of file qgscomposeritem.h.

◆ mBackgroundColor

QColor QgsComposerItem::mBackgroundColor
protected

Background color.

Definition at line 759 of file qgscomposeritem.h.

◆ mBlendMode

QPainter::CompositionMode QgsComposerItem::mBlendMode
protected

Composition blend mode for item.

Definition at line 779 of file qgscomposeritem.h.

◆ mBoundingResizeRectangle

QGraphicsRectItem* QgsComposerItem::mBoundingResizeRectangle = nullptr
protected

Rectangle used during move and resize actions.

Definition at line 743 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
Since
QGIS 2.4

Definition at line 806 of file qgscomposeritem.h.

◆ mCurrentMouseMoveAction

QgsComposerItem::MouseMoveAction QgsComposerItem::mCurrentMouseMoveAction
protected

Definition at line 736 of file qgscomposeritem.h.

◆ mEffect

QgsComposerEffect* QgsComposerItem::mEffect = nullptr
protected

Definition at line 781 of file qgscomposeritem.h.

◆ mEffectsEnabled

bool QgsComposerItem::mEffectsEnabled
protected

Definition at line 780 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 793 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 776 of file qgscomposeritem.h.

◆ mExcludeFromExports

bool QgsComposerItem::mExcludeFromExports
protected

Whether item should be excluded in exports.

Definition at line 787 of file qgscomposeritem.h.

◆ mFrame

bool QgsComposerItem::mFrame
protected

True if item fram needs to be painted.

Definition at line 748 of file qgscomposeritem.h.

◆ mFrameColor

QColor QgsComposerItem::mFrameColor
protected

Item frame color.

Definition at line 750 of file qgscomposeritem.h.

◆ mFrameJoinStyle

Qt::PenJoinStyle QgsComposerItem::mFrameJoinStyle = Qt::MiterJoin
protected

Frame join style.

Definition at line 754 of file qgscomposeritem.h.

◆ mFrameWidth

double QgsComposerItem::mFrameWidth = 0.3
protected

Item frame width.

Definition at line 752 of file qgscomposeritem.h.

◆ mHAlignSnapItem

QGraphicsLineItem* QgsComposerItem::mHAlignSnapItem = nullptr
protected

Definition at line 744 of file qgscomposeritem.h.

◆ mIsGroupMember

bool QgsComposerItem::mIsGroupMember
protected

Whether or not this item is part of a group.

Definition at line 799 of file qgscomposeritem.h.

◆ mItemPositionLocked

bool QgsComposerItem::mItemPositionLocked
protected

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

Definition at line 764 of file qgscomposeritem.h.

◆ mItemRotation

double QgsComposerItem::mItemRotation
protected

Item rotation in degrees, clockwise.

Definition at line 770 of file qgscomposeritem.h.

◆ mLastMouseEventPos

QPointF QgsComposerItem::mLastMouseEventPos
protected

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

Definition at line 740 of file qgscomposeritem.h.

◆ mLastUsedPositionMode

ItemPositionMode QgsComposerItem::mLastUsedPositionMode
protected

The item's position mode.

Definition at line 796 of file qgscomposeritem.h.

◆ mLastValidViewScaleFactor

double QgsComposerItem::mLastValidViewScaleFactor
mutableprotected

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

Definition at line 767 of file qgscomposeritem.h.

◆ mMouseMoveStartPos

QPointF QgsComposerItem::mMouseMoveStartPos
protected

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

Definition at line 738 of file qgscomposeritem.h.

◆ mOpacity

double QgsComposerItem::mOpacity = 1.0
protected

Item opacity, between 0 and 1.

Definition at line 784 of file qgscomposeritem.h.

◆ mRemovedFromComposition

bool QgsComposerItem::mRemovedFromComposition
protected

True if item has been removed from the composition.

Definition at line 734 of file qgscomposeritem.h.

◆ mVAlignSnapItem

QGraphicsLineItem* QgsComposerItem::mVAlignSnapItem = nullptr
protected

Definition at line 745 of file qgscomposeritem.h.


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