17 #ifndef QGSCOMPOSERITEM_H
18 #define QGSCOMPOSERITEM_H
23 #include <QGraphicsRectItem>
30 class QGraphicsLineItem;
44 ComposerItem = UserType + 100,
105 virtual int type()
const {
return ComposerItem; }
108 virtual void setSelected(
bool s );
111 virtual bool selected()
const {
return QGraphicsRectItem::isSelected();};
114 virtual bool writeSettings();
117 virtual bool readSettings();
120 virtual bool removeSettings();
123 void move(
double dx,
double dy );
128 virtual void moveContent(
double dx,
double dy ) { Q_UNUSED( dx ); Q_UNUSED( dy ); }
134 virtual void zoomContent(
int delta,
double x,
double y ) { Q_UNUSED( delta ); Q_UNUSED( x ); Q_UNUSED( y ); }
150 QPointF pagePos()
const;
160 void updatePagePos(
double newPageWidth,
double newPageHeight );
163 void setItemPosition(
double x,
double y, ItemPositionMode itemPoint = UpperLeft,
int page = -1 );
174 void setItemPosition(
double x,
double y,
double width,
double height, ItemPositionMode itemPoint = UpperLeft,
bool posIncludesFrame =
false,
int page = -1 );
183 virtual void setSceneRect(
const QRectF& rectangle );
189 virtual bool writeXML( QDomElement& elem, QDomDocument & doc )
const = 0;
192 bool _writeXML( QDomElement& itemElem, QDomDocument& doc )
const;
198 virtual bool readXML(
const QDomElement& itemElem,
const QDomDocument& doc ) = 0;
201 bool _readXML(
const QDomElement& itemElem,
const QDomDocument& doc );
216 void setFrameEnabled(
bool drawFrame );
224 virtual void setFrameOutlineWidth(
double outlineWidth );
248 void setFrameJoinStyle( Qt::PenJoinStyle style );
256 virtual double estimatedFrameBleed()
const;
266 virtual QRectF rectWithFrame()
const;
294 void setBackgroundColor(
const QColor& backgroundColor );
297 QPainter::CompositionMode
blendMode()
const {
return mBlendMode; }
300 void setBlendMode( QPainter::CompositionMode blendMode );
305 void setTransparency(
int transparency );
314 void setEffectsEnabled(
bool effectsEnabled );
333 void cancelCommand();
340 void drawText( QPainter* p,
double x,
double y,
const QString& text,
const QFont& font )
const;
351 void drawText( QPainter* p,
const QRectF& rect,
const QString& text,
const QFont& font, Qt::AlignmentFlag halignment = Qt::AlignLeft, Qt::AlignmentFlag valignment = Qt::AlignTop,
int flags = Qt::TextWordWrap )
const;
354 double textWidthMillimeters(
const QFont& font,
const QString& text )
const;
358 double fontHeightCharacterMM(
const QFont& font,
const QChar& c )
const;
361 double fontAscentMillimeters(
const QFont& font )
const;
364 double fontDescentMillimeters(
const QFont& font )
const;
370 double fontHeightMillimeters(
const QFont& font )
const;
373 double pixelFontSize(
double pointSize )
const;
376 QFont scaledFontPixelSize(
const QFont& font )
const;
380 void setPositionLock(
bool lock );
394 Q_DECL_DEPRECATED
double rotation()
const {
return mItemRotation; }
401 QString
id()
const {
return mId; }
405 virtual void setId(
const QString&
id );
410 QString
uuid()
const {
return mUuid; }
429 virtual void setRotation(
double r );
437 virtual void setItemRotation(
double r,
bool adjustPosition =
false );
493 virtual void drawSelectionBoxes( QPainter* p );
496 virtual void drawFrame( QPainter* p );
499 virtual void drawBackground( QPainter* p );
502 void drawArrowHead( QPainter* p,
double x,
double y,
double angle,
double arrowHeadWidth )
const;
505 double angle(
const QPointF& p1,
const QPointF& p2 )
const;
509 double rectHandlerBorderTolerance()
const;
513 double lockSymbolSize()
const;
518 double horizontalViewScaleFactor()
const;
523 bool imageSizeConsideringRotation(
double& width,
double& height,
double rotation )
const;
528 Q_DECL_DEPRECATED
bool imageSizeConsideringRotation(
double& width,
double& height )
const;
536 QRectF largestRotatedRectWithinBounds( QRectF originalRect, QRectF boundsRect,
double rotation )
const;
539 bool cornerPointOnRotatedAndScaledRect(
double& x,
double& y,
double width,
double height,
double rotation )
const;
544 Q_DECL_DEPRECATED
bool cornerPointOnRotatedAndScaledRect(
double& x,
double& y,
double width,
double height )
const;
547 void sizeChangedByRotation(
double& width,
double& height,
double rotation );
552 Q_DECL_DEPRECATED
void sizeChangedByRotation(
double& width,
double& height );
558 void rotate(
double angle,
double& x,
double& y )
const;
561 QGraphicsLineItem* hAlignSnapItem();
562 void deleteHAlignSnapItem();
564 QGraphicsLineItem* vAlignSnapItem();
565 void deleteVAlignSnapItem();
566 void deleteAlignItems();
570 void itemRotationChanged(
double newRotation );
587 void init(
bool manageZValue );
bool positionLock() const
Returns position lock for mouse drags (true means locked)
bool effectsEnabled() const
Returns true if effects (eg blend modes) are enabled for the item.
int mTransparency
Item transparency.
QPointF mLastMouseEventPos
Position of the last mouse move event (in scene coordinates)
virtual void beginItemCommand(const QString &text)
ItemPositionMode lastUsedPositionMode()
Returns item's last used position mode.
virtual bool selected() const
Is selected.
virtual void removeItems()
Qt::PenJoinStyle frameJoinStyle() const
Returns the join style used for drawing the item's frame.
A item that forms part of a map composition.
QgsComposerItem::MouseMoveAction mCurrentMouseMoveAction
double mLastValidViewScaleFactor
Backup to restore item appearance if no view scale factor is available.
ItemPositionMode mLastUsedPositionMode
The item's position mode.
A container for grouping several QgsComposerItems.
QColor backgroundColor() const
Gets the background color for this item.
QPainter::CompositionMode mBlendMode
Composition blend mode for item.
virtual void setCurrentExportLayer(int layerIdx=-1)
Sets the current layer to draw for exporting.
QgsComposition * composition()
double frameOutlineWidth() const
Returns the frame's outline width.
virtual int type() const
return correct graphics item type.
virtual void moveContent(double dx, double dy)
Move Content of item.
QString uuid() const
Get item identification name.
void setBackgroundEnabled(bool drawBackground)
Set whether this item has a Background drawn around it or not.
int transparency() const
Returns the item's transparency.
virtual void updateItem()
Updates item, with the possibility to do custom update for subclasses.
QGraphicsRectItem * mBoundingResizeRectangle
Rectangle used during move and resize actions.
bool mFrame
True if item fram needs to be painted.
double itemRotation() const
Returns the rotation for the composer item.
MouseMoveAction
Describes the action (move or resize in different directon) to be done during mouse move...
virtual int numberExportLayers() const
Get the number of layers that this item requires for exporting as layers.
QPointF mMouseMoveStartPos
Start point of the last mouse move action (in scene coordinates)
QgsComposition * mComposition
Graphics scene for map printing.
double ANALYSIS_EXPORT angle(Point3D *p1, Point3D *p2, Point3D *p3, Point3D *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored)
virtual void zoomContent(int delta, double x, double y)
Zoom content of item.
Q_DECL_DEPRECATED double rotation() const
Returns the rotation for the composer item.
Qt::PenJoinStyle mFrameJoinStyle
Frame join style.
QColor mBackgroundColor
Background color.
QGraphicsLineItem * mVAlignSnapItem
QGraphicsLineItem * mHAlignSnapItem
int mCurrentExportLayer
The layer that needs to be exported.
virtual void endItemCommand()
virtual void addItem(QgsComposerItem *item)
Composite operations for item groups do nothing per default.
bool mItemPositionLocked
True if item position and size cannot be changed with mouse move.
QPainter::CompositionMode blendMode() const
Returns the item's composition blending mode.
bool hasFrame() const
Whether this item has a frame or not.
const QgsComposition * composition() const
bool hasBackground() const
Whether this item has a Background or not.
QgsComposerEffect * mEffect
bool mBackground
True if item background needs to be painted.
double mItemRotation
Item rotation in degrees, clockwise.
QString id() const
Get item's id (which is not necessarly unique)