Skip to content

Commit

Permalink
Support multiple timesteps
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Dec 19, 2024
1 parent 2aa790e commit 4e1994d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "cafSelectionManager.h"

#include <QAction>
#include <QCoreApplication>

CAF_CMD_SOURCE_INIT( RicNewStatisticsContourMapViewFeature, "RicNewStatisticsContourMapViewFeature" );

Expand Down Expand Up @@ -120,7 +121,6 @@ RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createAndAdd
eclipseCase->updateConnectedEditors();
contourMapView->cellFilterCollection()->setCase( eclipseCase );
}
caf::SelectionManager::instance()->setSelectedItem( contourMapView );

contourMapView->createDisplayModelAndRedraw();
contourMapView->zoomAll();
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand All @@ -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( "<p><b><center>-- %1 --</center></b>" ).arg( dateTimeString ) +
Expand Down
33 changes: 26 additions & 7 deletions ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void RimStatisticsContourMap::computeStatistics()

if ( m_resultDefinition()->hasDynamicResult() )
{
for ( auto ts : m_selectedTimeSteps() )
for ( auto ts : selectedTimeSteps() )
{
std::vector<double> result =
contourMapProjection.generateResults( m_resultDefinition()->eclipseResultAddress(), resultAggregation, ts );
Expand Down Expand Up @@ -388,21 +388,40 @@ RigContourMapGrid* RimStatisticsContourMap::contourMapGrid() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimStatisticsContourMap::maxTimeStepCount() const
std::vector<double> 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<double> RimStatisticsContourMap::result( size_t timeStep, StatisticsType statisticsType ) const
std::vector<int> RimStatisticsContourMap::selectedTimeSteps() const
{
if ( !m_timeResults.contains( timeStep ) ) return {};
if ( m_selectedTimeSteps().empty() )
{
std::vector<int> 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 );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class RimStatisticsContourMap : public RimNamedObject
double sampleSpacingFactor() const;
bool isColumnResult() const;

int maxTimeStepCount() const;
std::vector<int> selectedTimeSteps() const;
QString timeStepName( int timeStep ) const;

protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -234,7 +235,7 @@ size_t RimStatisticsContourMapView::onTimeStepCountRequested()
{
if ( statisticsContourMap() )
{
return (size_t)statisticsContourMap()->maxTimeStepCount();
return (size_t)statisticsContourMap()->selectedTimeSteps().size();
}

return 0;
Expand All @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions ApplicationLibCode/UserInterface/RiuViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>( compView->timeStepCount() ) - 1 );
m_animationProgressCompView->setValue( compView->currentTimeStep() );
m_animationProgressCompView->setMinimum( 1 );
m_animationProgressCompView->setMaximum( static_cast<int>( compView->timeStepCount() + 1 ) );
m_animationProgressCompView->setValue( compView->currentTimeStep() + 1 );

m_animationProgressCompView->resize( columnWidth, m_animationProgressCompView->sizeHint().height() );

Expand Down Expand Up @@ -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<int>( view->timeStepCount() ) - 1 );
m_animationProgress->setValue( view->currentTimeStep() );
m_animationProgress->setMinimum( 1 );
m_animationProgress->setMaximum( static_cast<int>( view->timeStepCount() + 1 ) );
m_animationProgress->setValue( view->currentTimeStep() + 1 );

m_animationProgress->resize( columnWidth, m_animationProgress->sizeHint().height() );
m_animationProgress->render( painter, QPoint( columnPos, yPos ) );
Expand Down

0 comments on commit 4e1994d

Please sign in to comment.