QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
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
20#include "qgsapplication.h"
21#include "qgsdatetimeedit.h"
26#include "qgsrasterlayer.h"
28#include "qgsrasterrenderer.h"
30#include "qgsunittypes.h"
31
32#include <QAction>
33#include <QMenu>
34
35#include "moc_qgsrasterlayertemporalpropertieswidget.cpp"
36
38 : QWidget( parent )
39 , mLayer( layer )
40{
41 Q_ASSERT( mLayer );
42 setupUi( this );
43
44 // make a useful default expression for per band ranges, just to give users some hints about how to do this...
45 mFixedRangeLowerExpression = QStringLiteral( "make_datetime(%1,1,1,0,0,0) + make_interval(days:=@band)" ).arg( QDate::currentDate().year() );
46 mFixedRangeUpperExpression = QStringLiteral( "make_datetime(%1,1,1,23,59,59) + make_interval(days:=@band)" ).arg( QDate::currentDate().year() );
47
48 mExtraWidgetLayout = new QVBoxLayout();
49 mExtraWidgetLayout->setContentsMargins( 0, 0, 0, 0 );
50 mExtraWidgetLayout->addStretch();
51 mExtraWidgetContainer->setLayout( mExtraWidgetLayout );
52
53 if ( mLayer->dataProvider() && mLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
54 {
55 mModeComboBox->addItem( tr( "Automatic" ), QVariant::fromValue( Qgis::RasterTemporalMode::TemporalRangeFromDataProvider ) );
56 }
57 mModeComboBox->addItem( tr( "Fixed Date/Time" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedDateTime ) );
58 mModeComboBox->addItem( tr( "Fixed Time Range" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedTemporalRange ) );
59 mModeComboBox->addItem( tr( "Fixed Time Range Per Band" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedRangePerBand ) );
60 mModeComboBox->addItem( tr( "Represents Temporal Values" ), QVariant::fromValue( Qgis::RasterTemporalMode::RepresentsTemporalValues ) );
61 mModeComboBox->addItem( tr( "Redraw Layer Only" ), QVariant::fromValue( Qgis::RasterTemporalMode::RedrawLayerOnly ) );
62
63 for ( const Qgis::TemporalUnit unit :
64 {
75 } )
76 {
77 mScaleUnitComboBox->addItem( QgsUnitTypes::toString( unit ), static_cast<int>( unit ) );
78 }
79 mScaleUnitComboBox->setCurrentIndex( mScaleUnitComboBox->findData( static_cast<int>( Qgis::TemporalUnit::Days ) ) );
80
81 mStackedWidget->setSizeMode( QgsStackedWidget::SizeMode::CurrentPageOnly );
82
83 mFixedRangePerBandModel = new QgsRasterBandFixedTemporalRangeModel( this );
84 mBandRangesTable->verticalHeader()->setVisible( false );
85 mBandRangesTable->setModel( mFixedRangePerBandModel );
86 QgsFixedTemporalRangeDelegate *tableDelegate = new QgsFixedTemporalRangeDelegate( mBandRangesTable );
87 mBandRangesTable->setItemDelegateForColumn( 1, tableDelegate );
88 mBandRangesTable->setItemDelegateForColumn( 2, tableDelegate );
89
90 connect( mModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerTemporalPropertiesWidget::modeChanged );
91
92 connect( mTemporalGroupBox, &QGroupBox::toggled, this, &QgsRasterLayerTemporalPropertiesWidget::temporalGroupBoxChecked );
93
94 mFixedDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
95 mStartTemporalDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
96 mEndTemporalDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
97 mOffsetDateTimeEdit->setDisplayFormat( QStringLiteral( "yyyy-MM-dd HH:mm:ss" ) );
98
99 QMenu *calculateFixedRangePerBandMenu = new QMenu( mCalculateFixedRangePerBandButton );
100 mCalculateFixedRangePerBandButton->setMenu( calculateFixedRangePerBandMenu );
101 mCalculateFixedRangePerBandButton->setPopupMode( QToolButton::InstantPopup );
102 QAction *calculateLowerAction = new QAction( "Calculate Beginning by Expression…", calculateFixedRangePerBandMenu );
103 calculateFixedRangePerBandMenu->addAction( calculateLowerAction );
104 connect( calculateLowerAction, &QAction::triggered, this, [this] {
105 calculateRangeByExpression( false );
106 } );
107 QAction *calculateUpperAction = new QAction( "Calculate End by Expression…", calculateFixedRangePerBandMenu );
108 calculateFixedRangePerBandMenu->addAction( calculateUpperAction );
109 connect( calculateUpperAction, &QAction::triggered, this, [this] {
110 calculateRangeByExpression( true );
111 } );
112
113
114 syncToLayer();
115}
116
118{
119 mLayer->temporalProperties()->setIsActive( mTemporalGroupBox->isChecked() );
120
121 QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast<QgsRasterLayerTemporalProperties *>( mLayer->temporalProperties() );
122
123 temporalProperties->setMode( mModeComboBox->currentData().value<Qgis::RasterTemporalMode>() );
124 temporalProperties->setBandNumber( mBandComboBox->currentBand() );
125
126 switch ( temporalProperties->mode() )
127 {
129 {
130 const QgsDateTimeRange normalRange = QgsDateTimeRange( mFixedDateTimeEdit->dateTime(), mFixedDateTimeEdit->dateTime() );
131 temporalProperties->setFixedTemporalRange( normalRange );
132 break;
133 }
135 {
136 const QgsDateTimeRange normalRange = QgsDateTimeRange( mStartTemporalDateTimeEdit->dateTime(), mEndTemporalDateTimeEdit->dateTime() );
137 temporalProperties->setFixedTemporalRange( normalRange );
138 break;
139 }
144 break;
145 }
146
147 temporalProperties->setFixedRangePerBand( mFixedRangePerBandModel->rangeData() );
148
149 temporalProperties->setTemporalRepresentationOffset( mOffsetDateTimeEdit->dateTime() );
150 temporalProperties->setAccumulatePixels( mAccumulateCheckBox->isChecked() );
151
152 const QgsInterval scale( mScaleSpinBox->value(), static_cast<Qgis::TemporalUnit>( mScaleUnitComboBox->currentData().toInt() ) );
153 temporalProperties->setTemporalRepresentationScale( scale );
154
155 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
156 {
157 widget->apply();
158 }
159}
160
162{
163 const QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast<const QgsRasterLayerTemporalProperties *>( mLayer->temporalProperties() );
164 mModeComboBox->setCurrentIndex( mModeComboBox->findData( QVariant::fromValue( temporalProperties->mode() ) ) );
165 switch ( temporalProperties->mode() )
166 {
168 mStackedWidget->setCurrentWidget( mPageAutomatic );
169 break;
171 mStackedWidget->setCurrentWidget( mPageFixedDateTime );
172 break;
174 mStackedWidget->setCurrentWidget( mPageFixedRange );
175 break;
177 mStackedWidget->setCurrentWidget( mPageRedrawOnly );
178 break;
180 mStackedWidget->setCurrentWidget( mPageFixedRangePerBand );
181 break;
183 mStackedWidget->setCurrentWidget( mPageRepresentsTemporalValues );
184 break;
185 }
186
187 if ( mLayer->renderer() && QgsApplication::rasterRendererRegistry()->rendererCapabilities( mLayer->renderer()->type() ) & Qgis::RasterRendererCapability::UsesMultipleBands )
188 {
189 mWidgetFixedRangePerBand->hide();
190 mFixedRangePerBandLabel->setText( tr( "This mode cannot be used with a multi-band renderer." ) );
191 }
192
193 mBandComboBox->setLayer( mLayer );
194 mBandComboBox->setBand( temporalProperties->bandNumber() );
195
196 mFixedDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
197 mStartTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
198 mEndTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().end() );
199
200 mFixedRangePerBandModel->setLayerData( mLayer, temporalProperties->fixedRangePerBand() );
201 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
202 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::Stretch );
203 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 2, QHeaderView::Stretch );
204
205 mOffsetDateTimeEdit->setDateTime( temporalProperties->temporalRepresentationOffset() );
206 mAccumulateCheckBox->setChecked( temporalProperties->accumulatePixels() );
207
208 mScaleSpinBox->setValue( temporalProperties->temporalRepresentationScale().originalDuration() );
209 mScaleUnitComboBox->setCurrentIndex( mScaleUnitComboBox->findData( static_cast<int>( temporalProperties->temporalRepresentationScale().originalUnit() ) ) );
210
211 mTemporalGroupBox->setChecked( temporalProperties->isActive() );
212
213 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
214 {
215 widget->syncToLayer( mLayer );
216 }
217}
218
220{
221 mExtraWidgets << widget;
222 mExtraWidgetLayout->insertWidget( mExtraWidgetLayout->count() - 1, widget );
223}
224
225void QgsRasterLayerTemporalPropertiesWidget::temporalGroupBoxChecked( bool checked )
226{
227 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
228 {
229 widget->emit dynamicTemporalControlToggled( checked );
230 }
231}
232
233void QgsRasterLayerTemporalPropertiesWidget::modeChanged()
234{
235 if ( mModeComboBox->currentData().isValid() )
236 {
237 switch ( mModeComboBox->currentData().value<Qgis::RasterTemporalMode>() )
238 {
240 mStackedWidget->setCurrentWidget( mPageAutomatic );
241 break;
243 mStackedWidget->setCurrentWidget( mPageFixedDateTime );
244 break;
246 mStackedWidget->setCurrentWidget( mPageFixedRange );
247 break;
249 mStackedWidget->setCurrentWidget( mPageRedrawOnly );
250 break;
252 mStackedWidget->setCurrentWidget( mPageFixedRangePerBand );
253 break;
255 mStackedWidget->setCurrentWidget( mPageRepresentsTemporalValues );
256 break;
257 }
258 }
259}
260
261void QgsRasterLayerTemporalPropertiesWidget::calculateRangeByExpression( bool isUpper )
262{
263 QgsExpressionContext expressionContext;
264 QgsExpressionContextScope *bandScope = new QgsExpressionContextScope();
265 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band" ), 1, true, false, tr( "Band number" ) ) );
266 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_name" ), mLayer->dataProvider()->displayBandName( 1 ), true, false, tr( "Band name" ) ) );
267 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_description" ), mLayer->dataProvider()->bandDescription( 1 ), true, false, tr( "Band description" ) ) );
268
269 expressionContext.appendScope( bandScope );
271 expressionContext.setHighlightedVariables( { QStringLiteral( "band" ), QStringLiteral( "band_name" ), QStringLiteral( "band_description" ) } );
272
273 QgsExpressionBuilderDialog dlg = QgsExpressionBuilderDialog( nullptr, isUpper ? mFixedRangeUpperExpression : mFixedRangeLowerExpression, this, QStringLiteral( "generic" ), expressionContext );
274 dlg.setExpectedOutputFormat( !isUpper ? tr( "Temporal range start date / time" ) : tr( "Temporal range end date / time" ) );
275
276 QList<QPair<QString, QVariant>> bandChoices;
277 for ( int band = 1; band <= mLayer->bandCount(); ++band )
278 {
279 bandChoices << qMakePair( mLayer->dataProvider()->displayBandName( band ), band );
280 }
281 dlg.expressionBuilder()->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant &value ) -> QgsExpressionContext {
282 return createExpressionContextForBand( value.toInt() );
283 } );
284
285 if ( dlg.exec() )
286 {
287 if ( isUpper )
288 mFixedRangeUpperExpression = dlg.expressionText();
289 else
290 mFixedRangeLowerExpression = dlg.expressionText();
291
292 QgsExpression exp( dlg.expressionText() );
293 exp.prepare( &expressionContext );
294 for ( int band = 1; band <= mLayer->bandCount(); ++band )
295 {
296 bandScope->setVariable( QStringLiteral( "band" ), band );
297 bandScope->setVariable( QStringLiteral( "band_name" ), mLayer->dataProvider()->displayBandName( band ) );
298 bandScope->setVariable( QStringLiteral( "band_description" ), mLayer->dataProvider()->bandDescription( band ) );
299
300 const QVariant res = exp.evaluate( &expressionContext );
301 mFixedRangePerBandModel->setData( mFixedRangePerBandModel->index( band - 1, isUpper ? 2 : 1 ), res, Qt::EditRole );
302 }
303 }
304}
305
306QgsExpressionContext QgsRasterLayerTemporalPropertiesWidget::createExpressionContextForBand( int band ) const
307{
308 QgsExpressionContext context;
310 QgsExpressionContextScope *bandScope = new QgsExpressionContextScope();
311 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band" ), band, true, false, tr( "Band number" ) ) );
312 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_name" ), ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->displayBandName( band ) : QString(), true, false, tr( "Band name" ) ) );
313 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( QStringLiteral( "band_description" ), ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->bandDescription( band ) : QString(), true, false, tr( "Band description" ) ) );
314 context.appendScope( bandScope );
315 context.setHighlightedVariables( { QStringLiteral( "band" ), QStringLiteral( "band_name" ), QStringLiteral( "band_description" ) } );
316 return context;
317}
318
320
321//
322// QgsRasterBandFixedTemporalRangeModel
323//
324
325QgsRasterBandFixedTemporalRangeModel::QgsRasterBandFixedTemporalRangeModel( QObject *parent )
326 : QAbstractItemModel( parent )
327{
328}
329
330int QgsRasterBandFixedTemporalRangeModel::columnCount( const QModelIndex & ) const
331{
332 return 3;
333}
334
335int QgsRasterBandFixedTemporalRangeModel::rowCount( const QModelIndex &parent ) const
336{
337 if ( parent.isValid() )
338 return 0;
339 return mBandCount;
340}
341
342QModelIndex QgsRasterBandFixedTemporalRangeModel::index( int row, int column, const QModelIndex &parent ) const
343{
344 if ( hasIndex( row, column, parent ) )
345 {
346 return createIndex( row, column, row );
347 }
348
349 return QModelIndex();
350}
351
352QModelIndex QgsRasterBandFixedTemporalRangeModel::parent( const QModelIndex &child ) const
353{
354 Q_UNUSED( child )
355 return QModelIndex();
356}
357
358Qt::ItemFlags QgsRasterBandFixedTemporalRangeModel::flags( const QModelIndex &index ) const
359{
360 if ( !index.isValid() )
361 return Qt::ItemFlags();
362
363 if ( index.row() < 0 || index.row() >= mBandCount || index.column() < 0 || index.column() >= columnCount() )
364 return Qt::ItemFlags();
365
366 switch ( index.column() )
367 {
368 case 0:
369 return Qt::ItemFlag::ItemIsEnabled;
370 case 1:
371 case 2:
372 return Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsEditable | Qt::ItemFlag::ItemIsSelectable;
373 default:
374 break;
375 }
376
377 return Qt::ItemFlags();
378}
379
380QVariant QgsRasterBandFixedTemporalRangeModel::data( const QModelIndex &index, int role ) const
381{
382 if ( !index.isValid() )
383 return QVariant();
384
385 if ( index.row() < 0 || index.row() >= mBandCount || index.column() < 0 || index.column() >= columnCount() )
386 return QVariant();
387
388 const int band = index.row() + 1;
389 const QgsDateTimeRange range = mRanges.value( band );
390
391 switch ( role )
392 {
393 case Qt::DisplayRole:
394 case Qt::EditRole:
395 case Qt::ToolTipRole:
396 {
397 switch ( index.column() )
398 {
399 case 0:
400 return mBandNames.value( band, QString::number( band ) );
401
402 case 1:
403 return range.begin().isValid() ? range.begin() : QVariant();
404
405 case 2:
406 return range.end().isValid() ? range.end() : QVariant();
407
408 default:
409 break;
410 }
411 break;
412 }
413
414 case Qt::TextAlignmentRole:
415 {
416 switch ( index.column() )
417 {
418 case 0:
419 return static_cast<Qt::Alignment::Int>( Qt::AlignLeft | Qt::AlignVCenter );
420
421 case 1:
422 case 2:
423 return static_cast<Qt::Alignment::Int>( Qt::AlignRight | Qt::AlignVCenter );
424 default:
425 break;
426 }
427 break;
428 }
429
430 default:
431 break;
432 }
433 return QVariant();
434}
435
436QVariant QgsRasterBandFixedTemporalRangeModel::headerData( int section, Qt::Orientation orientation, int role ) const
437{
438 if ( role == Qt::DisplayRole && orientation == Qt::Horizontal )
439 {
440 switch ( section )
441 {
442 case 0:
443 return tr( "Band" );
444 case 1:
445 return tr( "Begin" );
446 case 2:
447 return tr( "End" );
448 default:
449 break;
450 }
451 }
452 return QAbstractItemModel::headerData( section, orientation, role );
453}
454
455bool QgsRasterBandFixedTemporalRangeModel::setData( const QModelIndex &index, const QVariant &value, int role )
456{
457 if ( !index.isValid() )
458 return false;
459
460 if ( index.row() > mBandCount || index.row() < 0 )
461 return false;
462
463 const int band = index.row() + 1;
464 const QgsDateTimeRange range = mRanges.value( band );
465
466 switch ( role )
467 {
468 case Qt::EditRole:
469 {
470 const QDateTime newValue = value.toDateTime();
471 if ( !newValue.isValid() )
472 return false;
473
474 switch ( index.column() )
475 {
476 case 1:
477 {
478 mRanges[band] = QgsDateTimeRange( newValue, range.end(), range.includeBeginning(), range.includeEnd() );
479 emit dataChanged( index, index, QVector<int>() << role );
480 break;
481 }
482
483 case 2:
484 mRanges[band] = QgsDateTimeRange( range.begin(), newValue, range.includeBeginning(), range.includeEnd() );
485 emit dataChanged( index, index, QVector<int>() << role );
486 break;
487
488 default:
489 break;
490 }
491 return true;
492 }
493
494 default:
495 break;
496 }
497
498 return false;
499}
500
501void QgsRasterBandFixedTemporalRangeModel::setLayerData( QgsRasterLayer *layer, const QMap<int, QgsDateTimeRange> &ranges )
502{
503 beginResetModel();
504
505 mBandCount = layer->bandCount();
506 mRanges = ranges;
507
508 mBandNames.clear();
509 for ( int band = 1; band <= mBandCount; ++band )
510 {
511 mBandNames[band] = layer->dataProvider()->displayBandName( band );
512 }
513
514 endResetModel();
515}
516
517//
518// QgsFixedTemporalRangeDelegate
519//
520
521QgsFixedTemporalRangeDelegate::QgsFixedTemporalRangeDelegate( QObject *parent )
522 : QStyledItemDelegate( parent )
523{
524}
525
526QWidget *QgsFixedTemporalRangeDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const
527{
528 QgsDateTimeEdit *editor = new QgsDateTimeEdit( parent );
529 editor->setAllowNull( true );
530 return editor;
531}
532
533void QgsFixedTemporalRangeDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
534{
535 if ( QgsDateTimeEdit *dateTimeEdit = qobject_cast<QgsDateTimeEdit *>( editor ) )
536 {
537 model->setData( index, dateTimeEdit->dateTime() );
538 }
539}
TemporalUnit
Temporal units.
Definition qgis.h:5159
@ Milliseconds
Milliseconds.
Definition qgis.h:5160
@ Hours
Hours.
Definition qgis.h:5163
@ Centuries
Centuries.
Definition qgis.h:5169
@ Seconds
Seconds.
Definition qgis.h:5161
@ Weeks
Weeks.
Definition qgis.h:5165
@ Years
Years.
Definition qgis.h:5167
@ Decades
Decades.
Definition qgis.h:5168
@ Months
Months.
Definition qgis.h:5166
@ Minutes
Minutes.
Definition qgis.h:5162
RasterTemporalMode
Raster layer temporal modes.
Definition qgis.h:2621
@ RepresentsTemporalValues
Pixel values represent an datetime.
Definition qgis.h:2626
@ RedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbo...
Definition qgis.h:2624
@ FixedRangePerBand
Layer has a fixed temporal range per band.
Definition qgis.h:2625
@ TemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
Definition qgis.h:2623
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
Definition qgis.h:2622
@ FixedDateTime
Layer has a fixed date time instant.
Definition qgis.h:2627
@ UsesMultipleBands
The renderer utilizes multiple raster bands for color data (note that alpha bands are not considered ...
Definition qgis.h:1524
static QgsRasterRendererRegistry * rasterRendererRegistry()
Returns the application's raster renderer registry, used for managing raster layer renderers.
A QDateTimeEdit with the capability of setting/reading null date/times.
void setAllowNull(bool allowNull)
Determines if the widget allows setting null date/time.
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.
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.
A representation of the interval between two datetime values.
Definition qgsinterval.h:47
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.
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 setAccumulatePixels(bool accumulate)
Sets whether pixels will be accumulated over time (i.e.
void setTemporalRepresentationScale(const QgsInterval &scale)
Sets the scale, which is an interval factor which should be applied to individual pixel values from t...
bool accumulatePixels() const
Returns true if pixels will be accumulated over time (i.e.
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.
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
@ 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.
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:761