Skip to content

Commit

Permalink
fix #28761 [mesh] Time slider for non-temporal data should be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterPetrik committed Jul 1, 2019
1 parent b89ed82 commit 28bb53e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/app/mesh/qgsmeshrendereractivedatasetwidget.cpp
Expand Up @@ -116,7 +116,14 @@ void QgsMeshRendererActiveDatasetWidget::setTimeRange()
mTimeComboBox->blockSignals( false );

// enable/disable time controls depending on whether the data set is time varying
bool isTimeVarying = datasetCount > 1;
enableTimeControls();
}

void QgsMeshRendererActiveDatasetWidget::enableTimeControls()
{
const int scalarDatesets = mMeshLayer->dataProvider()->datasetCount( mActiveScalarDatasetGroup );
const int vectorDatesets = mMeshLayer->dataProvider()->datasetCount( mActiveVectorDatasetGroup );
const bool isTimeVarying = ( scalarDatesets > 1 ) || ( vectorDatesets > 1 );
mTimeComboBox->setEnabled( isTimeVarying );
mDatasetSlider->setEnabled( isTimeVarying );
mTimeFormatButton->setEnabled( isTimeVarying );
Expand All @@ -132,6 +139,10 @@ void QgsMeshRendererActiveDatasetWidget::onActiveScalarGroupChanged( int groupIn
return;

mActiveScalarDatasetGroup = groupIndex;

// enable/disable time slider controls
enableTimeControls();

// keep the same timestep if possible
onActiveTimeChanged( mTimeComboBox->currentIndex() );
emit activeScalarGroupChanged( mActiveScalarDatasetGroup );
Expand All @@ -143,6 +154,8 @@ void QgsMeshRendererActiveDatasetWidget::onActiveVectorGroupChanged( int groupIn
return;

mActiveVectorDatasetGroup = groupIndex;
// enable/disable time slider controls
enableTimeControls();

// keep the same timestep if possible
onActiveTimeChanged( mTimeComboBox->currentIndex() );
Expand Down
8 changes: 6 additions & 2 deletions src/app/mesh/qgsmeshrendereractivedatasetwidget.h
Expand Up @@ -28,8 +28,9 @@ class QgsMeshLayer;
* Widget for selection of active dataset group from tree view.
* Also selects the active scalar and vector dataset by slider
*
* At the moment, it is not possible to select different vector and
* scalar dataset
* User can choose different scalar and vector dataset.
* Time slider is deactivated when no dataset is selected or
* when all selected datasets are non-temporal.
*/
class APP_EXPORT QgsMeshRendererActiveDatasetWidget : public QWidget, private Ui::QgsMeshRendererActiveDatasetWidgetBase
{
Expand Down Expand Up @@ -88,6 +89,9 @@ class APP_EXPORT QgsMeshRendererActiveDatasetWidget : public QWidget, private Ui
//! Loops through all dataset groups and finds the maximum number of datasets
void setTimeRange();

//! Enables/Disables time controls depending on whether the selected datasets are time varying
void enableTimeControls();

void updateMetadata();

QgsMeshLayer *mMeshLayer = nullptr; // not owned
Expand Down

0 comments on commit 28bb53e

Please sign in to comment.