QGIS API Documentation 3.43.0-Master (3ee7834ace6)
qgsrasterlayertemporalpropertieswidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsrasterlayertemporalpropertieswidget.cpp
3 ------------------------------
4 begin : January 2020
5 copyright : (C) 2020 by Samweli Mwakisambwe
6 email : samweli at kartoza dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
19#include "moc_qgsrasterlayertemporalpropertieswidget.cpp"
21#include "qgsrasterlayer.h"
24#include "qgsdatetimeedit.h"
27#include "qgsunittypes.h"
28#include "qgsapplication.h"
30#include "qgsrasterrenderer.h"
31
32#include <QMenu>
33#include <QAction>
34
36 : QWidget( parent )
37 , mLayer( layer )
38{
39 Q_ASSERT( mLayer );
40 setupUi( this );
41
42 // make a useful default expression for per band ranges, just to give users some hints about how to do this...
43 mFixedRangeLowerExpression = QStringLiteral( "make_datetime(%1,1,1,0,0,0) + make_interval(days:=@band)" ).arg( QDate::currentDate().year() );
44 mFixedRangeUpperExpression = QStringLiteral( "make_datetime(%1,1,1,23,59,59) + make_interval(days:=@band)" ).arg( QDate::currentDate().year() );
45
46 mExtraWidgetLayout = new QVBoxLayout();
47 mExtraWidgetLayout->setContentsMargins( 0, 0, 0, 0 );
48 mExtraWidgetLayout->addStretch();
49 mExtraWidgetContainer->setLayout( mExtraWidgetLayout );
50
52 {
53 mModeComboBox->addItem( tr( "Automatic" ), QVariant::fromValue( Qgis::RasterTemporalMode::TemporalRangeFromDataProvider ) );
54 }
55 mModeComboBox->addItem( tr( "Fixed Date/Time" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedDateTime ) );
56 mModeComboBox->addItem( tr( "Fixed Time Range" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedTemporalRange ) );
57 mModeComboBox->addItem( tr( "Fixed Time Range Per Band" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedRangePerBand ) );
58 mModeComboBox->addItem( tr( "Represents Temporal Values" ), QVariant::fromValue( Qgis::RasterTemporalMode::RepresentsTemporalValues ) );
59 mModeComboBox->addItem( tr( "Redraw Layer Only" ), QVariant::fromValue( Qgis::RasterTemporalMode::RedrawLayerOnly ) );
60
61 for ( const Qgis::TemporalUnit unit :
62 {
73 } )
74 {
75 mScaleUnitComboBox->addItem( QgsUnitTypes::toString( unit ), static_cast<int>( unit ) );
76 }
77 mScaleUnitComboBox->setCurrentIndex( mScaleUnitComboBox->findData( static_cast<int>( Qgis::TemporalUnit::Days ) ) );
78
79 mStackedWidget->setSizeMode( QgsStackedWidget::SizeMode::CurrentPageOnly );
80
81 mFixedRangePerBandModel = new QgsRasterBandFixedTemporalRangeModel( this );
82 mBandRangesTable->verticalHeader()->setVisible( false );
83 mBandRangesTable->setModel( mFixedRangePerBandModel );
84 QgsFixedTemporalRangeDelegate *tableDelegate = new QgsFixedTemporalRangeDelegate( mBandRangesTable );
85 mBandRangesTable->setItemDelegateForColumn( 1, tableDelegate );
86 mBandRangesTable->setItemDelegateForColumn( 2, tableDelegate );
87
88 connect( mModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerTemporalPropertiesWidget::modeChanged );
89
90 connect( mTemporalGroupBox, &QGroupBox::toggled, this, &QgsRasterLayerTemporalPropertiesWidget::temporalGroupBoxChecked );
91
92 mFixedDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
93 mStartTemporalDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
94 mEndTemporalDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
95 mOffsetDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
96
97 QMenu *calculateFixedRangePerBandMenu = new QMenu( mCalculateFixedRangePerBandButton );
98 mCalculateFixedRangePerBandButton->setMenu( calculateFixedRangePerBandMenu );
99 mCalculateFixedRangePerBandButton->setPopupMode( QToolButton::InstantPopup );
100 QAction *calculateLowerAction = new QAction( "Calculate Beginning by Expression…", calculateFixedRangePerBandMenu );
101 calculateFixedRangePerBandMenu->addAction( calculateLowerAction );
102 connect( calculateLowerAction, &QAction::triggered, this, [this] {
103 calculateRangeByExpression( false );
104 } );
105 QAction *calculateUpperAction = new QAction( "Calculate End by Expression…", calculateFixedRangePerBandMenu );
106 calculateFixedRangePerBandMenu->addAction( calculateUpperAction );
107 connect( calculateUpperAction, &QAction::triggered, this, [this] {
108 calculateRangeByExpression( true );
109 } );
110
111
112 syncToLayer();
113}
114
116{
117 mLayer->temporalProperties()->setIsActive( mTemporalGroupBox->isChecked() );
118
119 QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast<QgsRasterLayerTemporalProperties *>( mLayer->temporalProperties() );
120
121 temporalProperties->setMode( mModeComboBox->currentData().value<Qgis::RasterTemporalMode>() );
122 temporalProperties->setBandNumber( mBandComboBox->currentBand() );
123
124 switch ( temporalProperties->mode() )
125 {
127 {
128 const QgsDateTimeRange normalRange = QgsDateTimeRange( mFixedDateTimeEdit->dateTime(), mFixedDateTimeEdit->dateTime() );
129 temporalProperties->setFixedTemporalRange( normalRange );
130 break;
131 }
133 {
134 const QgsDateTimeRange normalRange = QgsDateTimeRange( mStartTemporalDateTimeEdit->dateTime(), mEndTemporalDateTimeEdit->dateTime() );
135 temporalProperties->setFixedTemporalRange( normalRange );
136 break;
137 }
142 break;
143 }
144
145 temporalProperties->setFixedRangePerBand( mFixedRangePerBandModel->rangeData() );
146
147 temporalProperties->setTemporalRepresentationOffset( mOffsetDateTimeEdit->dateTime() );
148
149 const QgsInterval scale( mScaleSpinBox->value(), static_cast<Qgis::TemporalUnit>( mScaleUnitComboBox->currentData().toInt() ) );
150 temporalProperties->setTemporalRepresentationScale( scale );
151
152 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
153 {
154 widget->apply();
155 }
156}
157
159{
160 const QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast<const QgsRasterLayerTemporalProperties *>( mLayer->temporalProperties() );
161 mModeComboBox->setCurrentIndex( mModeComboBox->findData( QVariant::fromValue( temporalProperties->mode() ) ) );
162 switch ( temporalProperties->mode() )
163 {
165 mStackedWidget->setCurrentWidget( mPageAutomatic );
166 break;
168 mStackedWidget->setCurrentWidget( mPageFixedDateTime );
169 break;
171 mStackedWidget->setCurrentWidget( mPageFixedRange );
172 break;
174 mStackedWidget->setCurrentWidget( mPageRedrawOnly );
175 break;
177 mStackedWidget->setCurrentWidget( mPageFixedRangePerBand );
178 break;
180 mStackedWidget->setCurrentWidget( mPageRepresentsTemporalValues );
181 break;
182 }
183
185 {
186 mWidgetFixedRangePerBand->hide();
187 mFixedRangePerBandLabel->setText( tr( "This mode cannot be used with a multi-band renderer." ) );
188 }
189
190 mBandComboBox->setLayer( mLayer );
191 mBandComboBox->setBand( temporalProperties->bandNumber() );
192
193 mFixedDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
194 mStartTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
195 mEndTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().end() );
196
197 mFixedRangePerBandModel->setLayerData( mLayer, temporalProperties->fixedRangePerBand() );
198 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
199 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::Stretch );
200 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 2, QHeaderView::Stretch );
201
202 mOffsetDateTimeEdit->setDateTime( temporalProperties->temporalRepresentationOffset() );
203
204 mScaleSpinBox->setValue( temporalProperties->temporalRepresentationScale().originalDuration() );
205 mScaleUnitComboBox->setCurrentIndex( mScaleUnitComboBox->findData( static_cast<int>( temporalProperties->temporalRepresentationScale().originalUnit() ) ) );
206
207 mTemporalGroupBox->setChecked( temporalProperties->isActive() );
208
209 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
210 {
211 widget->syncToLayer( mLayer );
212 }
213}
214
216{
217 mExtraWidgets << widget;
218 mExtraWidgetLayout->insertWidget( mExtraWidgetLayout->count() - 1, widget );
219}
220
221void QgsRasterLayerTemporalPropertiesWidget::temporalGroupBoxChecked( bool checked )
222{
223 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
224 {
225 widget->emit dynamicTemporalControlToggled( checked );
226 }
227}
228
229void QgsRasterLayerTemporalPropertiesWidget::modeChanged()
230{
231 if ( mModeComboBox->currentData().isValid() )
232 {
233 switch ( mModeComboBox->currentData().value<Qgis::RasterTemporalMode>() )
234 {
236 mStackedWidget->setCurrentWidget( mPageAutomatic );
237 break;
239 mStackedWidget->setCurrentWidget( mPageFixedDateTime );
240 break;
242 mStackedWidget->setCurrentWidget( mPageFixedRange );
243 break;
245 mStackedWidget->setCurrentWidget( mPageRedrawOnly );
246 break;
248 mStackedWidget->setCurrentWidget( mPageFixedRangePerBand );
249 break;
251 mStackedWidget->setCurrentWidget( mPageRepresentsTemporalValues );
252 break;
253 }
254 }
255}
256
257void QgsRasterLayerTemporalPropertiesWidget::calculateRangeByExpression( bool isUpper )
258{
259 QgsExpressionContext expressionContext;
261 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band" ), 1, true, false, tr( "Band number" ) ) );
262 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_name" ), mLayer->dataProvider()->displayBandName( 1 ), true, false, tr( "Band name" ) ) );
263 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_description" ), mLayer->dataProvider()->bandDescription( 1 ), true, false, tr( "Band description" ) ) );
264
265 expressionContext.appendScope( bandScope );
267 expressionContext.setHighlightedVariables( { QStringLiteral( "band" ), QStringLiteral( "band_name" ), QStringLiteral( "band_description" ) } );
268
269 QgsExpressionBuilderDialog dlg = QgsExpressionBuilderDialog( nullptr, isUpper ? mFixedRangeUpperExpression : mFixedRangeLowerExpression, this, QStringLiteral( "generic" ), expressionContext );
270 dlg.setExpectedOutputFormat( !isUpper ? tr( "Temporal range start date / time" ) : tr( "Temporal range end date / time" ) );
271
272 QList<QPair<QString, QVariant>> bandChoices;
273 for ( int band = 1; band <= mLayer->bandCount(); ++band )
274 {
275 bandChoices << qMakePair( mLayer->dataProvider()->displayBandName( band ), band );
276 }
277 dlg.expressionBuilder()->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant &value ) -> QgsExpressionContext {
278 return createExpressionContextForBand( value.toInt() );
279 } );
280
281 if ( dlg.exec() )
282 {
283 if ( isUpper )
284 mFixedRangeUpperExpression = dlg.expressionText();
285 else
286 mFixedRangeLowerExpression = dlg.expressionText();
287
288 QgsExpression exp( dlg.expressionText() );
289 exp.prepare( &expressionContext );
290 for ( int band = 1; band <= mLayer->bandCount(); ++band )
291 {
292 bandScope->setVariable( QStringLiteral( "band" ), band );
293 bandScope->setVariable( QStringLiteral( "band_name" ), mLayer->dataProvider()->displayBandName( band ) );
294 bandScope->setVariable( QStringLiteral( "band_description" ), mLayer->dataProvider()->bandDescription( band ) );
295
296 const QVariant res = exp.evaluate( &expressionContext );
297 mFixedRangePerBandModel->setData( mFixedRangePerBandModel->index( band - 1, isUpper ? 2 : 1 ), res, Qt::EditRole );
298 }
299 }
300}
301
302QgsExpressionContext QgsRasterLayerTemporalPropertiesWidget::createExpressionContextForBand( int band ) const
303{
304 QgsExpressionContext context;
307 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band" ), band, true, false, tr( "Band number" ) ) );
308 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_name" ), ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->displayBandName( band ) : QString(), true, false, tr( "Band name" ) ) );
309 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_description" ), ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->bandDescription( band ) : QString(), true, false, tr( "Band description" ) ) );
310 context.appendScope( bandScope );
311 context.setHighlightedVariables( { QStringLiteral( "band" ), QStringLiteral( "band_name" ), QStringLiteral( "band_description" ) } );
312 return context;
313}
314
316
317//
318// QgsRasterBandFixedTemporalRangeModel
319//
320
321QgsRasterBandFixedTemporalRangeModel::QgsRasterBandFixedTemporalRangeModel( QObject *parent )
322 : QAbstractItemModel( parent )
323{
324}
325
326int QgsRasterBandFixedTemporalRangeModel::columnCount( const QModelIndex & ) const
327{
328 return 3;
329}
330
331int QgsRasterBandFixedTemporalRangeModel::rowCount( const QModelIndex &parent ) const
332{
333 if ( parent.isValid() )
334 return 0;
335 return mBandCount;
336}
337
338QModelIndex QgsRasterBandFixedTemporalRangeModel::index( int row, int column, const QModelIndex &parent ) const
339{
340 if ( hasIndex( row, column, parent ) )
341 {
342 return createIndex( row, column, row );
343 }
344
345 return QModelIndex();
346}
347
348QModelIndex QgsRasterBandFixedTemporalRangeModel::parent( const QModelIndex &child ) const
349{
350 Q_UNUSED( child )
351 return QModelIndex();
352}
353
354Qt::ItemFlags QgsRasterBandFixedTemporalRangeModel::flags( const QModelIndex &index ) const
355{
356 if ( !index.isValid() )
357 return Qt::ItemFlags();
358
359 if ( index.row() < 0 || index.row() >= mBandCount || index.column() < 0 || index.column() >= columnCount() )
360 return Qt::ItemFlags();
361
362 switch ( index.column() )
363 {
364 case 0:
365 return Qt::ItemFlag::ItemIsEnabled;
366 case 1:
367 case 2:
368 return Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsEditable | Qt::ItemFlag::ItemIsSelectable;
369 default:
370 break;
371 }
372
373 return Qt::ItemFlags();
374}
375
376QVariant QgsRasterBandFixedTemporalRangeModel::data( const QModelIndex &index, int role ) const
377{
378 if ( !index.isValid() )
379 return QVariant();
380
381 if ( index.row() < 0 || index.row() >= mBandCount || index.column() < 0 || index.column() >= columnCount() )
382 return QVariant();
383
384 const int band = index.row() + 1;
385 const QgsDateTimeRange range = mRanges.value( band );
386
387 switch ( role )
388 {
389 case Qt::DisplayRole:
390 case Qt::EditRole:
391 case Qt::ToolTipRole:
392 {
393 switch ( index.column() )
394 {
395 case 0:
396 return mBandNames.value( band, QString::number( band ) );
397
398 case 1:
399 return range.begin().isValid() ? range.begin() : QVariant();
400
401 case 2:
402 return range.end().isValid() ? range.end() : QVariant();
403
404 default:
405 break;
406 }
407 break;
408 }
409
410 case Qt::TextAlignmentRole:
411 {
412 switch ( index.column() )
413 {
414 case 0:
415 return static_cast<Qt::Alignment::Int>( Qt::AlignLeft | Qt::AlignVCenter );
416
417 case 1:
418 case 2:
419 return static_cast<Qt::Alignment::Int>( Qt::AlignRight | Qt::AlignVCenter );
420 default:
421 break;
422 }
423 break;
424 }
425
426 default:
427 break;
428 }
429 return QVariant();
430}
431
432QVariant QgsRasterBandFixedTemporalRangeModel::headerData( int section, Qt::Orientation orientation, int role ) const
433{
434 if ( role == Qt::DisplayRole && orientation == Qt::Horizontal )
435 {
436 switch ( section )
437 {
438 case 0:
439 return tr( "Band" );
440 case 1:
441 return tr( "Begin" );
442 case 2:
443 return tr( "End" );
444 default:
445 break;
446 }
447 }
448 return QAbstractItemModel::headerData( section, orientation, role );
449}
450
451bool QgsRasterBandFixedTemporalRangeModel::setData( const QModelIndex &index, const QVariant &value, int role )
452{
453 if ( !index.isValid() )
454 return false;
455
456 if ( index.row() > mBandCount || index.row() < 0 )
457 return false;
458
459 const int band = index.row() + 1;
460 const QgsDateTimeRange range = mRanges.value( band );
461
462 switch ( role )
463 {
464 case Qt::EditRole:
465 {
466 const QDateTime newValue = value.toDateTime();
467 if ( !newValue.isValid() )
468 return false;
469
470 switch ( index.column() )
471 {
472 case 1:
473 {
474 mRanges[band] = QgsDateTimeRange( newValue, range.end(), range.includeBeginning(), range.includeEnd() );
475 emit dataChanged( index, index, QVector<int>() << role );
476 break;
477 }
478
479 case 2:
480 mRanges[band] = QgsDateTimeRange( range.begin(), newValue, range.includeBeginning(), range.includeEnd() );
481 emit dataChanged( index, index, QVector<int>() << role );
482 break;
483
484 default:
485 break;
486 }
487 return true;
488 }
489
490 default:
491 break;
492 }
493
494 return false;
495}
496
497void QgsRasterBandFixedTemporalRangeModel::setLayerData( QgsRasterLayer *layer, const QMap<int, QgsDateTimeRange> &ranges )
498{
499 beginResetModel();
500
501 mBandCount = layer->bandCount();
502 mRanges = ranges;
503
504 mBandNames.clear();
505 for ( int band = 1; band <= mBandCount; ++band )
506 {
507 mBandNames[band] = layer->dataProvider()->displayBandName( band );
508 }
509
510 endResetModel();
511}
512
513//
514// QgsFixedTemporalRangeDelegate
515//
516
517QgsFixedTemporalRangeDelegate::QgsFixedTemporalRangeDelegate( QObject *parent )
518 : QStyledItemDelegate( parent )
519{
520}
521
522QWidget *QgsFixedTemporalRangeDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const
523{
524 QgsDateTimeEdit *editor = new QgsDateTimeEdit( parent );
525 editor->setAllowNull( true );
526 return editor;
527}
528
529void QgsFixedTemporalRangeDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
530{
531 if ( QgsDateTimeEdit *dateTimeEdit = qobject_cast<QgsDateTimeEdit *>( editor ) )
532 {
533 model->setData( index, dateTimeEdit->dateTime() );
534 }
535}
TemporalUnit
Temporal units.
Definition qgis.h:4984
@ Milliseconds
Milliseconds.
@ Centuries
Centuries.
RasterTemporalMode
Raster layer temporal modes.
Definition qgis.h:2569
@ RepresentsTemporalValues
Pixel values represent an datetime.
@ RedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbo...
@ FixedRangePerBand
Layer has a fixed temporal range per band.
@ TemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
@ FixedDateTime
Layer has a fixed date time instant.
@ UsesMultipleBands
The renderer utilizes multiple raster bands for color data (note that alpha bands are not considered ...
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers.
bool hasTemporalCapabilities() const
Returns true if the provider has temporal capabilities available.
The QgsDateTimeEdit class is a QDateTimeEdit with the capability of setting/reading null date/times.
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
A generic dialog for building expression strings.
void setExpectedOutputFormat(const QString &expected)
Set the expected format string, which is shown in the dialog.
QgsExpressionBuilderWidget * expressionBuilder()
The builder widget that is used by the dialog.
void setCustomPreviewGenerator(const QString &label, const QList< QPair< QString, QVariant > > &choices, const std::function< QgsExpressionContext(const QVariant &)> &previewContextGenerator)
Sets the widget to run using a custom preview generator.
Single scope for storing variables and functions for use within a QgsExpressionContext.
void addVariable(const QgsExpressionContextScope::StaticVariable &variable)
Adds a variable into the context scope.
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void setHighlightedVariables(const QStringList &variableNames)
Sets the list of variable names within the context intended to be highlighted to the user.
void appendScopes(const QList< QgsExpressionContextScope * > &scopes)
Appends a list of scopes to the end of the context.
Class for parsing and evaluation of expressions (formerly called "search strings").
A representation of the interval between two datetime values.
Definition qgsinterval.h:46
double originalDuration() const
Returns the original interval duration.
Qgis::TemporalUnit originalUnit() const
Returns the original interval temporal unit.
A panel widget that can be shown in the map style dock.
QgsRasterDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
virtual QString bandDescription(int bandNumber)
Returns the description for band bandNumber, or an empty string if the band is not valid or has not d...
QString displayBandName(int bandNumber) const
Generates a friendly, descriptive name for the specified bandNumber.
void addWidget(QgsMapLayerConfigWidget *widget)
Adds a child widget to the properties widget.
void syncToLayer()
Updates the widget state to match the current layer state.
void saveTemporalProperties()
Save widget temporal properties inputs.
QgsRasterLayerTemporalPropertiesWidget(QWidget *parent=nullptr, QgsRasterLayer *layer=nullptr)
Constructor for QgsRasterLayerTemporalPropertiesWidget.
Implementation of map layer temporal properties for raster layers.
QDateTime temporalRepresentationOffset() const
Returns the temporal offset, which is a fixed datetime which should be added to individual pixel valu...
void setTemporalRepresentationOffset(const QDateTime &offset)
Sets the temporal offset, which is a fixed datetime which should be added to individual pixel values ...
const QgsInterval & temporalRepresentationScale() const
Returns the scale, which is an interval factor which should be applied to individual pixel values fro...
Qgis::RasterTemporalMode mode() const
Returns the temporal properties mode.
void setTemporalRepresentationScale(const QgsInterval &scale)
Sets the scale, which is an interval factor which should be applied to individual pixel values from t...
void setMode(Qgis::RasterTemporalMode mode)
Sets the temporal properties mode.
void setFixedTemporalRange(const QgsDateTimeRange &range)
Sets a temporal range to apply to the whole layer.
void setFixedRangePerBand(const QMap< int, QgsDateTimeRange > &ranges)
Sets the fixed temporal range for each band.
QMap< int, QgsDateTimeRange > fixedRangePerBand() const
Returns the fixed temporal range for each band.
int bandNumber() const
Returns the band number from which temporal values should be taken.
const QgsDateTimeRange & fixedTemporalRange() const
Returns the fixed temporal range for the layer.
void setBandNumber(int number)
Sets the band number from which temporal values should be taken.
Represents a raster layer.
int bandCount() const
Returns the number of bands in this layer.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
QgsRasterRenderer * renderer() const
Returns the raster's renderer.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
Qgis::RasterRendererCapabilities rendererCapabilities(const QString &rendererName) const
Returns the capabilities for the renderer with the specified name.
virtual QString type() const
Returns a unique string representation of the renderer type.
@ CurrentPageOnly
Only the size of the current page is considered when calculating the stacked widget size.
bool isActive() const
Returns true if the temporal property is active.
void setIsActive(bool active)
Sets whether the temporal property is active.
T begin() const
Returns the beginning of the range.
Definition qgsrange.h:446
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:453
bool includeEnd() const
Returns true if the end is inclusive, or false if the end is exclusive.
Definition qgsrange.h:468
bool includeBeginning() const
Returns true if the beginning is inclusive, or false if the beginning is exclusive.
Definition qgsrange.h:461
static Q_INVOKABLE QString toString(Qgis::DistanceUnit unit)
Returns a translated string representing a distance unit.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
Definition qgsrange.h:760
Single variable definition for use within a QgsExpressionContextScope.