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 );
96 mMaxErrorSpinBox->setClearValue( 3 );
98 connect( mMaxErrorSpinBox, qOverload<double>( &QgsDoubleSpinBox::valueChanged ),
this, &QgsTiledSceneRendererPropertiesWidget::emitWidgetChanged );
116 mLayer = qobject_cast< QgsTiledSceneLayer * >( layer );
118 mBlockChangedSignal =
true;
119 mOpacityWidget->setOpacity( mLayer->
opacity() );
121 mBlendModeComboBox->setBlendMode( mLayer->
blendMode() );
126 const QString rendererName = mLayer->
renderer()->
type();
128 const int rendererIdx = cboRenderers->findData( rendererName );
129 cboRenderers->setCurrentIndex( rendererIdx );
132 Q_ASSERT( rendererIdx != -1 &&
"there must be a renderer!" );
138 mBlockChangedSignal =
false;
150 mLayer->
setOpacity( mOpacityWidget->opacity() );
151 mLayer->
setBlendMode( mBlendModeComboBox->blendMode() );
155 else if ( !cboRenderers->currentData().toString().isEmpty() )
165void QgsTiledSceneRendererPropertiesWidget::rendererChanged()
167 if ( cboRenderers->currentIndex() == -1 )
169 QgsDebugError( QStringLiteral(
"No current item -- this should never happen!" ) );
173 const QString rendererName = cboRenderers->currentData().toString();
176 std::unique_ptr< QgsTiledSceneRenderer > oldRenderer;
177 std::unique_ptr< QgsTiledSceneRenderer > newRenderer;
179 newRenderer.reset( mActiveWidget->
renderer() );
183 oldRenderer = std::move( newRenderer );
193 stackedWidget->removeWidget( mActiveWidget );
195 delete mActiveWidget;
196 mActiveWidget =
nullptr;
201 if ( rendererMetadata )
208 mActiveWidget = widget;
209 stackedWidget->addWidget( mActiveWidget );
210 stackedWidget->setCurrentWidget( mActiveWidget );
212 if ( mMapCanvas || mMessageBar )
227 stackedWidget->setCurrentWidget( pageNoWidget );
232void QgsTiledSceneRendererPropertiesWidget::emitWidgetChanged()
234 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 *)