Skip to content
Permalink
Browse files

[mesh] Misc GUI fixes for mesh layers

- correct rounding of time
- correct display of time (was off by an hour)
- fixed time combo box when not time-varying dataset group is loaded
- fixed switching of active dataset groups
- bonus: added missing space for arrows on grid ("10 px" not "10px")
  • Loading branch information
wonder-sk committed Oct 2, 2018
1 parent d2fdfe8 commit 6bff7f0896abc897a08655d8ff4bab660af7fc74
@@ -191,9 +191,6 @@ class APP_EXPORT QgsMeshDatasetGroupTreeView : public QTreeView
//! Selected dataset group for vectors changed. -1 for invalid group
void activeVectorGroupChanged( int groupIndex );

private slots:
// void onSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected );

private:
void setActiveGroupFromActiveDataset();

@@ -27,7 +27,7 @@ QgsMeshRendererActiveDatasetWidget::QgsMeshRendererActiveDatasetWidget( QWidget
{
setupUi( this );

connect( mTimeComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), this, &QgsMeshRendererActiveDatasetWidget::onActiveDatasetChanged );
connect( mTimeComboBox, qgis::overload<int>::of( &QComboBox::currentIndexChanged ), this, &QgsMeshRendererActiveDatasetWidget::onActiveTimeChanged );
connect( mDatasetSlider, &QSlider::valueChanged, mTimeComboBox, &QComboBox::setCurrentIndex );

connect( mFirstDatasetButton, &QToolButton::clicked, this, &QgsMeshRendererActiveDatasetWidget::onFirstTimeClicked );
@@ -69,9 +69,10 @@ QgsMeshDatasetIndex QgsMeshRendererActiveDatasetWidget::activeVectorDataset() co

void QgsMeshRendererActiveDatasetWidget::setTimeRange()
{
int datasetCount = 1;
// figure out which dataset group contains the greatest number of datasets.
// this group will be used to initialize the time combo box.
int datasetCount = 0;
int groupWithMaximumDatasets = -1;

if ( mMeshLayer && mMeshLayer->dataProvider() )
{
for ( int i = 0; i < mMeshLayer->dataProvider()->datasetGroupCount(); ++i )
@@ -120,8 +121,7 @@ void QgsMeshRendererActiveDatasetWidget::onActiveScalarGroupChanged( int groupIn
mActiveScalarDatasetGroup = groupIndex;

// keep the same timestep if possible
int val = mTimeComboBox->currentIndex();
mTimeComboBox->setCurrentIndex( val );
onActiveTimeChanged( mTimeComboBox->currentIndex() );
emit activeScalarGroupChanged( mActiveScalarDatasetGroup );
}

@@ -133,12 +133,11 @@ void QgsMeshRendererActiveDatasetWidget::onActiveVectorGroupChanged( int groupIn
mActiveVectorDatasetGroup = groupIndex;

// keep the same timestep if possible
int val = mTimeComboBox->currentIndex();
mTimeComboBox->setCurrentIndex( val );
onActiveTimeChanged( mTimeComboBox->currentIndex() );
emit activeVectorGroupChanged( mActiveVectorDatasetGroup );
}

void QgsMeshRendererActiveDatasetWidget::onActiveDatasetChanged( int value )
void QgsMeshRendererActiveDatasetWidget::onActiveTimeChanged( int value )
{
if ( !mMeshLayer || !mMeshLayer->dataProvider() )
return;
@@ -153,7 +152,6 @@ void QgsMeshRendererActiveDatasetWidget::onActiveDatasetChanged( int value )
{
mActiveScalarDataset = activeScalarDataset;
changed = true;
emit activeScalarDatasetChanged( mActiveScalarDataset );
}

QgsMeshDatasetIndex activeVectorDataset(
@@ -164,7 +162,6 @@ void QgsMeshRendererActiveDatasetWidget::onActiveDatasetChanged( int value )
{
mActiveVectorDataset = activeVectorDataset;
changed = true;
emit activeVectorDatasetChanged( mActiveVectorDataset );
}

if ( changed )
@@ -251,14 +248,9 @@ void QgsMeshRendererActiveDatasetWidget::updateMetadata()
QString QgsMeshRendererActiveDatasetWidget::timeToString( double val )
{
// time val should be in hours
#if QT_VERSION >= 0x050800
qint64 seconds = static_cast<qint64>( val * 3600.0 );
return QDateTime::fromSecsSinceEpoch( seconds ).toString( "hh:mm:ss" );
#else
QDateTime t;
t.setTime_t( static_cast<uint>( val * 3600.0 ) );
return t.toString( "hh:mm:ss" );
#endif
int seconds = static_cast<int>( qgsRound( val * 3600.0, 0 ) );
QTime t = QTime( 0, 0 ).addSecs( seconds );
return t.toString(); // the format is "HH:mm:ss"
}

QString QgsMeshRendererActiveDatasetWidget::metadata( QgsMeshDatasetIndex datasetIndex )
@@ -63,12 +63,6 @@ class APP_EXPORT QgsMeshRendererActiveDatasetWidget : public QWidget, private Ui

signals:

//! Emitted when active scalar dataset changed
void activeScalarDatasetChanged( QgsMeshDatasetIndex index );

//! Emitted when active vector dataset changed
void activeVectorDatasetChanged( QgsMeshDatasetIndex index );

//! Emitted when the current scalar group gets changed
void activeScalarGroupChanged( int groupIndex );

@@ -81,7 +75,7 @@ class APP_EXPORT QgsMeshRendererActiveDatasetWidget : public QWidget, private Ui
private slots:
void onActiveScalarGroupChanged( int groupIndex );
void onActiveVectorGroupChanged( int groupIndex );
void onActiveDatasetChanged( int value );
void onActiveTimeChanged( int value );
void onFirstTimeClicked();
void onPreviousTimeClicked();
void onNextTimeClicked();
@@ -111,7 +111,7 @@
<item row="1" column="1">
<widget class="QSpinBox" name="mYSpacingSpinBox">
<property name="suffix">
<string>px</string>
<string> px</string>
</property>
<property name="minimum">
<number>1</number>

0 comments on commit 6bff7f0

Please sign in to comment.
You can’t perform that action at this time.