25using namespace Qt::StringLiterals;
38 auto r = std::make_unique< QgsAnnotationLayer3DRenderer >();
39 r->readXml( elem, context );
52 mTextFormat.setSize( 20 );
62 return qobject_cast<QgsAnnotationLayer *>( mLayerRef.layer );
67 mLayerRef.resolve( &project );
72 return mShowCalloutLines;
77 mShowCalloutLines = show;
82 mCalloutLineColor = color;
87 return mCalloutLineColor;
92 mCalloutLineWidth = width;
97 return mCalloutLineWidth;
107 mTextFormat = format;
117 auto r = std::make_unique< QgsAnnotationLayer3DRenderer >();
118 r->mLayerRef = mLayerRef;
119 r->mAltClamping = mAltClamping;
120 r->mZOffset = mZOffset;
121 r->mShowCalloutLines = mShowCalloutLines;
122 r->mCalloutLineColor = mCalloutLineColor;
123 r->mCalloutLineWidth = mCalloutLineWidth;
124 r->mTextFormat = mTextFormat;
139 constexpr double MINIMUM_ANNOTATION_Z_ESTIMATE = -100000;
140 constexpr double MAXIMUM_ANNOTATION_Z_ESTIMATE = 100000;
142 double minimumZ = MINIMUM_ANNOTATION_Z_ESTIMATE;
143 double maximumZ = MAXIMUM_ANNOTATION_Z_ESTIMATE;
144 switch ( mAltClamping )
157 return new QgsAnnotationLayerChunkedEntity( map, l, mAltClamping, mZOffset, mShowCalloutLines, mCalloutLineColor, mCalloutLineWidth, mTextFormat, minimumZ, maximumZ );
162 QDomDocument doc = elem.ownerDocument();
164 elem.setAttribute( u
"layer"_s, mLayerRef.layerId );
166 elem.setAttribute( u
"offset"_s, mZOffset );
167 if ( mShowCalloutLines )
168 elem.setAttribute( u
"callouts"_s, u
"1"_s );
170 if ( mTextFormat.isValid() )
172 elem.appendChild( mTextFormat.writeXml( doc, context ) );
180 mZOffset = elem.attribute( u
"offset"_s, QString::number( DEFAULT_Z_OFFSET ) ).toDouble();
181 mShowCalloutLines = elem.attribute( u
"callouts"_s, u
"0"_s ).toInt();
182 if ( !elem.firstChildElement( u
"text-style"_s ).isNull() )
185 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