25using namespace Qt::StringLiterals;
37 auto r = std::make_unique< QgsAnnotationLayer3DRenderer >();
38 r->readXml( elem, context );
51 mTextFormat.setSize( 20 );
61 return qobject_cast<QgsAnnotationLayer *>( mLayerRef.layer );
66 mLayerRef.resolve( &project );
71 return mShowCalloutLines;
76 mShowCalloutLines = show;
81 mCalloutLineColor = color;
86 return mCalloutLineColor;
91 mCalloutLineWidth = width;
96 return mCalloutLineWidth;
106 mTextFormat = format;
116 auto r = std::make_unique< QgsAnnotationLayer3DRenderer >();
117 r->mLayerRef = mLayerRef;
118 r->mAltClamping = mAltClamping;
119 r->mZOffset = mZOffset;
120 r->mShowCalloutLines = mShowCalloutLines;
121 r->mCalloutLineColor = mCalloutLineColor;
122 r->mCalloutLineWidth = mCalloutLineWidth;
123 r->mTextFormat = mTextFormat;
138 constexpr double MINIMUM_ANNOTATION_Z_ESTIMATE = -100000;
139 constexpr double MAXIMUM_ANNOTATION_Z_ESTIMATE = 100000;
141 double minimumZ = MINIMUM_ANNOTATION_Z_ESTIMATE;
142 double maximumZ = MAXIMUM_ANNOTATION_Z_ESTIMATE;
143 switch ( mAltClamping )
156 return new QgsAnnotationLayerChunkedEntity( map, l, mAltClamping, mZOffset, mShowCalloutLines, mCalloutLineColor, mCalloutLineWidth, mTextFormat, minimumZ, maximumZ );
161 QDomDocument doc = elem.ownerDocument();
163 elem.setAttribute( u
"layer"_s, mLayerRef.layerId );
165 elem.setAttribute( u
"offset"_s, mZOffset );
166 if ( mShowCalloutLines )
167 elem.setAttribute( u
"callouts"_s, u
"1"_s );
169 if ( mTextFormat.isValid() )
171 elem.appendChild( mTextFormat.writeXml( doc, context ) );
179 mZOffset = elem.attribute( u
"offset"_s, QString::number( DEFAULT_Z_OFFSET ) ).toDouble();
180 mShowCalloutLines = elem.attribute( u
"callouts"_s, u
"0"_s ).toInt();
181 if ( !elem.firstChildElement( u
"text-style"_s ).isNull() )
184 mTextFormat.readXml( elem.firstChildElement( u
"text-style"_s ), context );
@ Relative
Elevation is relative to terrain height (final elevation = terrain elevation + feature elevation).
@ Terrain
Elevation is clamped to terrain (final elevation = terrain elevation).
@ Absolute
Elevation is taken directly from feature and is independent of terrain height (final elevation = feat...
Base class for all renderers that participate in 3D views.
QString type() const override
Returns unique identifier of the renderer class (used to identify subclass).
Qt3DCore::QEntity * createEntity(Qgs3DMapSettings *map) const override
Returns a 3D entity that will be used to show renderer's data in 3D scene.
void writeXml(QDomElement &elem, const QgsReadWriteContext &context) const override
Writes renderer's properties to given XML element.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context) override
Reads renderer's properties from given XML element.
QColor calloutLineColor() const
Returns the callout line color.
void setCalloutLineColor(const QColor &color)
Sets the callout line color.
void setShowCalloutLines(bool show)
Sets whether callout lines are shown, vertically joining the annotations to the terrain.
QgsTextFormat textFormat() const
Returns the text format to use for rendering text annotations in 3D.
void resolveReferences(const QgsProject &project) override
Resolves references to other objects - second phase of loading - after readXml().
double calloutLineWidth() const
Returns the callout line width.
QgsAnnotationLayer * layer() const
Returns the annotation layer associated with the renderer.
bool showCalloutLines() const
Returns true if callout lines are shown, vertically joining the annotations to the terrain.
QgsAnnotationLayer3DRenderer()
void setCalloutLineWidth(double width)
Sets the callout line width.
void setLayer(QgsAnnotationLayer *layer)
Sets the annotation layer associated with the renderer.
void setTextFormat(const QgsTextFormat &format)
Sets the text format to use for rendering text annotations in 3D.
QgsAnnotationLayer3DRenderer * clone() const override
Returns a cloned instance.
Represents a map layer containing a set of georeferenced annotations, e.g.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A container for the context for various read/write operations on objects.
QgsTextFormat defaultTextFormat(QgsStyle::TextFormatContext context=QgsStyle::TextFormatContext::Labeling) const
Returns the default text format to use for new text based objects in the specified context.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
Container for all settings relating to text rendering.
void setNamedStyle(const QString &style)
Sets the named style for the font used for rendering text.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
_LayerRef< QgsMapLayer > QgsMapLayerRef