40#include <QDesktopServices>
45#include "moc_qgsmeshlayerproperties.cpp"
47using namespace Qt::StringLiterals;
53 Q_ASSERT( mMeshLayer );
58 mOptsPage_StyleContent->layout()->addWidget( mRendererMeshPropertiesWidget );
60 mSimplifyReductionFactorSpinBox->setClearValue( 10.0 );
61 mSimplifyMeshResolutionSpinBox->setClearValue( 5 );
63 mStaticDatasetWidget->setLayer( mMeshLayer );
86 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsMeshLayerProperties::showHelp );
88 connect( mTemporalReloadButton, &QPushButton::clicked,
this, &QgsMeshLayerProperties::reloadTemporalProperties );
89 connect( mTemporalDateTimeReference, &QDateTimeEdit::dateTimeChanged,
this, &QgsMeshLayerProperties::onTimeReferenceChange );
93 mScaleRangeWidget->setMapCanvas(
mCanvas );
97 connect( mAlwaysTimeFromSourceCheckBox, &QCheckBox::stateChanged,
this, [
this] {
98 mTemporalDateTimeReference->setEnabled( !mAlwaysTimeFromSourceCheckBox->isChecked() );
99 if ( mAlwaysTimeFromSourceCheckBox->isChecked() )
100 reloadTemporalProperties();
106 QVBoxLayout *labelingLayout =
nullptr;
111 labelingLayout =
new QVBoxLayout( labelingFrame );
112 labelingLayout->setContentsMargins( 0, 0, 0, 0 );
114 mLabelingDialog->layout()->setContentsMargins( 0, 0, 0, 0 );
115 labelingLayout->addWidget( mLabelingDialog );
116 labelingFrame->setLayout( labelingLayout );
120 mLabelingDialog =
nullptr;
121 mOptsPage_Labels->setEnabled(
false );
124 QVBoxLayout *metadataLayout =
new QVBoxLayout( metadataFrame );
125 metadataLayout->setContentsMargins( 0, 0, 0, 0 );
126 metadataFrame->setContentsMargins( 0, 0, 0, 0 );
128 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
129 mMetadataWidget->setMapCanvas(
mCanvas );
130 metadataLayout->addWidget( mMetadataWidget );
131 metadataFrame->setLayout( metadataLayout );
132 mOptsPage_Metadata->setContentsMargins( 0, 0, 0, 0 );
133 mBackupCrs = mMeshLayer->crs();
135 mTemporalDateTimeStart->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
136 mTemporalDateTimeEnd->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
137 mTemporalDateTimeReference->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
147 if ( !settings.
contains( u
"/Windows/MeshLayerProperties/tab"_s ) )
153 mOptsPage_Information->setProperty(
"helpPage", u
"working_with_mesh/mesh_properties.html#information-properties"_s );
154 mOptsPage_Source->setProperty(
"helpPage", u
"working_with_mesh/mesh_properties.html#source-properties"_s );
155 mOptsPage_Style->setProperty(
"helpPage", u
"working_with_mesh/mesh_properties.html#symbology-properties"_s );
156 mOptsPage_Rendering->setProperty(
"helpPage", u
"working_with_mesh/mesh_properties.html#rendering-properties"_s );
157 mOptsPage_Temporal->setProperty(
"helpPage", u
"working_with_mesh/mesh_properties.html#temporal-properties"_s );
158 mOptsPage_Metadata->setProperty(
"helpPage", u
"working_with_mesh/mesh_properties.html#metadata-properties"_s );
160 mBtnStyle =
new QPushButton( tr(
"Style" ) );
161 QMenu *menuStyle =
new QMenu(
this );
164 menuStyle->addSeparator();
168 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsMeshLayerProperties::aboutToShowStyleMenu );
170 buttonBox->addButton(
mBtnStyle, QDialogButtonBox::ResetRole );
172 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
173 QMenu *menuMetadata =
new QMenu(
this );
177 buttonBox->addButton(
mBtnMetadata, QDialogButtonBox::ResetRole );
184 Q_ASSERT( mRendererMeshPropertiesWidget );
191 myStyle.append( u
"body { margin: 10px; }\n "_s );
192 mInformationTextBrowser->clear();
193 mInformationTextBrowser->document()->setDefaultStyleSheet( myStyle );
194 mInformationTextBrowser->setHtml( mMeshLayer->htmlMetadata() );
195 mInformationTextBrowser->setOpenLinks(
false );
202 mLayerOrigNameLineEd->setText( mMeshLayer->name() );
205 mDatasetGroupTreeWidget->syncToLayer( mMeshLayer );
209 w->syncToLayer( mMeshLayer );
212 if ( mMeshLayer->isEditable() )
213 mSimplifyMeshGroupBox->setEnabled(
false );
216 mSimplifyMeshGroupBox->setChecked( simplifySettings.
isEnabled() );
217 mSimplifyReductionFactorSpinBox->setValue( simplifySettings.
reductionFactor() );
218 mSimplifyMeshResolutionSpinBox->setValue( simplifySettings.
meshResolution() );
221 const QgsMeshLayerTemporalProperties *temporalProperties = qobject_cast<const QgsMeshLayerTemporalProperties *>( mMeshLayer->temporalProperties() );
224 mTemporalDateTimeStart->setDateTime( timeRange.
begin() );
225 mTemporalDateTimeEnd->setDateTime( timeRange.
end() );
226 if ( mMeshLayer->dataProvider() )
228 mTemporalProviderTimeUnitComboBox->setCurrentIndex( mTemporalProviderTimeUnitComboBox->findData(
static_cast<int>( mMeshLayer->dataProvider()->temporalCapabilities()->temporalUnit() ) ) );
231 mComboBoxTemporalDatasetMatchingMethod->setCurrentIndex( mComboBoxTemporalDatasetMatchingMethod->findData( temporalProperties->
matchingMethod() ) );
233 mStaticDatasetWidget->syncToLayer();
234 mStaticDatasetGroupBox->setChecked( !mMeshLayer->temporalProperties()->isActive() );
237 mLegendConfigEmbeddedWidget->setLayer( mMeshLayer );
258 Q_ASSERT( mRendererMeshPropertiesWidget );
260 mLegendConfigEmbeddedWidget->applyToLayer();
266 mMeshLayer->setName( mLayerOrigNameLineEd->text() );
272 mDatasetGroupTreeWidget->apply();
285 simplifySettings.
setEnabled( mSimplifyMeshGroupBox->isChecked() );
288 bool needMeshUpdating
289 = ( ( 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(
static_cast<Qgis::TemporalUnit>( mTemporalProviderTimeUnitComboBox->currentData().toInt() ) );
315 mStaticDatasetWidget->apply();
316 bool needEmitRendererChanged = mMeshLayer->temporalProperties()->isActive() == mStaticDatasetGroupBox->isChecked();
317 mMeshLayer->temporalProperties()->setIsActive( !mStaticDatasetGroupBox->isChecked() );
321 mMetadataWidget->acceptMetadata();
323 mBackupCrs = mMeshLayer->crs();
325 if ( needMeshUpdating )
326 mMeshLayer->reload();
328 if ( needEmitRendererChanged )
329 emit mMeshLayer->rendererChanged();
338 mMeshLayer->triggerRepaint();
344 mStaticDatasetWidget->syncToLayer();
346 w->syncToLayer( mMeshLayer );
352 mMeshLayer->
setCrs( crs );
355void QgsMeshLayerProperties::syncAndRepaint()
358 mMeshLayer->triggerRepaint();
361void QgsMeshLayerProperties::showHelp()
363 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
365 if ( helpPage.isValid() )
375void QgsMeshLayerProperties::aboutToShowStyleMenu()
377 QMenu *m = qobject_cast<QMenu *>( sender() );
385void QgsMeshLayerProperties::reloadTemporalProperties()
387 if ( !mMeshLayer->dataProvider() )
389 QgsMeshDataProviderTemporalCapabilities *temporalCapabalities = mMeshLayer->dataProvider()->temporalCapabilities();
391 QDateTime referenceTime = temporalCapabalities->
referenceTime();
392 if ( referenceTime.isValid() )
394 timeExtent = temporalCapabalities->
timeExtent();
395 whileBlocking( mTemporalDateTimeReference )->setDateTime( referenceTime );
399 timeExtent = temporalCapabalities->
timeExtent( mTemporalDateTimeReference->dateTime() );
401 mTemporalDateTimeStart->setDateTime( timeExtent.
begin() );
402 mTemporalDateTimeEnd->setDateTime( timeExtent.
end() );
405void QgsMeshLayerProperties::onTimeReferenceChange()
407 if ( !mMeshLayer->dataProvider() )
409 const QgsDateTimeRange &timeExtent = mMeshLayer->dataProvider()->temporalCapabilities()->timeExtent( mTemporalDateTimeReference->dateTime() );
410 mTemporalDateTimeStart->setDateTime( timeExtent.
begin() );
411 mTemporalDateTimeEnd->setDateTime( timeExtent.
end() );
416 if ( mBackupCrs != mMeshLayer->crs() )
417 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.