Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Merge pull request #4073 from nyalldawson/annotations
Refactor annotations, add new annotation features + some other exciting stuff
- Loading branch information
Showing
138 changed files
with
4,610 additions
and
2,671 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,84 @@ | ||
%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/ = 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 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 = 0; | ||
virtual void readXml( const QDomElement& itemElem, const QDomDocument& doc ) = 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; | ||
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,24 @@ | ||
class QgsAnnotationManager : QObject | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsannotationmanager.h> | ||
%End | ||
public: | ||
|
||
explicit QgsAnnotationManager( QgsProject* project = nullptr ); | ||
~QgsAnnotationManager(); | ||
|
||
bool addAnnotation( QgsAnnotation* annotation /Transfer/ ); | ||
bool removeAnnotation( QgsAnnotation* annotation ); | ||
void clear(); | ||
QList< QgsAnnotation* > annotations() const; | ||
bool readXml( const QDomElement& element, const QDomDocument& doc ); | ||
QDomElement writeXml( QDomDocument& doc ) const; | ||
|
||
signals: | ||
|
||
void annotationAdded( QgsAnnotation* annotation ); | ||
void annotationRemoved(); | ||
void annotationAboutToBeRemoved( QgsAnnotation* annotation ); | ||
|
||
}; |
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,28 @@ | ||
class QgsHtmlAnnotation : QgsAnnotation | ||
{ | ||
%TypeHeaderCode | ||
#include <qgshtmlannotation.h> | ||
%End | ||
public: | ||
|
||
QgsHtmlAnnotation( QObject* parent /TransferThis/ = nullptr ); | ||
|
||
~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 ); | ||
|
||
virtual void setAssociatedFeature( const QgsFeature& feature ); | ||
|
||
static QgsHtmlAnnotation* create() /Factory/; | ||
|
||
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,22 @@ | ||
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; | ||
|
||
static QgsSvgAnnotation* create() /Factory/; | ||
|
||
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,22 @@ | ||
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 ); | ||
|
||
static QgsTextAnnotation* create() /Factory/; | ||
|
||
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
class QgsMargins | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsmargins.h> | ||
%End | ||
|
||
public: | ||
|
||
QgsMargins(); | ||
QgsMargins( double left, double top, double right, double bottom ); | ||
|
||
bool isNull() const; | ||
|
||
double left() const; | ||
double top() const; | ||
double right() const; | ||
double bottom() const; | ||
|
||
void setLeft( double left ); | ||
void setTop( double top ); | ||
void setRight( double right ); | ||
void setBottom( double bottom ); | ||
|
||
QgsMargins &operator+=( const QgsMargins &margins ); | ||
QgsMargins &operator-=( const QgsMargins &margins ); | ||
QgsMargins &operator+=( double addend ); | ||
QgsMargins &operator-=( double subtrahend ); | ||
QgsMargins &operator*=( double factor ); | ||
QgsMargins &operator/=( double divisor ); | ||
|
||
QString toString() const; | ||
static QgsMargins fromString( const QString& string ); | ||
}; | ||
|
||
bool operator==( const QgsMargins &lhs, const QgsMargins &rhs ); | ||
bool operator!=( const QgsMargins &lhs, const QgsMargins &rhs ); | ||
QgsMargins operator+( const QgsMargins &m1, const QgsMargins &m2 ); | ||
QgsMargins operator-( const QgsMargins &m1, const QgsMargins &m2 ); | ||
QgsMargins operator+( const QgsMargins &lhs, double rhs ); | ||
QgsMargins operator+( double lhs, const QgsMargins &rhs ); | ||
QgsMargins operator-( const QgsMargins &lhs, double rhs ); | ||
QgsMargins operator*( const QgsMargins &margins, double factor ); | ||
QgsMargins operator*( double factor, const QgsMargins &margins ); | ||
QgsMargins operator/( const QgsMargins &margins, double divisor ); | ||
QgsMargins operator+( const QgsMargins &margins ); | ||
QgsMargins operator-( const QgsMargins &margins ); | ||
|
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.