QGIS API Documentation 3.99.0-Master (e9821da5c6b)
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 :
67 {
78 } )
79 {
80 mScaleUnitComboBox->addItem( QgsUnitTypes::toString( unit ), static_cast<int>( unit ) );
81 }
82 mScaleUnitComboBox->setCurrentIndex( mScaleUnitComboBox->findData( static_cast<int>( Qgis::TemporalUnit::Days ) ) );
83
84 mStackedWidget->setSizeMode( QgsStackedWidget::SizeMode::CurrentPageOnly );
85
86 mFixedRangePerBandModel = new QgsRasterBandFixedTemporalRangeModel( this );
87 mBandRangesTable->verticalHeader()->setVisible( false );
88 mBandRangesTable->setModel( mFixedRangePerBandModel );
89 QgsFixedTemporalRangeDelegate *tableDelegate = new QgsFixedTemporalRangeDelegate( mBandRangesTable );
90 mBandRangesTable->setItemDelegateForColumn( 1, tableDelegate );
91 mBandRangesTable->setItemDelegateForColumn( 2, tableDelegate );
92
93 connect( mModeComboBox, qOverload<int>( &QComboBox::currentIndexChanged ), this, &QgsRasterLayerTemporalPropertiesWidget::modeChanged );
94
95 connect( mTemporalGroupBox, &QGroupBox::toggled, this, &QgsRasterLayerTemporalPropertiesWidget::temporalGroupBoxChecked );
96
97 mFixedDateTimeEdit->setDisplayFormat( u"yyyy-MM-dd HH:mm:ss"_s );
98 mStartTemporalDateTimeEdit->setDisplayFormat( u"yyyy-MM-dd HH:mm:ss"_s );
99 mEndTemporalDateTimeEdit->setDisplayFormat( u"yyyy-MM-dd HH:mm:ss"_s );
100 mOffsetDateTimeEdit->setDisplayFormat( u"yyyy-MM-dd HH:mm:ss"_s );
101
102 QMenu *calculateFixedRangePerBandMenu = new QMenu( mCalculateFixedRangePerBandButton );
103 mCalculateFixedRangePerBandButton->setMenu( calculateFixedRangePerBandMenu );
104 mCalculateFixedRangePerBandButton->setPopupMode( QToolButton::InstantPopup );
105 QAction *calculateLowerAction = new QAction( "Calculate Beginning by Expression…", calculateFixedRangePerBandMenu );
106 calculateFixedRangePerBandMenu->addAction( calculateLowerAction );
107 connect( calculateLowerAction, &QAction::triggered, this, [this] {
108 calculateRangeByExpression( false );
109 } );
110 QAction *calculateUpperAction = new QAction( "Calculate End by Expression…", calculateFixedRangePerBandMenu );
111 calculateFixedRangePerBandMenu->addAction( calculateUpperAction );
112 connect( calculateUpperAction, &QAction::triggered, this, [this] {
113 calculateRangeByExpression( true );
114 } );
115
116
117 syncToLayer();
118}
119
121{
122 mLayer->temporalProperties()->setIsActive( mTemporalGroupBox->isChecked() );
123
124 QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast<QgsRasterLayerTemporalProperties *>( mLayer->temporalProperties() );
125
126 temporalProperties->setMode( mModeComboBox->currentData().value<Qgis::RasterTemporalMode>() );
127 temporalProperties->setBandNumber( mBandComboBox->currentBand() );
128
129 switch ( temporalProperties->mode() )
130 {
132 {
133 const QgsDateTimeRange normalRange = QgsDateTimeRange( mFixedDateTimeEdit->dateTime(), mFixedDateTimeEdit->dateTime() );
134 temporalProperties->setFixedTemporalRange( normalRange );
135 break;
136 }
138 {
139 const QgsDateTimeRange normalRange = QgsDateTimeRange( mStartTemporalDateTimeEdit->dateTime(), mEndTemporalDateTimeEdit->dateTime() );
140 temporalProperties->setFixedTemporalRange( normalRange );
141 break;
142 }
147 break;
148 }
149
150 temporalProperties->setFixedRangePerBand( mFixedRangePerBandModel->rangeData() );
151
152 temporalProperties->setTemporalRepresentationOffset( mOffsetDateTimeEdit->dateTime() );
153 temporalProperties->setAccumulatePixels( mAccumulateCheckBox->isChecked() );
154
155 const QgsInterval scale( mScaleSpinBox->value(), static_cast<Qgis::TemporalUnit>( mScaleUnitComboBox->currentData().toInt() ) );
156 temporalProperties->setTemporalRepresentationScale( scale );
157
158 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
159 {
160 widget->apply();
161 }
162}
163
165{
166 const QgsRasterLayerTemporalProperties *temporalProperties = qobject_cast<const QgsRasterLayerTemporalProperties *>( mLayer->temporalProperties() );
167 mModeComboBox->setCurrentIndex( mModeComboBox->findData( QVariant::fromValue( temporalProperties->mode() ) ) );
168 switch ( temporalProperties->mode() )
169 {
171 mStackedWidget->setCurrentWidget( mPageAutomatic );
172 break;
174 mStackedWidget->setCurrentWidget( mPageFixedDateTime );
175 break;
177 mStackedWidget->setCurrentWidget( mPageFixedRange );
178 break;
180 mStackedWidget->setCurrentWidget( mPageRedrawOnly );
181 break;
183 mStackedWidget->setCurrentWidget( mPageFixedRangePerBand );
184 break;
186 mStackedWidget->setCurrentWidget( mPageRepresentsTemporalValues );
187 break;
188 }
189
190 if ( mLayer->renderer() && QgsApplication::rasterRendererRegistry()->rendererCapabilities( mLayer->renderer()->type() ) & Qgis::RasterRendererCapability::UsesMultipleBands )
191 {
192 mWidgetFixedRangePerBand->hide();
193 mFixedRangePerBandLabel->setText( tr( "This mode cannot be used with a multi-band renderer." ) );
194 }
195
196 mBandComboBox->setLayer( mLayer );
197 mBandComboBox->setBand( temporalProperties->bandNumber() );
198
199 mFixedDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
200 mStartTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().begin() );
201 mEndTemporalDateTimeEdit->setDateTime( temporalProperties->fixedTemporalRange().end() );
202
203 mFixedRangePerBandModel->setLayerData( mLayer, temporalProperties->fixedRangePerBand() );
204 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 0, QHeaderView::Stretch );
205 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 1, QHeaderView::Stretch );
206 mBandRangesTable->horizontalHeader()->setSectionResizeMode( 2, QHeaderView::Stretch );
207
208 mOffsetDateTimeEdit->setDateTime( temporalProperties->temporalRepresentationOffset() );
209 mAccumulateCheckBox->setChecked( temporalProperties->accumulatePixels() );
210
211 mScaleSpinBox->setValue( temporalProperties->temporalRepresentationScale().originalDuration() );
212 mScaleUnitComboBox->setCurrentIndex( mScaleUnitComboBox->findData( static_cast<int>( temporalProperties->temporalRepresentationScale().originalUnit() ) ) );
213
214 mTemporalGroupBox->setChecked( temporalProperties->isActive() );
215
216 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
217 {
218 widget->syncToLayer( mLayer );
219 }
220}
221
223{
224 mExtraWidgets << widget;
225 mExtraWidgetLayout->insertWidget( mExtraWidgetLayout->count() - 1, widget );
226}
227
228void QgsRasterLayerTemporalPropertiesWidget::temporalGroupBoxChecked( bool checked )
229{
230 for ( QgsMapLayerConfigWidget *widget : std::as_const( mExtraWidgets ) )
231 {
232 widget->emit dynamicTemporalControlToggled( checked );
233 }
234}
235
236void QgsRasterLayerTemporalPropertiesWidget::modeChanged()
237{
238 if ( mModeComboBox->currentData().isValid() )
239 {
240 switch ( mModeComboBox->currentData().value<Qgis::RasterTemporalMode>() )
241 {
243 mStackedWidget->setCurrentWidget( mPageAutomatic );
244 break;
246 mStackedWidget->setCurrentWidget( mPageFixedDateTime );
247 break;
249 mStackedWidget->setCurrentWidget( mPageFixedRange );
250 break;
252 mStackedWidget->setCurrentWidget( mPageRedrawOnly );
253 break;
255 mStackedWidget->setCurrentWidget( mPageFixedRangePerBand );
256 break;
258 mStackedWidget->setCurrentWidget( mPageRepresentsTemporalValues );
259 break;
260 }
261 }
262}
263
264void QgsRasterLayerTemporalPropertiesWidget::calculateRangeByExpression( bool isUpper )
265{
266 QgsExpressionContext expressionContext;
267 QgsExpressionContextScope *bandScope = new QgsExpressionContextScope();
268 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band"_s, 1, true, false, tr( "Band number" ) ) );
269 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band_name"_s, mLayer->dataProvider()->displayBandName( 1 ), true, false, tr( "Band name" ) ) );
270 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band_description"_s, mLayer->dataProvider()->bandDescription( 1 ), true, false, tr( "Band description" ) ) );
271
272 expressionContext.appendScope( bandScope );
274 expressionContext.setHighlightedVariables( { u"band"_s, u"band_name"_s, u"band_description"_s } );
275
276 QgsExpressionBuilderDialog dlg = QgsExpressionBuilderDialog( nullptr, isUpper ? mFixedRangeUpperExpression : mFixedRangeLowerExpression, this, u"generic"_s, expressionContext );
277 dlg.setExpectedOutputFormat( !isUpper ? tr( "Temporal range start date / time" ) : tr( "Temporal range end date / time" ) );
278
279 QList<QPair<QString, QVariant>> bandChoices;
280 for ( int band = 1; band <= mLayer->bandCount(); ++band )
281 {
282 bandChoices << qMakePair( mLayer->dataProvider()->displayBandName( band ), band );
283 }
284 dlg.expressionBuilder()->setCustomPreviewGenerator( tr( "Band" ), bandChoices, [this]( const QVariant &value ) -> QgsExpressionContext {
285 return createExpressionContextForBand( value.toInt() );
286 } );
287
288 if ( dlg.exec() )
289 {
290 if ( isUpper )
291 mFixedRangeUpperExpression = dlg.expressionText();
292 else
293 mFixedRangeLowerExpression = dlg.expressionText();
294
295 QgsExpression exp( dlg.expressionText() );
296 exp.prepare( &expressionContext );
297 for ( int band = 1; band <= mLayer->bandCount(); ++band )
298 {
299 bandScope->setVariable( u"band"_s, band );
300 bandScope->setVariable( u"band_name"_s, mLayer->dataProvider()->displayBandName( band ) );
301 bandScope->setVariable( u"band_description"_s, mLayer->dataProvider()->bandDescription( band ) );
302
303 const QVariant res = exp.evaluate( &expressionContext );
304 mFixedRangePerBandModel->setData( mFixedRangePerBandModel->index( band - 1, isUpper ? 2 : 1 ), res, Qt::EditRole );
305 }
306 }
307}
308
309QgsExpressionContext QgsRasterLayerTemporalPropertiesWidget::createExpressionContextForBand( int band ) const
310{
311 QgsExpressionContext context;
313 QgsExpressionContextScope *bandScope = new QgsExpressionContextScope();
314 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band"_s, band, true, false, tr( "Band number" ) ) );
315 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band_name"_s, ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->displayBandName( band ) : QString(), true, false, tr( "Band name" ) ) );
316 bandScope->addVariable( QgsExpressionContextScope::StaticVariable( u"band_description"_s, ( mLayer && mLayer->dataProvider() ) ? mLayer->dataProvider()->bandDescription( band ) : QString(), true, false, tr( "Band description" ) ) );
317 context.appendScope( bandScope );
318 context.setHighlightedVariables( { u"band"_s, u"band_name"_s, u"band_description"_s } );
319 return context;
320}
321
323
324//
325// QgsRasterBandFixedTemporalRangeModel
326//
327
328QgsRasterBandFixedTemporalRangeModel::QgsRasterBandFixedTemporalRangeModel( QObject *parent )
329 : QAbstractItemModel( parent )
330{
331}
332
333int QgsRasterBandFixedTemporalRangeModel::columnCount( const QModelIndex & ) const
334{
335 return 3;
336}
337
338int QgsRasterBandFixedTemporalRangeModel::rowCount( const QModelIndex &parent ) const
339{
340 if ( parent.isValid() )
341 return 0;
342 return mBandCount;
343}
344
345QModelIndex QgsRasterBandFixedTemporalRangeModel::index( int row, int column, const QModelIndex &parent ) const
346{
347 if ( hasIndex( row, column, parent ) )
348 {
349 return createIndex( row, column, row );
350 }
351
352 return QModelIndex();
353}
354
355QModelIndex QgsRasterBandFixedTemporalRangeModel::parent( const QModelIndex &child ) const
356{
357 Q_UNUSED( child )
358 return QModelIndex();
359}
360
361Qt::ItemFlags QgsRasterBandFixedTemporalRangeModel::flags( const QModelIndex &index ) const
362{
363 if ( !index.isValid() )
364 return Qt::ItemFlags();
365
366 if ( index.row() < 0 || index.row() >= mBandCount || index.column() < 0 || index.column() >= columnCount() )
367 return Qt::ItemFlags();
368
369 switch ( index.column() )
370 {
371 case 0:
372 return Qt::ItemFlag::ItemIsEnabled;
373 case 1:
374 case 2:
375 return Qt::ItemFlag::ItemIsEnabled | Qt::ItemFlag::ItemIsEditable | Qt::ItemFlag::ItemIsSelectable;
376 default:
377 break;
378 }
379
380 return Qt::ItemFlags();
381}
382
383QVariant QgsRasterBandFixedTemporalRangeModel::data( const QModelIndex &index, int role ) const
384{
385 if ( !index.isValid() )
386 return QVariant();
387
388 if ( index.row() < 0 || index.row() >= mBandCount || index.column() < 0 || index.column() >= columnCount() )
389 return QVariant();
390
391 const int band = index.row() + 1;
392 const QgsDateTimeRange range = mRanges.value( band );
393
394 switch ( role )
395 {
396 case Qt::DisplayRole:
397 case Qt::EditRole:
398 case Qt::ToolTipRole:
399 {
400 switch ( index.column() )
401 {
402 case 0:
403 return mBandNames.value( band, QString::number( band ) );
404
405 case 1:
406 return range.begin().isValid() ? range.begin() : QVariant();
407
408 case 2:
409 return range.end().isValid() ? range.end() : QVariant();
410
411 default:
412 break;
413 }
414 break;
415 }
416
417 case Qt::TextAlignmentRole:
418 {
419 switch ( index.column() )
420 {
421 case 0:
422 return static_cast<Qt::Alignment::Int>( Qt::AlignLeft | Qt::AlignVCenter );
423
424 case 1:
425 case 2:
426 return static_cast<Qt::Alignment::Int>( Qt::AlignRight | Qt::AlignVCenter );
427 default:
428 break;
429 }
430 break;
431 }
432
433 default:
434 break;
435 }
436 return QVariant();
437}
438
439QVariant QgsRasterBandFixedTemporalRangeModel::headerData( int section, Qt::Orientation orientation, int role ) const
440{
441 if ( role == Qt::DisplayRole && orientation == Qt::Horizontal )
442 {
443 switch ( section )
444 {
445 case 0:
446 return tr( "Band" );
447 case 1:
448 return tr( "Begin" );
449 case 2:
450 return tr( "End" );
451 default:
452 break;
453 }
454 }
455 return QAbstractItemModel::headerData( section, orientation, role );
456}
457
458bool QgsRasterBandFixedTemporalRangeModel::setData( const QModelIndex &index, const QVariant &value, int role )
459{
460 if ( !index.isValid() )
461 return false;
462
463 if ( index.row() > mBandCount || index.row() < 0 )
464 return false;
465
466 const int band = index.row() + 1;
467 const QgsDateTimeRange range = mRanges.value( band );
468
469 switch ( role )
470 {
471 case Qt::EditRole:
472 {
473 const QDateTime newValue = value.toDateTime();
474 if ( !newValue.isValid() )
475 return false;
476
477 switch ( index.column() )
478 {
479 case 1:
480 {
481 mRanges[band] = QgsDateTimeRange( newValue, range.end(), range.includeBeginning(), range.includeEnd() );
482 emit dataChanged( index, index, QVector<int>() << role );
483 break;
484 }
485
486 case 2:
487 mRanges[band] = QgsDateTimeRange( range.begin(), newValue, range.includeBeginning(), range.includeEnd() );
488 emit dataChanged( index, index, QVector<int>() << role );
489 break;
490
491 default:
492 break;
493 }
494 return true;
495 }
496
497 default:
498 break;
499 }
500
501 return false;
502}
503
504void QgsRasterBandFixedTemporalRangeModel::setLayerData( QgsRasterLayer *layer, const QMap<int, QgsDateTimeRange> &ranges )
505{
506 beginResetModel();
507
508 mBandCount = layer->bandCount();
509 mRanges = ranges;
510
511 mBandNames.clear();
512 for ( int band = 1; band <= mBandCount; ++band )
513 {
514 mBandNames[band] = layer->dataProvider()->displayBandName( band );
515 }
516
517 endResetModel();
518}
519
520//
521// QgsFixedTemporalRangeDelegate
522//
523
524QgsFixedTemporalRangeDelegate::QgsFixedTemporalRangeDelegate( QObject *parent )
525 : QStyledItemDelegate( parent )
526{
527}
528
529QWidget *QgsFixedTemporalRangeDelegate::createEditor( QWidget *parent, const QStyleOptionViewItem &, const QModelIndex & ) const
530{
531 QgsDateTimeEdit *editor = new QgsDateTimeEdit( parent );
532 editor->setAllowNull( true );
533 return editor;
534}
535
536void QgsFixedTemporalRangeDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
537{
538 if ( QgsDateTimeEdit *dateTimeEdit = qobject_cast<QgsDateTimeEdit *>( editor ) )
539 {
540 model->setData( index, dateTimeEdit->dateTime() );
541 }
542}
TemporalUnit
Temporal units.
Definition qgis.h:5255
@ Milliseconds
Milliseconds.
Definition qgis.h:5256
@ Hours
Hours.
Definition qgis.h:5259
@ Centuries
Centuries.
Definition qgis.h:5265
@ Seconds
Seconds.
Definition qgis.h:5257
@ Weeks
Weeks.
Definition qgis.h:5261
@ Years
Years.
Definition qgis.h:5263
@ Decades
Decades.
Definition qgis.h:5264
@ Months
Months.
Definition qgis.h:5262
@ Minutes
Minutes.
Definition qgis.h:5258
RasterTemporalMode
Raster layer temporal modes.
Definition qgis.h:2679
@ RepresentsTemporalValues
Pixel values represent an datetime.
Definition qgis.h:2684
@ RedrawLayerOnly
Redraw the layer when temporal range changes, but don't apply any filtering. Useful when raster symbo...
Definition qgis.h:2682
@ FixedRangePerBand
Layer has a fixed temporal range per band.
Definition qgis.h:2683
@ TemporalRangeFromDataProvider
Mode when raster layer delegates temporal range handling to the dataprovider.
Definition qgis.h:2681
@ FixedTemporalRange
Mode when temporal properties have fixed start and end datetimes.
Definition qgis.h:2680
@ FixedDateTime
Layer has a fixed date time instant.
Definition qgis.h:2685
@ UsesMultipleBands
The renderer utilizes multiple raster bands for color data (note that alpha bands are not considered ...
Definition qgis.h:1582
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:50
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:449
T end() const
Returns the upper bound of the range.
Definition qgsrange.h:456
bool includeEnd() const
Returns true if the end is inclusive, or false if the end is exclusive.
Definition qgsrange.h:471
bool includeBeginning() const
Returns true if the beginning is inclusive, or false if the beginning is exclusive.
Definition qgsrange.h:464
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:764