37#include <QDesktopServices>
45 Q_ASSERT( mMeshLayer );
50 mOptsPage_StyleContent->layout()->addWidget( mRendererMeshPropertiesWidget );
52 mSimplifyReductionFactorSpinBox->setClearValue( 10.0 );
53 mSimplifyMeshResolutionSpinBox->setClearValue( 5 );
55 mStaticDatasetWidget->setLayer( mMeshLayer );
78 connect( buttonBox, &QDialogButtonBox::helpRequested,
this, &QgsMeshLayerProperties::showHelp );
80 connect( mTemporalReloadButton, &QPushButton::clicked,
this, &QgsMeshLayerProperties::reloadTemporalProperties );
81 connect( mTemporalDateTimeReference, &QDateTimeEdit::dateTimeChanged,
this, &QgsMeshLayerProperties::onTimeReferenceChange );
85 mScaleRangeWidget->setMapCanvas(
mCanvas );
89 connect( mAlwaysTimeFromSourceCheckBox, &QCheckBox::stateChanged,
this, [
this]
91 mTemporalDateTimeReference->setEnabled( !mAlwaysTimeFromSourceCheckBox->isChecked() );
92 if ( mAlwaysTimeFromSourceCheckBox->isChecked() )
93 reloadTemporalProperties();
96 mComboBoxTemporalDatasetMatchingMethod->addItem( tr(
"Find Closest Dataset Before Requested Time" ),
98 mComboBoxTemporalDatasetMatchingMethod->addItem( tr(
"Find Closest Dataset From Requested Time (After or Before)" ),
101 QVBoxLayout *layout =
new QVBoxLayout( metadataFrame );
102 layout->setContentsMargins( 0, 0, 0, 0 );
103 metadataFrame->setContentsMargins( 0, 0, 0, 0 );
105 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
107 layout->addWidget( mMetadataWidget );
108 metadataFrame->setLayout( layout );
109 mOptsPage_Metadata->setContentsMargins( 0, 0, 0, 0 );
110 mBackupCrs = mMeshLayer->
crs();
112 mTemporalDateTimeStart->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
113 mTemporalDateTimeEnd->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
114 mTemporalDateTimeReference->setDisplayFormat(
"yyyy-MM-dd HH:mm:ss" );
124 if ( !settings.
contains( QStringLiteral(
"/Windows/MeshLayerProperties/tab" ) ) )
126 settings.
setValue( QStringLiteral(
"Windows/MeshLayerProperties/tab" ),
131 mOptsPage_Information->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#information-properties" ) );
132 mOptsPage_Source->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#source-properties" ) );
133 mOptsPage_Style->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#symbology-properties" ) );
134 mOptsPage_Rendering->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#rendering-properties" ) );
135 mOptsPage_Temporal->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#temporal-properties" ) );
136 mOptsPage_Metadata->setProperty(
"helpPage", QStringLiteral(
"working_with_mesh/mesh_properties.html#metadata-properties" ) );
138 mBtnStyle =
new QPushButton( tr(
"Style" ) );
139 QMenu *menuStyle =
new QMenu(
this );
142 menuStyle->addSeparator();
146 connect( menuStyle, &QMenu::aboutToShow,
this, &QgsMeshLayerProperties::aboutToShowStyleMenu );
148 buttonBox->addButton(
mBtnStyle, QDialogButtonBox::ResetRole );
150 mBtnMetadata =
new QPushButton( tr(
"Metadata" ),
this );
151 QMenu *menuMetadata =
new QMenu(
this );
155 buttonBox->addButton(
mBtnMetadata, QDialogButtonBox::ResetRole );
162 Q_ASSERT( mRendererMeshPropertiesWidget );
164 QgsDebugMsgLevel( QStringLiteral(
"populate general information tab" ), 4 );
169 myStyle.append( QStringLiteral(
"body { margin: 10px; }\n " ) );
170 mInformationTextBrowser->clear();
171 mInformationTextBrowser->document()->setDefaultStyleSheet( myStyle );
172 mInformationTextBrowser->setHtml( mMeshLayer->
htmlMetadata() );
173 mInformationTextBrowser->setOpenLinks(
false );
180 mLayerOrigNameLineEd->setText( mMeshLayer->
name() );
183 mDatasetGroupTreeWidget->syncToLayer( mMeshLayer );
187 w->syncToLayer( mMeshLayer );
191 mSimplifyMeshGroupBox->setEnabled(
false );
194 mSimplifyMeshGroupBox->setChecked( simplifySettings.
isEnabled() );
195 mSimplifyReductionFactorSpinBox->setValue( simplifySettings.
reductionFactor() );
196 mSimplifyMeshResolutionSpinBox->setValue( simplifySettings.
meshResolution() );
202 mTemporalDateTimeStart->setDateTime( timeRange.
begin() );
203 mTemporalDateTimeEnd->setDateTime( timeRange.
end() );
206 mTemporalProviderTimeUnitComboBox->setCurrentIndex(
210 mComboBoxTemporalDatasetMatchingMethod->setCurrentIndex(
211 mComboBoxTemporalDatasetMatchingMethod->findData( temporalProperties->
matchingMethod() ) );
213 mStaticDatasetWidget->syncToLayer();
234 Q_ASSERT( mRendererMeshPropertiesWidget );
240 mMeshLayer->
setName( mLayerOrigNameLineEd->text() );
246 mDatasetGroupTreeWidget->apply();
258 simplifySettings.
setEnabled( mSimplifyMeshGroupBox->isChecked() );
278 static_cast<Qgis::TemporalUnit>( mTemporalProviderTimeUnitComboBox->currentData().toInt() ) );
280 mStaticDatasetWidget->apply();
284 mComboBoxTemporalDatasetMatchingMethod->currentData().toInt() ) );
286 mMeshLayer->
temporalProperties() )->setAlwaysLoadReferenceTimeFromSource( mAlwaysTimeFromSourceCheckBox->isChecked() );
290 mBackupCrs = mMeshLayer->
crs();
292 if ( needMeshUpdating )
295 if ( needEmitRendererChanged )
305 mStaticDatasetWidget->syncToLayer();
307 w->syncToLayer( mMeshLayer );
316void QgsMeshLayerProperties::syncAndRepaint()
322void QgsMeshLayerProperties::showHelp()
324 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property(
"helpPage" );
326 if ( helpPage.isValid() )
336void QgsMeshLayerProperties::aboutToShowStyleMenu()
338 QMenu *m = qobject_cast<QMenu *>( sender() );
346void QgsMeshLayerProperties::reloadTemporalProperties()
352 QDateTime referenceTime = temporalCapabalities->
referenceTime();
353 if ( referenceTime.isValid() )
355 timeExtent = temporalCapabalities->
timeExtent();
356 whileBlocking( mTemporalDateTimeReference )->setDateTime( referenceTime );
360 timeExtent = temporalCapabalities->
timeExtent( mTemporalDateTimeReference->dateTime() );
362 mTemporalDateTimeStart->setDateTime( timeExtent.
begin() );
363 mTemporalDateTimeEnd->setDateTime( timeExtent.
end() );
366void QgsMeshLayerProperties::onTimeReferenceChange()
371 mTemporalDateTimeStart->setDateTime( timeExtent.
begin() );
372 mTemporalDateTimeEnd->setDateTime( timeExtent.
end() );
377 if ( mBackupCrs != mMeshLayer->
crs() )
378 mMeshLayer->
setCrs( mBackupCrs );
TemporalUnit
Temporal units.
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
This class 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.
Base class for "layer properties" dialogs, containing common utilities for handling functionality in ...
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.
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.
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.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
QgsCoordinateReferenceSystem crs
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
void rendererChanged()
Signal emitted when renderer is changed.
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
void dataChanged()
Data of layer changed.
void setName(const QString &name)
Set the display name of the layer.
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.
Class for handling properties relating to a mesh data provider's temporal capabilities.
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...
Qgis::TemporalUnit temporalUnit() const
Returns the temporal unit used to read data by the data provider.
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.
void setTemporalUnit(Qgis::TemporalUnit unit)
Sets the temporal unit of the provider and reload data if it changes.
QgsMeshDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
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.
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 setMeshSimplificationSettings(const QgsMeshSimplificationSettings &meshSimplificationSettings)
Sets mesh simplification settings.
void activeScalarDatasetGroupChanged(int index)
Emitted when active scalar group dataset is changed.
void activeVectorDatasetGroupChanged(int index)
Emitted when active vector group dataset is changed.
void reload() override
Synchronises with changes in the datasource.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
QgsMeshSimplificationSettings meshSimplificationSettings() const
Returns mesh simplification settings.
bool isEditable() const override
Returns true if the layer can be edited.
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
void setReferenceTime(const QDateTime &referenceTime)
Sets the reference time of the layer.
void setTemporalMatchingMethod(const QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod &matchingMethod)
Sets the method used to match the temporal dataset from a requested time, see activeVectorDatasetAtTi...
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).
This class is a composition of two QSettings instances:
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 isActive() const
Returns true if the temporal property is active.
void setIsActive(bool active)
Sets whether the temporal property is active.
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)
const QgsCoordinateReferenceSystem & crs