Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
1 parent
8ba609e
commit c853f4f
Showing
81 changed files
with
2,402 additions
and
1,715 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
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 ); | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class QgsHtmlAnnotation : QgsAnnotation | ||
{ | ||
%TypeHeaderCode | ||
#include <qgshtmlannotation.h> | ||
%End | ||
public: | ||
|
||
QgsHtmlAnnotation( QObject* parent /TransferThis/ = nullptr, QgsVectorLayer* vlayer = nullptr, bool hasFeature = false, int feature = 0 ); | ||
|
||
~QgsHtmlAnnotation(); | ||
|
||
QSizeF minimumFrameSize() const; | ||
|
||
void setSourceFile( const QString& htmlFile ); | ||
QString sourceFile() const; | ||
|
||
virtual void writeXml( QDomElement& elem, QDomDocument & doc ) const; | ||
virtual void readXml( const QDomElement& itemElem, const QDomDocument& doc ); | ||
|
||
QgsVectorLayer* vectorLayer() const; | ||
|
||
protected: | ||
|
||
void renderAnnotation( QgsRenderContext& context, QSizeF size ) const; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class QgsSvgAnnotation : QgsAnnotation | ||
{ | ||
%TypeHeaderCode | ||
#include <qgssvgannotation.h> | ||
%End | ||
public: | ||
|
||
QgsSvgAnnotation( QObject* parent /TransferThis/ = nullptr ); | ||
|
||
virtual void writeXml( QDomElement& elem, QDomDocument & doc ) const; | ||
virtual void readXml( const QDomElement& itemElem, const QDomDocument& doc ); | ||
|
||
void setFilePath( const QString& file ); | ||
QString filePath() const; | ||
|
||
protected: | ||
|
||
void renderAnnotation( QgsRenderContext& context, QSizeF size ) const; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class QgsTextAnnotation : QgsAnnotation | ||
{ | ||
%TypeHeaderCode | ||
#include <qgstextannotation.h> | ||
%End | ||
public: | ||
|
||
QgsTextAnnotation( QObject* parent /TransferThis/ = nullptr ); | ||
|
||
const QTextDocument* document() const; | ||
void setDocument( const QTextDocument* doc ); | ||
|
||
virtual void writeXml( QDomElement& elem, QDomDocument & doc ) const; | ||
virtual void readXml( const QDomElement& itemElem, const QDomDocument& doc ); | ||
|
||
protected: | ||
|
||
void renderAnnotation( QgsRenderContext& context, QSizeF size ) const; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.