QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsannotationitem.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsannotationitem.cpp
3  -----------------
4  begin : August 2021
5  copyright : (C) 2021 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsannotationitem.h"
19 #include "qgsannotationitemnode.h"
20 
21 Qgis::AnnotationItemFlags QgsAnnotationItem::flags() const
22 {
23  return Qgis::AnnotationItemFlags();
24 }
25 
27 {
29 }
30 
32 {
33  return nullptr;
34 }
35 
36 QList<QgsAnnotationItemNode> QgsAnnotationItem::nodes() const
37 {
38  return {};
39 }
40 
42 {
43  setZIndex( other->zIndex() );
46 }
47 
48 bool QgsAnnotationItem::writeCommonProperties( QDomElement &element, QDomDocument &, const QgsReadWriteContext & ) const
49 {
50  element.setAttribute( QStringLiteral( "zIndex" ), zIndex() );
51  element.setAttribute( QStringLiteral( "useReferenceScale" ), useSymbologyReferenceScale() ? QStringLiteral( "1" ) : QStringLiteral( "0" ) );
52  element.setAttribute( QStringLiteral( "referenceScale" ), qgsDoubleToString( symbologyReferenceScale() ) );
53  return true;
54 }
55 
56 bool QgsAnnotationItem::readCommonProperties( const QDomElement &element, const QgsReadWriteContext & )
57 {
58  setZIndex( element.attribute( QStringLiteral( "zIndex" ) ).toInt() );
59  setUseSymbologyReferenceScale( element.attribute( QStringLiteral( "useReferenceScale" ), QStringLiteral( "0" ) ).toInt() );
60  setSymbologyReferenceScale( element.attribute( QStringLiteral( "referenceScale" ) ).toDouble() );
61  return true;
62 }
QgsAnnotationItem::nodes
virtual QList< QgsAnnotationItemNode > nodes() const
Returns the nodes for the item, used for editing the item.
Definition: qgsannotationitem.cpp:36
QgsAnnotationItem::useSymbologyReferenceScale
bool useSymbologyReferenceScale() const
Returns true if the annotation item uses a symbology reference scale.
Definition: qgsannotationitem.h:188
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:34
qgsDoubleToString
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
Definition: qgis.h:2204
Qgis::AnnotationItemEditOperationResult
AnnotationItemEditOperationResult
Results from an edit operation on an annotation item.
Definition: qgis.h:1153
QgsAnnotationItem::writeCommonProperties
bool writeCommonProperties(QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context) const
Writes common properties from the base class into an XML element.
Definition: qgsannotationitem.cpp:48
QgsAnnotationItem::readCommonProperties
bool readCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Reads common properties from the base class from the given DOM element.
Definition: qgsannotationitem.cpp:56
QgsAbstractAnnotationItemEditOperation
Abstract base class for annotation item edit operations.
Definition: qgsannotationitemeditoperation.h:32
qgsannotationitemnode.h
QgsAnnotationItem::zIndex
int zIndex() const
Returns the item's z index, which controls the order in which annotation items are rendered in the la...
Definition: qgsannotationitem.h:165
QgsAnnotationItem::applyEdit
virtual Qgis::AnnotationItemEditOperationResult applyEdit(QgsAbstractAnnotationItemEditOperation *operation)
Applies an edit operation to the item.
Definition: qgsannotationitem.cpp:26
QgsAnnotationItem::flags
virtual Qgis::AnnotationItemFlags flags() const
Returns item flags.
Definition: qgsannotationitem.cpp:21
qgsannotationitem.h
QgsAnnotationItem::transientEditResults
virtual QgsAnnotationItemEditOperationTransientResults * transientEditResults(QgsAbstractAnnotationItemEditOperation *operation)
Retrieves the results of a transient (in progress) edit operation on the item.
Definition: qgsannotationitem.cpp:31
QgsAnnotationItem::copyCommonProperties
void copyCommonProperties(const QgsAnnotationItem *other)
Copies common properties from the base class from an other item.
Definition: qgsannotationitem.cpp:41
QgsAnnotationItem::setSymbologyReferenceScale
void setSymbologyReferenceScale(double scale)
Sets the annotation's symbology reference scale.
Definition: qgsannotationitem.h:230
QgsAnnotationItem::symbologyReferenceScale
double symbologyReferenceScale() const
Returns the annotation's symbology reference scale.
Definition: qgsannotationitem.h:213
QgsAnnotationItem::setZIndex
void setZIndex(int index)
Sets the item's z index, which controls the order in which annotation items are rendered in the layer...
Definition: qgsannotationitem.h:173
QgsAnnotationItem
Abstract base class for annotation items which are drawn with QgsAnnotationLayers.
Definition: qgsannotationitem.h:42
QgsAnnotationItemEditOperationTransientResults
Encapsulates the transient results of an in-progress annotation edit operation.
Definition: qgsannotationitemeditoperation.h:226
QgsAnnotationItem::setUseSymbologyReferenceScale
void setUseSymbologyReferenceScale(bool enabled)
Sets whether the annotation item uses a symbology reference scale.
Definition: qgsannotationitem.h:196
Qgis::AnnotationItemEditOperationResult::Invalid
@ Invalid
Operation has invalid parameters for the item, no change occurred.