40#include <QDesktopServices>
44#include "moc_qgsmeshlayerproperties.cpp"
50 Q_ASSERT( mMeshLayer );
55 mOptsPage_StyleContent->layout()->addWidget( mRendererMeshPropertiesWidget );
57 mSimplifyReductionFactorSpinBox->setClearValue( 10.0 );
58 mSimplifyMeshResolutionSpinBox->setClearValue( 5 );
60 mStaticDatasetWidget->setLayer( mMeshLayer );
83 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsMeshLayerProperties::showHelp );
85 connect( mTemporalReloadButton, &QPushButton::clicked,
this, &QgsMeshLayerProperties::reloadTemporalProperties );
86 connect( mTemporalDateTimeReference, &QDateTimeEdit::dateTimeChanged,
this, &QgsMeshLayerProperties::onTimeReferenceChange );
90 mScaleRangeWidget->setMapCanvas(
mCanvas );
94 connect( mAlwaysTimeFromSourceCheckBox, &QCheckBox::stateChanged,
this, [
this] {
95 mTemporalDateTimeReference->setEnabled( !mAlwaysTimeFromSourceCheckBox->isChecked() );
96 if ( mAlwaysTimeFromSourceCheckBox->isChecked() )
97 reloadTemporalProperties();
103 QVBoxLayout *labelingLayout =
nullptr;
108 labelingLayout =
new QVBoxLayout( labelingFrame );
109 labelingLayout->setContentsMargins( 0, 0, 0, 0 );
111 mLabelingDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
112 labelingLayout->addWidget( mLabelingDialog );
113 labelingFrame->setLayout( labelingLayout );
117 mLabelingDialog =
nullptr;
118 mOptsPage_Labels->setEnabled(
false );
121 QVBoxLayout *metadataLayout =
new QVBoxLayout( metadataFrame );
122 metadataLayout->setContentsMargins( 0, 0, 0, 0 );
123 metadataFrame->setContentsMargins( 0, 0, 0, 0 );
125 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
126 mMetadataWidget->setMapCanvas(
mCanvas );
127 metadataLayout->addWidget( mMetadataWidget );
128 metadataFrame->setLayout( metadataLayout );
129 mOptsPage_Metadata->setContentsMargins( 0, 0, 0, 0 );
130 mBackupCrs = mMeshLayer->crs();
132 mTemporalDateTimeStart->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
133 mTemporalDateTimeEnd->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
134 mTemporalDateTimeReference->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
144 if ( !settings.
contains( QStringLiteral(
"/Windows/MeshLayerProperties/tab" ) ) )
150 mOptsPage_Information->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#information-properties" ) );
151 mOptsPage_Source->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#source-properties" ) );
152 mOptsPage_Style->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#symbology-properties" ) );
153 mOptsPage_Rendering->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#rendering-properties" ) );
154 mOptsPage_Temporal->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#temporal-properties" ) );
155 mOptsPage_Metadata->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#metadata-properties" ) );
157 mBtnStyle =
new QPushButton( tr(
"Style" ) );
158 QMenu *menuStyle =
new QMenu(
this );
161 menuStyle->addSeparator();
165 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsMeshLayerProperties::aboutToShowStyleMenu );
167 buttonBox->addButton(
mBtnStyle, QDialogButtonBox::ResetRole );
169 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
170 QMenu *menuMetadata =
new QMenu(
this );
174 buttonBox->addButton(
mBtnMetadata, QDialogButtonBox::ResetRole );
181 Q_ASSERT( mRendererMeshPropertiesWidget );
183 QgsDebugMsgLevel( QStringLiteral(
"populate general information tab" ), 4 );
188 myStyle.append( QStringLiteral(
"body { margin: 10px; }\n " ) );
189 mInformationTextBrowser->clear();
190 mInformationTextBrowser->document()->setDefaultStyleSheet( myStyle );
191 mInformationTextBrowser->setHtml( mMeshLayer->htmlMetadata() );
192 mInformationTextBrowser->setOpenLinks(
false );
199 mLayerOrigNameLineEd->setText( mMeshLayer->name() );
202 mDatasetGroupTreeWidget->syncToLayer( mMeshLayer );
206 w->syncToLayer( mMeshLayer );
209 if ( mMeshLayer->isEditable() )
210 mSimplifyMeshGroupBox->setEnabled(
false );
213 mSimplifyMeshGroupBox->setChecked( simplifySettings.
isEnabled() );
214 mSimplifyReductionFactorSpinBox->setValue( simplifySettings.
reductionFactor() );
215 mSimplifyMeshResolutionSpinBox->setValue( simplifySettings.
meshResolution() );
218 const QgsMeshLayerTemporalProperties *temporalProperties = qobject_cast<const QgsMeshLayerTemporalProperties *>( mMeshLayer->temporalProperties() );
221 mTemporalDateTimeStart->setDateTime( timeRange.
begin() );
222 mTemporalDateTimeEnd->setDateTime( timeRange.
end() );
223 if ( mMeshLayer->dataProvider() )
225 mTemporalProviderTimeUnitComboBox->setCurrentIndex(
226 mTemporalProviderTimeUnitComboBox->findData(
static_cast<int>( mMeshLayer->dataProvider()->temporalCapabilities()->temporalUnit() ) )
230 mComboBoxTemporalDatasetMatchingMethod->setCurrentIndex(
231 mComboBoxTemporalDatasetMatchingMethod->findData( temporalProperties->
matchingMethod() )
234 mStaticDatasetWidget->syncToLayer();
235 mStaticDatasetGroupBox->setChecked( !mMeshLayer->temporalProperties()->isActive() );
238 mLegendConfigEmbeddedWidget->setLayer( mMeshLayer );
259 Q_ASSERT( mRendererMeshPropertiesWidget );
261 mLegendConfigEmbeddedWidget->applyToLayer();
267 mMeshLayer->setName( mLayerOrigNameLineEd->text() );
273 mDatasetGroupTreeWidget->apply();
286 simplifySettings.
setEnabled( mSimplifyMeshGroupBox->isChecked() );
289 bool needMeshUpdating = ( ( simplifySettings.
isEnabled() != mMeshLayer->meshSimplificationSettings().isEnabled() ) || ( simplifySettings.
reductionFactor() != mMeshLayer->meshSimplificationSettings().reductionFactor() ) );
291 mMeshLayer->setMeshSimplificationSettings( simplifySettings );
293 mMeshLayer->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
294 mMeshLayer->setMinimumScale( mScaleRangeWidget->minimumScale() );
295 mMeshLayer->setMaximumScale( mScaleRangeWidget->maximumScale() );
301 if ( mLabelingDialog )
303 mLabelingDialog->writeSettingsToLayer();
311 mMeshLayer->setReferenceTime( mTemporalDateTimeReference->dateTime() );
312 if ( mMeshLayer->dataProvider() )
313 mMeshLayer->dataProvider()->setTemporalUnit(
314 static_cast<Qgis::TemporalUnit>( mTemporalProviderTimeUnitComboBox->currentData().toInt() )
317 mStaticDatasetWidget->apply();
318 bool needEmitRendererChanged = mMeshLayer->temporalProperties()->isActive() == mStaticDatasetGroupBox->isChecked();
319 mMeshLayer->temporalProperties()->setIsActive( !mStaticDatasetGroupBox->isChecked() );
321 mComboBoxTemporalDatasetMatchingMethod->currentData().toInt()
324 mMeshLayer->temporalProperties()
328 mMetadataWidget->acceptMetadata();
330 mBackupCrs = mMeshLayer->crs();
332 if ( needMeshUpdating )
333 mMeshLayer->reload();
335 if ( needEmitRendererChanged )
336 emit mMeshLayer->rendererChanged();
345 mMeshLayer->triggerRepaint();
351 mStaticDatasetWidget->syncToLayer();
353 w->syncToLayer( mMeshLayer );
359 mMeshLayer->
setCrs( crs );
362void QgsMeshLayerProperties::syncAndRepaint()
365 mMeshLayer->triggerRepaint();
368void QgsMeshLayerProperties::showHelp()
370 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
372 if ( helpPage.isValid() )
382void QgsMeshLayerProperties::aboutToShowStyleMenu()
384 QMenu *m = qobject_cast<QMenu *>( sender() );
392void QgsMeshLayerProperties::reloadTemporalProperties()
394 if ( !mMeshLayer->dataProvider() )
396 QgsMeshDataProviderTemporalCapabilities *temporalCapabalities = mMeshLayer->dataProvider()->temporalCapabilities();
398 QDateTime referenceTime = temporalCapabalities->
referenceTime();
399 if ( referenceTime.isValid() )
401 timeExtent = temporalCapabalities->
timeExtent();
402 whileBlocking( mTemporalDateTimeReference )->setDateTime( referenceTime );
406 timeExtent = temporalCapabalities->
timeExtent( mTemporalDateTimeReference->dateTime() );
408 mTemporalDateTimeStart->setDateTime( timeExtent.
begin() );
409 mTemporalDateTimeEnd->setDateTime( timeExtent.
end() );
412void QgsMeshLayerProperties::onTimeReferenceChange()
414 if ( !mMeshLayer->dataProvider() )
416 const QgsDateTimeRange &timeExtent = mMeshLayer->dataProvider()->temporalCapabilities()->timeExtent( mTemporalDateTimeReference->dateTime() );
417 mTemporalDateTimeStart->setDateTime( timeExtent.
begin() );
418 mTemporalDateTimeEnd->setDateTime( timeExtent.
end() );
423 if ( mBackupCrs != mMeshLayer->crs() )
424 mMeshLayer->setCrs( mBackupCrs );
TemporalUnit
Temporal units.
@ ExcludeByDefault
If set, the layer should not be included in legends by default, and must be manually added by a user.
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
Represents a coordinate reference system (CRS).
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
QPushButton * mBtnStyle
Style button.
void saveMetadataToFile()
Allows the user to save the layer's metadata as a file.
virtual void rollback()
Rolls back changes made to the layer.
void saveStyleAsDefault()
Saves the current layer style as the default for the layer.
QList< QgsMapLayerConfigWidget * > mConfigWidgets
Layer config widgets.
void setMetadataWidget(QgsMetadataWidget *widget, QWidget *page)
Sets the metadata widget and page associated with the dialog.
void loadDefaultStyle()
Reloads the default style for the layer.
void saveStyleToFile()
Allows the user to save the layer's style to a file.
QgsMapCanvas * mCanvas
Associated map canvas.
QgsLayerPropertiesDialog(QgsMapLayer *layer, QgsMapCanvas *canvas, const QString &settingsKey, QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags(), QgsSettings *settings=nullptr)
Constructor for QgsLayerPropertiesDialog.
void loadMetadataFromFile()
Allows the user to load layer metadata from a file.
void loadStyleFromFile()
Allows the user to load layer style from a file.
QPushButton * mBtnMetadata
Metadata button.
void initialize()
Initialize the dialog.
void openUrl(const QUrl &url)
Handles opening a url from the dialog.
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
An abstract interface for implementations of legends for one map layer.
void removesExtraMenuSeparators(QMenu *m)
removes extra separators from the menu
void addStyleManagerActions(QMenu *m, QgsMapLayer *layer)
adds actions to the menu in accordance to the layer
static QgsMapLayerStyleGuiUtils * instance()
returns a singleton instance of this class
void currentStyleChanged(const QString ¤tName)
Emitted when the current style has been changed.
Base class for all map layer types.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
void dataChanged()
Data of layer changed.
double minimumScale() const
Returns the minimum map scale (i.e.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
double maximumScale() const
Returns the maximum map scale (i.e.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
QDateTime referenceTime() const
Returns the reference time.
QgsDateTimeRange timeExtent() const
Returns the time extent using the internal reference time and the first and last times available from...
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
@ FindClosestDatasetBeforeStartRangeTime
@ FindClosestDatasetFromStartRangeTime
Finds the closest dataset which have its time before the requested start range time.
Q_DECL_DEPRECATED void saveStyleAs() SIP_DEPRECATED
Saves a style when appriate button is pressed.
Q_DECL_DEPRECATED void saveDefaultStyle() SIP_DEPRECATED
Saves the default style when appropriate button is pressed.
Q_DECL_DEPRECATED void loadStyle() SIP_DEPRECATED
Loads a saved style when appropriate button is pressed.
QgsMeshLayerProperties(QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent=nullptr, Qt::WindowFlags=QgsGuiUtils::ModalDialogFlags)
Constructor.
Implementation of map layer temporal properties for mesh layers.
QDateTime referenceTime() const
Returns the reference time.
void setAlwaysLoadReferenceTimeFromSource(bool autoReloadFromProvider)
Sets whether the time proporties are automatically reloaded from provider when project is opened or l...
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod matchingMethod() const
Returns the method used to match dataset from temporal capabilities.
bool alwaysLoadReferenceTimeFromSource() const
Returns whether the time proporties are automatically reloaded from provider when project is opened o...
QgsDateTimeRange timeExtent() const
Returns the time extent.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
void activeScalarDatasetGroupChanged(int index)
Emitted when active scalar group dataset is changed.
void activeVectorDatasetGroupChanged(int index)
Emitted when active vector group dataset is changed.
Represents an overview renderer settings.
void setMeshResolution(int meshResolution)
Sets the mesh resolution i.e., the minimum size (average) of triangles in pixels This value is used d...
void setEnabled(bool isEnabled)
Sets if the overview is active.
double reductionFactor() const
Returns the reduction factor used to build simplified mesh.
bool isEnabled() const
Returns if the overview is active.
int meshResolution() const
Returns the mesh resolution i.e., the minimum size (average) of triangles in pixels.
void setReductionFactor(double value)
Sets the reduction factor used to build simplified mesh.
QStackedWidget * mOptStackedWidget
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
static QgsProject * instance()
Returns the QgsProject singleton instance.
void setDirty(bool b=true)
Flag the project as dirty (modified).
Stores settings for use within QGIS.
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.
bool isTemporal() const
Returns true if the object's temporal range is enabled, and the object will be filtered when renderin...
T begin() const
Returns the beginning of the range.
T end() const
Returns the upper bound of the range.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
#define QgsDebugMsgLevel(str, level)
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.