From 4e1994d779282b67ced7f9b69bd2a59761b35e3d Mon Sep 17 00:00:00 2001 From: Jon Jenssen Date: Thu, 19 Dec 2024 18:19:35 +0100 Subject: [PATCH] Support multiple timesteps --- .../RicNewStatisticsContourMapViewFeature.cpp | 9 +++-- .../Rim3dOverlayInfoConfig.cpp | 4 +-- .../RimStatisticsContourMap.cpp | 33 +++++++++++++++---- .../RimStatisticsContourMap.h | 3 +- .../RimStatisticsContourMapView.cpp | 31 ++++++++++++++--- .../RimStatisticsContourMapView.h | 7 ++-- .../UserInterface/RiuViewer.cpp | 12 +++---- 7 files changed, 74 insertions(+), 25 deletions(-) diff --git a/ApplicationLibCode/Commands/RicNewStatisticsContourMapViewFeature.cpp b/ApplicationLibCode/Commands/RicNewStatisticsContourMapViewFeature.cpp index 56308fbacd..bb5141f364 100644 --- a/ApplicationLibCode/Commands/RicNewStatisticsContourMapViewFeature.cpp +++ b/ApplicationLibCode/Commands/RicNewStatisticsContourMapViewFeature.cpp @@ -38,6 +38,7 @@ #include "cafSelectionManager.h" #include +#include CAF_CMD_SOURCE_INIT( RicNewStatisticsContourMapViewFeature, "RicNewStatisticsContourMapViewFeature" ); @@ -120,7 +121,6 @@ RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createAndAdd eclipseCase->updateConnectedEditors(); contourMapView->cellFilterCollection()->setCase( eclipseCase ); } - caf::SelectionManager::instance()->setSelectedItem( contourMapView ); contourMapView->createDisplayModelAndRedraw(); contourMapView->zoomAll(); @@ -130,8 +130,13 @@ RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createAndAdd // RimOilField* oilField = project->activeOilField(); // oilField->eclipseContourMapCollection()->updateConnectedEditors(); - Riu3DMainWindowTools::setExpanded( statisticsContourMap ); + statisticsContourMap->updateConnectedEditors(); + + // caf::SelectionManager::instance()->setSelectedItem( contourMapView ); + QCoreApplication::processEvents(); + Riu3DMainWindowTools::selectAsCurrentItem( contourMapView ); + Riu3DMainWindowTools::setExpanded( statisticsContourMap ); Riu3DMainWindowTools::setExpanded( contourMapView ); return contourMapView; diff --git a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 59e3709f1a..a42b7222b2 100644 --- a/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -1048,7 +1048,7 @@ QString Rim3dOverlayInfoConfig::timeStepText( RimEclipseView* eclipseView ) QString dateString = RiaQDateTimeTools::toStringUsingApplicationLocale( timeSteps[currTimeStepIndex], dateFormat ); dateTimeString = - QString( "Time Step: %1/%2 %3" ).arg( QString::number( currTimeStepIndex ), QString::number( timeSteps.size() - 1 ), dateString ); + QString( "Time Step: %1/%2 %3" ).arg( QString::number( currTimeStepIndex + 1 ), QString::number( timeSteps.size() ), dateString ); } } @@ -1071,7 +1071,7 @@ QString Rim3dOverlayInfoConfig::timeStepText( RimGeoMechView* geoMechView ) { dateTimeString = QString( "Time Step: %1/%2 %3" ) - .arg( QString::number( currTimeStepIndex ), QString::number( timeSteps.size() - 1 ), timeSteps[currTimeStepIndex] ); + .arg( QString::number( currTimeStepIndex + 1 ), QString::number( timeSteps.size() ), timeSteps[currTimeStepIndex] ); } return QString( "

