QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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#include <QString>
35
36#include "moc_qgsrasterlayertemporalpropertieswidget.cpp"
37
38using namespace Qt::StringLiterals;
39
41 : QWidget( parent )
42 , mLayer( layer )
43{
44 Q_ASSERT( mLayer );
45 setupUi( this );
46
47 // make a useful default expression for per band ranges, just to give users some hints about how to do this...
48 mFixedRangeLowerExpression = u"make_datetime(%1,1,1,0,0,0) + make_interval(days:=@band)"_s.arg( QDate::currentDate().year() );
49 mFixedRangeUpperExpression = u"make_datetime(%1,1,1,23,59,59) + make_interval(days:=@band)"_s.arg( QDate::currentDate().year() );
50
51 mExtraWidgetLayout = new QVBoxLayout();
52 mExtraWidgetLayout->setContentsMargins( 0, 0, 0, 0 );
53 mExtraWidgetLayout->addStretch();
54 mExtraWidgetContainer->setLayout( mExtraWidgetLayout );
55
56 if ( mLayer->dataProvider() && mLayer->dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
57 {
58 mModeComboBox->addItem( tr( "Automatic" ), QVariant::fromValue( Qgis::RasterTemporalMode::TemporalRangeFromDataProvider ) );
59 }
60 mModeComboBox->addItem( tr( "Fixed Date/Time" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedDateTime ) );
61 mModeComboBox->addItem( tr( "Fixed Time Range" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedTemporalRange ) );
62 mModeComboBox->addItem( tr( "Fixed Time Range Per Band" ), QVariant::fromValue( Qgis::RasterTemporalMode::FixedRangePerBand ) );
63 mModeComboBox->addItem( tr( "Represents Temporal Values" ), QVariant::fromValue( Qgis::RasterTemporalMode::RepresentsTemporalValues ) );
64 mModeComboBox->addItem( tr( "Redraw Layer Only" ), QVariant::fromValue( Qgis::RasterTemporalMode::RedrawLayerOnly ) );
65
66 for ( const Qgis::TemporalUnit unit : {
77 } )
78 {
79 mScaleUnitComboBox->addItem( QgsUnitTypes::toString( unit ), static_cast<int>( unit ) );
80 }
81 mScaleUnitComboBox->setCurrentIndex( mScaleUnitComboBox->findData( static_cast<int>( Qgis::TemporalUnit::Days ) ) );
82
83 mStackedWidget->setSizeMode( QgsStackedWidget::SizeMode::CurrentPageOnly );
84
85 mFixedRangePerBandModel = new QgsRasterBandFixedTemporalRangeModel( this );
86 mBandRangesTable->verticalHeader()->setVisible( false );
87 mBandRangesTable->setModel( mFixedRangePerBandModel );
88 QgsFixedTemporalRangeDelegate *tableDelegate = new QgsFixedTemporalRangeDelegate( mBandRangesTable );
89 mBandRangesTable->setItemDelegateForColumn( 1, tableDelegate );
90 mBandRangesTable->setItemDelegateForColumn( 2, tableDelegate );
91
92 connect( mModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerTemporalPropertiesWidget::modeChanged );
93
94 connect( mTemporalGroupBox, &QGroupBox::toggled, this, &QgsRasterLayerTemporalPropertiesWidget::temporalGroupBoxChecked );
95
96 mFixedDateTimeEdit->setDisplayFormat( u"yyyy-MM-dd HH:mm:ss"_s );
97 mStartTemporalDateTimeEdit->setDisplayFormat( u"yyyy-MM-dd HH:mm:ss"_s );
98 mEndTemporalDateTimeEdit->setDisplayFormat( u"yyyy-MM-dd HH:mm:ss"_s );
99 mOffsetDateTimeEdit->setDisplayFormat( u"yyyy-MM-dd HH:mm:ss"_s );
100
101 QMenu *calculateFixedRangePerBandMenu = new QMenu( mCalculateFixedRangePerBandButton );
102 mCalculateFixedRangePerBandButton->setMenu( calculateFixedRangePerBandMenu );
103 mCalculateFixedRangePerBandButton->setPopupMode( QToolButton::InstantPopup );
104 QAction *calculateLowerAction = new QAction( "Calculate Beginning by Expression…", calculateFixedRangePerBandMenu );
105 calculateFixedRangePerBandMenu->addAction( calculateLowerAction );
106 connect( calculateLowerAction, &QAction::triggered, this, [this] { calculateRangeByExpression( false ); } );
107 QAction *calculateUpperAction = new QAction( "Calculate End by Expression…", calculateFixedRangePerBandMenu );
108 calculateFixedRangePerBandMenu->addAction( calculateUpperAction );
109 connect( calculateUpperAction, &QAction::triggered, this, [this] { calculateRangeByExpression( true ); } );
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 temporalProperties->setAccumulatePixels( mAccumulateCheckBox->isChecked() );
149
150 const QgsInterval scale( mScaleSpinBox->value(), static_cast<Qgis::TemporalUnit>( mScaleUnitComboBox->currentData().toInt() ) );
151 temporalProperties->setTemporalRepresentationScale( scale );
152
153 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
154 {
155 widget->apply();
156 }
157}
158
160{
161 const QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast<const QgsRasterLayerTemporalProperties *>( mLayer->temporalProperties() );
162 mModeComboBox->setCurrentIndex( mModeComboBox->findData( QVariant::fromValue( temporalProperties->mode() ) ) );
163 switch ( temporalProperties->mode() )
164 {
166 mStackedWidget->setCurrentWidget( mPageAutomatic );
167 break;
169 mStackedWidget->setCurrentWidget( mPageFixedDateTime );
170 break;
172 mStackedWidget->setCurrentWidget( mPageFixedRange );
173 break;
175 mStackedWidget->setCurrentWidget( mPageRedrawOnly );
176 break;
178 mStackedWidget->setCurrentWidget( mPageFixedRangePerBand );
179 break;
181 mStackedWidget->setCurrentWidget( mPageRepresentsTemporalValues );
182 break;
183 }
184
185 if ( mLayer->renderer() && QgsApplication::rasterRendererRegistry()->rendererCapabilities( mLayer->renderer()->type() ) & Qgis::RasterRendererCapability::UsesMultipleBands )
186 {
187 mWidgetFixedRangePerBand->hide();
188 mFixedRangePerBandLabel->setText( tr( "This mode cannot be used with a multi-band renderer." ) );
189 }
190
191 mBandComboBox->setLayer( mLayer );
192 mBandComboBox->setBand( temporalProperties->bandNumber() );
193
194 mFixedDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
195 mStartTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
196 mEndTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().end() );
197
198 mFixedRangePerBandModel->setLayerData( mLayer, temporalProperties->fixedRangePerBand() );
199 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
200 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::Stretch );
201 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 2, QHeaderView::Stretch );
202
203 mOffsetDateTimeEdit->setDateTime( temporalProperties->temporalRepresentationOffset() );
204 mAccumulateCheckBox->setChecked( temporalProperties->accumulatePixels() );
205
206 mScaleSpinBox->setValue( temporalProperties->temporalRepresentationScale().originalDuration() );
207 mScaleUnitComboBox->setCurrentIndex( mScaleUnitComboBox->findData( static_cast<int>( temporalProperties->temporalRepresentationScale().originalUnit() ) ) );
208
209 mTemporalGroupBox->setChecked( temporalProperties->isActive() );
210
211 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
212 {
213 widget->syncToLayer( mLayer );
214 }
215}
216
218{
219 mExtraWidgets << widget;
220 mExtraWidgetLayout->insertWidget( mExtraWidgetLayout->count() - 1, widget );
221}
222
223void QgsRasterLayerTemporalPropertiesWidget::temporalGroupBoxChecked( bool checked )
224{
225 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
226 {
227 widget->emit dynamicTemporalControlToggled( checked );
228 }
229}
230
231void QgsRasterLayerTemporalPropertiesWidget::modeChanged()
232{
233 if ( mModeComboBox->currentData().isValid() )
234 {
235 switch ( mModeComboBox->currentData().value<Qgis::RasterTemporalMode>() )
236 {
238 mStackedWidget->setCurrentWidget( mPageAutomatic );
239 break;
241 mStackedWidget->setCurrentWidget( mPageFixedDateTime );
242 break;
244 mStackedWidget->setCurrentWidget( mPageFixedRange );
245 break;
247 mStackedWidget->setCurrentWidget( mPageRedrawOnly );
248 break;
250 mStackedWidget->setCurrentWidget( mPageFixedRangePerBand );
251 break;
253 mStackedWidget->setCurrentWidget( mPageRepresentsTemporalValues );
254 break;
255 }
256 }
257}
258
259void QgsRasterLayerTemporalPropertiesWidget::calculateRangeByExpression( bool isUpper )
260{
261 QgsExpressionContext expressionContext;
262 QgsExpressionContextScope *bandScope = new QgsExpressionContextScope();
263 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band"_s, 1, true, false, tr( "Band number" ) ) );
264 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band_name"_s, mLayer->dataProvider()->displayBandName( 1 ), true, false, tr( "Band name" ) ) );
265 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band_description"_s, mLayer->dataProvider()->bandDescription( 1 ), true, false, tr( "Band description" ) ) );
266
267 expressionContext.appendScope( bandScope );
269 expressionContext.setHighlightedVariables( { u"band"_s, u"band_name"_s, u"band_description"_s } );
270
271 QgsExpressionBuilderDialog dlg = QgsExpressionBuilderDialog( nullptr, isUpper ? mFixedRangeUpperExpression : mFixedRangeLowerExpression, this, u"generic"_s, expressionContext );
272 dlg.setExpectedOutputFormat( !isUpper ? tr( "Temporal range start date / time" ) : tr( "Temporal range end date / time" ) );
273
274 QList<QPair<QString, QVariant>> bandChoices;
275 for ( int band = 1; band <= mLayer->bandCount(); ++band )
276 {
277 bandChoices << qMakePair( mLayer->dataProvider()->displayBandName( band ), band );
278 }
279 dlg.expressionBuilder()->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant &value ) -> QgsExpressionContext { return createExpressionContextForBand( value.toInt() ); } );
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( u"band"_s, band );
293 bandScope->setVariable( u"band_name"_s, mLayer->dataProvider()->displayBandName( band ) );
294 bandScope->setVariable( u"band_description"_s, 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;
306 QgsExpressionContextScope *bandScope = new QgsExpressionContextScope();
307 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band"_s, band, true, false, tr( "Band number" ) ) );
308 bandScope->addVariable(
309 QgsExpressionContextScope::StaticVariable( u"band_name"_s, ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->displayBandName( band ) : QString(), true, false, tr( "Band name" ) )
310 );
311 bandScope->addVariable(
312 QgsExpressionContextScope::StaticVariable( u"band_description"_s, ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->bandDescription( band ) : QString(), true, false, tr( "Band description" ) )
313 );
314 context.appendScope( bandScope );
315 context.setHighlightedVariables( { u"band"_s, u"band_name"_s, u"band_description"_s } );
316 return context;
317}
318
320
321//
322// QgsRasterBandFixedTemporalRangeModel
323//
324
325QgsRasterBandFixedTemporalRangeModel::QgsRasterBandFixedTemporalRangeModel( QObject *parent )
326 : QAbstractItemModel( parent )
327{}
328
329int QgsRasterBandFixedTemporalRangeModel::columnCount( const QModelIndex & ) const
330{
331 return 3;
332}
333
334int QgsRasterBandFixedTemporalRangeModel::rowCount( const QModelIndex &parent ) const
335{
336 if ( parent.isValid() )
337 return 0;
338 return mBandCount;
339}
340
341QModelIndex QgsRasterBandFixedTemporalRangeModel::index( int row, int column, const QModelIndex &parent ) const
342{
343 if ( hasIndex( row, column, parent ) )
344 {
345 return createIndex( row, column, row );
346 }
347
348 return QModelIndex();
349}
350
351QModelIndex QgsRasterBandFixedTemporalRangeModel::parent( const QModelIndex &child ) const
352{
353 Q_UNUSED( child )
354 return QModelIndex();
355}
356
357Qt::ItemFlags QgsRasterBandFixedTemporalRangeModel::flags( const QModelIndex &index ) const
358{
359 if ( !index.isValid() )
360 return Qt::ItemFlags();
361
362 if ( index.row() < 0 || index.row() >= mBandCount || index.column() < 0 || index.column() >= columnCount() )
363 return Qt::ItemFlags();
364
365 switch ( index.column() )
366 {
367 case 0:
368 return Qt::ItemFlag::ItemIsEnabled;
369 case 1:
370 case 2:
371 return Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsEditable | Qt::ItemFlag::ItemIsSelectable;
372 default:
373 break;
374 }
375
376 return Qt::ItemFlags();
377}
378
379QVariant QgsRasterBandFixedTemporalRangeModel::data( const QModelIndex &index, int role ) const
380{
381 if ( !index.isValid() )
382 return QVariant();
383
384 if ( index.row() < 0 || index.row() >= mBandCount || index.column() < 0 || index.column() >= columnCount() )
385 return QVariant();
386
387 const int band = index.row() + 1;
388 const QgsDateTimeRange range = mRanges.value( band );
389
390 switch ( role )
391 {
392 case Qt::DisplayRole:
393 case Qt::EditRole:
394 case Qt::ToolTipRole:
395 {
396 switch ( index.column() )
397 {
398 case 0:
399 return mBandNames.value( band, QString::number( band ) );
400
401 case 1:
402 return range.begin().isValid() ? range.begin() : QVariant();
403
404 case 2:
405 return range.end().isValid() ? range.end() : QVariant();
406
407 default:
408 break;
409 }
410 break;
411 }
412
413 case Qt::TextAlignmentRole:
414 {
415 switch ( index.column() )
416 {
417 case 0:
418 return static_cast<Qt::Alignment::Int>( Qt::AlignLeft | Qt::AlignVCenter );
419
420 case 1:
421 case 2:
422 return static_cast<Qt::Alignment::Int>( Qt::AlignRight | Qt::AlignVCenter );
423 default:
424 break;
425 }
426 break;
427 }
428
429 default:
430 break;
431 }
432 return QVariant();
433}
434
435QVariant QgsRasterBandFixedTemporalRangeModel::headerData( int section, Qt::Orientation orientation, int role ) const
436{
437 if ( role == Qt::DisplayRole && orientation == Qt::Horizontal )
438 {
439 switch ( section )
440 {
441 case 0:
442 return tr( "Band" );
443 case 1:
444 return tr( "Begin" );
445 case 2:
446 return tr( "End" );
447 default:
448 break;
449 }
450 }
451 return QAbstractItemModel::headerData( section, orientation, role );
452}
453
454bool QgsRasterBandFixedTemporalRangeModel::setData( const QModelIndex &index, const QVariant &value, int role )
455{
456 if ( !index.isValid() )
457 return false;
458
459 if ( index.row() > mBandCount || index.row() < 0 )
460 return false;
461
462 const int band = index.row() + 1;
463 const QgsDateTimeRange range = mRanges.value( band );
464
465 switch ( role )
466 {
467 case Qt::EditRole:
468 {
469 const QDateTime newValue = value.toDateTime();
470 if ( !newValue.isValid() )
471 return false;
472
473 switch ( index.column() )
474 {
475 case 1:
476 {
477 mRanges[band] = QgsDateTimeRange( newValue, range.end(), range.includeBeginning(), range.includeEnd() );
478 emit dataChanged( index, index, QVector<int>() << role );
479 break;
480 }
481
482 case 2:
483 mRanges[band] = QgsDateTimeRange( range.begin(), newValue, range.includeBeginning(), range.includeEnd() );
484 emit dataChanged( index, index, QVector<int>() << role );
485 break;
486
487 default:
488 break;
489 }
490 return true;
491 }
492
493 default:
494 break;
495 }
496
497 return false;
498}
499
500void QgsRasterBandFixedTemporalRangeModel::setLayerData( QgsRasterLayer *layer, const QMap<int, QgsDateTimeRange> &ranges )
501{
502 beginResetModel();
503
504 mBandCount = layer->bandCount();
505 mRanges = ranges;
506
507 mBandNames.clear();
508 for ( int band = 1; band <= mBandCount; ++band )
509 {
510 mBandNames[band] = layer->dataProvider()->displayBandName( band );
511 }
512
513 endResetModel();
514}
515
516//
517// QgsFixedTemporalRangeDelegate
518//
519
520QgsFixedTemporalRangeDelegate::QgsFixedTemporalRangeDelegate( QObject *parent )
521 : QStyledItemDelegate( parent )
522{}
523
524QWidget *QgsFixedTemporalRangeDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const
525{
526 QgsDateTimeEdit *editor = new QgsDateTimeEdit( parent );
527 editor->setAllowNull( true );
528 return editor;
529}
530
531void QgsFixedTemporalRangeDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
532{
533 if ( QgsDateTimeEdit *dateTimeEdit = qobject_cast<QgsDateTimeEdit *>( editor ) )
534 {
535 model->setData( index, dateTimeEdit->dateTime() );
536 }
537}
TemporalUnit
Temporal units.
Definition qgis.h:5316
@ Milliseconds
Milliseconds.
Definition qgis.h:5317
@ Hours
Hours.
Definition qgis.h:5320
@ Centuries
Centuries.
Definition qgis.h:5326
@ Seconds
Seconds.
Definition qgis.h:5318
@ Weeks
Weeks.
Definition qgis.h:5322
@ Years
Years.
Definition qgis.h:5324
@ Decades
Decades.
Definition qgis.h:5325
@ Months
Months.
Definition qgis.h:5323
@ Minutes
Minutes.
Definition qgis.h:5319
RasterTemporalMode
Raster layer temporal modes.
Definition qgis.h:2712
@ RepresentsTemporalValues
Pixel values represent an datetime.
Definition qgis.h:2718
@ RedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbo...
Definition qgis.h:2715
@ FixedRangePerBand
Layer has a fixed temporal range per band.
Definition qgis.h:2717
@ TemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
Definition qgis.h:2714
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
Definition qgis.h:2713
@ FixedDateTime
Layer has a fixed date time instant.
Definition qgis.h:2719
@ UsesMultipleBands
The renderer utilizes multiple raster bands for color data (note that alpha bands are not considered ...
Definition qgis.h:1603
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:52
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:408
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:415
bool includeEnd() const
Returns true if the end is inclusive, or false if the end is exclusive.
Definition qgsrange.h:430
bool includeBeginning() const
Returns true if the beginning is inclusive, or false if the beginning is exclusive.
Definition qgsrange.h:423
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:705