33 if ( !rendererAbstractMetadata )
36 if ( !rendererMetadata )
41 if ( !iconName.isEmpty() )
50void QgsTiledSceneRendererPropertiesWidget::initRendererWidgetFunctions()
52 static bool sInitialized =
false;
56 initTiledSceneRenderer( QStringLiteral(
"texture" ), QgsTiledSceneTextureRendererWidget::create, QStringLiteral(
"styleicons/tiledscenetexture.svg" ) );
57 initTiledSceneRenderer( QStringLiteral(
"wireframe" ), QgsTiledSceneWireframeRendererWidget::create, QStringLiteral(
"styleicons/tiledscenewireframe.svg" ) );
69 layout()->setContentsMargins( 0, 0, 0, 0 );
72 initRendererWidgetFunctions();
76 for (
const QString &name : renderers )
79 cboRenderers->addItem( m->icon(), m->visibleName(), name );
82 cboRenderers->setCurrentIndex( -1 );
84 connect( cboRenderers,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTiledSceneRendererPropertiesWidget::rendererChanged );
86 connect( mBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &QgsTiledSceneRendererPropertiesWidget::emitWidgetChanged );
95 mMaxErrorSpinBox->setClearValue( 3 );
97 connect( mMaxErrorSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsTiledSceneRendererPropertiesWidget::emitWidgetChanged );
115 mLayer = qobject_cast< QgsTiledSceneLayer * >( layer );
117 mBlockChangedSignal =
true;
118 mOpacityWidget->setOpacity( mLayer->
opacity() );
120 mBlendModeComboBox->setBlendMode( mLayer->
blendMode() );
125 const QString rendererName = mLayer->
renderer()->
type();
127 const int rendererIdx = cboRenderers->findData( rendererName );
128 cboRenderers->setCurrentIndex( rendererIdx );
131 Q_ASSERT( rendererIdx != -1 &&
"there must be a renderer!" );
137 mBlockChangedSignal =
false;
149 mLayer->
setOpacity( mOpacityWidget->opacity() );
150 mLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
154 else if ( !cboRenderers->currentData().toString().isEmpty() )
164void QgsTiledSceneRendererPropertiesWidget::rendererChanged()
166 if ( cboRenderers->currentIndex() == -1 )
168 QgsDebugError( QStringLiteral(
"No current item -- this should never happen!" ) );
172 const QString rendererName = cboRenderers->currentData().toString();
175 std::unique_ptr< QgsTiledSceneRenderer > oldRenderer;
176 std::unique_ptr< QgsTiledSceneRenderer > newRenderer;
178 newRenderer.reset( mActiveWidget->
renderer() );
182 oldRenderer = std::move( newRenderer );
192 stackedWidget->removeWidget( mActiveWidget );
194 delete mActiveWidget;
195 mActiveWidget =
nullptr;
200 if ( rendererMetadata )
207 mActiveWidget = widget;
208 stackedWidget->addWidget( mActiveWidget );
209 stackedWidget->setCurrentWidget( mActiveWidget );
211 if ( mMapCanvas || mMessageBar )
226 stackedWidget->setCurrentWidget( pageNoWidget );
231void QgsTiledSceneRendererPropertiesWidget::emitWidgetChanged()
233 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 *)