34 auto r = std::make_unique< QgsAnnotationLayer3DRenderer >();
35 r->readXml( elem, context );
48 mTextFormat.setSize( 20 );
58 return qobject_cast<QgsAnnotationLayer *>( mLayerRef.layer );
63 mLayerRef.resolve( &project );
68 return mShowCalloutLines;
73 mShowCalloutLines = show;
78 mCalloutLineColor = color;
83 return mCalloutLineColor;
88 mCalloutLineWidth = width;
93 return mCalloutLineWidth;
103 mTextFormat = format;
113 auto r = std::make_unique< QgsAnnotationLayer3DRenderer >();
114 r->mLayerRef = mLayerRef;
115 r->mAltClamping = mAltClamping;
116 r->mZOffset = mZOffset;
117 r->mShowCalloutLines = mShowCalloutLines;
118 r->mCalloutLineColor = mCalloutLineColor;
119 r->mCalloutLineWidth = mCalloutLineWidth;
120 r->mTextFormat = mTextFormat;
135 constexpr double MINIMUM_ANNOTATION_Z_ESTIMATE = -100000;
136 constexpr double MAXIMUM_ANNOTATION_Z_ESTIMATE = 100000;
138 double minimumZ = MINIMUM_ANNOTATION_Z_ESTIMATE;
139 double maximumZ = MAXIMUM_ANNOTATION_Z_ESTIMATE;
140 switch ( mAltClamping )
153 return new QgsAnnotationLayerChunkedEntity( map, l, mAltClamping, mZOffset, mShowCalloutLines, mCalloutLineColor, mCalloutLineWidth, mTextFormat, minimumZ, maximumZ );
158 QDomDocument doc = elem.ownerDocument();
160 elem.setAttribute( QStringLiteral(
"layer" ), mLayerRef.layerId );
161 elem.setAttribute( QStringLiteral(
"clamping" ),
qgsEnumValueToKey( mAltClamping ) );
162 elem.setAttribute( QStringLiteral(
"offset" ), mZOffset );
163 if ( mShowCalloutLines )
164 elem.setAttribute( QStringLiteral(
"callouts" ), QStringLiteral(
"1" ) );
166 if ( mTextFormat.isValid() )
168 elem.appendChild( mTextFormat.writeXml( doc, context ) );
174 mLayerRef =
QgsMapLayerRef( elem.attribute( QStringLiteral(
"layer" ) ) );
176 mZOffset = elem.attribute( QStringLiteral(
"offset" ), QString::number( DEFAULT_Z_OFFSET ) ).toDouble();
177 mShowCalloutLines = elem.attribute( QStringLiteral(
"callouts" ), QStringLiteral(
"0" ) ).toInt();
178 if ( !elem.firstChildElement( QStringLiteral(
"text-style" ) ).isNull() )
181 mTextFormat.readXml( elem.firstChildElement( QStringLiteral(
"text-style" ) ), 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