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 ); }
137 void setItemPosition(
double x,
double y, ItemPositionMode itemPoint = UpperLeft );
148 void setItemPosition(
double x,
double y,
double width,
double height, ItemPositionMode itemPoint = UpperLeft,
bool posIncludesFrame =
false );
157 virtual void setSceneRect(
const QRectF& rectangle );
163 virtual bool writeXML( QDomElement& elem, QDomDocument & doc )
const = 0;
166 bool _writeXML( QDomElement& itemElem, QDomDocument& doc )
const;
172 virtual bool readXML(
const QDomElement& itemElem,
const QDomDocument& doc ) = 0;
175 bool _readXML(
const QDomElement& itemElem,
const QDomDocument& doc );
190 void setFrameEnabled(
bool drawFrame );
198 virtual void setFrameOutlineWidth(
double outlineWidth );
206 virtual double estimatedFrameBleed()
const;
216 virtual QRectF rectWithFrame()
const;
244 void setBackgroundColor(
const QColor& backgroundColor );
247 QPainter::CompositionMode
blendMode()
const {
return mBlendMode;}
250 void setBlendMode( QPainter::CompositionMode blendMode );
255 void setTransparency(
int transparency );
264 void setEffectsEnabled(
bool effectsEnabled );
283 void cancelCommand();
290 void drawText( QPainter* p,
double x,
double y,
const QString& text,
const QFont& font )
const;
293 void drawText( QPainter* p,
const QRectF& rect,
const QString& text,
const QFont& font, Qt::AlignmentFlag halignment = Qt::AlignLeft, Qt::AlignmentFlag valignment = Qt::AlignTop )
const;
296 double textWidthMillimeters(
const QFont& font,
const QString& text )
const;
300 double fontHeightCharacterMM(
const QFont& font,
const QChar& c )
const;
303 double fontAscentMillimeters(
const QFont& font )
const;
306 double fontDescentMillimeters(
const QFont& font )
const;
309 double pixelFontSize(
double pointSize )
const;
312 QFont scaledFontPixelSize(
const QFont& font )
const;
316 void setPositionLock(
bool lock );
337 QString
id()
const {
return mId; }
341 virtual void setId(
const QString&
id );
346 QString
uuid()
const {
return mUuid; }
352 virtual void setRotation(
double r );
360 virtual void setItemRotation(
double r,
bool adjustPosition =
false );
409 virtual void drawSelectionBoxes( QPainter* p );
412 virtual void drawFrame( QPainter* p );
415 virtual void drawBackground( QPainter* p );
418 void drawArrowHead( QPainter* p,
double x,
double y,
double angle,
double arrowHeadWidth )
const;
421 double angle(
const QPointF& p1,
const QPointF& p2 )
const;
425 double rectHandlerBorderTolerance()
const;
429 double lockSymbolSize()
const;
434 double horizontalViewScaleFactor()
const;
439 bool imageSizeConsideringRotation(
double& width,
double& height,
double rotation )
const;
444 bool imageSizeConsideringRotation(
double& width,
double& height )
const;
452 QRectF largestRotatedRectWithinBounds( QRectF originalRect, QRectF boundsRect,
double rotation )
const;
455 bool cornerPointOnRotatedAndScaledRect(
double& x,
double& y,
double width,
double height,
double rotation )
const;
460 bool cornerPointOnRotatedAndScaledRect(
double& x,
double& y,
double width,
double height )
const;
463 void sizeChangedByRotation(
double& width,
double& height,
double rotation );
468 void sizeChangedByRotation(
double& width,
double& height );
474 void rotate(
double angle,
double& x,
double& y )
const;
477 QGraphicsLineItem* hAlignSnapItem();
478 void deleteHAlignSnapItem();
480 QGraphicsLineItem* vAlignSnapItem();
481 void deleteVAlignSnapItem();
482 void deleteAlignItems();
486 void itemRotationChanged(
double newRotation );
503 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()
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.
QgsComposition * composition()
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...
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.
double rotation() const
Returns the rotation for the composer item.
QColor mBackgroundColor
Background color.
QGraphicsLineItem * mVAlignSnapItem
QGraphicsLineItem * mHAlignSnapItem
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)