-- %1 --
" ).arg( dateTimeString ) + diff --git a/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.cpp b/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.cpp index 7e0d73d8be..f6288449f4 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.cpp @@ -287,7 +287,7 @@ void RimStatisticsContourMap::computeStatistics() if ( m_resultDefinition()->hasDynamicResult() ) { - for ( auto ts : m_selectedTimeSteps() ) + for ( auto ts : selectedTimeSteps() ) { std::vector result = contourMapProjection.generateResults( m_resultDefinition()->eclipseResultAddress(), resultAggregation, ts ); @@ -388,21 +388,40 @@ RigContourMapGrid* RimStatisticsContourMap::contourMapGrid() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RimStatisticsContourMap::maxTimeStepCount() const +std::vector RimStatisticsContourMap::result( size_t timeStep, StatisticsType statisticsType ) const { - return m_selectedTimeSteps().size(); + if ( !m_timeResults.contains( timeStep ) ) return {}; + + if ( !m_timeResults.at( timeStep ).contains( statisticsType ) ) return {}; + + return m_timeResults.at( timeStep ).at( statisticsType ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimStatisticsContourMap::result( size_t timeStep, StatisticsType statisticsType ) const +std::vector RimStatisticsContourMap::selectedTimeSteps() const { - if ( !m_timeResults.contains( timeStep ) ) return {}; + if ( m_selectedTimeSteps().empty() ) + { + std::vector retVec; + for ( int i = 0; i < (int)eclipseCase()->timeStepStrings().size(); i++ ) + retVec.push_back( i ); + return retVec; + } + return m_selectedTimeSteps(); +} - if ( !m_timeResults.at( timeStep ).contains( statisticsType ) ) return {}; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimStatisticsContourMap::timeStepName( int timeStep ) const +{ + if ( eclipseCase() == nullptr ) return ""; - return m_timeResults.at( timeStep ).at( statisticsType ); + if ( ( timeStep < 0 ) || ( timeStep >= eclipseCase()->timeStepStrings().size() ) ) return ""; + + return eclipseCase()->timeStepName( timeStep ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.h b/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.h index 3775c55116..927f5650f3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.h +++ b/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.h @@ -73,7 +73,8 @@ class RimStatisticsContourMap : public RimNamedObject double sampleSpacingFactor() const; bool isColumnResult() const; - int maxTimeStepCount() const; + std::vector selectedTimeSteps() const; + QString timeStepName( int timeStep ) const; protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; diff --git a/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMapView.cpp b/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMapView.cpp index 4d036be839..11c591aa3c 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMapView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMapView.cpp @@ -218,9 +218,10 @@ void RimStatisticsContourMapView::onClampCurrentTimestep() { if ( statisticsContourMap() ) { - if ( m_currentTimeStep() >= statisticsContourMap()->maxTimeStepCount() ) + auto maxSteps = statisticsContourMap()->selectedTimeSteps().size(); + if ( m_currentTimeStep() >= maxSteps ) { - m_currentTimeStep = statisticsContourMap()->maxTimeStepCount() - 1; + m_currentTimeStep = maxSteps - 1; } } @@ -234,7 +235,7 @@ size_t RimStatisticsContourMapView::onTimeStepCountRequested() { if ( statisticsContourMap() ) { - return (size_t)statisticsContourMap()->maxTimeStepCount(); + return (size_t)statisticsContourMap()->selectedTimeSteps().size(); } return 0; @@ -245,5 +246,27 @@ size_t RimStatisticsContourMapView::onTimeStepCountRequested() //-------------------------------------------------------------------------------------------------- QString RimStatisticsContourMapView::timeStepName( int frameIdx ) const { - return QString( "Step %1" ).arg( frameIdx ); + if ( !statisticsContourMap() ) return ""; + + auto steps = statisticsContourMap()->selectedTimeSteps(); + if ( frameIdx >= steps.size() ) return ""; + auto realTimeStep = steps[frameIdx]; + return statisticsContourMap()->timeStepName( realTimeStep ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimStatisticsContourMapView::timeStepStrings() const +{ + QStringList retList; + + if ( !statisticsContourMap() ) return retList; + + for ( auto ts : statisticsContourMap()->selectedTimeSteps() ) + { + retList.append( statisticsContourMap()->timeStepName( ts ) ); + } + + return retList; } diff --git a/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMapView.h b/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMapView.h index 3b179a101a..0fdaa1bc58 100644 --- a/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMapView.h +++ b/ApplicationLibCode/ProjectDataModel/RimStatisticsContourMapView.h @@ -39,9 +39,10 @@ class RimStatisticsContourMapView : public RimEclipseContourMapView void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - void onClampCurrentTimestep() override; - size_t onTimeStepCountRequested() override; - QString timeStepName( int frameIdx ) const override; + void onClampCurrentTimestep() override; + size_t onTimeStepCountRequested() override; + QString timeStepName( int frameIdx ) const override; + QStringList timeStepStrings() const override; // void createContourMapGeometry(); void onUpdateLegends() override; diff --git a/ApplicationLibCode/UserInterface/RiuViewer.cpp b/ApplicationLibCode/UserInterface/RiuViewer.cpp index d9b8733ae4..bc26a44c00 100644 --- a/ApplicationLibCode/UserInterface/RiuViewer.cpp +++ b/ApplicationLibCode/UserInterface/RiuViewer.cpp @@ -460,9 +460,9 @@ void RiuViewer::paintOverlayItems( QPainter* painter ) QString stepName = compView->timeStepName( compView->currentTimeStep() ); m_animationProgressCompView->setFormat( "Time Step: %v/%m " + stepName ); - m_animationProgressCompView->setMinimum( 0 ); - m_animationProgressCompView->setMaximum( static_cast( compView->timeStepCount() ) - 1 ); - m_animationProgressCompView->setValue( compView->currentTimeStep() ); + m_animationProgressCompView->setMinimum( 1 ); + m_animationProgressCompView->setMaximum( static_cast( compView->timeStepCount() + 1 ) ); + m_animationProgressCompView->setValue( compView->currentTimeStep() + 1 ); m_animationProgressCompView->resize( columnWidth, m_animationProgressCompView->sizeHint().height() ); @@ -492,9 +492,9 @@ void RiuViewer::paintOverlayItems( QPainter* painter ) QString stepName = view->timeStepName( view->currentTimeStep() ); m_animationProgress->setFormat( "Time Step: %v/%m " + stepName ); - m_animationProgress->setMinimum( 0 ); - m_animationProgress->setMaximum( static_cast( view->timeStepCount() ) - 1 ); - m_animationProgress->setValue( view->currentTimeStep() ); + m_animationProgress->setMinimum( 1 ); + m_animationProgress->setMaximum( static_cast( view->timeStepCount() + 1 ) ); + m_animationProgress->setValue( view->currentTimeStep() + 1 ); m_animationProgress->resize( columnWidth, m_animationProgress->sizeHint().height() ); m_animationProgress->render( painter, QPoint( columnPos, yPos ) );