16#include "moc_qgstiledscenerendererpropertieswidget.cpp"
34 if ( !rendererAbstractMetadata )
37 if ( !rendererMetadata )
42 if ( !iconName.isEmpty() )
51void QgsTiledSceneRendererPropertiesWidget::initRendererWidgetFunctions()
53 static bool sInitialized =
false;
57 initTiledSceneRenderer( QStringLiteral(
"texture" ), QgsTiledSceneTextureRendererWidget::create, QStringLiteral(
"styleicons/tiledscenetexture.svg" ) );
58 initTiledSceneRenderer( QStringLiteral(
"wireframe" ), QgsTiledSceneWireframeRendererWidget::create, QStringLiteral(
"styleicons/tiledscenewireframe.svg" ) );
70 layout()->setContentsMargins( 0, 0, 0, 0 );
73 initRendererWidgetFunctions();
77 for (
const QString &name : renderers )
80 cboRenderers->addItem( m->icon(), m->visibleName(), name );
83 cboRenderers->setCurrentIndex( -1 );
85 connect( cboRenderers,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTiledSceneRendererPropertiesWidget::rendererChanged );
87 connect( mBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTiledSceneRendererPropertiesWidget::emitWidgetChanged );
91 mMaxErrorSpinBox->setClearValue( 3 );
93 connect( mMaxErrorSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsTiledSceneRendererPropertiesWidget::emitWidgetChanged );
111 mLayer = qobject_cast<QgsTiledSceneLayer *>( layer );
113 mBlockChangedSignal =
true;
114 mOpacityWidget->setOpacity( mLayer->
opacity() );
116 mBlendModeComboBox->setBlendMode( mLayer->
blendMode() );
121 const QString rendererName = mLayer->
renderer()->
type();
123 const int rendererIdx = cboRenderers->findData( rendererName );
124 cboRenderers->setCurrentIndex( rendererIdx );
127 Q_ASSERT( rendererIdx != -1 &&
"there must be a renderer!" );
133 mBlockChangedSignal =
false;
145 mLayer->
setOpacity( mOpacityWidget->opacity() );
146 mLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
150 else if ( !cboRenderers->currentData().toString().isEmpty() )
160void QgsTiledSceneRendererPropertiesWidget::rendererChanged()
162 if ( cboRenderers->currentIndex() == -1 )
164 QgsDebugError( QStringLiteral(
"No current item -- this should never happen!" ) );
168 const QString rendererName = cboRenderers->currentData().toString();
171 std::unique_ptr<QgsTiledSceneRenderer> oldRenderer;
172 std::unique_ptr<QgsTiledSceneRenderer> newRenderer;
174 newRenderer.reset( mActiveWidget->
renderer() );
178 oldRenderer = std::move( newRenderer );
188 stackedWidget->removeWidget( mActiveWidget );
190 delete mActiveWidget;
191 mActiveWidget =
nullptr;
196 if ( rendererMetadata )
203 mActiveWidget = widget;
204 stackedWidget->addWidget( mActiveWidget );
205 stackedWidget->setCurrentWidget( mActiveWidget );
207 if ( mMapCanvas || mMessageBar )
222 stackedWidget->setCurrentWidget( pageNoWidget );
227void QgsTiledSceneRendererPropertiesWidget::emitWidgetChanged()
229 if ( !mBlockChangedSignal )
@ Millimeters
Millimeters.
@ Points
Points (e.g., for font sizes)
@ MetersInMapUnits
Meters value as Map units.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsTiledSceneRendererRegistry * tiledSceneRendererRegistry()
Returns the application's tiled scene renderer registry, used for managing tiled scene layer 2D rende...
Base class for all map layer types.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
static bool layerIsContainedInGroupLayer(QgsProject *project, QgsMapLayer *layer)
Returns true if the specified layer is a child layer from any QgsGroupLayer in the given project.
static QgsProject * instance()
Returns the QgsProject singleton instance.
The class is used as a container of context for various read/write operations on other objects.
Contains settings which reflect the context in which a symbol (or renderer) widget is shown,...
void setMapCanvas(QgsMapCanvas *canvas)
Sets the map canvas associated with the widget.
void setMessageBar(QgsMessageBar *bar)
Sets the message bar associated with the widget.
QgsMapCanvas * mapCanvas() const
Returns the map canvas associated with the widget.
QgsMessageBar * messageBar() const
Returns the message bar associated with the widget.
Represents a map layer supporting display of tiled scene objects.
void setRenderer(QgsTiledSceneRenderer *renderer)
Sets the 2D renderer for the tiled scene.
QgsTiledSceneRenderer * renderer()
Returns the 2D renderer for the tiled scene.
Registry of 2D renderers for tiled scenes.
QgsTiledSceneRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
QStringList renderersList() const
Returns a list of available renderers.
virtual QString type() const =0
Returns the identifier of the renderer type.
void setMaximumScreenErrorUnit(Qgis::RenderUnit unit)
Sets the unit for the maximum screen error allowed when rendering the tiled scene.
Qgis::RenderUnit maximumScreenErrorUnit() const
Returns the unit for the maximum screen error allowed when rendering the tiled scene.
virtual QgsTiledSceneRenderer * clone() const =0
Create a deep copy of this renderer.
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the tiled scene.
void setMaximumScreenError(double error)
Sets the maximum screen error allowed when rendering the tiled scene.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QgsTiledSceneRendererWidget *(* QgsTiledSceneRendererWidgetFunc)(QgsTiledSceneLayer *, QgsStyle *, QgsTiledSceneRenderer *)