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() {
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 );
141 void setItemPosition(
double x,
double y,
double width,
double height, ItemPositionMode itemPoint = UpperLeft );
150 virtual void setSceneRect(
const QRectF& rectangle );
156 virtual bool writeXML( QDomElement& elem, QDomDocument & doc )
const = 0;
159 bool _writeXML( QDomElement& itemElem, QDomDocument& doc )
const;
165 virtual bool readXML(
const QDomElement& itemElem,
const QDomDocument& doc ) = 0;
168 bool _readXML(
const QDomElement& itemElem,
const QDomDocument& doc );
212 void setBackgroundColor(
const QColor& backgroundColor );
215 QPainter::CompositionMode
blendMode()
const {
return mBlendMode;}
218 void setBlendMode( QPainter::CompositionMode blendMode );
223 void setTransparency(
int transparency );
232 void setEffectsEnabled(
bool effectsEnabled );
251 void cancelCommand();
258 void drawText( QPainter* p,
double x,
double y,
const QString& text,
const QFont& font )
const;
261 void drawText( QPainter* p,
const QRectF& rect,
const QString& text,
const QFont& font, Qt::AlignmentFlag halignment = Qt::AlignLeft, Qt::AlignmentFlag valignment = Qt::AlignTop )
const;
264 double textWidthMillimeters(
const QFont& font,
const QString& text )
const;
268 double fontHeightCharacterMM(
const QFont& font,
const QChar& c )
const;
271 double fontAscentMillimeters(
const QFont& font )
const;
274 double fontDescentMillimeters(
const QFont& font )
const;
277 double pixelFontSize(
double pointSize )
const;
280 QFont scaledFontPixelSize(
const QFont& font )
const;
292 void updateCursor(
const QPointF& itemPos );
301 QString
id()
const {
return mId; }
305 virtual void setId(
const QString&
id );
310 QString
uuid()
const {
return mUuid; }
313 virtual void setRotation(
double r );
361 virtual void mouseMoveEvent( QGraphicsSceneMouseEvent * event );
362 virtual void mousePressEvent( QGraphicsSceneMouseEvent * event );
363 virtual void mouseReleaseEvent( QGraphicsSceneMouseEvent * event );
365 virtual void hoverMoveEvent( QGraphicsSceneHoverEvent * event );
368 Qt::CursorShape cursorForPosition(
const QPointF& itemCoordPos );
381 void changeItemRectangle(
const QPointF& currentPosition,
const QPointF& mouseMoveStartPos,
const QGraphicsRectItem* originalItem,
double dx,
double dy, QGraphicsRectItem* changeItem );
384 virtual void drawSelectionBoxes( QPainter* p );
387 virtual void drawFrame( QPainter* p );
390 virtual void drawBackground( QPainter* p );
393 void drawArrowHead( QPainter* p,
double x,
double y,
double angle,
double arrowHeadWidth )
const;
396 double angle(
const QPointF& p1,
const QPointF& p2 )
const;
400 double rectHandlerBorderTolerance()
const;
404 double lockSymbolSize()
const;
409 double horizontalViewScaleFactor()
const;
414 bool imageSizeConsideringRotation(
double& width,
double& height )
const;
416 bool cornerPointOnRotatedAndScaledRect(
double& x,
double& y,
double width,
double height )
const;
419 void sizeChangedByRotation(
double& width,
double& height );
424 void rotate(
double angle,
double& x,
double& y )
const;
427 QGraphicsLineItem* hAlignSnapItem();
428 void deleteHAlignSnapItem();
430 QGraphicsLineItem* vAlignSnapItem();
431 void deleteVAlignSnapItem();
432 void deleteAlignItems();
436 void rotationChanged(
double newRotation );
449 void init(
bool manageZValue );