20 #include <QDomDocument> 21 #include <QDomElement> 36 QDomElement documentElem = doc.documentElement();
37 if ( documentElem.isNull() )
42 QDomElement svgAnnotationElem = doc.createElement(
"SVGAnnotationItem" );
45 documentElem.appendChild( svgAnnotationElem );
52 QDomElement annotationElem = itemElem.firstChildElement(
"AnnotationItem" );
53 if ( !annotationElem.isNull() )
73 QRect viewBox = mSvgRenderer.viewBox();
74 if ( viewBox.isValid() )
76 double widthRatio =
mFrameSize.width() / viewBox.width();
77 double heightRatio =
mFrameSize.height() / viewBox.height();
78 double renderWidth = 0;
79 double renderHeight = 0;
80 if ( widthRatio <= heightRatio )
83 renderHeight = viewBox.height() *
mFrameSize.width() / viewBox.width();
88 renderWidth = viewBox.width() *
mFrameSize.height() / viewBox.height();
103 mSvgRenderer.load( mFilePath );
void _readXML(const QDomDocument &doc, const QDomElement &annotationElem)
QPointF mOffsetFromReferencePoint
Describes the shift of the item content box to the reference point.
void setFilePath(const QString &file)
QgsSvgAnnotationItem(QgsMapCanvas *canvas)
void writeXML(QDomDocument &doc) const override
QString readPath(QString filename) const
turn filename read from the project file to an absolute path
Map canvas is a class for displaying all GIS data types on a canvas.
void drawSelectionBoxes(QPainter *p)
void readXML(const QDomDocument &doc, const QDomElement &itemElem) override
void drawMarkerSymbol(QPainter *p)
void paint(QPainter *painter) override
function to be implemented by derived classes
An annotation item can be either placed either on screen corrdinates or on map coordinates.
bool mMapPositionFixed
True: the item stays at the same map position, False: the item stays on same screen position...
void _writeXML(QDomDocument &doc, QDomElement &itemElem) const
static QgsProject * instance()
access to canonical QgsProject instance
void drawFrame(QPainter *p)
QSizeF mFrameSize
Size of the frame (without balloon)