QGIS API Documentation  2.99.0-Master (8ec3eaf)
qgsannotationitem.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationitem.cpp
3  ----------------------
4  begin : February 9, 2010
5  copyright : (C) 2010 by Marco Hugentobler
6  email : marco dot hugentobler at hugis dot net
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsannotationitem.h"
19 #include "qgsmapcanvas.h"
20 #include "qgsrendercontext.h"
21 #include "qgssymbollayerutils.h"
22 #include "qgssymbol.h"
23 #include <QPainter>
24 #include <QPen>
25 
27  : QgsMapCanvasItem( mapCanvas )
28  , mMapPositionFixed( true )
29  , mMapPositionCrs( QgsCoordinateReferenceSystem() )
30  , mOffsetFromReferencePoint( QPointF( 50, -50 ) )
31  , mBalloonSegment( -1 )
32 {
33  setFlag( QGraphicsItem::ItemIsSelectable, true );
35  mFrameBorderWidth = 1.0;
36  mFrameColor = QColor( 0, 0, 0 );
37  mFrameBackgroundColor = QColor( 255, 255, 255 );
38  setData( 0, "AnnotationItem" );
39 }
40 
42 {
43  delete mMarkerSymbol;
44 }
45 
47 {
48  delete mMarkerSymbol;
49  mMarkerSymbol = symbol;
51 }
52 
54 {
55  mMapPosition = pos;
56 
57  setPos( toCanvasCoordinates( mMapPosition ) );
59 }
60 
62 {
63  double x = pos().x() / mMapCanvas->width();
64  double y = pos().y() / mMapCanvas->height();
65  return QPointF( x, y );
66 }
67 
69 {
70  return 1.0 / mMapCanvas->logicalDpiX() * 25.4;
71 }
72 
74 {
75  mMapPositionCrs = crs;
76 }
77 
79 {
82  updateBalloon();
83 }
84 
86 {
87  if ( mMapPositionFixed && !fixed )
88  {
89  //set map position to the top left corner of the balloon
90  setMapPosition( toMapCoordinates( QPointF( pos() + mOffsetFromReferencePoint ).toPoint() ) );
91  mOffsetFromReferencePoint = QPointF( 0, 0 );
92  }
93  else if ( fixed && !mMapPositionFixed )
94  {
95  setMapPosition( toMapCoordinates( QPointF( pos() + QPointF( -100, -100 ) ).toPoint() ) );
96  mOffsetFromReferencePoint = QPointF( 100, 100 );
97  }
98  mMapPositionFixed = fixed;
100  updateBalloon();
101  update();
102 }
103 
105 {
106  if ( mMapPositionFixed )
107  {
109  setPos( toCanvasCoordinates( t.transform( mMapPosition ) ) );
110  }
111  else
112  {
113  mMapPosition = toMapCoordinates( pos().toPoint() );
114  }
115 }
116 
118 {
119  return mBoundingRect;
120 }
121 
123 {
124  return QSizeF( 0, 0 );
125 }
126 
128 {
129  prepareGeometryChange();
130  double halfSymbolSize = 0.0;
131  if ( mMarkerSymbol )
132  {
133  halfSymbolSize = scaledSymbolSize() / 2.0;
134  }
135 
136  double xMinPos = qMin( -halfSymbolSize, mOffsetFromReferencePoint.x() - mFrameBorderWidth );
137  double xMaxPos = qMax( halfSymbolSize, mOffsetFromReferencePoint.x() + mFrameSize.width() + mFrameBorderWidth );
138  double yMinPos = qMin( -halfSymbolSize, mOffsetFromReferencePoint.y() - mFrameBorderWidth );
139  double yMaxPos = qMax( halfSymbolSize, mOffsetFromReferencePoint.y() + mFrameSize.height() + mFrameBorderWidth );
140  mBoundingRect = QRectF( xMinPos, yMinPos, xMaxPos - xMinPos, yMaxPos - yMinPos );
141 }
142 
144 {
145  //first test if the point is in the frame. In that case we don't need a balloon.
146  if ( !mMapPositionFixed ||
147  ( mOffsetFromReferencePoint.x() < 0 && ( mOffsetFromReferencePoint.x() + mFrameSize.width() ) > 0
148  && mOffsetFromReferencePoint.y() < 0 && ( mOffsetFromReferencePoint.y() + mFrameSize.height() ) > 0 ) )
149  {
150  mBalloonSegment = -1;
151  return;
152  }
153 
154  //edge list
155  QList<QLineF> segmentList;
156  segmentList << segment( 0 );
157  segmentList << segment( 1 );
158  segmentList << segment( 2 );
159  segmentList << segment( 3 );
160 
161  //find closest edge / closest edge point
162  double minEdgeDist = DBL_MAX;
163  int minEdgeIndex = -1;
164  QLineF minEdge;
165  QgsPoint minEdgePoint;
166  QgsPoint origin( 0, 0 );
167 
168  for ( int i = 0; i < 4; ++i )
169  {
170  QLineF currentSegment = segmentList.at( i );
171  QgsPoint currentMinDistPoint;
172  double currentMinDist = origin.sqrDistToSegment( currentSegment.x1(), currentSegment.y1(), currentSegment.x2(), currentSegment.y2(), currentMinDistPoint );
173  if ( currentMinDist < minEdgeDist )
174  {
175  minEdgeIndex = i;
176  minEdgePoint = currentMinDistPoint;
177  minEdgeDist = currentMinDist;
178  minEdge = currentSegment;
179  }
180  }
181 
182  if ( minEdgeIndex < 0 )
183  {
184  return;
185  }
186 
187  //make that configurable for the item
188  double segmentPointWidth = 10;
189 
190  mBalloonSegment = minEdgeIndex;
191  QPointF minEdgeEnd = minEdge.p2();
192  mBalloonSegmentPoint1 = QPointF( minEdgePoint.x(), minEdgePoint.y() );
193  if ( sqrt( minEdgePoint.sqrDist( minEdgeEnd.x(), minEdgeEnd.y() ) ) < segmentPointWidth )
194  {
195  mBalloonSegmentPoint1 = pointOnLineWithDistance( minEdge.p2(), minEdge.p1(), segmentPointWidth );
196  }
197 
199 }
200 
201 void QgsAnnotationItem::drawFrame( QPainter* p ) const
202 {
203  QPen framePen( mFrameColor );
204  framePen.setWidthF( mFrameBorderWidth );
205 
206  p->setPen( framePen );
207  QBrush frameBrush( mFrameBackgroundColor );
208  p->setBrush( frameBrush );
209  p->setRenderHint( QPainter::Antialiasing, true );
210 
211  QPolygonF poly;
212  for ( int i = 0; i < 4; ++i )
213  {
214  QLineF currentSegment = segment( i );
215  poly << currentSegment.p1();
216  if ( i == mBalloonSegment && mMapPositionFixed )
217  {
218  poly << mBalloonSegmentPoint1;
219  poly << QPointF( 0, 0 );
220  poly << mBalloonSegmentPoint2;
221  }
222  poly << currentSegment.p2();
223  }
224  p->drawPolygon( poly );
225 }
226 
228 {
229  QSizeF frameSize = minimumFrameSize().expandedTo( size ); //don't allow frame sizes below minimum
232  updateBalloon();
233 }
234 
235 void QgsAnnotationItem::drawMarkerSymbol( QPainter* p ) const
236 {
237  if ( !p )
238  {
239  return;
240  }
241 
242  QgsRenderContext renderContext;
243  if ( !setRenderContextVariables( p, renderContext ) )
244  {
245  return;
246  }
247 
248  if ( mMarkerSymbol )
249  {
250  mMarkerSymbol->startRender( renderContext );
251  mMarkerSymbol->renderPoint( QPointF( 0, 0 ), nullptr, renderContext );
252  mMarkerSymbol->stopRender( renderContext );
253  }
254 }
255 
256 void QgsAnnotationItem::drawSelectionBoxes( QPainter* p ) const
257 {
258  if ( !p )
259  {
260  return;
261  }
262 
263  //no selection boxes for composer mode
264  if ( data( 1 ).toString() == QLatin1String( "composer" ) )
265  {
266  return;
267  }
268 
269  double handlerSize = 10;
270  p->setPen( Qt::NoPen );
271  p->setBrush( QColor( 200, 200, 210, 120 ) );
272  p->drawRect( QRectF( mBoundingRect.left(), mBoundingRect.top(), handlerSize, handlerSize ) );
273  p->drawRect( QRectF( mBoundingRect.right() - handlerSize, mBoundingRect.top(), handlerSize, handlerSize ) );
274  p->drawRect( QRectF( mBoundingRect.right() - handlerSize, mBoundingRect.bottom() - handlerSize, handlerSize, handlerSize ) );
275  p->drawRect( QRectF( mBoundingRect.left(), mBoundingRect.bottom() - handlerSize, handlerSize, handlerSize ) );
276 }
277 
279 {
280  switch ( index )
281  {
282  case 0:
284  + mFrameSize.width(), mOffsetFromReferencePoint.y() );
285  case 1:
286  return QLineF( mOffsetFromReferencePoint.x() + mFrameSize.width(), mOffsetFromReferencePoint.y(),
288  case 2:
289  return QLineF( mOffsetFromReferencePoint.x() + mFrameSize.width(), mOffsetFromReferencePoint.y() + mFrameSize.height(),
291  case 3:
292  return QLineF( mOffsetFromReferencePoint.x(), mOffsetFromReferencePoint.y() + mFrameSize.height(),
294  default:
295  return QLineF();
296  }
297 }
298 
299 QPointF QgsAnnotationItem::pointOnLineWithDistance( QPointF startPoint, QPointF directionPoint, double distance ) const
300 {
301  double dx = directionPoint.x() - startPoint.x();
302  double dy = directionPoint.y() - startPoint.y();
303  double length = sqrt( dx * dx + dy * dy );
304  double scaleFactor = distance / length;
305  return QPointF( startPoint.x() + dx * scaleFactor, startPoint.y() + dy * scaleFactor );
306 }
307 
309 {
310  QPointF itemPos = mapFromScene( pos );
311 
312  int cursorSensitivity = 7;
313 
314  if ( qAbs( itemPos.x() ) < cursorSensitivity && qAbs( itemPos.y() ) < cursorSensitivity ) //move map point if position is close to the origin
315  {
316  return MoveMapPosition;
317  }
318 
319  bool left, right, up, down;
320  left = qAbs( itemPos.x() - mOffsetFromReferencePoint.x() ) < cursorSensitivity;
321  right = qAbs( itemPos.x() - ( mOffsetFromReferencePoint.x() + mFrameSize.width() ) ) < cursorSensitivity;
322  up = qAbs( itemPos.y() - mOffsetFromReferencePoint.y() ) < cursorSensitivity;
323  down = qAbs( itemPos.y() - ( mOffsetFromReferencePoint.y() + mFrameSize.height() ) ) < cursorSensitivity;
324 
325  if ( left && up )
326  {
327  return ResizeFrameLeftUp;
328  }
329  else if ( right && up )
330  {
331  return ResizeFrameRightUp;
332  }
333  else if ( left && down )
334  {
335  return ResizeFrameLeftDown;
336  }
337  else if ( right && down )
338  {
339  return ResizeFrameRightDown;
340  }
341  if ( left )
342  {
343  return ResizeFrameLeft;
344  }
345  if ( right )
346  {
347  return ResizeFrameRight;
348  }
349  if ( up )
350  {
351  return ResizeFrameUp;
352  }
353  if ( down )
354  {
355  return ResizeFrameDown;
356  }
357 
358  //finally test if pos is in the frame area
359  if ( itemPos.x() >= mOffsetFromReferencePoint.x() && itemPos.x() <= ( mOffsetFromReferencePoint.x() + mFrameSize.width() )
360  && itemPos.y() >= mOffsetFromReferencePoint.y() && itemPos.y() <= ( mOffsetFromReferencePoint.y() + mFrameSize.height() ) )
361  {
362  return MoveFramePosition;
363  }
364  return NoAction;
365 }
366 
367 Qt::CursorShape QgsAnnotationItem::cursorShapeForAction( MouseMoveAction moveAction ) const
368 {
369  switch ( moveAction )
370  {
371  case NoAction:
372  return Qt::ArrowCursor;
373  case MoveMapPosition:
374  case MoveFramePosition:
375  return Qt::SizeAllCursor;
376  case ResizeFrameUp:
377  case ResizeFrameDown:
378  return Qt::SizeVerCursor;
379  case ResizeFrameLeft:
380  case ResizeFrameRight:
381  return Qt::SizeHorCursor;
382  case ResizeFrameLeftUp:
384  return Qt::SizeFDiagCursor;
385  case ResizeFrameRightUp:
386  case ResizeFrameLeftDown:
387  return Qt::SizeBDiagCursor;
388  default:
389  return Qt::ArrowCursor;
390  }
391 }
392 
394 {
395  if ( !mMarkerSymbol )
396  {
397  return 0.0;
398  }
399 
400  if ( !mMapCanvas )
401  {
402  return mMarkerSymbol->size();
403  }
404 
405  double dpmm = mMapCanvas->logicalDpiX() / 25.4;
406  return dpmm * mMarkerSymbol->size();
407 }
408 
409 void QgsAnnotationItem::_writeXml( QDomDocument& doc, QDomElement& itemElem ) const
410 {
411  if ( itemElem.isNull() )
412  {
413  return;
414  }
415  QDomElement annotationElem = doc.createElement( QStringLiteral( "AnnotationItem" ) );
416  annotationElem.setAttribute( QStringLiteral( "mapPositionFixed" ), mMapPositionFixed );
417  annotationElem.setAttribute( QStringLiteral( "mapPosX" ), qgsDoubleToString( mMapPosition.x() ) );
418  annotationElem.setAttribute( QStringLiteral( "mapPosY" ), qgsDoubleToString( mMapPosition.y() ) );
419  if ( mMapPositionCrs.isValid() )
420  mMapPositionCrs.writeXml( annotationElem, doc );
421  annotationElem.setAttribute( QStringLiteral( "offsetX" ), qgsDoubleToString( mOffsetFromReferencePoint.x() ) );
422  annotationElem.setAttribute( QStringLiteral( "offsetY" ), qgsDoubleToString( mOffsetFromReferencePoint.y() ) );
423  annotationElem.setAttribute( QStringLiteral( "frameWidth" ), qgsDoubleToString( mFrameSize.width() ) );
424  annotationElem.setAttribute( QStringLiteral( "frameHeight" ), qgsDoubleToString( mFrameSize.height() ) );
425  QPointF canvasPos = pos();
426  annotationElem.setAttribute( QStringLiteral( "canvasPosX" ), qgsDoubleToString( canvasPos.x() ) );
427  annotationElem.setAttribute( QStringLiteral( "canvasPosY" ), qgsDoubleToString( canvasPos.y() ) );
428  annotationElem.setAttribute( QStringLiteral( "frameBorderWidth" ), qgsDoubleToString( mFrameBorderWidth ) );
429  annotationElem.setAttribute( QStringLiteral( "frameColor" ), mFrameColor.name() );
430  annotationElem.setAttribute( QStringLiteral( "frameColorAlpha" ), mFrameColor.alpha() );
431  annotationElem.setAttribute( QStringLiteral( "frameBackgroundColor" ), mFrameBackgroundColor.name() );
432  annotationElem.setAttribute( QStringLiteral( "frameBackgroundColorAlpha" ), mFrameBackgroundColor.alpha() );
433  annotationElem.setAttribute( QStringLiteral( "visible" ), isVisible() );
434  if ( mMarkerSymbol )
435  {
436  QDomElement symbolElem = QgsSymbolLayerUtils::saveSymbol( QStringLiteral( "marker symbol" ), mMarkerSymbol, doc );
437  if ( !symbolElem.isNull() )
438  {
439  annotationElem.appendChild( symbolElem );
440  }
441  }
442  itemElem.appendChild( annotationElem );
443 }
444 
445 void QgsAnnotationItem::_readXml( const QDomDocument& doc, const QDomElement& annotationElem )
446 {
447  Q_UNUSED( doc );
448  if ( annotationElem.isNull() )
449  {
450  return;
451  }
452  QPointF pos;
453  pos.setX( annotationElem.attribute( QStringLiteral( "canvasPosX" ), QStringLiteral( "0" ) ).toDouble() );
454  pos.setY( annotationElem.attribute( QStringLiteral( "canvasPosY" ), QStringLiteral( "0" ) ).toDouble() );
455  setPos( pos );
456  QgsPoint mapPos;
457  mapPos.setX( annotationElem.attribute( QStringLiteral( "mapPosX" ), QStringLiteral( "0" ) ).toDouble() );
458  mapPos.setY( annotationElem.attribute( QStringLiteral( "mapPosY" ), QStringLiteral( "0" ) ).toDouble() );
459  mMapPosition = mapPos;
460 
461  if ( !mMapPositionCrs.readXml( annotationElem ) )
462  {
464  }
465 
466  mFrameBorderWidth = annotationElem.attribute( QStringLiteral( "frameBorderWidth" ), QStringLiteral( "0.5" ) ).toDouble();
467  mFrameColor.setNamedColor( annotationElem.attribute( QStringLiteral( "frameColor" ), QStringLiteral( "#000000" ) ) );
468  mFrameColor.setAlpha( annotationElem.attribute( QStringLiteral( "frameColorAlpha" ), QStringLiteral( "255" ) ).toInt() );
469  mFrameBackgroundColor.setNamedColor( annotationElem.attribute( QStringLiteral( "frameBackgroundColor" ) ) );
470  mFrameBackgroundColor.setAlpha( annotationElem.attribute( QStringLiteral( "frameBackgroundColorAlpha" ), QStringLiteral( "255" ) ).toInt() );
471  mFrameSize.setWidth( annotationElem.attribute( QStringLiteral( "frameWidth" ), QStringLiteral( "50" ) ).toDouble() );
472  mFrameSize.setHeight( annotationElem.attribute( QStringLiteral( "frameHeight" ), QStringLiteral( "50" ) ).toDouble() );
473  mOffsetFromReferencePoint.setX( annotationElem.attribute( QStringLiteral( "offsetX" ), QStringLiteral( "0" ) ).toDouble() );
474  mOffsetFromReferencePoint.setY( annotationElem.attribute( QStringLiteral( "offsetY" ), QStringLiteral( "0" ) ).toDouble() );
475  mMapPositionFixed = annotationElem.attribute( QStringLiteral( "mapPositionFixed" ), QStringLiteral( "1" ) ).toInt();
476  setVisible( annotationElem.attribute( QStringLiteral( "visible" ), QStringLiteral( "1" ) ).toInt() );
477 
478  //marker symbol
479  QDomElement symbolElem = annotationElem.firstChildElement( QStringLiteral( "symbol" ) );
480  if ( !symbolElem.isNull() )
481  {
482  QgsMarkerSymbol* symbol = QgsSymbolLayerUtils::loadSymbol<QgsMarkerSymbol>( symbolElem );
483  if ( symbol )
484  {
485  delete mMarkerSymbol;
486  mMarkerSymbol = symbol;
487  }
488  }
489 
491  updateBalloon();
492 }
493 
494 void QgsAnnotationItem::setItemData( int role, const QVariant& value )
495 {
496  setData( role, value );
497 }
498 
499 void QgsAnnotationItem::paint( QPainter* painter, const QStyleOptionGraphicsItem*, QWidget* )
500 {
501  // maintain API compatibility, if annotation item subclasses only implement the paint( QPainter* ) override
502  paint( painter );
503 }
504 
505 void QgsAnnotationItem::paint( QPainter* painter )
506 {
507  Q_UNUSED( painter );
508 }
void setMarkerSymbol(QgsMarkerSymbol *symbol)
Set symbol that is drawn on map position. Takes ownership.
static unsigned index
double y
Definition: qgspoint.h:147
QgsPoint toMapCoordinates(QPoint point) const
transformation from screen coordinates to map coordinates
double mFrameBorderWidth
Width of the frame.
static QDomElement saveSymbol(const QString &symbolName, QgsSymbol *symbol, QDomDocument &doc)
QPointF mOffsetFromReferencePoint
Describes the shift of the item content box to the reference point.
void drawMarkerSymbol(QPainter *p) const
Draws the map position marker symbol to a destination painter.
An abstract class for items that can be placed on the map canvas.
Qt::CursorShape cursorShapeForAction(MouseMoveAction moveAction) const
Returns suitable cursor shape for mouse move action.
virtual void setItemData(int role, const QVariant &value) override
deprecated - do not use
QSizeF frameSize() const
void drawSelectionBoxes(QPainter *p) const
Draws selection handles around the item.
virtual void setMapPositionCrs(const QgsCoordinateReferenceSystem &crs)
Sets the CRS of the map position.
bool writeXml(QDomNode &theNode, QDomDocument &theDoc) const
Stores state to the given Dom node in the given document.
QgsAnnotationItem::MouseMoveAction moveActionForPosition(QPointF pos) const
Returns the mouse move behaviour for a given position.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:106
void setFrameSize(QSizeF size)
void startRender(QgsRenderContext &context, const QgsFields &fields=QgsFields())
Begins the rendering process for the symbol.
Definition: qgssymbol.cpp:387
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
void updatePosition() override
called on changed extent or resize event to update position of the item
QRectF mBoundingRect
Bounding rect (including item frame and balloon)
QPointF toCanvasCoordinates(const QgsPoint &point) const
transformation from map coordinates to screen coordinates
void renderPoint(QPointF point, const QgsFeature *f, QgsRenderContext &context, int layer=-1, bool selected=false)
Definition: qgssymbol.cpp:1436
QPointF mBalloonSegmentPoint1
First segment point for drawing the connection (ccw direction)
virtual void setMapPosition(const QgsPoint &pos)
double sqrDistToSegment(double x1, double y1, double x2, double y2, QgsPoint &minDistPoint, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Returns the minimum distance between this point and a segment.
Definition: qgspoint.cpp:486
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition: qgis.h:184
QgsAnnotationItem(QgsMapCanvas *mapCanvas)
virtual QSizeF minimumFrameSize() const
int mBalloonSegment
Segment number where the connection to the map point is attached. -1 if no balloon needed (e...
QRectF boundingRect() const override
default implementation for canvas items
A class to represent a point.
Definition: qgspoint.h:142
void setX(double x)
Sets the x value of the point.
Definition: qgspoint.h:192
void setOffsetFromReferencePoint(QPointF offset)
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget=nullptr) override
Paint the annotation to a destination painter.
QgsCoordinateReferenceSystem mMapPositionCrs
CRS of the map position.
void setY(double y)
Sets the y value of the point.
Definition: qgspoint.h:200
const QgsMapSettings & mapSettings() const
Get access to properties used for map rendering.
double scaledSymbolSize() const
Returns the symbol size scaled in (mapcanvas) pixels. Used for the counding rect calculation.
bool mMapPositionFixed
True: the item stays at the same map position, False: the item stays on same screen position...
QColor mFrameColor
Frame / balloon color.
Contains information about the context of a rendering operation.
void updateBalloon()
Check where to attach the balloon connection between frame and map point.
double size() const
Returns the size for the whole symbol, which is the maximum size of all marker symbol layers in the s...
Definition: qgssymbol.cpp:1217
void _writeXml(QDomDocument &doc, QDomElement &itemElem) const
Serialize to XML.
QgsMapCanvas * mMapCanvas
pointer to map canvas
This class represents a coordinate reference system (CRS).
QgsMarkerSymbol * mMarkerSymbol
Point symbol that is to be drawn at the map reference location.
Class for doing transforms between two map coordinate systems.
QLineF segment(int index) const
Returns frame width in painter units.
virtual QPointF relativePosition() const override
Returns the relative position of the annotation, if it is not attached to a fixed map position...
double sqrDist(double x, double y) const
Returns the squared distance between this point a specified x, y coordinate.
Definition: qgspoint.cpp:382
QPointF pointOnLineWithDistance(QPointF startPoint, QPointF directionPoint, double distance) const
Returns a point on the line from startPoint to directionPoint that is a certain distance away from th...
QPointF mBalloonSegmentPoint2
Second segment point for drawing the balloon connection (ccw direction)
virtual double scaleFactor() const override
Returns a scaling factor which should be applied to painters before rendering the item...
QgsPoint mMapPosition
Map position (in case mMapPositionFixed is true)
void stopRender(QgsRenderContext &context)
Ends the rendering process.
Definition: qgssymbol.cpp:408
QSizeF mFrameSize
Size of the frame (without balloon)
bool readXml(const QDomNode &theNode)
Restores state from the given DOM node.
void setMapPositionFixed(bool fixed)
bool setRenderContextVariables(QPainter *p, QgsRenderContext &context) const
Sets render context parameters.
void drawFrame(QPainter *p) const
Draws the annotation frame to a destination painter.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
void _readXml(const QDomDocument &doc, const QDomElement &annotationElem)
Deserialize from XML.
double x
Definition: qgspoint.h:146