QGIS/python/core/annotations/qgsannotation.sip
Martin Dobias 8ffd91ea90 Propagate path resolver through renderers, annotations, diagrams
This is necessary in order to be able to correctly translate between absolute and relative paths
deeper in the code - e.g. paths to SVG files used in marker or fill symbols.

Until now, relative paths were translated to absolute paths on the fly.
This is now changed - paths to files should be always absolute within QGIS objects - and paths
only get turned into relative when saving projects. When loading a project, relative paths
are translated to absolute paths immediately.

This should lower the overall confusion about relative/absolute paths within QGIS, and also
allow having different base directories for relative paths (e.g. QML or QPT files may use relative paths
to their directory - rather than to the project directory)
2017-05-13 18:02:19 +08:00

89 lines
2.6 KiB
Plaintext

%ModuleHeaderCode
#include <qgshtmlannotation.h>
#include <qgssvgannotation.h>
#include <qgstextannotation.h>
%End
class QgsAnnotation : QObject
{
%TypeHeaderCode
#include <qgsannotation.h>
%End
%ConvertToSubClassCode
if ( dynamic_cast< QgsTextAnnotation* > ( sipCpp ) )
sipType = sipType_QgsTextAnnotation;
else if ( dynamic_cast< QgsSvgAnnotation* > ( sipCpp ) )
sipType = sipType_QgsSvgAnnotation;
else if ( dynamic_cast< QgsHtmlAnnotation* > ( sipCpp ) )
sipType = sipType_QgsHtmlAnnotation;
else
sipType = NULL;
%End
public:
QgsAnnotation( QObject *parent /TransferThis/ = 0 );
virtual QgsAnnotation *clone() const = 0 /Factory/;
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 setContentsMargin( const QgsMargins &margins );
QgsMargins contentsMargin() const;
void setFillSymbol( QgsFillSymbol *symbol /Transfer/ );
QgsFillSymbol *fillSymbol() const;
void render( QgsRenderContext &context ) const;
virtual void writeXml( QDomElement &elem, QDomDocument &doc, const QgsPathResolver &pathResolver ) const = 0;
virtual void readXml( const QDomElement &itemElem, const QDomDocument &doc, const QgsPathResolver &pathResolver ) = 0;
void setMarkerSymbol( QgsMarkerSymbol *symbol /Transfer/ );
QgsMarkerSymbol *markerSymbol() const;
QgsMapLayer *mapLayer() const;
void setMapLayer( QgsMapLayer *layer );
QgsFeature associatedFeature() const;
virtual void setAssociatedFeature( const QgsFeature &feature );
signals:
void appearanceChanged();
void moved();
void mapLayerChanged();
protected:
virtual void renderAnnotation( QgsRenderContext &context, QSizeF size ) const = 0;
virtual QSizeF minimumFrameSize() const;
void _writeXml( QDomElement &itemElem, QDomDocument &doc, const QgsPathResolver &pathResolver ) const;
void _readXml( const QDomElement &annotationElem, const QDomDocument &doc, const QgsPathResolver &pathResolver );
void copyCommonProperties( QgsAnnotation *target ) const;
};