mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-01 00:05:25 -04:00
Splits the rendering component of annotations out from map canvas item component. A new core abstract base class QgsAnnotation handles the management of the common properties associated with an annotation, and handles rendering the annotation onto a QgsRenderContext destination. Existing annotation classes have been ported to this, and with the exception of the form annotation moved into core. Form annotations are dependant on editor widgets and must remain in GUI. A new QgsMapCanvasAnnotationItem item class implements a QgsMapCanvasItem which draws an annotation inside the canvas, and handles synchronising the position and size of the canvas item with the QgsAnnotation position/size. This allows annotations to be safely used in a multi-canvas environment, with a single QgsAnnotation being displayed in multiple canvases (even if the canvases have different extent/crs/etc). Additionally it allows annotations to be directly rendered to a map (eg in composer) without going through the gui based Qt graphics scene framework. Also removes lots of duplicate code, and adds some basic unit tests for annotations.
63 lines
1.7 KiB
Plaintext
63 lines
1.7 KiB
Plaintext
class QgsAnnotation : QObject
|
|
{
|
|
%TypeHeaderCode
|
|
#include <qgsannotation.h>
|
|
%End
|
|
public:
|
|
|
|
QgsAnnotation( QObject* parent /TransferThis/ = nullptr );
|
|
|
|
bool isVisible() const;
|
|
void setVisible( bool visible );
|
|
|
|
bool hasFixedMapPosition() const;
|
|
void setHasFixedMapPosition( bool fixed );
|
|
|
|
QgsPoint mapPosition() const;
|
|
void setMapPosition( const QgsPoint& position );
|
|
|
|
QgsCoordinateReferenceSystem mapPositionCrs() const;
|
|
void setMapPositionCrs( const QgsCoordinateReferenceSystem& crs );
|
|
|
|
QPointF relativePosition() const;
|
|
void setRelativePosition( QPointF position );
|
|
|
|
void setFrameOffsetFromReferencePoint( QPointF offset );
|
|
QPointF frameOffsetFromReferencePoint() const;
|
|
|
|
void setFrameSize( QSizeF size );
|
|
QSizeF frameSize() const;
|
|
|
|
void setFrameBorderWidth( double width );
|
|
double frameBorderWidth() const;
|
|
|
|
void setFrameColor( const QColor& color );
|
|
QColor frameColor() const;
|
|
|
|
void setFrameBackgroundColor( const QColor& color );
|
|
QColor frameBackgroundColor() const;
|
|
|
|
void render( QgsRenderContext& context ) const;
|
|
|
|
virtual void writeXml( QDomElement& elem, QDomDocument & doc ) const = 0;
|
|
virtual void readXml( const QDomElement& itemElem, const QDomDocument& doc ) = 0;
|
|
|
|
void setMarkerSymbol( QgsMarkerSymbol* symbol /Transfer/ );
|
|
QgsMarkerSymbol* markerSymbol() const;
|
|
|
|
signals:
|
|
|
|
void appearanceChanged();
|
|
void moved();
|
|
|
|
protected:
|
|
|
|
virtual void renderAnnotation( QgsRenderContext& context, QSizeF size ) const = 0;
|
|
|
|
virtual QSizeF minimumFrameSize() const;
|
|
|
|
void _writeXml( QDomElement& itemElem, QDomDocument& doc ) const;
|
|
void _readXml( const QDomElement& annotationElem, const QDomDocument& doc );
|
|
|
|
};
|