mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Statistics Contourmap UI updates (#12060)
* Enable time step selections and controls in view * Support loading just what we need for statistics contour maps by using custom reader settings * Close case once done with it unless there are active views. * Add selection of user interface case (for result selection, display of wells, faults...) * Avoid int overflow for nested progresses by using double * Improve auto naming * Misc. UI improvements
This commit is contained in:
parent
ba1224c9de
commit
b999faf293
@ -391,8 +391,8 @@ int RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl( const QStr
|
||||
else
|
||||
{
|
||||
// Make sure the placeholder result entries are created, as this functionality is triggered when creating a
|
||||
// view. See RimEclipseView::onLoadDataAndUpdate() and the call to openReserviorCase()
|
||||
rimResultReservoir->openReserviorCase();
|
||||
// view. See RimEclipseView::onLoadDataAndUpdate() and the call to openReservoirCase()
|
||||
rimResultReservoir->openReservoirCase();
|
||||
|
||||
analysisModels->updateConnectedEditors();
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ caf::PdmScriptResponse RicfExportProperty::execute()
|
||||
|
||||
if ( !eclipseCase->eclipseCaseData() )
|
||||
{
|
||||
if ( !eclipseCase->openReserviorCase() )
|
||||
if ( !eclipseCase->openReservoirCase() )
|
||||
{
|
||||
QString error = QString( "exportProperty: Could not find eclipseCaseData with ID %1" ).arg( m_caseId() );
|
||||
RiaLogging::error( error );
|
||||
|
@ -107,7 +107,7 @@ RimEclipseCaseEnsemble* RicCreateGridCaseEnsemblesFromFilesFeature::importSingle
|
||||
|
||||
caf::ProgressInfo progInfo( fileNames.size() + 1, "Creating Grid Ensembles" );
|
||||
|
||||
for ( auto caseFileName : fileNames )
|
||||
for ( const auto& caseFileName : fileNames )
|
||||
{
|
||||
auto task = progInfo.task( "Loading files", 1 );
|
||||
|
||||
|
@ -62,7 +62,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFileName( RimViewWindow* v
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView( Rim3dView* rimView )
|
||||
{
|
||||
QStringList timeSteps = rimView->ownerCase()->timeStepStrings();
|
||||
QStringList timeSteps = rimView->timeStepStrings();
|
||||
int timeStep = rimView->currentTimeStep();
|
||||
|
||||
QString fileName =
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include "RimProject.h"
|
||||
#include "RimRegularLegendConfig.h"
|
||||
#include "RimSimWellInViewCollection.h"
|
||||
#include "RimStatisticsContourMapView.h"
|
||||
#include "RimSurfaceInViewCollection.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
@ -67,6 +68,8 @@ const size_t largeSamplingThresholdCellCount = 5000000u;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewContourMapViewFeature::isCommandEnabled() const
|
||||
{
|
||||
if ( caf::SelectionManager::instance()->selectedItemOfType<RimStatisticsContourMapView>() != nullptr ) return false;
|
||||
|
||||
bool selectedView = caf::SelectionManager::instance()->selectedItemOfType<RimGridView>() != nullptr;
|
||||
bool selectedCase = caf::SelectionManager::instance()->selectedItemOfType<RimCase>() != nullptr;
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include "RimEclipseCaseEnsemble.h"
|
||||
#include "RimStatisticsContourMap.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
@ -41,6 +43,8 @@ void RicNewStatisticsContourMapFeature::addStatisticsContourMap( RimEclipseCaseE
|
||||
statisticsContourMap->setEclipseCase( cases[0] );
|
||||
eclipseCaseEnsemble->addStatisticsContourMap( statisticsContourMap );
|
||||
eclipseCaseEnsemble->updateConnectedEditors();
|
||||
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( statisticsContourMap );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -58,36 +58,13 @@ void RicNewStatisticsContourMapViewFeature::onActionTriggered( bool isChecked )
|
||||
auto contourMap = caf::SelectionManager::instance()->selectedItemOfType<RimStatisticsContourMap>();
|
||||
if ( !contourMap ) return;
|
||||
|
||||
RimEclipseCase* eclipseCase = contourMap->eclipseCase();
|
||||
if ( !eclipseCase ) return;
|
||||
contourMap->ensureResultsComputed();
|
||||
auto view = createAndAddView( contourMap );
|
||||
contourMap->updateConnectedEditors();
|
||||
|
||||
if ( auto eclipseContourMap = createStatisticsContourMapView( contourMap, eclipseCase ) )
|
||||
{
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
eclipseContourMap->loadDataAndUpdate();
|
||||
|
||||
// make sure no surfaces are shown in the view when the contourmap is generated
|
||||
if ( eclipseContourMap->surfaceInViewCollection() ) eclipseContourMap->surfaceInViewCollection()->setCheckState( Qt::Unchecked );
|
||||
|
||||
if ( eclipseCase )
|
||||
{
|
||||
eclipseCase->updateConnectedEditors();
|
||||
eclipseContourMap->cellFilterCollection()->setCase( eclipseCase );
|
||||
}
|
||||
caf::SelectionManager::instance()->setSelectedItem( eclipseContourMap );
|
||||
|
||||
eclipseContourMap->createDisplayModelAndRedraw();
|
||||
eclipseContourMap->zoomAll();
|
||||
|
||||
RimProject* project = RimProject::current();
|
||||
|
||||
RimOilField* oilField = project->activeOilField();
|
||||
|
||||
oilField->eclipseContourMapCollection()->updateConnectedEditors();
|
||||
|
||||
Riu3DMainWindowTools::setExpanded( eclipseContourMap );
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( eclipseContourMap );
|
||||
}
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( view );
|
||||
Riu3DMainWindowTools::setExpanded( contourMap );
|
||||
Riu3DMainWindowTools::setExpanded( view );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -102,27 +79,55 @@ void RicNewStatisticsContourMapViewFeature::setupActionLook( QAction* actionToSe
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
|
||||
RimEclipseCase* eclipseCase )
|
||||
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap )
|
||||
{
|
||||
RimStatisticsContourMapView* contourMap = new RimStatisticsContourMapView;
|
||||
contourMap->setStatisticsContourMap( statisticsContourMap );
|
||||
contourMap->setEclipseCase( eclipseCase );
|
||||
RimEclipseCase* eclipseCase = statisticsContourMap->eclipseCase();
|
||||
if ( !eclipseCase ) return nullptr;
|
||||
|
||||
caf::PdmDocument::updateUiIconStateRecursively( contourMap );
|
||||
RimStatisticsContourMapView* contourMapView = new RimStatisticsContourMapView;
|
||||
contourMapView->setStatisticsContourMap( statisticsContourMap );
|
||||
contourMapView->setEclipseCase( eclipseCase );
|
||||
|
||||
size_t i = eclipseCase->contourMapCollection()->views().size();
|
||||
contourMap->setName( QString( "Contour Map %1" ).arg( i + 1 ) );
|
||||
caf::PdmDocument::updateUiIconStateRecursively( contourMapView );
|
||||
|
||||
contourMap->faultCollection()->setActive( false );
|
||||
contourMap->wellCollection()->isActive = false;
|
||||
contourMapView->faultCollection()->setActive( false );
|
||||
contourMapView->wellCollection()->isActive = false;
|
||||
|
||||
eclipseCase->contourMapCollection()->addView( contourMap );
|
||||
statisticsContourMap->addView( contourMapView );
|
||||
|
||||
auto col = RiuGuiTheme::getColorByVariableName( "backgroundColor2" );
|
||||
contourMap->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
|
||||
contourMapView->setBackgroundColor( RiaColorTools::fromQColorTo3f( col ) ); // Ignore original view background
|
||||
contourMapView->initAfterReadRecursively();
|
||||
|
||||
contourMap->initAfterReadRecursively();
|
||||
|
||||
return contourMap;
|
||||
return contourMapView;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimStatisticsContourMapView* RicNewStatisticsContourMapViewFeature::createAndAddView( RimStatisticsContourMap* statisticsContourMap )
|
||||
{
|
||||
if ( auto contourMapView = createStatisticsContourMapView( statisticsContourMap ) )
|
||||
{
|
||||
// Must be run before buildViewItems, as wells are created in this function
|
||||
contourMapView->loadDataAndUpdate();
|
||||
|
||||
// make sure no surfaces are shown in the view when the contourmap is generated
|
||||
if ( contourMapView->surfaceInViewCollection() ) contourMapView->surfaceInViewCollection()->setCheckState( Qt::Unchecked );
|
||||
|
||||
if ( auto eclipseCase = statisticsContourMap->eclipseCase() )
|
||||
{
|
||||
eclipseCase->updateConnectedEditors();
|
||||
contourMapView->cellFilterCollection()->setCase( eclipseCase );
|
||||
}
|
||||
|
||||
contourMapView->createDisplayModelAndRedraw();
|
||||
contourMapView->zoomAll();
|
||||
|
||||
statisticsContourMap->updateConnectedEditors();
|
||||
|
||||
return contourMapView;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RimEclipseCase;
|
||||
class RimStatisticsContourMapView;
|
||||
class RimStatisticsContourMap;
|
||||
|
||||
@ -31,11 +30,12 @@ class RicNewStatisticsContourMapViewFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
static RimStatisticsContourMapView* createAndAddView( RimStatisticsContourMap* statisticsContourMap );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() const override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
static RimStatisticsContourMapView* createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap,
|
||||
RimEclipseCase* eclipseCase );
|
||||
static RimStatisticsContourMapView* createStatisticsContourMapView( RimStatisticsContourMap* statisticsContourMap );
|
||||
};
|
||||
|
@ -154,7 +154,7 @@ std::vector<RimEclipseCase*> openEclipseCasesForCellPlotting( QStringList gridFi
|
||||
|
||||
analysisModels->cases.push_back( rimResultReservoir );
|
||||
|
||||
if ( !rimResultReservoir->openReserviorCase() )
|
||||
if ( !rimResultReservoir->openReservoirCase() )
|
||||
{
|
||||
analysisModels->removeCaseFromAllGroups( rimResultReservoir );
|
||||
|
||||
|
@ -58,7 +58,7 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips
|
||||
RigActiveCellGrid* activeGrid = new RigActiveCellGrid();
|
||||
eclipseCaseData->setMainGrid( activeGrid );
|
||||
|
||||
caf::ProgressInfo progInfo( 5, "Importing Eclipse Grid" );
|
||||
caf::ProgressInfo progInfo( 4, "Importing Eclipse Grid" );
|
||||
|
||||
Opm::EclIO::EGrid opmGrid( m_gridFileName );
|
||||
|
||||
@ -119,7 +119,7 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips
|
||||
activeCellInfo->setGridCount( 1 + numLGRs );
|
||||
fractureActiveCellInfo->setGridCount( 1 + numLGRs );
|
||||
|
||||
auto task = progInfo.task( "Getting Active Cell Information", 1 );
|
||||
auto task = progInfo.task( "Getting Active Cell Information" );
|
||||
|
||||
for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ )
|
||||
{
|
||||
@ -163,12 +163,12 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips
|
||||
.arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalActiveCells() ) ) )
|
||||
.arg( QString::fromStdString( RiaStdStringTools::formatThousandGrouping( opmGrid.totalNumberOfCells() ) ) ) );
|
||||
|
||||
auto task = progInfo.task( "Loading Active Cell Main Grid Geometry", 1 );
|
||||
auto task = progInfo.task( "Loading Active Cell Main Grid Geometry" );
|
||||
transferActiveGeometry( opmGrid, opmGrid, activeGrid, activeGrid, eclipseCaseData );
|
||||
|
||||
bool hasParentInfo = ( lgr_parent_names.size() >= (size_t)numLGRs );
|
||||
|
||||
auto task2 = progInfo.task( "Loading Active Cell LGR Grid Geometry ", 1 );
|
||||
auto task2 = progInfo.task( "Loading Active Cell LGR Grid Geometry" );
|
||||
|
||||
for ( int lgrIdx = 0; lgrIdx < numLGRs; lgrIdx++ )
|
||||
{
|
||||
@ -193,7 +193,7 @@ bool RifReaderOpmCommonActive::importGrid( RigMainGrid* /* mainGrid*/, RigEclips
|
||||
|
||||
if ( isNNCsEnabled() )
|
||||
{
|
||||
auto task = progInfo.task( "Loading NNC data", 1 );
|
||||
auto task = progInfo.task( "Loading NNC data" );
|
||||
transferStaticNNCData( opmGrid, lgrGrids, activeGrid );
|
||||
}
|
||||
|
||||
|
@ -455,7 +455,7 @@ size_t Rim2dIntersectionView::onTimeStepCountRequested()
|
||||
{
|
||||
if ( isTimeStepDependentDataVisible() && ownerCase() )
|
||||
{
|
||||
return ownerCase()->timeStepStrings().size();
|
||||
return timeStepStrings().size();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -330,9 +330,13 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimEclipseView* eclipseView )
|
||||
}
|
||||
|
||||
infoText += QString( "<p><b>-- Contour Map: %1 --</b><p> "
|
||||
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>"
|
||||
"<b>Projection Type:</b> %4%5<br>" )
|
||||
.arg( caseName, totCellCount, activeCellCountText, aggregationType, weightingParameterString );
|
||||
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>" )
|
||||
.arg( caseName, totCellCount, activeCellCountText );
|
||||
|
||||
if ( !contourMap->contourMapProjection()->isColumnResult() )
|
||||
{
|
||||
infoText += QString( "<b>Projection Type:</b> %1%2<br>" ).arg( aggregationType, weightingParameterString );
|
||||
}
|
||||
}
|
||||
else if ( eclipseView->mainGrid() )
|
||||
{
|
||||
@ -392,9 +396,13 @@ QString Rim3dOverlayInfoConfig::caseInfoText( RimGeoMechView* geoMechView )
|
||||
QString aggregationType = contourMap->contourMapProjection()->resultAggregationText();
|
||||
|
||||
infoText += QString( "<p><b>-- Contour Map: %1 --</b><p> "
|
||||
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>"
|
||||
"<b>Projection Type:</b> %4<br>" )
|
||||
.arg( caseName, totCellCount, activeCellCountText, aggregationType );
|
||||
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>" )
|
||||
.arg( caseName, totCellCount, activeCellCountText );
|
||||
|
||||
if ( !contourMap->contourMapProjection()->isColumnResult() )
|
||||
{
|
||||
infoText += QString( "<b>Projection Type:</b> %1<br>" ).arg( aggregationType );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -456,10 +464,7 @@ QString Rim3dOverlayInfoConfig::resultInfoText( const RigHistogramData& histData
|
||||
{
|
||||
QString propName = contourMap->contourMapProjection()->resultVariableName();
|
||||
QString diffResString = eclipseView->cellResult()->additionalResultText();
|
||||
if ( !contourMap->contourMapProjection()->isColumnResult() )
|
||||
{
|
||||
infoText += QString( "<b>Cell Property:</b> %1<br>" ).arg( propName );
|
||||
}
|
||||
infoText += QString( "<b>Cell Property:</b> %1<br>" ).arg( propName );
|
||||
if ( !diffResString.isEmpty() )
|
||||
{
|
||||
infoText += QString( "%1<br>" ).arg( diffResString );
|
||||
@ -1048,7 +1053,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 +1076,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 ) +
|
||||
|
@ -604,13 +604,25 @@ size_t Rim3dView::timeStepCount()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString Rim3dView::timeStepName( int frameIdx ) const
|
||||
{
|
||||
if ( this->ownerCase() )
|
||||
if ( ownerCase() )
|
||||
{
|
||||
return this->ownerCase()->timeStepName( frameIdx );
|
||||
return ownerCase()->timeStepName( frameIdx );
|
||||
}
|
||||
return QString( "" );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QStringList Rim3dView::timeStepStrings() const
|
||||
{
|
||||
if ( ownerCase() )
|
||||
{
|
||||
return ownerCase()->timeStepStrings();
|
||||
}
|
||||
return QStringList();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -150,12 +150,13 @@ public:
|
||||
void forceShowWindowOn();
|
||||
|
||||
// Timestep control
|
||||
int currentTimeStep() const;
|
||||
void setCurrentTimeStep( int frameIdx );
|
||||
void setCurrentTimeStepAndUpdate( int frameIdx ) override;
|
||||
bool isTimeStepDependentDataVisibleInThisOrComparisonView() const;
|
||||
size_t timeStepCount();
|
||||
QString timeStepName( int frameIdx ) const override;
|
||||
int currentTimeStep() const;
|
||||
void setCurrentTimeStep( int frameIdx );
|
||||
void setCurrentTimeStepAndUpdate( int frameIdx ) override;
|
||||
bool isTimeStepDependentDataVisibleInThisOrComparisonView() const;
|
||||
size_t timeStepCount();
|
||||
QString timeStepName( int frameIdx ) const override;
|
||||
virtual QStringList timeStepStrings() const;
|
||||
|
||||
// Animation control
|
||||
caf::Signal<> updateAnimations;
|
||||
|
@ -162,7 +162,7 @@ void RimAdvancedSnapshotExportDefinition::getTimeStepStrings( QList<caf::PdmOpti
|
||||
|
||||
QStringList timeSteps;
|
||||
|
||||
timeSteps = view->ownerCase()->timeStepStrings();
|
||||
timeSteps = view->timeStepStrings();
|
||||
|
||||
for ( int i = 0; i < timeSteps.size(); i++ )
|
||||
{
|
||||
|
@ -403,6 +403,8 @@ void RimContourMapProjection::clearResults()
|
||||
m_currentResultTimestep = -1;
|
||||
|
||||
clearResultVariable();
|
||||
|
||||
clearTimeStepRange();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -502,8 +504,8 @@ void RimContourMapProjection::defineEditorAttribute( const caf::PdmFieldHandle*
|
||||
if ( myAttr )
|
||||
{
|
||||
myAttr->m_minimum = 0.2;
|
||||
myAttr->m_maximum = 2.0;
|
||||
myAttr->m_sliderTickCount = 9;
|
||||
myAttr->m_maximum = 20.0;
|
||||
myAttr->m_sliderTickCount = 20;
|
||||
myAttr->m_delaySliderUpdateUntilRelease = true;
|
||||
}
|
||||
}
|
||||
|
@ -109,9 +109,9 @@ protected:
|
||||
bool resultsNeedsUpdating( int timeStep ) const;
|
||||
bool geometryNeedsUpdating() const;
|
||||
bool resultRangeIsValid() const;
|
||||
void clearTimeStepRange();
|
||||
void clearGridMapping();
|
||||
void clearResults();
|
||||
void clearTimeStepRange();
|
||||
|
||||
virtual std::pair<double, double> minmaxValuesAllTimeSteps() = 0;
|
||||
|
||||
|
@ -955,16 +955,16 @@ void RimEclipseCase::setFilesContainingFaults( const std::vector<QString>& pathS
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseCase::ensureReservoirCaseIsOpen()
|
||||
{
|
||||
// Call openReserviorCase, as this is a cheap method to call multiple times
|
||||
// Call openReservoirCase, as this is a cheap method to call multiple times
|
||||
// Add extra testing here if performance issues are seen
|
||||
|
||||
return openReserviorCase();
|
||||
return openReservoirCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimEclipseCase::openReserviorCase()
|
||||
bool RimEclipseCase::openReservoirCase()
|
||||
{
|
||||
if ( !openEclipseGridFile() )
|
||||
{
|
||||
@ -1048,15 +1048,18 @@ bool RimEclipseCase::openReserviorCase()
|
||||
|
||||
createTimeStepFormatString();
|
||||
|
||||
// Associate existing well paths with simulation wells
|
||||
RimProject* proj = RimProject::current();
|
||||
for ( const auto& oilField : proj->oilFields() )
|
||||
if ( !m_readerSettings.skipWellData )
|
||||
{
|
||||
for ( const auto& wellPath : oilField->wellPathCollection()->allWellPaths() )
|
||||
// Associate existing well paths with simulation wells
|
||||
RimProject* proj = RimProject::current();
|
||||
for ( const auto& oilField : proj->oilFields() )
|
||||
{
|
||||
if ( !wellPath->isAssociatedWithSimulationWell() )
|
||||
for ( const auto& wellPath : oilField->wellPathCollection()->allWellPaths() )
|
||||
{
|
||||
wellPath->tryAssociateWithSimulationWell();
|
||||
if ( !wellPath->isAssociatedWithSimulationWell() )
|
||||
{
|
||||
wellPath->tryAssociateWithSimulationWell();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1064,6 +1067,23 @@ bool RimEclipseCase::openReserviorCase()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseCase::reloadEclipseGridFile()
|
||||
{
|
||||
closeReservoirCase();
|
||||
openReservoirCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseCase::closeReservoirCase()
|
||||
{
|
||||
setReservoirData( nullptr );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -1180,6 +1200,14 @@ void RimEclipseCase::setReaderSettings( RifReaderSettings& readerSettings )
|
||||
m_readerSettings = readerSettings;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifReaderSettings RimEclipseCase::readerSettings() const
|
||||
{
|
||||
return m_readerSettings;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -75,8 +75,10 @@ public:
|
||||
void setFilesContainingFaults( const std::vector<QString>& val );
|
||||
|
||||
bool ensureReservoirCaseIsOpen();
|
||||
bool openReserviorCase();
|
||||
bool openReservoirCase();
|
||||
virtual void closeReservoirCase();
|
||||
virtual bool openEclipseGridFile() = 0;
|
||||
virtual void reloadEclipseGridFile();
|
||||
virtual bool importAsciiInputProperties( const QStringList& fileNames );
|
||||
|
||||
RigEclipseCaseData* eclipseCaseData();
|
||||
@ -114,8 +116,6 @@ public:
|
||||
cvf::BoundingBox allCellsBoundingBox() const override;
|
||||
cvf::Vec3d displayModelOffset() const override;
|
||||
|
||||
virtual void reloadEclipseGridFile() = 0;
|
||||
|
||||
double characteristicCellSize() const override;
|
||||
|
||||
std::set<QString> sortedSimWellNames() const;
|
||||
@ -127,7 +127,8 @@ public:
|
||||
void createDisplayModelAndUpdateAllViews();
|
||||
void computeActiveCellsBoundingBox();
|
||||
|
||||
void setReaderSettings( RifReaderSettings& readerSettings );
|
||||
void setReaderSettings( RifReaderSettings& readerSettings );
|
||||
RifReaderSettings readerSettings() const;
|
||||
|
||||
void updateResultAddressCollection();
|
||||
|
||||
|
@ -47,8 +47,6 @@ RimEclipseCaseEnsemble::RimEclipseCaseEnsemble()
|
||||
m_caseCollection->uiCapability()->setUiName( "Cases" );
|
||||
m_caseCollection->uiCapability()->setUiIconFromResourceString( ":/Cases16x16.png" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectedCase, "SelectedCase", "Selected Case" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_viewCollection, "ViewCollection", "Views" );
|
||||
m_viewCollection = new RimEclipseViewCollection;
|
||||
|
||||
@ -106,6 +104,16 @@ bool RimEclipseCaseEnsemble::contains( RimEclipseCase* reservoir ) const
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RimEclipseCaseEnsemble::findByDescription( const QString& caseDescription ) const
|
||||
{
|
||||
if ( !m_caseCollection ) return nullptr;
|
||||
|
||||
return m_caseCollection->findByDescription( caseDescription );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -116,6 +124,24 @@ std::vector<RimEclipseCase*> RimEclipseCaseEnsemble::cases() const
|
||||
return m_caseCollection->reservoirs.childrenByType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RimEclipseCase*> RimEclipseCaseEnsemble::casesInViews() const
|
||||
{
|
||||
if ( !m_caseCollection ) return {};
|
||||
if ( !m_viewCollection || m_viewCollection->isEmpty() ) return {};
|
||||
|
||||
std::set<RimEclipseCase*> retCases;
|
||||
|
||||
for ( auto view : m_viewCollection->views() )
|
||||
{
|
||||
if ( view->eclipseCase() != nullptr ) retCases.insert( view->eclipseCase() );
|
||||
}
|
||||
|
||||
return retCases;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -140,43 +166,6 @@ RimEclipseView* RimEclipseCaseEnsemble::addViewForCase( RimEclipseCase* eclipseC
|
||||
return m_viewCollection->addView( eclipseCase );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimEclipseCaseEnsemble::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_selectedCase )
|
||||
{
|
||||
for ( auto eclCase : cases() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( eclCase->caseUserDescription(), eclCase, false, eclCase->uiIconProvider() ) );
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseCaseEnsemble::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_selectedCase )
|
||||
{
|
||||
for ( auto view : m_viewCollection->views() )
|
||||
{
|
||||
view->setEclipseCase( m_selectedCase() );
|
||||
view->loadDataAndUpdate();
|
||||
view->updateGridBoxData();
|
||||
view->updateAnnotationItems();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -210,4 +199,14 @@ void RimEclipseCaseEnsemble::addWellTargetsGenerator( RimWellTargetCandidatesGen
|
||||
void RimEclipseCaseEnsemble::addStatisticsContourMap( RimStatisticsContourMap* statisticsContourMap )
|
||||
{
|
||||
m_statisticsContourMaps.push_back( statisticsContourMap );
|
||||
statisticsContourMap->setName( QString( "Statistics Contour Map #%1" ).arg( m_statisticsContourMaps.size() ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseCaseEnsemble::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( nameField() );
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
class RimCaseCollection;
|
||||
class RimEclipseCase;
|
||||
class RimEclipseView;
|
||||
@ -49,7 +51,10 @@ public:
|
||||
void removeCase( RimEclipseCase* reservoir );
|
||||
bool contains( RimEclipseCase* reservoir ) const;
|
||||
|
||||
RimEclipseCase* findByDescription( const QString& description ) const;
|
||||
|
||||
std::vector<RimEclipseCase*> cases() const;
|
||||
std::set<RimEclipseCase*> casesInViews() const;
|
||||
|
||||
void addView( RimEclipseView* view );
|
||||
RimEclipseView* addViewForCase( RimEclipseCase* eclipseCase );
|
||||
@ -62,9 +67,8 @@ public:
|
||||
void addStatisticsContourMap( RimStatisticsContourMap* statisticsContourMap );
|
||||
|
||||
protected:
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<int> m_groupId;
|
||||
|
@ -235,15 +235,6 @@ bool RimEclipseInputCase::openEclipseGridFile()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseInputCase::reloadEclipseGridFile()
|
||||
{
|
||||
setReservoirData( nullptr );
|
||||
openReserviorCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -50,7 +50,6 @@ public:
|
||||
|
||||
// RimCase overrides
|
||||
bool openEclipseGridFile() override;
|
||||
void reloadEclipseGridFile() override;
|
||||
|
||||
// Overrides from RimCase
|
||||
QString locationOnDisc() const override;
|
||||
|
@ -287,12 +287,11 @@ bool RimEclipseResultCase::importAsciiInputProperties( const QStringList& fileNa
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseResultCase::reloadEclipseGridFile()
|
||||
void RimEclipseResultCase::closeReservoirCase()
|
||||
{
|
||||
RimEclipseCase::closeReservoirCase();
|
||||
m_gridAndWellDataIsReadFromFile = false;
|
||||
m_activeCellInfoIsReadFromFile = false;
|
||||
setReservoirData( nullptr );
|
||||
openReserviorCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -55,11 +55,11 @@ public:
|
||||
bool hasSourSimFile();
|
||||
|
||||
bool openEclipseGridFile() override;
|
||||
void closeReservoirCase() override;
|
||||
|
||||
bool importGridAndResultMetaData( bool showTimeStepFilter );
|
||||
bool importAsciiInputProperties( const QStringList& fileNames ) override;
|
||||
|
||||
void reloadEclipseGridFile() override;
|
||||
bool openAndReadActiveCellData( RigEclipseCaseData* mainEclipseCase );
|
||||
void readGridDimensions( std::vector<std::vector<int>>& gridDimensions );
|
||||
|
||||
|
@ -202,15 +202,6 @@ bool RimEclipseStatisticsCase::openEclipseGridFile()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEclipseStatisticsCase::reloadEclipseGridFile()
|
||||
{
|
||||
setReservoirData( nullptr );
|
||||
openReserviorCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -561,7 +552,10 @@ void RimEclipseStatisticsCase::defineUiOrdering( QString uiConfigName, caf::PdmU
|
||||
uiOrdering.skipRemainingFields();
|
||||
}
|
||||
|
||||
QList<caf::PdmOptionItemInfo> toOptionList( const QStringList& varList )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimEclipseStatisticsCase::toOptionList( const QStringList& varList )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> optionList;
|
||||
int i;
|
||||
@ -904,9 +898,7 @@ void RimEclipseStatisticsCase::updateSelectionListVisibilities()
|
||||
{
|
||||
bool isLocked = hasComputedStatistics();
|
||||
m_resultType.uiCapability()->setUiHidden( isLocked );
|
||||
m_porosityModel.uiCapability()->setUiHidden(
|
||||
isLocked ); // ||
|
||||
// !caseGroup()->mainCase()->reservoirData()->results(RiaDefines::FRACTURE_MODEL)->resultCount()
|
||||
m_porosityModel.uiCapability()->setUiHidden( isLocked );
|
||||
|
||||
m_selectedDynamicProperties.uiCapability()->setUiHidden( isLocked || m_porosityModel() != RiaDefines::PorosityModelType::MATRIX_MODEL ||
|
||||
m_resultType() != RiaDefines::ResultCatType::DYNAMIC_NATIVE );
|
||||
|
@ -72,7 +72,6 @@ public:
|
||||
void updateConnectedEditorsAndReservoirViews();
|
||||
|
||||
bool openEclipseGridFile() override;
|
||||
void reloadEclipseGridFile() override;
|
||||
|
||||
RimCaseCollection* parentStatisticsCaseCollection() const;
|
||||
|
||||
@ -106,6 +105,8 @@ private:
|
||||
void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||
void initializeSelectedTimeSteps();
|
||||
|
||||
static QList<caf::PdmOptionItemInfo> toOptionList( const QStringList& varList );
|
||||
|
||||
private:
|
||||
caf::PdmField<caf::AppEnum<DataSourceType>> m_dataSourceForStatistics;
|
||||
|
||||
|
@ -561,6 +561,38 @@ void RimEclipseView::onUpdateScaleTransform()
|
||||
if ( nativeOrOverrideViewer() ) nativeOrOverrideViewer()->updateCachedValuesInScene();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<size_t> RimEclipseView::activeTimeStepIndices( bool propertyFiltersActive )
|
||||
{
|
||||
std::vector<size_t> timeStepIndices;
|
||||
|
||||
// First entry in this vector is used to define the geometry only result mode with no results.
|
||||
timeStepIndices.push_back( 0 );
|
||||
|
||||
// Find the number of time frames the animation needs to show the requested data.
|
||||
if ( ( isTimeStepDependentDataVisibleInThisOrComparisonView() && currentGridCellResults()->maxTimeStepCount() > 0 ) )
|
||||
{
|
||||
CVF_ASSERT( currentGridCellResults() );
|
||||
|
||||
size_t i;
|
||||
for ( i = 0; i < currentGridCellResults()->maxTimeStepCount(); i++ )
|
||||
{
|
||||
timeStepIndices.push_back( i );
|
||||
}
|
||||
}
|
||||
else if ( cellResult()->hasStaticResult() || cellEdgeResult()->hasResult() || propertyFiltersActive ||
|
||||
intersectionCollection()->hasAnyActiveSeparateResults() ||
|
||||
( surfaceInViewCollection() && surfaceInViewCollection()->hasAnyActiveSeparateResults() ) )
|
||||
{
|
||||
// The one and only static result entry
|
||||
timeStepIndices.push_back( 0 );
|
||||
}
|
||||
|
||||
return timeStepIndices;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Create display model,
|
||||
/// or at least empty scenes as frames that is delivered to the viewer
|
||||
@ -585,30 +617,7 @@ void RimEclipseView::onCreateDisplayModel()
|
||||
|
||||
// Define a vector containing time step indices to produce geometry for.
|
||||
// First entry in this vector is used to define the geometry only result mode with no results.
|
||||
std::vector<size_t> timeStepIndices;
|
||||
|
||||
// The one and only geometry entry
|
||||
timeStepIndices.push_back( 0 );
|
||||
|
||||
// Find the number of time frames the animation needs to show the requested data.
|
||||
|
||||
if ( ( isTimeStepDependentDataVisibleInThisOrComparisonView() && currentGridCellResults()->maxTimeStepCount() > 0 ) )
|
||||
{
|
||||
CVF_ASSERT( currentGridCellResults() );
|
||||
|
||||
size_t i;
|
||||
for ( i = 0; i < currentGridCellResults()->maxTimeStepCount(); i++ )
|
||||
{
|
||||
timeStepIndices.push_back( i );
|
||||
}
|
||||
}
|
||||
else if ( cellResult()->hasStaticResult() || cellEdgeResult()->hasResult() || propertyFiltersActive ||
|
||||
intersectionCollection()->hasAnyActiveSeparateResults() ||
|
||||
( surfaceInViewCollection() && surfaceInViewCollection()->hasAnyActiveSeparateResults() ) )
|
||||
{
|
||||
// The one and only static result entry
|
||||
timeStepIndices.push_back( 0 );
|
||||
}
|
||||
std::vector<size_t> timeStepIndices = activeTimeStepIndices( propertyFiltersActive );
|
||||
|
||||
cvf::Collection<cvf::ModelBasicList> frameModels;
|
||||
size_t timeIdx;
|
||||
@ -1195,7 +1204,7 @@ void RimEclipseView::onLoadDataAndUpdate()
|
||||
|
||||
if ( eclipseCase() )
|
||||
{
|
||||
if ( !eclipseCase()->openReserviorCase() )
|
||||
if ( !eclipseCase()->openReservoirCase() )
|
||||
{
|
||||
RiaLogging::warning( "Could not open the Eclipse Grid file: \n" + eclipseCase()->gridFileName() );
|
||||
setEclipseCase( nullptr );
|
||||
|
@ -184,6 +184,8 @@ protected:
|
||||
void onLoadDataAndUpdate() override;
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
|
||||
virtual std::vector<size_t> activeTimeStepIndices( bool propertyFiltersActive );
|
||||
|
||||
bool isShowingActiveCellsOnly() override;
|
||||
void onUpdateDisplayModelForCurrentTimeStep() override;
|
||||
void updateVisibleCellColors();
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "Rim3dView.h"
|
||||
#include "RimCase.h"
|
||||
#include "RimCellEdgeColors.h"
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCellColors.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimFaultInViewCollection.h"
|
||||
@ -92,13 +93,6 @@ RimEclipseView* RimEclipseViewCollection::addView( RimEclipseCase* eclipseCase )
|
||||
|
||||
view->setEclipseCase( eclipseCase );
|
||||
|
||||
// Set default values
|
||||
if ( view->currentGridCellResults() )
|
||||
{
|
||||
auto defaultResult = view->currentGridCellResults()->defaultResult();
|
||||
view->cellResult()->setFromEclipseResultAddress( defaultResult );
|
||||
}
|
||||
|
||||
auto prefs = RiaPreferences::current();
|
||||
view->faultCollection()->setActive( prefs->enableFaultsByDefault() );
|
||||
|
||||
@ -114,6 +108,13 @@ RimEclipseView* RimEclipseViewCollection::addView( RimEclipseCase* eclipseCase )
|
||||
|
||||
view->loadDataAndUpdate();
|
||||
|
||||
// Set default values
|
||||
if ( view->currentGridCellResults() )
|
||||
{
|
||||
auto defaultResult = view->currentGridCellResults()->defaultResult();
|
||||
view->cellResult()->setFromEclipseResultAddress( defaultResult );
|
||||
}
|
||||
|
||||
updateConnectedEditors();
|
||||
|
||||
return view;
|
||||
|
@ -174,15 +174,6 @@ bool RimEmCase::openEclipseGridFile()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEmCase::reloadEclipseGridFile()
|
||||
{
|
||||
setReservoirData( nullptr );
|
||||
openReserviorCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -46,7 +46,6 @@ public:
|
||||
~RimEmCase() override;
|
||||
|
||||
bool openEclipseGridFile() override;
|
||||
void reloadEclipseGridFile() override;
|
||||
|
||||
QString locationOnDisc() const override;
|
||||
|
||||
|
@ -176,7 +176,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo()
|
||||
// When reading active cell info, only the total cell count is tested for consistency
|
||||
|
||||
RimEclipseCase* mainCase = caseCollection()->reservoirs[0];
|
||||
if ( !mainCase->openReserviorCase() )
|
||||
if ( !mainCase->openReservoirCase() )
|
||||
{
|
||||
QString errorMessage = QString( "Could not open the Eclipse Grid file: \n" ) + mainCase->gridFileName() + "\n" +
|
||||
"Current working directory is: \n" + QDir::currentPath();
|
||||
|
@ -111,15 +111,6 @@ bool RimRoffCase::openEclipseGridFile()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimRoffCase::reloadEclipseGridFile()
|
||||
{
|
||||
setReservoirData( nullptr );
|
||||
openReserviorCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -38,7 +38,7 @@ public:
|
||||
~RimRoffCase() override;
|
||||
|
||||
bool openEclipseGridFile() override;
|
||||
void reloadEclipseGridFile() override;
|
||||
|
||||
bool importAsciiInputProperties( const QStringList& fileNames ) override;
|
||||
|
||||
QString locationOnDisc() const override;
|
||||
|
@ -19,8 +19,13 @@
|
||||
#include "RimStatisticsContourMap.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferencesGrid.h"
|
||||
#include "RiaStatisticsTools.h"
|
||||
|
||||
#include "RicNewStatisticsContourMapViewFeature.h"
|
||||
|
||||
#include "RifReaderSettings.h"
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigContourMapCalculator.h"
|
||||
#include "RigContourMapGrid.h"
|
||||
@ -35,11 +40,17 @@
|
||||
#include "RimEclipseContourMapProjection.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSimWellInViewCollection.h"
|
||||
#include "RimStatisticsContourMapProjection.h"
|
||||
#include "RimStatisticsContourMapView.h"
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "cafCmdFeatureMenuBuilder.h"
|
||||
#include "cafPdmUiDoubleSliderEditor.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTreeSelectionEditor.h"
|
||||
#include "cafProgressInfo.h"
|
||||
|
||||
#include <limits>
|
||||
@ -66,14 +77,18 @@ void caf::AppEnum<RimStatisticsContourMap::StatisticsType>::setUp()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimStatisticsContourMap::RimStatisticsContourMap()
|
||||
{
|
||||
CAF_PDM_InitObject( "StatisticsContourMap", ":/Histogram16x16.png" );
|
||||
CAF_PDM_InitObject( "Statistics Contour Map", ":/Histogram16x16.png" );
|
||||
|
||||
CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 0.9, "Sample Spacing Factor" );
|
||||
CAF_PDM_InitField( &m_boundingBoxExpPercent, "BoundingBoxExpPercent", 5.0, "Bounding Box Expansion (%)" );
|
||||
m_boundingBoxExpPercent.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 2.0, "Sample Spacing Factor" );
|
||||
m_relativeSampleSpacing.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_resultAggregation, "ResultAggregation", "Result Aggregation" );
|
||||
|
||||
CAF_PDM_InitField( &m_timeStep, "TimeStep", 0, "Time Step" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_selectedTimeSteps, "SelectedTimeSteps", "Time Step Selection" );
|
||||
m_selectedTimeSteps.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_resultDefinition, "ResultDefinition", "" );
|
||||
m_resultDefinition.uiCapability()->setUiTreeChildrenHidden( true );
|
||||
@ -82,9 +97,20 @@ RimStatisticsContourMap::RimStatisticsContourMap()
|
||||
m_resultDefinition->setResultType( RiaDefines::ResultCatType::DYNAMIC_NATIVE );
|
||||
m_resultDefinition->setResultVariable( "SOIL" );
|
||||
|
||||
CAF_PDM_InitField( &m_primaryCase,
|
||||
"PrimaryCase",
|
||||
RiaResultNames::undefinedResultName(),
|
||||
"Primary Case",
|
||||
"",
|
||||
"Eclipse Case used for wells and faults shown in views, initializing available result list, timesteps, etc." );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_computeStatisticsButton, "ComputeStatisticsButton", "" );
|
||||
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_computeStatisticsButton );
|
||||
m_computeStatisticsButton = false;
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_views, "ContourMapViews", "Contour Maps", ":/CrossSection16x16.png" );
|
||||
|
||||
setDeletable( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -92,12 +118,31 @@ RimStatisticsContourMap::RimStatisticsContourMap()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMap::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_relativeSampleSpacing );
|
||||
uiOrdering.add( &m_resultAggregation );
|
||||
uiOrdering.add( &m_timeStep );
|
||||
if ( ( eclipseCase() == nullptr ) && ( ensemble()->cases().size() > 0 ) )
|
||||
{
|
||||
auto selCase = ensemble()->cases().front();
|
||||
setEclipseCase( selCase );
|
||||
m_primaryCase = selCase->caseUserDescription();
|
||||
}
|
||||
|
||||
caf::PdmUiGroup* resultDefinitionGroup = uiOrdering.addNewGroup( "Result Definition" );
|
||||
m_resultDefinition->uiOrdering( uiConfigName, *resultDefinitionGroup );
|
||||
uiOrdering.add( nameField() );
|
||||
|
||||
auto genGrp = uiOrdering.addNewGroup( "General" );
|
||||
|
||||
genGrp->add( &m_resultAggregation );
|
||||
genGrp->add( &m_primaryCase );
|
||||
genGrp->add( &m_relativeSampleSpacing );
|
||||
genGrp->add( &m_boundingBoxExpPercent );
|
||||
|
||||
auto tsGroup = uiOrdering.addNewGroup( "Time Step Selection" );
|
||||
tsGroup->setCollapsedByDefault();
|
||||
tsGroup->add( &m_selectedTimeSteps );
|
||||
|
||||
if ( !isColumnResult() )
|
||||
{
|
||||
auto resultDefinitionGroup = uiOrdering.addNewGroup( "Result Definition" );
|
||||
m_resultDefinition->uiOrdering( uiConfigName, *resultDefinitionGroup );
|
||||
}
|
||||
|
||||
uiOrdering.add( &m_computeStatisticsButton );
|
||||
}
|
||||
@ -108,6 +153,13 @@ void RimStatisticsContourMap::defineUiOrdering( QString uiConfigName, caf::PdmUi
|
||||
void RimStatisticsContourMap::setEclipseCase( RimEclipseCase* eclipseCase )
|
||||
{
|
||||
m_resultDefinition->setEclipseCase( eclipseCase );
|
||||
if ( eclipseCase ) m_primaryCase = eclipseCase->caseUserDescription();
|
||||
|
||||
for ( auto& view : m_views )
|
||||
{
|
||||
view->setEclipseCase( eclipseCase );
|
||||
}
|
||||
m_resultDefinition->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -127,7 +179,66 @@ void RimStatisticsContourMap::fieldChangedByUi( const caf::PdmFieldHandle* chang
|
||||
{
|
||||
computeStatistics();
|
||||
m_computeStatisticsButton = false;
|
||||
|
||||
if ( m_views.empty() )
|
||||
{
|
||||
auto view = RicNewStatisticsContourMapViewFeature::createAndAddView( this );
|
||||
updateConnectedEditors();
|
||||
Riu3DMainWindowTools::selectAsCurrentItem( view );
|
||||
Riu3DMainWindowTools::setExpanded( this );
|
||||
Riu3DMainWindowTools::setExpanded( view );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( auto& view : m_views )
|
||||
{
|
||||
auto proj = dynamic_cast<RimStatisticsContourMapProjection*>( view->contourMapProjection() );
|
||||
if ( proj != nullptr )
|
||||
proj->clearGridMappingAndRedraw();
|
||||
else
|
||||
view->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( &m_primaryCase == changedField )
|
||||
{
|
||||
switchToSelectedSourceCase();
|
||||
|
||||
// Update views
|
||||
for ( auto& view : m_views )
|
||||
{
|
||||
view->wellCollection()->wells.deleteChildren();
|
||||
view->updateDisplayModelForWellResults();
|
||||
view->wellCollection()->updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RimStatisticsContourMap::switchToSelectedSourceCase()
|
||||
{
|
||||
RimEclipseCase* sourceResultCase = ensemble()->findByDescription( m_primaryCase );
|
||||
if ( sourceResultCase == nullptr )
|
||||
{
|
||||
setEclipseCase( nullptr );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if ( sourceResultCase != eclipseCase() )
|
||||
{
|
||||
auto oldCase = eclipseCase();
|
||||
sourceResultCase->ensureReservoirCaseIsOpen();
|
||||
setEclipseCase( sourceResultCase );
|
||||
|
||||
if ( oldCase && !ensemble()->casesInViews().contains( oldCase ) )
|
||||
{
|
||||
oldCase->closeReservoirCase();
|
||||
}
|
||||
}
|
||||
|
||||
return sourceResultCase;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -137,14 +248,30 @@ QList<caf::PdmOptionItemInfo> RimStatisticsContourMap::calculateValueOptions( co
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_timeStep )
|
||||
if ( &m_selectedTimeSteps == fieldNeedingOptions )
|
||||
{
|
||||
auto ensemble = firstAncestorOrThisOfType<RimEclipseCaseEnsemble>();
|
||||
if ( ensemble && !ensemble->cases().empty() )
|
||||
if ( auto eCase = eclipseCase() )
|
||||
{
|
||||
RimEclipseCase* firstEclipseCase = ensemble->cases().front();
|
||||
RimTools::timeStepsForCase( firstEclipseCase, &options );
|
||||
const auto timeStepStrings = eCase->timeStepStrings();
|
||||
|
||||
int index = 0;
|
||||
for ( const auto& text : timeStepStrings )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( text, index++ ) );
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
else if ( &m_primaryCase == fieldNeedingOptions )
|
||||
{
|
||||
QStringList sourceCaseNames;
|
||||
sourceCaseNames += RiaResultNames::undefinedResultName();
|
||||
|
||||
for ( auto eCase : ensemble()->cases() )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( eCase->caseUserDescription(), eCase->caseUserDescription() ) );
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
return options;
|
||||
@ -162,14 +289,22 @@ void RimStatisticsContourMap::defineEditorAttribute( const caf::PdmFieldHandle*
|
||||
attrib->m_buttonText = "Compute";
|
||||
}
|
||||
}
|
||||
|
||||
if ( &m_relativeSampleSpacing == field )
|
||||
else if ( &m_relativeSampleSpacing == field )
|
||||
{
|
||||
if ( auto myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
|
||||
{
|
||||
myAttr->m_minimum = 0.2;
|
||||
myAttr->m_maximum = 2.0;
|
||||
myAttr->m_sliderTickCount = 9;
|
||||
myAttr->m_maximum = 20.0;
|
||||
myAttr->m_sliderTickCount = 20;
|
||||
myAttr->m_delaySliderUpdateUntilRelease = true;
|
||||
}
|
||||
}
|
||||
else if ( &m_boundingBoxExpPercent == field )
|
||||
{
|
||||
if ( auto myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
|
||||
{
|
||||
myAttr->m_minimum = 0.0;
|
||||
myAttr->m_maximum = 25.0;
|
||||
myAttr->m_delaySliderUpdateUntilRelease = true;
|
||||
}
|
||||
}
|
||||
@ -183,75 +318,26 @@ void RimStatisticsContourMap::initAfterRead()
|
||||
auto ensemble = firstAncestorOrThisOfType<RimEclipseCaseEnsemble>();
|
||||
if ( !ensemble ) return;
|
||||
|
||||
if ( ensemble->cases().empty() ) return;
|
||||
switchToSelectedSourceCase();
|
||||
|
||||
RimEclipseCase* eclipseCase = ensemble->cases().front();
|
||||
setEclipseCase( eclipseCase );
|
||||
for ( auto view : m_views )
|
||||
{
|
||||
view->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMap::computeStatistics()
|
||||
void RimStatisticsContourMap::doStatisticsCalculation( std::map<size_t, std::vector<std::vector<double>>>& timestepResults )
|
||||
{
|
||||
RiaLogging::info( "Computing statistics" );
|
||||
auto ensemble = firstAncestorOrThisOfType<RimEclipseCaseEnsemble>();
|
||||
if ( !ensemble ) return;
|
||||
m_timeResults.clear();
|
||||
|
||||
if ( ensemble->cases().empty() ) return;
|
||||
|
||||
RimEclipseCase* firstEclipseCase = ensemble->cases().front();
|
||||
firstEclipseCase->ensureReservoirCaseIsOpen();
|
||||
|
||||
RigContourMapCalculator::ResultAggregationType resultAggregation = m_resultAggregation();
|
||||
|
||||
cvf::BoundingBox gridBoundingBox = firstEclipseCase->activeCellsBoundingBox();
|
||||
|
||||
auto computeSampleSpacing = []( auto ec, double relativeSampleSpacing )
|
||||
for ( const auto& [timeStep, res] : timestepResults )
|
||||
{
|
||||
if ( ec )
|
||||
{
|
||||
if ( auto mainGrid = ec->mainGrid() )
|
||||
{
|
||||
return relativeSampleSpacing * mainGrid->characteristicIJCellSize();
|
||||
}
|
||||
}
|
||||
if ( res.empty() ) continue;
|
||||
|
||||
return 0.0;
|
||||
};
|
||||
|
||||
double sampleSpacing = computeSampleSpacing( firstEclipseCase, m_relativeSampleSpacing() );
|
||||
|
||||
auto contourMapGrid = std::make_unique<RigContourMapGrid>( gridBoundingBox, sampleSpacing );
|
||||
|
||||
auto firstEclipseCaseData = firstEclipseCase->eclipseCaseData();
|
||||
auto firstResultData = firstEclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||
|
||||
RigEclipseContourMapProjection contourMapProjection( *contourMapGrid, *firstEclipseCaseData, *firstResultData );
|
||||
m_gridMapping = contourMapProjection.generateGridMapping( resultAggregation, {} );
|
||||
|
||||
std::vector<std::vector<double>> results;
|
||||
for ( RimEclipseCase* eclipseCase : ensemble->cases() )
|
||||
{
|
||||
if ( eclipseCase->ensureReservoirCaseIsOpen() )
|
||||
{
|
||||
RiaLogging::info( QString( "Grid: %1" ).arg( eclipseCase->caseUserDescription() ) );
|
||||
|
||||
auto eclipseCaseData = eclipseCase->eclipseCaseData();
|
||||
auto resultData = eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||
|
||||
RigEclipseContourMapProjection contourMapProjection( *contourMapGrid, *eclipseCaseData, *resultData );
|
||||
contourMapProjection.generateGridMapping( resultAggregation, {} );
|
||||
|
||||
std::vector<double> result =
|
||||
contourMapProjection.generateResults( m_resultDefinition()->eclipseResultAddress(), resultAggregation, m_timeStep() );
|
||||
results.push_back( result );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !results.empty() )
|
||||
{
|
||||
int nCells = static_cast<int>( results[0].size() );
|
||||
int nCells = static_cast<int>( res[0].size() );
|
||||
std::vector<double> p10Results( nCells, std::numeric_limits<double>::infinity() );
|
||||
std::vector<double> p50Results( nCells, std::numeric_limits<double>::infinity() );
|
||||
std::vector<double> p90Results( nCells, std::numeric_limits<double>::infinity() );
|
||||
@ -259,13 +345,19 @@ void RimStatisticsContourMap::computeStatistics()
|
||||
std::vector<double> minResults( nCells, std::numeric_limits<double>::infinity() );
|
||||
std::vector<double> maxResults( nCells, std::numeric_limits<double>::infinity() );
|
||||
|
||||
const size_t numSamples = res.size();
|
||||
|
||||
// Clang version 16.0.6 does not handle OpenMP here, the compiler crashes.
|
||||
#ifndef __clang__
|
||||
#pragma omp parallel for
|
||||
#endif
|
||||
for ( int i = 0; i < nCells; i++ )
|
||||
{
|
||||
size_t numSamples = results.size();
|
||||
std::vector<double> samples( numSamples, 0.0 );
|
||||
for ( size_t s = 0; s < numSamples; s++ )
|
||||
samples[s] = results[s][i];
|
||||
{
|
||||
samples[s] = res[s][i];
|
||||
}
|
||||
|
||||
double p10 = std::numeric_limits<double>::infinity();
|
||||
double p50 = std::numeric_limits<double>::infinity();
|
||||
@ -286,25 +378,110 @@ void RimStatisticsContourMap::computeStatistics()
|
||||
if ( RiaStatisticsTools::isValidNumber( maxValue ) && maxValue > -std::numeric_limits<double>::max() ) maxResults[i] = maxValue;
|
||||
}
|
||||
|
||||
m_contourMapGrid = std::move( contourMapGrid );
|
||||
m_result[StatisticsType::P10] = p10Results;
|
||||
m_result[StatisticsType::P50] = p50Results;
|
||||
m_result[StatisticsType::P90] = p90Results;
|
||||
m_result[StatisticsType::MEAN] = meanResults;
|
||||
m_result[StatisticsType::MIN] = minResults;
|
||||
m_result[StatisticsType::MAX] = maxResults;
|
||||
m_timeResults[timeStep][StatisticsType::P10] = p10Results;
|
||||
m_timeResults[timeStep][StatisticsType::P50] = p50Results;
|
||||
m_timeResults[timeStep][StatisticsType::P90] = p90Results;
|
||||
m_timeResults[timeStep][StatisticsType::MEAN] = meanResults;
|
||||
m_timeResults[timeStep][StatisticsType::MIN] = minResults;
|
||||
m_timeResults[timeStep][StatisticsType::MAX] = maxResults;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMap::computeStatistics()
|
||||
{
|
||||
RiaLogging::info( "Computing statistics" );
|
||||
auto ensemble = firstAncestorOrThisOfType<RimEclipseCaseEnsemble>();
|
||||
if ( !ensemble ) return;
|
||||
|
||||
if ( ensemble->cases().empty() ) return;
|
||||
if ( eclipseCase() == nullptr ) return;
|
||||
|
||||
RigContourMapCalculator::ResultAggregationType resultAggregation = m_resultAggregation();
|
||||
|
||||
cvf::BoundingBox gridBoundingBox = eclipseCase()->activeCellsBoundingBox();
|
||||
gridBoundingBox.expandPercent( m_boundingBoxExpPercent() );
|
||||
|
||||
double sampleSpacing = 1.0;
|
||||
if ( auto mainGrid = eclipseCase()->mainGrid() )
|
||||
{
|
||||
sampleSpacing = m_relativeSampleSpacing * mainGrid->characteristicIJCellSize();
|
||||
}
|
||||
|
||||
auto contourMapGrid = std::make_unique<RigContourMapGrid>( gridBoundingBox, sampleSpacing );
|
||||
|
||||
auto firstEclipseCaseData = eclipseCase()->eclipseCaseData();
|
||||
auto firstResultData = firstEclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||
|
||||
RigEclipseContourMapProjection contourMapProjection( *contourMapGrid, *firstEclipseCaseData, *firstResultData );
|
||||
m_gridMapping = contourMapProjection.generateGridMapping( resultAggregation, {} );
|
||||
|
||||
const size_t nCases = ensemble->cases().size();
|
||||
|
||||
std::map<size_t, std::vector<std::vector<double>>> timestep_results;
|
||||
|
||||
caf::ProgressInfo progInfo( nCases, QString( "Reading Eclipse Ensemble" ) );
|
||||
|
||||
auto readerSettings = RiaPreferencesGrid::current()->gridOnlyReaderSettings();
|
||||
auto casesInViews = ensemble->casesInViews();
|
||||
|
||||
int i = 1;
|
||||
for ( RimEclipseCase* eCase : ensemble->cases() )
|
||||
{
|
||||
auto task = progInfo.task( QString( "Processing Case %1 of %2" ).arg( i++ ).arg( nCases ) );
|
||||
|
||||
RifReaderSettings oldSettings = eCase->readerSettings();
|
||||
eCase->setReaderSettings( readerSettings );
|
||||
|
||||
if ( eCase->ensureReservoirCaseIsOpen() )
|
||||
{
|
||||
RiaLogging::info( QString( "Grid: %1" ).arg( eCase->caseUserDescription() ) );
|
||||
|
||||
auto eclipseCaseData = eCase->eclipseCaseData();
|
||||
auto resultData = eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
|
||||
|
||||
RigEclipseContourMapProjection contourMapProjection( *contourMapGrid, *eclipseCaseData, *resultData );
|
||||
contourMapProjection.generateGridMapping( resultAggregation, {} );
|
||||
|
||||
if ( m_resultDefinition()->hasDynamicResult() )
|
||||
{
|
||||
for ( auto ts : selectedTimeSteps() )
|
||||
{
|
||||
std::vector<double> result =
|
||||
contourMapProjection.generateResults( m_resultDefinition()->eclipseResultAddress(), resultAggregation, ts );
|
||||
timestep_results[ts].push_back( result );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<double> result =
|
||||
contourMapProjection.generateResults( m_resultDefinition()->eclipseResultAddress(), resultAggregation, 0 );
|
||||
timestep_results[0].push_back( result );
|
||||
}
|
||||
}
|
||||
eCase->setReaderSettings( oldSettings );
|
||||
|
||||
if ( eCase->views().empty() && eCase != eclipseCase() && !casesInViews.contains( eCase ) )
|
||||
{
|
||||
eCase->closeReservoirCase();
|
||||
}
|
||||
}
|
||||
|
||||
m_contourMapGrid = std::move( contourMapGrid );
|
||||
|
||||
doStatisticsCalculation( timestep_results );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RimStatisticsContourMap::eclipseCase() const
|
||||
{
|
||||
auto ensemble = firstAncestorOrThisOfType<RimEclipseCaseEnsemble>();
|
||||
if ( !ensemble || ensemble->cases().empty() ) return nullptr;
|
||||
if ( !m_resultDefinition() ) return nullptr;
|
||||
|
||||
return ensemble->cases().front();
|
||||
return m_resultDefinition->eclipseCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -326,10 +503,53 @@ RigContourMapGrid* RimStatisticsContourMap::contourMapGrid() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RimStatisticsContourMap::result( StatisticsType statisticsType ) const
|
||||
std::vector<double> RimStatisticsContourMap::result( size_t timeStep, StatisticsType statisticsType ) const
|
||||
{
|
||||
if ( auto it = m_result.find( statisticsType ); it != m_result.end() ) return it->second;
|
||||
return {};
|
||||
auto realTimeSteps = selectedTimeSteps();
|
||||
if ( timeStep >= realTimeSteps.size() ) return {};
|
||||
|
||||
timeStep = (size_t)realTimeSteps[timeStep];
|
||||
|
||||
if ( !m_timeResults.contains( timeStep ) ) return {};
|
||||
|
||||
if ( !m_timeResults.at( timeStep ).contains( statisticsType ) ) return {};
|
||||
|
||||
return m_timeResults.at( timeStep ).at( statisticsType );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<int> RimStatisticsContourMap::selectedTimeSteps() const
|
||||
{
|
||||
auto steps = m_selectedTimeSteps();
|
||||
if ( m_selectedTimeSteps().empty() )
|
||||
{
|
||||
if ( eclipseCase() )
|
||||
{
|
||||
for ( int i = 0; i < (int)eclipseCase()->timeStepStrings().size(); i++ )
|
||||
{
|
||||
steps.push_back( i );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::sort( steps.begin(), steps.end() );
|
||||
}
|
||||
return steps;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimStatisticsContourMap::timeStepName( int timeStep ) const
|
||||
{
|
||||
if ( eclipseCase() == nullptr ) return "";
|
||||
|
||||
if ( ( timeStep < 0 ) || ( timeStep >= eclipseCase()->timeStepStrings().size() ) ) return "";
|
||||
|
||||
return eclipseCase()->timeStepName( timeStep );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -353,6 +573,7 @@ QString RimStatisticsContourMap::resultAggregationText() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimStatisticsContourMap::resultVariable() const
|
||||
{
|
||||
if ( m_resultDefinition().isNull() ) return "";
|
||||
return m_resultDefinition()->resultVariable();
|
||||
}
|
||||
|
||||
@ -371,3 +592,16 @@ double RimStatisticsContourMap::sampleSpacingFactor() const
|
||||
{
|
||||
return m_relativeSampleSpacing;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMap::addView( RimStatisticsContourMapView* view )
|
||||
{
|
||||
// make sure to update the other views as the calculated data might have changed
|
||||
for ( auto view : m_views )
|
||||
{
|
||||
view->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
m_views.push_back( view );
|
||||
}
|
||||
|
@ -18,8 +18,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RimNamedObject.h"
|
||||
#include "cafPdmChildArrayField.h"
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "RimContourMapProjection.h"
|
||||
|
||||
@ -28,13 +29,15 @@
|
||||
class RimEclipseCase;
|
||||
class RimEclipseResultDefinition;
|
||||
class RimEclipseCaseEnsemble;
|
||||
class RimEclipseContourMapView;
|
||||
class RimStatisticsContourMapView;
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RimStatisticsContourMap : public caf::PdmObject
|
||||
class RimStatisticsContourMap : public RimNamedObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
@ -57,9 +60,9 @@ public:
|
||||
RimEclipseCaseEnsemble* ensemble() const;
|
||||
|
||||
RigContourMapGrid* contourMapGrid() const;
|
||||
std::vector<double> result( StatisticsType statisticsType ) const;
|
||||
std::vector<double> result( size_t timeStep, StatisticsType statisticsType ) const;
|
||||
|
||||
std::vector<std::vector<std::pair<size_t, double>>> gridMapping() const;
|
||||
void addView( RimStatisticsContourMapView* view );
|
||||
|
||||
void ensureResultsComputed();
|
||||
|
||||
@ -68,6 +71,9 @@ public:
|
||||
double sampleSpacingFactor() const;
|
||||
bool isColumnResult() const;
|
||||
|
||||
std::vector<int> selectedTimeSteps() const;
|
||||
QString timeStepName( int timeStep ) const;
|
||||
|
||||
protected:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
@ -76,17 +82,25 @@ protected:
|
||||
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
RimEclipseCase* switchToSelectedSourceCase();
|
||||
|
||||
private:
|
||||
void computeStatistics();
|
||||
void doStatisticsCalculation( std::map<size_t, std::vector<std::vector<double>>>& timestep_results );
|
||||
|
||||
caf::PdmField<double> m_boundingBoxExpPercent;
|
||||
caf::PdmField<double> m_relativeSampleSpacing;
|
||||
caf::PdmField<RimContourMapProjection::ResultAggregation> m_resultAggregation;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
caf::PdmField<std::vector<int>> m_selectedTimeSteps;
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_resultDefinition;
|
||||
caf::PdmField<bool> m_computeStatisticsButton;
|
||||
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_resultDefinition;
|
||||
caf::PdmField<bool> m_computeStatisticsButton;
|
||||
caf::PdmField<QString> m_primaryCase;
|
||||
|
||||
std::unique_ptr<RigContourMapGrid> m_contourMapGrid;
|
||||
std::map<size_t, std::map<StatisticsType, std::vector<double>>> m_timeResults;
|
||||
|
||||
std::unique_ptr<RigContourMapGrid> m_contourMapGrid;
|
||||
std::map<StatisticsType, std::vector<double>> m_result;
|
||||
std::vector<std::vector<std::pair<size_t, double>>> m_gridMapping;
|
||||
|
||||
caf::PdmChildArrayField<RimStatisticsContourMapView*> m_views;
|
||||
};
|
||||
|
@ -63,19 +63,26 @@ QString RimStatisticsContourMapProjection::resultDescriptionText() const
|
||||
QString resultText;
|
||||
if ( auto scm = statisticsContourMap() )
|
||||
{
|
||||
resultText = scm->resultAggregationText();
|
||||
QString statisticsText = m_statisticsType().uiText();
|
||||
resultText = scm->resultAggregationText();
|
||||
|
||||
if ( !scm->isColumnResult() )
|
||||
{
|
||||
resultText += QString( ", %1" ).arg( scm->resultVariable() );
|
||||
}
|
||||
resultText += ", " + statisticsText;
|
||||
resultText += ", " + statisticsType();
|
||||
}
|
||||
|
||||
return resultText;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimStatisticsContourMapProjection::statisticsType() const
|
||||
{
|
||||
return m_statisticsType().uiText();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -83,11 +90,10 @@ QString RimStatisticsContourMapProjection::resultVariableName() const
|
||||
{
|
||||
if ( auto scm = statisticsContourMap() )
|
||||
{
|
||||
QString stasticsText = m_statisticsType().uiText();
|
||||
if ( !scm->isColumnResult() )
|
||||
return scm->resultVariable() + ", " + stasticsText;
|
||||
return scm->resultVariable() + ", " + statisticsType();
|
||||
else
|
||||
return scm->resultAggregationText() + ", " + stasticsText;
|
||||
return scm->resultAggregationText() + ", " + statisticsType();
|
||||
}
|
||||
|
||||
return "";
|
||||
@ -147,6 +153,13 @@ double RimStatisticsContourMapProjection::sampleSpacing() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMapProjection::clearGridMappingAndRedraw()
|
||||
{
|
||||
clearGridMapping();
|
||||
updateConnectedEditors();
|
||||
generateResultsIfNecessary( view()->currentTimeStep() );
|
||||
updateLegend();
|
||||
|
||||
RimEclipseView* parentView = firstAncestorOrThisOfTypeAsserted<RimEclipseView>();
|
||||
parentView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -165,7 +178,7 @@ void RimStatisticsContourMapProjection::generateAndSaveResults( int timeStep )
|
||||
if ( auto statistics = statisticsContourMap() )
|
||||
{
|
||||
dynamic_cast<RigStatisticsContourMapProjection*>( m_contourMapProjection.get() )
|
||||
->generateAndSaveResults( statistics->result( m_statisticsType() ) );
|
||||
->generateAndSaveResults( statistics->result( timeStep, m_statisticsType() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,9 +273,15 @@ std::pair<double, double> RimStatisticsContourMapProjection::minmaxValuesAllTime
|
||||
{
|
||||
clearTimeStepRange();
|
||||
|
||||
std::vector<double> aggregatedResults = statisticsContourMap()->result( m_statisticsType() );
|
||||
m_minResultAllTimeSteps = RigContourMapProjection::minValue( aggregatedResults );
|
||||
m_maxResultAllTimeSteps = RigContourMapProjection::maxValue( aggregatedResults );
|
||||
if ( auto map = statisticsContourMap() )
|
||||
{
|
||||
for ( size_t ts = 0; ts < map->selectedTimeSteps().size(); ts++ )
|
||||
{
|
||||
std::vector<double> aggregatedResults = statisticsContourMap()->result( ts, m_statisticsType() );
|
||||
m_minResultAllTimeSteps = std::min( m_minResultAllTimeSteps, RigContourMapProjection::minValue( aggregatedResults ) );
|
||||
m_maxResultAllTimeSteps = std::max( m_maxResultAllTimeSteps, RigContourMapProjection::maxValue( aggregatedResults ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair( m_minResultAllTimeSteps, m_maxResultAllTimeSteps );
|
||||
@ -297,8 +316,25 @@ bool RimStatisticsContourMapProjection::isColumnResult() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimStatisticsContourMapProjection::resultAggregationText() const
|
||||
{
|
||||
if ( statisticsContourMap() )
|
||||
return statisticsContourMap()->resultAggregationText();
|
||||
else
|
||||
return "";
|
||||
if ( statisticsContourMap() ) return statisticsContourMap()->resultAggregationText();
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMapProjection::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& oldValue,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
if ( ( changedField == &m_statisticsType ) || ( changedField == &m_showContourLines ) || ( changedField == &m_showContourLabels ) ||
|
||||
( changedField == &m_smoothContourLines ) )
|
||||
{
|
||||
clearGridMappingAndRedraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
RimContourMapProjection::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
|
||||
void clearGridMappingAndRedraw();
|
||||
|
||||
QString statisticsType() const;
|
||||
QString resultVariableName() const override;
|
||||
QString resultDescriptionText() const override;
|
||||
RimRegularLegendConfig* legendConfig() const override;
|
||||
@ -77,6 +78,7 @@ protected:
|
||||
protected:
|
||||
// Framework overrides
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
protected:
|
||||
caf::PdmField<caf::AppEnum<RimStatisticsContourMap::StatisticsType>> m_statisticsType;
|
||||
|
@ -92,9 +92,16 @@ QString RimStatisticsContourMapView::createAutoName() const
|
||||
generatedAutoTags.push_back( m_statisticsContourMap->resultAggregationText() );
|
||||
}
|
||||
|
||||
if ( nameConfig()->addProperty() && !m_statisticsContourMap->isColumnResult() )
|
||||
if ( nameConfig()->addProperty() )
|
||||
{
|
||||
generatedAutoTags.push_back( m_statisticsContourMap->resultVariable() );
|
||||
if ( auto proj = dynamic_cast<RimStatisticsContourMapProjection*>( m_contourMapProjection().p() ) )
|
||||
{
|
||||
if ( !m_statisticsContourMap->isColumnResult() )
|
||||
{
|
||||
generatedAutoTags.push_back( m_statisticsContourMap->resultVariable() );
|
||||
}
|
||||
generatedAutoTags.push_back( proj->statisticsType() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( nameConfig()->addSampleSpacing() )
|
||||
@ -114,13 +121,31 @@ QString RimStatisticsContourMapView::createAutoName() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMapView::setDefaultCustomName()
|
||||
{
|
||||
nameConfig()->setCustomName( "Contour Map" );
|
||||
nameConfig()->setCustomName( "" );
|
||||
nameConfig()->hideCaseNameField( false );
|
||||
nameConfig()->hideAggregationTypeField( false );
|
||||
nameConfig()->hidePropertyField( false );
|
||||
nameConfig()->hideSampleSpacingField( false );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMapView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "Contour Map Name" );
|
||||
nameConfig()->uiOrdering( uiConfigName, *nameGroup );
|
||||
|
||||
caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup( "Viewer" );
|
||||
viewGroup->add( userDescriptionField() );
|
||||
viewGroup->add( backgroundColorField() );
|
||||
viewGroup->add( &m_showAxisLines );
|
||||
viewGroup->add( &m_showScaleLegend );
|
||||
viewGroup->add( &m_showFaultLines );
|
||||
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -141,15 +166,15 @@ void RimStatisticsContourMapView::defineUiTreeOrdering( caf::PdmUiTreeOrdering&
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMapView::onUpdateLegends()
|
||||
{
|
||||
if ( nativeOrOverrideViewer() )
|
||||
if ( auto viewer = nativeOrOverrideViewer() )
|
||||
{
|
||||
if ( !isUsingOverrideViewer() )
|
||||
{
|
||||
nativeOrOverrideViewer()->removeAllColorLegends();
|
||||
viewer->removeAllColorLegends();
|
||||
}
|
||||
else if ( cellResult() && cellResult()->legendConfig() )
|
||||
{
|
||||
nativeOrOverrideViewer()->removeColorLegend( cellResult()->legendConfig()->titledOverlayFrame() );
|
||||
viewer->removeColorLegend( cellResult()->legendConfig()->titledOverlayFrame() );
|
||||
}
|
||||
|
||||
if ( m_contourMapProjection && m_contourMapProjection->isChecked() )
|
||||
@ -160,8 +185,7 @@ void RimStatisticsContourMapView::onUpdateLegends()
|
||||
m_contourMapProjection->updateLegend();
|
||||
if ( projectionLegend->showLegend() )
|
||||
{
|
||||
nativeOrOverrideViewer()->addColorLegendToBottomLeftCorner( projectionLegend->titledOverlayFrame(),
|
||||
isUsingOverrideViewer() );
|
||||
viewer->addColorLegendToBottomLeftCorner( projectionLegend->titledOverlayFrame(), isUsingOverrideViewer() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -181,7 +205,7 @@ void RimStatisticsContourMapView::onUpdateLegends()
|
||||
}
|
||||
}
|
||||
|
||||
nativeOrOverrideViewer()->showScaleLegend( any3DViewsLinked ? false : m_showScaleLegend() );
|
||||
viewer->showScaleLegend( any3DViewsLinked ? false : m_showScaleLegend() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,3 +216,84 @@ RimStatisticsContourMap* RimStatisticsContourMapView::statisticsContourMap() con
|
||||
{
|
||||
return m_statisticsContourMap;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Clamp the current timestep to actual possibilities
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStatisticsContourMapView::onClampCurrentTimestep()
|
||||
{
|
||||
if ( statisticsContourMap() )
|
||||
{
|
||||
auto maxSteps = (int)statisticsContourMap()->selectedTimeSteps().size();
|
||||
if ( m_currentTimeStep() >= maxSteps )
|
||||
{
|
||||
m_currentTimeStep = maxSteps - 1;
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_currentTimeStep < 0 ) m_currentTimeStep = 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RimStatisticsContourMapView::onTimeStepCountRequested()
|
||||
{
|
||||
if ( statisticsContourMap() )
|
||||
{
|
||||
return (size_t)statisticsContourMap()->selectedTimeSteps().size();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimStatisticsContourMapView::timeStepName( int frameIdx ) const
|
||||
{
|
||||
if ( !statisticsContourMap() ) return "";
|
||||
|
||||
auto steps = statisticsContourMap()->selectedTimeSteps();
|
||||
if ( frameIdx >= (int)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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<size_t> RimStatisticsContourMapView::activeTimeStepIndices( bool propertyFiltersActive )
|
||||
{
|
||||
std::vector<size_t> timeStepIndices;
|
||||
|
||||
// First entry in this vector is used to define the geometry only result mode with no results.
|
||||
timeStepIndices.push_back( 0 );
|
||||
|
||||
// add any timesteps with dynamic data
|
||||
if ( !statisticsContourMap() ) return timeStepIndices;
|
||||
|
||||
for ( size_t i = 0; i < statisticsContourMap()->selectedTimeSteps().size(); i++ )
|
||||
{
|
||||
timeStepIndices.push_back( i );
|
||||
}
|
||||
|
||||
return timeStepIndices;
|
||||
}
|
||||
|
@ -37,8 +37,15 @@ public:
|
||||
|
||||
protected:
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
std::vector<size_t> activeTimeStepIndices( bool propertyFiltersActive ) override;
|
||||
|
||||
void onClampCurrentTimestep() override;
|
||||
size_t onTimeStepCountRequested() override;
|
||||
QString timeStepName( int frameIdx ) const override;
|
||||
QStringList timeStepStrings() const override;
|
||||
|
||||
void createContourMapGeometry();
|
||||
void onUpdateLegends() override;
|
||||
|
||||
private:
|
||||
|
@ -299,6 +299,8 @@ std::pair<std::vector<RigContourMapTrianglesGenerator::ContourPolygons>, std::ve
|
||||
|
||||
const std::vector<double>& aggregatedVertexResults = contourMapProjection.aggregatedVertexResults();
|
||||
|
||||
if ( aggregatedVertexResults.empty() ) return {};
|
||||
|
||||
std::vector<caf::ContourLines::ListOfLineSegments> unorderedLineSegmentsPerLevel =
|
||||
caf::ContourLines::create( aggregatedVertexResults,
|
||||
contourMapProjection.xVertexPositions(),
|
||||
|
@ -124,7 +124,6 @@ std::pair<bool, std::vector<double>>
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO: this was RimEclipseCellColors->hasStaticResult()
|
||||
if ( resultAddress.resultCatType() == RiaDefines::ResultCatType::STATIC_NATIVE && timeStep > 0 ) timeStep = 0;
|
||||
|
||||
resultData.ensureKnownResultLoaded( resultAddress );
|
||||
|
@ -1009,7 +1009,7 @@ void RiuMainWindow::refreshAnimationActions()
|
||||
|
||||
if ( activeView->isTimeStepDependentDataVisibleInThisOrComparisonView() )
|
||||
{
|
||||
timeStepStrings = activeView->ownerCase()->timeStepStrings();
|
||||
timeStepStrings = activeView->timeStepStrings();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -323,11 +323,11 @@ static std::vector<size_t>& progressSpanStack()
|
||||
/// Calculate the total maximum value for the progress bar composed
|
||||
/// of the complete stack
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
static size_t currentTotalMaxProgressValue()
|
||||
static double currentTotalMaxProgressValue()
|
||||
{
|
||||
std::vector<size_t>& maxProgressStack_v = maxProgressStack();
|
||||
|
||||
size_t levCount = 1;
|
||||
double levCount = 1.0;
|
||||
for ( size_t levelDepth = 0; levelDepth < maxProgressStack_v.size(); ++levelDepth )
|
||||
{
|
||||
levCount *= maxProgressStack_v[levelDepth];
|
||||
@ -338,7 +338,7 @@ static size_t currentTotalMaxProgressValue()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Calculate the total progress value based on the current level subdivision and progress
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
static size_t currentTotalProgress()
|
||||
static double currentTotalProgress()
|
||||
{
|
||||
double progress = 0;
|
||||
|
||||
@ -349,12 +349,12 @@ static size_t currentTotalProgress()
|
||||
for ( int i = static_cast<int>( progressStack_v.size() ) - 1; i >= 0; --i )
|
||||
{
|
||||
size_t span = ( i < 1 ) ? 1 : progressSpanStack_v[i - 1];
|
||||
progress = span * ( progress + progressStack_v[i] ) / (double)maxProgressStack_v[i];
|
||||
progress = 1.0 * span * ( progress + progressStack_v[i] ) / (double)maxProgressStack_v[i];
|
||||
}
|
||||
|
||||
size_t totalIntProgress = static_cast<size_t>( currentTotalMaxProgressValue() * progress );
|
||||
double totalProgress = currentTotalMaxProgressValue() * progress;
|
||||
|
||||
return totalIntProgress;
|
||||
return totalProgress;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -533,8 +533,9 @@ void ProgressInfoStatic::start( ProgressInfo& progressInfo,
|
||||
|
||||
if ( dialog )
|
||||
{
|
||||
dialog->setMaximum( static_cast<int>( currentTotalMaxProgressValue() ) );
|
||||
dialog->setValue( static_cast<int>( currentTotalProgress() ) );
|
||||
double value = currentTotalProgress() / currentTotalMaxProgressValue();
|
||||
dialog->setMaximum( 100 );
|
||||
dialog->setValue( (int)( 100.0 * value ) );
|
||||
dialog->setLabelText( currentComposedLabel() );
|
||||
}
|
||||
|
||||
@ -583,10 +584,10 @@ void ProgressInfoStatic::setProgress( size_t progressValue )
|
||||
progressStack_v.back() = progressValue;
|
||||
progressSpanStack_v.back() = 1;
|
||||
|
||||
int totalProgress = static_cast<int>( currentTotalProgress() );
|
||||
int totalMaxProgress = static_cast<int>( currentTotalMaxProgressValue() );
|
||||
double totalProgress = currentTotalProgress();
|
||||
double totalMaxProgress = currentTotalMaxProgressValue();
|
||||
|
||||
if ( static_cast<int>( totalProgress ) > totalMaxProgress )
|
||||
if ( totalProgress > totalMaxProgress )
|
||||
{
|
||||
reportError( "totalProgress > totalMaxProgress"
|
||||
", totalProgress == " +
|
||||
@ -597,8 +598,9 @@ void ProgressInfoStatic::setProgress( size_t progressValue )
|
||||
QProgressDialog* dialog = progressDialog();
|
||||
if ( dialog )
|
||||
{
|
||||
dialog->setMaximum( totalMaxProgress );
|
||||
dialog->setValue( totalProgress );
|
||||
double value = currentTotalProgress() / currentTotalMaxProgressValue();
|
||||
dialog->setMaximum( 100 );
|
||||
dialog->setValue( (int)( 100.0 * value ) );
|
||||
}
|
||||
|
||||
if ( s_shouldProcessEvents ) QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
|
||||
|
@ -45,409 +45,432 @@ namespace cvf {
|
||||
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
/// \class cvf::BoundingBox
|
||||
/// \ingroup Geometry
|
||||
///
|
||||
/// The BoundingBox class implements an axis-aligned bounding box.
|
||||
///
|
||||
//==================================================================================================
|
||||
//==================================================================================================
|
||||
///
|
||||
/// \class cvf::BoundingBox
|
||||
/// \ingroup Geometry
|
||||
///
|
||||
/// The BoundingBox class implements an axis-aligned bounding box.
|
||||
///
|
||||
//==================================================================================================
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox::BoundingBox()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox::BoundingBox(const Vec3d& min, const Vec3d& max)
|
||||
: m_min(min), m_max(max)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox::BoundingBox(const Vec3f& min, const Vec3f& max)
|
||||
: m_min(min), m_max(max)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox::BoundingBox(const BoundingBox& other)
|
||||
: m_min(other.m_min),
|
||||
m_max(other.m_max)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox& BoundingBox::operator=(const BoundingBox& rhs)
|
||||
{
|
||||
m_min = rhs.m_min;
|
||||
m_max = rhs.m_max;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Initialize bounding box
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::reset()
|
||||
{
|
||||
const double maxDouble = std::numeric_limits<double>::max();
|
||||
|
||||
m_max.set(-maxDouble, -maxDouble, -maxDouble);
|
||||
m_min.set( maxDouble, maxDouble, maxDouble);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns false if no input has been given
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool BoundingBox::isValid() const
|
||||
{
|
||||
if (m_min.x() <= m_max.x() &&
|
||||
m_min.y() <= m_max.y() &&
|
||||
m_min.z() <= m_max.z())
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox::BoundingBox()
|
||||
{
|
||||
reset();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox::BoundingBox(const Vec3d& min, const Vec3d& max)
|
||||
: m_min(min), m_max(max)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox::BoundingBox(const Vec3f& min, const Vec3f& max)
|
||||
: m_min(min), m_max(max)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox::BoundingBox(const BoundingBox& other)
|
||||
: m_min(other.m_min),
|
||||
m_max(other.m_max)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
BoundingBox& BoundingBox::operator=(const BoundingBox& rhs)
|
||||
{
|
||||
m_min = rhs.m_min;
|
||||
m_max = rhs.m_max;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Initialize bounding box
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::reset()
|
||||
{
|
||||
const double maxDouble = std::numeric_limits<double>::max();
|
||||
|
||||
m_max.set(-maxDouble, -maxDouble, -maxDouble);
|
||||
m_min.set(maxDouble, maxDouble, maxDouble);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns false if no input has been given
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool BoundingBox::isValid() const
|
||||
{
|
||||
if (m_min.x() <= m_max.x() &&
|
||||
m_min.y() <= m_max.y() &&
|
||||
m_min.z() <= m_max.z())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const Vec3d& point)
|
||||
{
|
||||
if (point.x() < m_min.x()) m_min.x() = point.x();
|
||||
if (point.y() < m_min.y()) m_min.y() = point.y();
|
||||
if (point.z() < m_min.z()) m_min.z() = point.z();
|
||||
|
||||
if (point.x() > m_max.x()) m_max.x() = point.x();
|
||||
if (point.y() > m_max.y()) m_max.y() = point.y();
|
||||
if (point.z() > m_max.z()) m_max.z() = point.z();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const Vec3f& point)
|
||||
{
|
||||
if (point.x() < m_min.x()) m_min.x() = point.x();
|
||||
if (point.y() < m_min.y()) m_min.y() = point.y();
|
||||
if (point.z() < m_min.z()) m_min.z() = point.z();
|
||||
|
||||
if (point.x() > m_max.x()) m_max.x() = point.x();
|
||||
if (point.y() > m_max.y()) m_max.y() = point.y();
|
||||
if (point.z() > m_max.z()) m_max.z() = point.z();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const Vec3dArray& points)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < points.size(); i++)
|
||||
{
|
||||
add(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const Vec3fArray& points)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < points.size(); i++)
|
||||
{
|
||||
add(points[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const BoundingBox& bb)
|
||||
{
|
||||
if (bb.isValid())
|
||||
{
|
||||
add(bb.min());
|
||||
add(bb.max());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::addValid(const BoundingBox& bb)
|
||||
{
|
||||
if (bb.m_min.x() < m_min.x()) m_min.x() = bb.m_min.x();
|
||||
if (bb.m_min.y() < m_min.y()) m_min.y() = bb.m_min.y();
|
||||
if (bb.m_min.z() < m_min.z()) m_min.z() = bb.m_min.z();
|
||||
|
||||
if (bb.m_max.x() > m_max.x()) m_max.x() = bb.m_max.x();
|
||||
if (bb.m_max.y() > m_max.y()) m_max.y() = bb.m_max.y();
|
||||
if (bb.m_max.z() > m_max.z()) m_max.z() = bb.m_max.z();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Computes center of the bounding box
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Vec3d BoundingBox::center() const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(isValid());
|
||||
|
||||
return (m_min + m_max) / 2.0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Computes the total size of the bounding box
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Vec3d BoundingBox::extent() const
|
||||
{
|
||||
if (!isValid()) return { 0,0,0 };
|
||||
|
||||
return (m_max - m_min);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Compute radius as half the length of the box's diagonal
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double BoundingBox::radius() const
|
||||
{
|
||||
if (!isValid()) return 0.0;
|
||||
|
||||
return extent().length() / 2.0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const Vec3d& BoundingBox::min() const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(isValid());
|
||||
|
||||
return m_min;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const Vec3d& BoundingBox::max() const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(isValid());
|
||||
|
||||
return m_max;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Check if the bounding box contains the specified point
|
||||
///
|
||||
/// Note that a point on the box's surface is classified as being contained
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool BoundingBox::contains(const Vec3d& point) const
|
||||
{
|
||||
if (!isValid()) return false;
|
||||
|
||||
if (point.x() >= m_min.x() && point.x() <= m_max.x() &&
|
||||
point.y() >= m_min.y() && point.y() <= m_max.y() &&
|
||||
point.z() >= m_min.z() && point.z() <= m_max.z())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool BoundingBox::intersects(const BoundingBox& box) const
|
||||
{
|
||||
if (!isValid() || !box.isValid()) return false;
|
||||
|
||||
if (m_max.x() < box.m_min.x() || m_min.x() > box.m_max.x()) return false;
|
||||
if (m_max.y() < box.m_min.y() || m_min.y() > box.m_max.y()) return false;
|
||||
if (m_max.z() < box.m_min.z() || m_min.z() > box.m_max.z()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get corner points of box
|
||||
///
|
||||
/// \param corners Array of Vec3d. Must be allocated 8 vectors long.
|
||||
///
|
||||
/// <PRE>
|
||||
/// 7---------6
|
||||
/// /| /| |z
|
||||
/// / | / | | / y
|
||||
/// 4---------5 | |/
|
||||
/// | 3------|--2 *---x
|
||||
/// | / | /
|
||||
/// |/ |/
|
||||
/// 0---------1 </PRE>
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::cornerVertices(Vec3d corners[8]) const
|
||||
{
|
||||
return false;
|
||||
corners[0].set(m_min.x(), m_min.y(), m_min.z());
|
||||
corners[1].set(m_max.x(), m_min.y(), m_min.z());
|
||||
corners[2].set(m_max.x(), m_max.y(), m_min.z());
|
||||
corners[3].set(m_min.x(), m_max.y(), m_min.z());
|
||||
corners[4].set(m_min.x(), m_min.y(), m_max.z());
|
||||
corners[5].set(m_max.x(), m_min.y(), m_max.z());
|
||||
corners[6].set(m_max.x(), m_max.y(), m_max.z());
|
||||
corners[7].set(m_min.x(), m_max.y(), m_max.z());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const Vec3d& point)
|
||||
{
|
||||
if (point.x() < m_min.x()) m_min.x() = point.x();
|
||||
if (point.y() < m_min.y()) m_min.y() = point.y();
|
||||
if (point.z() < m_min.z()) m_min.z() = point.z();
|
||||
|
||||
if (point.x() > m_max.x()) m_max.x() = point.x();
|
||||
if (point.y() > m_max.y()) m_max.y() = point.y();
|
||||
if (point.z() > m_max.z()) m_max.z() = point.z();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const Vec3f& point)
|
||||
{
|
||||
if (point.x() < m_min.x()) m_min.x() = point.x();
|
||||
if (point.y() < m_min.y()) m_min.y() = point.y();
|
||||
if (point.z() < m_min.z()) m_min.z() = point.z();
|
||||
|
||||
if (point.x() > m_max.x()) m_max.x() = point.x();
|
||||
if (point.y() > m_max.y()) m_max.y() = point.y();
|
||||
if (point.z() > m_max.z()) m_max.z() = point.z();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const Vec3dArray& points)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < points.size(); i++)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Expands the bounding box by the given amount in all three directions
|
||||
///
|
||||
/// If a bounding box is expanded by 2, the bounding box's size will increase by 2 in each direction
|
||||
/// \sa extent()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::expand(double amount)
|
||||
{
|
||||
add(points[i]);
|
||||
double half = amount / 2;
|
||||
m_min.x() -= half;
|
||||
m_min.y() -= half;
|
||||
m_min.z() -= half;
|
||||
m_max.x() += half;
|
||||
m_max.y() += half;
|
||||
m_max.z() += half;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const Vec3fArray& points)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < points.size(); i++)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Expands the bounding box by the given percent in all three directions
|
||||
///
|
||||
/// If a bounding box is expanded by 10%, the bounding box's size will increase by 5% in each direction
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::expandPercent(double percent)
|
||||
{
|
||||
add(points[i]);
|
||||
const auto ext = extent();
|
||||
const double factor = percent / 100.0;
|
||||
|
||||
const double xHalf = (ext.x() / 2) * factor;
|
||||
const double yHalf = (ext.y() / 2) * factor;
|
||||
const double zHalf = (ext.z() / 2) * factor;
|
||||
|
||||
m_min.x() -= xHalf;
|
||||
m_min.y() -= yHalf;
|
||||
m_min.z() -= zHalf;
|
||||
m_max.x() += xHalf;
|
||||
m_max.y() += yHalf;
|
||||
m_max.z() += zHalf;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::add(const BoundingBox& bb)
|
||||
{
|
||||
if (bb.isValid())
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Transform the min and max coordinate with the given transformation matrix
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::transform(const Mat4d& matrix)
|
||||
{
|
||||
add(bb.min());
|
||||
add(bb.max());
|
||||
// Check if box is invalid, and don't transform if so
|
||||
if (!isValid()) return;
|
||||
|
||||
BoundingBox newBox;
|
||||
newBox.reset();
|
||||
|
||||
Vec3d node;
|
||||
|
||||
node.set(m_min.x(), m_min.y(), m_min.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_max.x(), m_min.y(), m_min.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_max.x(), m_max.y(), m_min.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_min.x(), m_max.y(), m_min.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_min.x(), m_min.y(), m_max.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_max.x(), m_min.y(), m_max.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_max.x(), m_max.y(), m_max.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_min.x(), m_max.y(), m_max.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
*this = newBox;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::addValid(const BoundingBox& bb)
|
||||
{
|
||||
if (bb.m_min.x() < m_min.x()) m_min.x() = bb.m_min.x();
|
||||
if (bb.m_min.y() < m_min.y()) m_min.y() = bb.m_min.y();
|
||||
if (bb.m_min.z() < m_min.z()) m_min.z() = bb.m_min.z();
|
||||
|
||||
if (bb.m_max.x() > m_max.x()) m_max.x() = bb.m_max.x();
|
||||
if (bb.m_max.y() > m_max.y()) m_max.y() = bb.m_max.y();
|
||||
if (bb.m_max.z() > m_max.z()) m_max.z() = bb.m_max.z();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Computes center of the bounding box
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Vec3d BoundingBox::center() const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(isValid());
|
||||
|
||||
return (m_min + m_max) / 2.0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Computes the total size of the bounding box
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
Vec3d BoundingBox::extent() const
|
||||
{
|
||||
if (!isValid()) return { 0,0,0 };
|
||||
|
||||
return (m_max - m_min);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Compute radius as half the length of the box's diagonal
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double BoundingBox::radius() const
|
||||
{
|
||||
if (!isValid()) return 0.0;
|
||||
|
||||
return extent().length() / 2.0;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const Vec3d& BoundingBox::min() const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(isValid());
|
||||
|
||||
return m_min;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const Vec3d& BoundingBox::max() const
|
||||
{
|
||||
CVF_TIGHT_ASSERT(isValid());
|
||||
|
||||
return m_max;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Check if the bounding box contains the specified point
|
||||
///
|
||||
/// Note that a point on the box's surface is classified as being contained
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool BoundingBox::contains(const Vec3d& point) const
|
||||
{
|
||||
if (!isValid()) return false;
|
||||
|
||||
if (point.x() >= m_min.x() && point.x() <= m_max.x() &&
|
||||
point.y() >= m_min.y() && point.y() <= m_max.y() &&
|
||||
point.z() >= m_min.z() && point.z() <= m_max.z())
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns this BoundingBox transformed with the given transformation matrix
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const BoundingBox BoundingBox::getTransformed(const Mat4d& matrix) const
|
||||
{
|
||||
return true;
|
||||
BoundingBox box(*this);
|
||||
box.transform(matrix);
|
||||
|
||||
return box;
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
String BoundingBox::debugString() const
|
||||
{
|
||||
return false;
|
||||
String str = "BoundingBox:";
|
||||
str += " min: x=" + String::number(m_min.x()) + " y=" + String::number(m_min.y()) + " z=" + String::number(m_min.z());
|
||||
str += " max: x=" + String::number(m_max.x()) + " y=" + String::number(m_max.y()) + " z=" + String::number(m_max.z());
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Cuts the box at the given depth, to never go below the given depth
|
||||
///
|
||||
/// Note: cutting is a one time operation, adding new points to the box might extend the box below the cut depth
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::cutBelow(double depth)
|
||||
{
|
||||
if (m_min.z() < depth) m_min.z() = depth;
|
||||
if (m_max.z() < depth) m_max.z() = depth;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool BoundingBox::intersects(const BoundingBox& box) const
|
||||
{
|
||||
if (!isValid() || !box.isValid()) return false;
|
||||
|
||||
if (m_max.x() < box.m_min.x() || m_min.x() > box.m_max.x()) return false;
|
||||
if (m_max.y() < box.m_min.y() || m_min.y() > box.m_max.y()) return false;
|
||||
if (m_max.z() < box.m_min.z() || m_min.z() > box.m_max.z()) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get corner points of box
|
||||
///
|
||||
/// \param corners Array of Vec3d. Must be allocated 8 vectors long.
|
||||
///
|
||||
/// <PRE>
|
||||
/// 7---------6
|
||||
/// /| /| |z
|
||||
/// / | / | | / y
|
||||
/// 4---------5 | |/
|
||||
/// | 3------|--2 *---x
|
||||
/// | / | /
|
||||
/// |/ |/
|
||||
/// 0---------1 </PRE>
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::cornerVertices(Vec3d corners[8]) const
|
||||
{
|
||||
corners[0].set(m_min.x(), m_min.y(), m_min.z());
|
||||
corners[1].set(m_max.x(), m_min.y(), m_min.z());
|
||||
corners[2].set(m_max.x(), m_max.y(), m_min.z());
|
||||
corners[3].set(m_min.x(), m_max.y(), m_min.z());
|
||||
corners[4].set(m_min.x(), m_min.y(), m_max.z());
|
||||
corners[5].set(m_max.x(), m_min.y(), m_max.z());
|
||||
corners[6].set(m_max.x(), m_max.y(), m_max.z());
|
||||
corners[7].set(m_min.x(), m_max.y(), m_max.z());
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Expands the bounding box by the given amount in all three directions
|
||||
///
|
||||
/// If a bounding box is expanded by 2, the bounding box's size will increase by 2 in each direction
|
||||
/// \sa extent()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::expand(double amount)
|
||||
{
|
||||
double half = amount/2;
|
||||
m_min.x() -= half;
|
||||
m_min.y() -= half;
|
||||
m_min.z() -= half;
|
||||
m_max.x() += half;
|
||||
m_max.y() += half;
|
||||
m_max.z() += half;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Transform the min and max coordinate with the given transformation matrix
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::transform(const Mat4d& matrix)
|
||||
{
|
||||
// Check if box is invalid, and don't transform if so
|
||||
if (!isValid()) return;
|
||||
|
||||
BoundingBox newBox;
|
||||
newBox.reset();
|
||||
|
||||
Vec3d node;
|
||||
|
||||
node.set(m_min.x(), m_min.y(), m_min.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_max.x(), m_min.y(), m_min.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_max.x(), m_max.y(), m_min.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_min.x(), m_max.y(), m_min.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_min.x(), m_min.y(), m_max.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_max.x(), m_min.y(), m_max.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_max.x(), m_max.y(), m_max.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
node.set(m_min.x(), m_max.y(), m_max.z());
|
||||
node.transformPoint(matrix);
|
||||
newBox.add(node);
|
||||
|
||||
*this = newBox;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Returns this BoundingBox transformed with the given transformation matrix
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const BoundingBox BoundingBox::getTransformed(const Mat4d& matrix) const
|
||||
{
|
||||
BoundingBox box(*this);
|
||||
box.transform(matrix);
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
String BoundingBox::debugString() const
|
||||
{
|
||||
String str = "BoundingBox:";
|
||||
str += " min: x=" + String::number(m_min.x()) + " y=" + String::number(m_min.y()) + " z=" + String::number(m_min.z());
|
||||
str += " max: x=" + String::number(m_max.x()) + " y=" + String::number(m_max.y()) + " z=" + String::number(m_max.z());
|
||||
return str;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Cuts the box at the given depth, to never go below the given depth
|
||||
///
|
||||
/// Note: cutting is a one time operation, adding new points to the box might extend the box below the cut depth
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::cutBelow(double depth)
|
||||
{
|
||||
if (m_min.z() < depth) m_min.z() = depth;
|
||||
if (m_max.z() < depth) m_max.z() = depth;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Cuts the box at the given depth, to never go above the given depth
|
||||
///
|
||||
/// Note: cutting is a one time operation, adding new points to the box might extend the box below the cut depth
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::cutAbove(double depth)
|
||||
{
|
||||
if (m_min.z() > depth) m_min.z() = depth;
|
||||
if (m_max.z() > depth) m_max.z() = depth;
|
||||
}
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Cuts the box at the given depth, to never go above the given depth
|
||||
///
|
||||
/// Note: cutting is a one time operation, adding new points to the box might extend the box below the cut depth
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void BoundingBox::cutAbove(double depth)
|
||||
{
|
||||
if (m_min.z() > depth) m_min.z() = depth;
|
||||
if (m_max.z() > depth) m_max.z() = depth;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -44,56 +44,57 @@
|
||||
namespace cvf {
|
||||
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
// Axis aligned bounding box
|
||||
//
|
||||
//==================================================================================================
|
||||
class BoundingBox
|
||||
{
|
||||
public:
|
||||
BoundingBox();
|
||||
BoundingBox(const Vec3f& min, const Vec3f& max);
|
||||
BoundingBox(const Vec3d& min, const Vec3d& max);
|
||||
BoundingBox(const BoundingBox& other);
|
||||
//==================================================================================================
|
||||
//
|
||||
// Axis aligned bounding box
|
||||
//
|
||||
//==================================================================================================
|
||||
class BoundingBox
|
||||
{
|
||||
public:
|
||||
BoundingBox();
|
||||
BoundingBox(const Vec3f& min, const Vec3f& max);
|
||||
BoundingBox(const Vec3d& min, const Vec3d& max);
|
||||
BoundingBox(const BoundingBox& other);
|
||||
|
||||
BoundingBox& operator=(const BoundingBox& rhs);
|
||||
BoundingBox& operator=(const BoundingBox& rhs);
|
||||
|
||||
void reset();
|
||||
void reset();
|
||||
|
||||
bool isValid() const;
|
||||
bool isValid() const;
|
||||
|
||||
void add(const Vec3f& vertex);
|
||||
void add(const Vec3d& vertex);
|
||||
void add(const Vec3fArray& vertices);
|
||||
void add(const Vec3dArray& vertices);
|
||||
void add(const BoundingBox& bb);
|
||||
void addValid(const BoundingBox& bb);
|
||||
void add(const Vec3f& vertex);
|
||||
void add(const Vec3d& vertex);
|
||||
void add(const Vec3fArray& vertices);
|
||||
void add(const Vec3dArray& vertices);
|
||||
void add(const BoundingBox& bb);
|
||||
void addValid(const BoundingBox& bb);
|
||||
|
||||
const Vec3d& min() const;
|
||||
const Vec3d& max() const;
|
||||
const Vec3d& min() const;
|
||||
const Vec3d& max() const;
|
||||
|
||||
Vec3d center() const;
|
||||
Vec3d extent() const;
|
||||
double radius() const;
|
||||
Vec3d center() const;
|
||||
Vec3d extent() const;
|
||||
double radius() const;
|
||||
|
||||
bool contains(const Vec3d& point) const;
|
||||
bool intersects(const BoundingBox& box) const;
|
||||
bool contains(const Vec3d& point) const;
|
||||
bool intersects(const BoundingBox& box) const;
|
||||
|
||||
void cornerVertices(Vec3d corners[8]) const;
|
||||
void cornerVertices(Vec3d corners[8]) const;
|
||||
|
||||
void expand(double amount);
|
||||
void transform(const Mat4d& matrix);
|
||||
const BoundingBox getTransformed(const Mat4d& matrix) const;
|
||||
void expand(double amount);
|
||||
void expandPercent(double percent);
|
||||
void transform(const Mat4d& matrix);
|
||||
const BoundingBox getTransformed(const Mat4d& matrix) const;
|
||||
|
||||
void cutBelow(double depth);
|
||||
void cutAbove(double depth);
|
||||
void cutBelow(double depth);
|
||||
void cutAbove(double depth);
|
||||
|
||||
String debugString() const;
|
||||
String debugString() const;
|
||||
|
||||
private:
|
||||
Vec3d m_min;
|
||||
Vec3d m_max;
|
||||
};
|
||||
private:
|
||||
Vec3d m_min;
|
||||
Vec3d m_max;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user