18 #ifndef QGSANNOTATION_H 19 #define QGSANNOTATION_H 21 #include "qgis_core.h" 52 if ( dynamic_cast< QgsTextAnnotation * >( sipCpp ) )
53 sipType = sipType_QgsTextAnnotation;
54 else if ( dynamic_cast< QgsSvgAnnotation * >( sipCpp ) )
55 sipType = sipType_QgsSvgAnnotation;
56 else if ( dynamic_cast< QgsHtmlAnnotation * >( sipCpp ) )
57 sipType = sipType_QgsHtmlAnnotation;
65 Q_PROPERTY(
bool visible READ isVisible WRITE setVisible )
66 Q_PROPERTY(
bool hasFixedMapPosition READ hasFixedMapPosition WRITE setHasFixedMapPosition )
67 Q_PROPERTY(
QgsPointXY mapPosition READ mapPosition WRITE setMapPosition )
68 Q_PROPERTY( QSizeF frameSize READ frameSize WRITE setFrameSize )
87 bool isVisible()
const {
return mVisible; }
93 void setVisible(
bool visible );
110 void setHasFixedMapPosition(
bool fixed );
126 void setMapPosition(
const QgsPointXY &position );
155 void setRelativePosition( QPointF position );
161 void setFrameOffsetFromReferencePoint( QPointF offset );
174 void setFrameSize( QSizeF size );
188 void setContentsMargin(
const QgsMargins &margins );
221 virtual void writeXml( QDomElement &elem, QDomDocument &doc,
const QgsReadWriteContext &context )
const = 0;
229 virtual void readXml(
const QDomElement &itemElem,
const QgsReadWriteContext &context ) = 0;
271 virtual void setAssociatedFeature(
const QgsFeature &feature );
276 void appearanceChanged();
287 void mapLayerChanged();
295 virtual void renderAnnotation(
QgsRenderContext &context, QSizeF size )
const = 0;
301 virtual QSizeF minimumFrameSize()
const;
309 void _writeXml( QDomElement &itemElem, QDomDocument &doc,
const QgsReadWriteContext &context )
const;
330 void updateBalloon();
333 QLineF segment(
int index )
const;
336 QPointF pointOnLineWithDistance( QPointF startPoint, QPointF directionPoint,
double distance )
const;
344 bool mVisible =
true;
347 bool mHasFixedMapPosition =
true;
356 QPointF mRelativePosition;
359 QPointF mOffsetFromReferencePoint = QPointF( 50, -50 );
365 std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
370 std::unique_ptr<QgsFillSymbol> mFillSymbol;
373 int mBalloonSegment = -1;
376 QPointF mBalloonSegmentPoint1;
379 QPointF mBalloonSegmentPoint2;
389 #endif // QGSANNOTATION_H The class is used as a container of context for various read/write operations on other objects...
Base class for all map layer types.
A class to represent a 2D point.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QPointer< QgsMapLayer > QgsWeakMapLayerPointer
Weak pointer for QgsMapLayer.
QPointF relativePosition() const
Returns the relative position of the annotation, if it is not attached to a fixed map position...
Abstract base class for annotation items which are drawn over a map.
QgsPointXY mapPosition() const
Returns the map position of the annotation, if it is attached to a fixed map position.
QgsMargins contentsMargin() const
Returns the margins (in millimeters) between the outside of the frame and the annotation content...
QgsMarkerSymbol * markerSymbol() const
Returns the symbol that is drawn at the annotation's map position.
QgsMapLayer * mapLayer() const
Returns the map layer associated with the annotation.
QSizeF frameSize() const
Returns the size of the annotation's frame (the main area in which the annotation's content is drawn)...
QgsCoordinateReferenceSystem mapPositionCrs() const
Returns the CRS of the map position, or an invalid CRS if the annotation does not have a fixed map po...
Contains information about the context of a rendering operation.
QPointF frameOffsetFromReferencePoint() const
Returns the annotation's frame's offset from the mapPosition() reference point.
This class represents a coordinate reference system (CRS).
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
QgsFeature associatedFeature() const
Returns the feature associated with the annotation, or an invalid feature if none has been set...
bool hasFixedMapPosition() const
Returns true if the annotation is attached to a fixed map position, or false if the annotation uses a...
QgsFillSymbol * fillSymbol() const
Returns the symbol that is used for rendering the annotation frame.
The QgsMargins class defines the four margins of a rectangle.