26#include "moc_qgsrenderermeshpropertieswidget.cpp"
39 mMeshRendererActiveDatasetWidget->setLayer( mMeshLayer );
40 mMeshRendererScalarSettingsWidget->setLayer( mMeshLayer );
41 mMeshRendererScalarSettingsWidget->setCanvas(
mMapCanvas );
45 mMeshRendererVectorSettingsWidget->setLayer( mMeshLayer );
46 m3dAveragingSettingsWidget->setLayer( mMeshLayer );
51 mBlendModeComboBox->setBlendMode( mMeshLayer->blendMode() );
52 connect( mBlendModeComboBox,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, &
QgsPanelWidget::widgetChanged );
54 mOpacityWidget->setOpacity( mMeshLayer->opacity() );
80 const bool edgeMeshRenderingIsEnabled = mEdgeMeshGroup->isChecked();
82 edgeMeshSettings.
setEnabled( edgeMeshRenderingIsEnabled );
85 const bool nativeMeshRenderingIsEnabled = mNativeMeshGroup->isChecked();
87 nativeMeshSettings.
setEnabled( nativeMeshRenderingIsEnabled );
90 const bool triangularMeshRenderingIsEnabled = mTriangularMeshGroup->isChecked();
92 triangularMeshSettings.
setEnabled( triangularMeshRenderingIsEnabled );
95 int activeScalarDatasetGroupIndex = mMeshRendererActiveDatasetWidget->activeScalarDatasetGroup();
96 if ( !mContoursGroupBox->isChecked() )
97 activeScalarDatasetGroupIndex = -1;
100 int activeVectorDatasetGroupIndex = mMeshRendererActiveDatasetWidget->activeVectorDatasetGroup();
101 if ( !mVectorsGroupBox->isChecked() )
102 activeVectorDatasetGroupIndex = -1;
110 if ( activeScalarDatasetGroupIndex > -1 )
111 settings.
setScalarSettings( activeScalarDatasetGroupIndex, mMeshRendererScalarSettingsWidget->settings() );
114 if ( activeVectorDatasetGroupIndex > -1 )
115 settings.
setVectorSettings( activeVectorDatasetGroupIndex, mMeshRendererVectorSettingsWidget->settings() );
117 const QgsMeshDatasetIndex staticScalarDatasetIndex( activeScalarDatasetGroupIndex, mMeshLayer->staticScalarDatasetIndex().dataset() );
118 const QgsMeshDatasetIndex staticVectorDatasetIndex( activeVectorDatasetGroupIndex, mMeshLayer->staticVectorDatasetIndex().dataset() );
119 mMeshLayer->setStaticScalarDatasetIndex( staticScalarDatasetIndex );
120 mMeshLayer->setStaticVectorDatasetIndex( staticVectorDatasetIndex );
123 mMeshLayer->setBlendMode( mBlendModeComboBox->blendMode() );
124 mLayer->setOpacity( mOpacityWidget->opacity() );
126 const std::unique_ptr<QgsMesh3DAveragingMethod> averagingMethod( m3dAveragingSettingsWidget->averagingMethod() );
128 mMeshLayer->setRendererSettings( settings );
129 mMeshLayer->triggerRepaint();
132 windowsSettings.
setValue( QStringLiteral(
"/Windows/RendererMeshProperties/tab" ), mStyleOptionsTab->currentIndex() );
137 QgsMeshLayer *ml = qobject_cast<QgsMeshLayer *>( mapLayer );
141 mMeshRendererActiveDatasetWidget->setLayer( ml );
145 m3dAveragingSettingsWidget->setLayer( ml );
150 syncToLayerPrivate();
153void QgsRendererMeshPropertiesWidget::syncToLayerPrivate()
158 mMeshRendererActiveDatasetWidget->syncToLayer();
159 mNativeMeshSettingsWidget->syncToLayer();
160 mTriangularMeshSettingsWidget->syncToLayer();
161 mEdgeMeshSettingsWidget->syncToLayer();
162 m3dAveragingSettingsWidget->syncToLayer();
172 mFaceMeshGroupBox->setVisible( hasFaces || !mMeshLayer->
isValid() );
175 mEdgeMeshGroupBox->setVisible( hasEdges || !mMeshLayer->
isValid() );
178 if ( !settings.
contains( QStringLiteral(
"/Windows/RendererMeshProperties/tab" ) ) )
179 settings.
setValue( QStringLiteral(
"/Windows/RendererMeshProperties/tab" ), 0 );
181 mStyleOptionsTab->setCurrentIndex( settings.
value( QStringLiteral(
"/Windows/RendererMeshProperties/tab" ) ).toInt() );
184void QgsRendererMeshPropertiesWidget::onActiveScalarGroupChanged(
int groupIndex )
186 mMeshRendererScalarSettingsWidget->setActiveDatasetGroup( groupIndex );
187 mMeshRendererScalarSettingsWidget->syncToLayer();
188 mContoursGroupBox->setChecked( groupIndex >= 0 );
189 mContoursGroupBox->setEnabled( groupIndex >= 0 );
192void QgsRendererMeshPropertiesWidget::onActiveVectorGroupChanged(
int groupIndex )
194 if ( groupIndex >= 0 && !mMeshLayer->datasetGroupMetadata( groupIndex ).isVector() )
196 mMeshRendererVectorSettingsWidget->setActiveDatasetGroup( groupIndex );
197 mMeshRendererVectorSettingsWidget->syncToLayer();
198 mVectorsGroupBox->setChecked( groupIndex >= 0 );
199 mVectorsGroupBox->setEnabled( groupIndex >= 0 );
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
void dataChanged()
Data of layer changed.
An index that identifies the dataset group (e.g.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
Represents a mesh renderer settings for mesh objects.
void setEnabled(bool enabled)
Sets whether mesh structure rendering is enabled.
bool isEnabled() const
Returns whether mesh structure rendering is enabled.
Represents all mesh renderer settings.
void setAveragingMethod(QgsMesh3DAveragingMethod *method)
Sets averaging method for conversion of 3d stacked mesh data to 2d data.
void setActiveVectorDatasetGroup(int activeVectorDatasetGroup)
Sets the active vector dataset group.
int activeVectorDatasetGroup() const
Returns the active vector dataset group.
void setEdgeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new edge mesh renderer settings.
int activeScalarDatasetGroup() const
Returns the active scalar dataset group.
void setActiveScalarDatasetGroup(int activeScalarDatasetGroup)
Sets the active scalar dataset group.
void setVectorSettings(int groupIndex, const QgsMeshRendererVectorSettings &settings)
Sets new renderer settings.
void setTriangularMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new triangular mesh renderer settings.
QgsMeshRendererMeshSettings edgeMeshSettings() const
Returns edge mesh renderer settings.
QgsMeshRendererMeshSettings nativeMeshSettings() const
Returns native mesh renderer settings.
void setScalarSettings(int groupIndex, const QgsMeshRendererScalarSettings &settings)
Sets new renderer settings.
QgsMeshRendererMeshSettings triangularMeshSettings() const
Returns triangular mesh renderer settings.
void setNativeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new native mesh renderer settings, triggers repaint.
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.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.