2012-09-11 09:22:36 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 15:04:57 +02:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
2012-09-11 09:22:36 +02:00
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "Rim3dOverlayInfoConfig.h"
2013-05-06 10:55:00 +02:00
2018-10-01 20:50:43 +02:00
#include "RiaQDateTimeTools.h"
2017-11-16 10:39:54 +01:00
#include "RicGridStatisticsDialog.h"
2014-07-24 10:11:43 +02:00
#include "RigCaseCellResultsData.h"
2017-01-10 09:51:39 +01:00
#include "RigEclipseCaseData.h"
2016-10-18 07:31:02 +02:00
#include "RigEclipseNativeVisibleCellsStatCalc.h"
#include "RigFemNativeVisibleCellsStatCalc.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemResultAddress.h"
2017-10-19 07:44:21 +02:00
#include "RigFlowDiagResults.h"
#include "RigFlowDiagVisibleCellsStatCalc.h"
2016-10-18 07:31:02 +02:00
#include "RigGeoMechCaseData.h"
2017-01-09 19:04:45 +01:00
#include "RigMainGrid.h"
2016-10-18 07:31:02 +02:00
#include "RigStatisticsDataCache.h"
2019-01-16 10:51:43 +01:00
#include "RimGeoMechContourMapView.h"
2019-01-11 13:56:35 +01:00
#include "RimEclipseContourMapView.h"
2019-01-16 10:51:43 +01:00
#include "RimGeoMechContourMapProjection.h"
2019-01-11 13:03:46 +01:00
#include "RimEclipseContourMapProjection.h"
2018-02-15 13:00:33 +01:00
#include "Rim2dIntersectionView.h"
#include "Rim2dIntersectionViewCollection.h"
#include "Rim3dView.h"
#include "RimCase.h"
2015-06-25 13:45:32 +02:00
#include "RimCellEdgeColors.h"
2016-10-18 07:31:02 +02:00
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
2015-06-25 13:32:00 +02:00
#include "RimEclipseFaultColors.h"
2016-10-18 07:31:02 +02:00
#include "RimEclipsePropertyFilterCollection.h"
2015-05-21 10:34:38 +02:00
#include "RimEclipseView.h"
2017-10-15 21:20:03 +02:00
#include "RimFaultInViewCollection.h"
2016-10-18 07:31:02 +02:00
#include "RimGeoMechCase.h"
#include "RimGeoMechResultDefinition.h"
2015-04-29 22:19:49 +02:00
#include "RimGeoMechView.h"
2016-10-18 07:31:02 +02:00
#include "RimReservoirCellResultsStorage.h"
2017-10-19 07:44:21 +02:00
#include "RimSimWellInViewCollection.h"
2017-11-28 15:07:46 +01:00
#include "RimTools.h"
2012-09-11 09:22:36 +02:00
2016-10-18 07:31:02 +02:00
#include "RiuViewer.h"
2017-10-19 07:44:21 +02:00
#include <QMessageBox>
2017-11-29 13:34:55 +01:00
#include <QApplication>
2017-10-19 07:44:21 +02:00
2012-09-13 15:17:59 +02:00
CAF_PDM_SOURCE_INIT ( Rim3dOverlayInfoConfig , "View3dOverlayInfoConfig" );
2015-11-04 12:51:55 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
namespace caf
{
2017-10-18 10:43:27 +02:00
template <>
void caf :: AppEnum < Rim3dOverlayInfoConfig :: StatisticsTimeRangeType >:: setUp ()
{
addItem ( Rim3dOverlayInfoConfig :: ALL_TIMESTEPS , "ALL_TIMESTEPS" , "All Time Steps" );
addItem ( Rim3dOverlayInfoConfig :: CURRENT_TIMESTEP , "CURRENT_TIMESTEP" , "Current Time Step" );
setDefault ( Rim3dOverlayInfoConfig :: ALL_TIMESTEPS );
}
2015-11-04 12:51:55 +01:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
namespace caf
{
2017-10-18 10:43:27 +02:00
template <>
void caf :: AppEnum < Rim3dOverlayInfoConfig :: StatisticsCellRangeType >:: setUp ()
{
addItem ( Rim3dOverlayInfoConfig :: ALL_CELLS , "ALL_CELLS" , "All Active Cells" );
addItem ( Rim3dOverlayInfoConfig :: VISIBLE_CELLS , "VISIBLE_CELLS" , "Visible Cells" );
setDefault ( Rim3dOverlayInfoConfig :: ALL_CELLS );
}
2015-11-04 12:51:55 +01:00
}
2012-09-11 09:22:36 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-10-18 10:43:27 +02:00
Rim3dOverlayInfoConfig :: Rim3dOverlayInfoConfig ()
2012-09-11 09:22:36 +02:00
{
2015-08-09 11:16:52 +02:00
CAF_PDM_InitObject ( "Info Box" , ":/InfoBox16x16.png" , "" , "" );
2012-09-11 09:22:36 +02:00
2018-02-15 13:00:33 +01:00
CAF_PDM_InitField ( & m_active , "Active" , true , "Active" , "" , "" , "" );
m_active . uiCapability () -> setUiHidden ( true );
2013-04-26 14:47:34 +02:00
2018-02-15 13:00:33 +01:00
CAF_PDM_InitField ( & m_showAnimProgress , "ShowAnimProgress" , true , "Animation progress" , "" , "" , "" );
CAF_PDM_InitField ( & m_showCaseInfo , "ShowInfoText" , true , "Case Info" , "" , "" , "" );
CAF_PDM_InitField ( & m_showResultInfo , "ShowResultInfo" , true , "Result Info" , "" , "" , "" );
CAF_PDM_InitField ( & m_showHistogram , "ShowHistogram" , true , "Histogram" , "" , "" , "" );
CAF_PDM_InitField ( & m_showVolumeWeightedMean , "ShowVolumeWeightedMean" , true , "Mobile Volume Weighted Mean" , "" , "" , "" );
2015-11-04 12:51:55 +01:00
CAF_PDM_InitFieldNoDefault ( & m_statisticsTimeRange , "StatisticsTimeRange" , "Statistics Time Range" , "" , "" , "" );
CAF_PDM_InitFieldNoDefault ( & m_statisticsCellRange , "StatisticsCellRange" , "Statistics Cell Range" , "" , "" , "" );
2015-11-06 10:18:55 +01:00
//m_statisticsCellRange.uiCapability()->setUiHidden(true);
2015-11-27 16:37:26 +01:00
m_isVisCellStatUpToDate = false ;
2017-11-16 10:39:54 +01:00
m_gridStatisticsDialog = std :: unique_ptr < RicGridStatisticsDialog > ( new RicGridStatisticsDialog ( nullptr ));
2012-09-11 09:22:36 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dOverlayInfoConfig ::~ Rim3dOverlayInfoConfig ()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig :: fieldChangedByUi ( const caf :: PdmFieldHandle * changedField , const QVariant & oldValue , const QVariant & newValue )
{
2017-10-27 17:12:25 +02:00
if ( hasInvalidStatisticsCombination () )
2015-11-12 11:53:22 +01:00
{
displayPropertyFilteredStatisticsMessage ( false );
2017-10-27 17:12:25 +02:00
if ( changedField == & m_statisticsTimeRange ) m_statisticsTimeRange = CURRENT_TIMESTEP ;
if ( changedField == & m_statisticsCellRange ) m_statisticsCellRange = ALL_CELLS ;
2015-11-12 11:53:22 +01:00
}
2018-02-15 13:00:33 +01:00
if ( changedField == & m_showResultInfo )
2017-11-16 10:50:48 +01:00
{
2018-02-15 13:00:33 +01:00
if ( ! m_showResultInfo ())
2017-11-16 10:50:48 +01:00
{
2018-02-15 13:00:33 +01:00
m_showVolumeWeightedMean = false ;
m_showVolumeWeightedMean . uiCapability () -> setUiReadOnly ( true );
2017-11-16 10:50:48 +01:00
}
else
{
2018-02-15 13:00:33 +01:00
m_showVolumeWeightedMean = true ;
m_showVolumeWeightedMean . uiCapability () -> setUiReadOnly ( false );
2017-11-16 10:50:48 +01:00
}
}
2012-09-11 09:22:36 +02:00
this -> update3DInfo ();
2013-04-29 08:32:59 +02:00
2015-04-29 22:19:49 +02:00
if ( m_viewDef && m_viewDef -> viewer ())
2013-04-29 08:32:59 +02:00
{
2015-09-01 18:04:35 +02:00
m_viewDef -> viewer () -> update ();
2013-04-29 08:32:59 +02:00
}
2017-11-16 10:50:48 +01:00
2012-09-11 09:22:36 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig :: setPosition ( cvf :: Vec2ui position )
{
m_position = position ;
}
2017-11-15 20:45:56 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-11-16 14:13:50 +01:00
Rim3dOverlayInfoConfig :: HistogramData Rim3dOverlayInfoConfig :: histogramData ()
{
auto eclipseView = dynamic_cast < RimEclipseView *> ( m_viewDef . p ());
auto geoMechView = dynamic_cast < RimGeoMechView *> ( m_viewDef . p ());
2019-01-16 10:51:43 +01:00
auto eclipseContourMap = dynamic_cast < RimEclipseContourMapView *> ( eclipseView );
auto geoMechContourMap = dynamic_cast < RimGeoMechContourMapView *> ( geoMechView );
2017-11-16 14:13:50 +01:00
2019-01-16 10:51:43 +01:00
if ( eclipseContourMap ) return histogramData ( eclipseContourMap );
else if ( geoMechContourMap ) return histogramData ( geoMechContourMap );
2018-11-06 12:47:54 +01:00
else if ( eclipseView ) return histogramData ( eclipseView );
else if ( geoMechView ) return histogramData ( geoMechView );
2017-11-16 14:13:50 +01:00
return HistogramData ();
}
2017-11-28 15:07:46 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString Rim3dOverlayInfoConfig :: timeStepText ()
{
RimEclipseView * eclipseView = dynamic_cast < RimEclipseView *> ( m_viewDef . p ());
RimGeoMechView * geoMechView = dynamic_cast < RimGeoMechView *> ( m_viewDef . p ());
if ( eclipseView ) return timeStepText ( eclipseView );
if ( geoMechView ) return timeStepText ( geoMechView );
return "" ;
}
2017-11-16 14:13:50 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString Rim3dOverlayInfoConfig :: caseInfoText ()
{
auto eclipseView = dynamic_cast < RimEclipseView *> ( m_viewDef . p ());
auto geoMechView = dynamic_cast < RimGeoMechView *> ( m_viewDef . p ());
if ( eclipseView ) return caseInfoText ( eclipseView );
if ( geoMechView ) return caseInfoText ( geoMechView );
return "" ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-01-26 15:52:59 +01:00
QString Rim3dOverlayInfoConfig :: resultInfoText ( const HistogramData & histData )
2017-11-16 14:13:50 +01:00
{
auto eclipseView = dynamic_cast < RimEclipseView *> ( m_viewDef . p ());
auto geoMechView = dynamic_cast < RimGeoMechView *> ( m_viewDef . p ());
2018-02-15 13:00:33 +01:00
if ( eclipseView ) return resultInfoText ( histData , eclipseView , m_showVolumeWeightedMean ());
2017-11-16 14:13:50 +01:00
if ( geoMechView ) return resultInfoText ( histData , geoMechView );
return "" ;
}
2017-11-29 13:34:55 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QImage Rim3dOverlayInfoConfig :: statisticsDialogScreenShotImage ()
{
2017-11-30 12:11:57 +01:00
if ( m_gridStatisticsDialog -> isVisible ())
2017-11-29 13:34:55 +01:00
{
2017-11-30 12:11:57 +01:00
return m_gridStatisticsDialog -> screenShotImage ();
2017-11-29 13:34:55 +01:00
}
2017-11-30 12:11:57 +01:00
return QImage ();
2017-11-29 13:34:55 +01:00
}
2018-02-15 13:00:33 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-03-06 16:05:01 +01:00
bool Rim3dOverlayInfoConfig :: showAnimProgress () const
2018-02-15 13:00:33 +01:00
{
return m_showAnimProgress ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-03-06 16:05:01 +01:00
bool Rim3dOverlayInfoConfig :: showCaseInfo () const
2018-02-15 13:00:33 +01:00
{
return m_showCaseInfo ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-03-06 16:05:01 +01:00
bool Rim3dOverlayInfoConfig :: showResultInfo () const
2018-02-15 13:00:33 +01:00
{
return m_showResultInfo ;
}
2018-03-06 16:05:01 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim3dOverlayInfoConfig :: isActive () const
{
return m_active ;
}
2018-10-23 16:32:40 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig :: setIsActive ( bool active )
{
m_active = active ;
}
2018-11-06 12:47:54 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-01-11 13:56:35 +01:00
Rim3dOverlayInfoConfig :: HistogramData Rim3dOverlayInfoConfig :: histogramData ( RimEclipseContourMapView * contourMap )
2018-11-06 12:47:54 +01:00
{
HistogramData histData ;
if ( contourMap )
{
2018-11-15 21:40:10 +01:00
bool isResultsInfoRelevant = contourMap -> contourMapProjection () -> numberOfValidCells () > 0u ;
2018-11-06 12:47:54 +01:00
if ( isResultsInfoRelevant )
{
2018-11-09 09:04:40 +01:00
histData . min = contourMap -> contourMapProjection () -> minValue ();
histData . max = contourMap -> contourMapProjection () -> maxValue ();
histData . mean = contourMap -> contourMapProjection () -> meanValue ();
histData . sum = contourMap -> contourMapProjection () -> sumAllValues ();
2018-11-06 12:47:54 +01:00
}
}
return histData ;
}
2019-01-16 10:51:43 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dOverlayInfoConfig :: HistogramData Rim3dOverlayInfoConfig :: histogramData ( RimGeoMechContourMapView * contourMap )
{
HistogramData histData ;
if ( contourMap )
{
bool isResultsInfoRelevant = contourMap -> contourMapProjection () -> numberOfValidCells () > 0u ;
if ( isResultsInfoRelevant )
{
histData . min = contourMap -> contourMapProjection () -> minValue ();
histData . max = contourMap -> contourMapProjection () -> maxValue ();
histData . mean = contourMap -> contourMapProjection () -> meanValue ();
histData . sum = contourMap -> contourMapProjection () -> sumAllValues ();
}
}
return histData ;
}
2018-11-06 12:47:54 +01:00
2017-11-16 14:13:50 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rim3dOverlayInfoConfig :: HistogramData Rim3dOverlayInfoConfig :: histogramData ( RimEclipseView * eclipseView )
2017-11-15 20:45:56 +01:00
{
HistogramData histData ;
2017-11-16 11:43:24 +01:00
2017-11-16 12:51:08 +01:00
if ( eclipseView )
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
bool isResultsInfoRelevant = eclipseView -> hasUserRequestedAnimation () && eclipseView -> cellResult () -> hasResult ();
2017-11-15 20:45:56 +01:00
2017-11-16 12:51:08 +01:00
if ( isResultsInfoRelevant )
2017-11-15 20:45:56 +01:00
{
2019-01-23 14:24:12 +01:00
RigEclipseResultAddress eclResAddr = eclipseView -> cellResult () -> eclipseResultAddress ();
2017-11-15 20:45:56 +01:00
2019-01-22 08:54:00 +01:00
if ( eclResAddr . isValid ())
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
if ( m_statisticsCellRange == ALL_CELLS )
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
if ( m_statisticsTimeRange == ALL_TIMESTEPS )
2017-11-15 20:45:56 +01:00
{
2019-01-22 08:54:00 +01:00
eclipseView -> currentGridCellResults () -> minMaxCellScalarValues ( eclResAddr , histData . min , histData . max );
eclipseView -> currentGridCellResults () -> p10p90CellScalarValues ( eclResAddr , histData . p10 , histData . p90 );
eclipseView -> currentGridCellResults () -> meanCellScalarValues ( eclResAddr , histData . mean );
eclipseView -> currentGridCellResults () -> sumCellScalarValues ( eclResAddr , histData . sum );
eclipseView -> currentGridCellResults () -> mobileVolumeWeightedMean ( eclResAddr , histData . weightedMean );
histData . histogram = & ( eclipseView -> currentGridCellResults () -> cellScalarValuesHistogram ( eclResAddr ));
2017-11-16 12:51:08 +01:00
}
else if ( m_statisticsTimeRange == CURRENT_TIMESTEP )
{
int currentTimeStep = eclipseView -> currentTimeStep ();
if ( eclipseView -> cellResult () -> hasStaticResult ())
{
currentTimeStep = 0 ;
}
2019-01-22 08:54:00 +01:00
eclipseView -> currentGridCellResults () -> minMaxCellScalarValues ( eclResAddr , currentTimeStep , histData . min , histData . max );
eclipseView -> currentGridCellResults () -> p10p90CellScalarValues ( eclResAddr , currentTimeStep , histData . p10 , histData . p90 );
eclipseView -> currentGridCellResults () -> meanCellScalarValues ( eclResAddr , currentTimeStep , histData . mean );
eclipseView -> currentGridCellResults () -> sumCellScalarValues ( eclResAddr , currentTimeStep , histData . sum );
eclipseView -> currentGridCellResults () -> mobileVolumeWeightedMean ( eclResAddr , currentTimeStep , histData . weightedMean );
2017-11-16 15:28:12 +01:00
2019-01-22 08:54:00 +01:00
histData . histogram = & ( eclipseView -> currentGridCellResults () -> cellScalarValuesHistogram ( eclResAddr , currentTimeStep ));
2017-11-16 12:51:08 +01:00
}
else
{
CVF_ASSERT ( false );
2017-11-15 20:45:56 +01:00
}
}
2017-11-16 12:51:08 +01:00
else if ( m_statisticsCellRange == VISIBLE_CELLS )
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
updateVisCellStatsIfNeeded ();
if ( m_statisticsTimeRange == ALL_TIMESTEPS )
{
// TODO: Only valid if we have no dynamic property filter
m_visibleCellStatistics -> meanCellScalarValues ( histData . mean );
m_visibleCellStatistics -> minMaxCellScalarValues ( histData . min , histData . max );
m_visibleCellStatistics -> p10p90CellScalarValues ( histData . p10 , histData . p90 );
m_visibleCellStatistics -> sumCellScalarValues ( histData . sum );
2017-11-20 09:28:31 +01:00
m_visibleCellStatistics -> mobileVolumeWeightedMean ( histData . weightedMean );
2017-11-15 20:45:56 +01:00
2017-11-16 12:51:08 +01:00
histData . histogram = & ( m_visibleCellStatistics -> cellScalarValuesHistogram ());
}
else if ( m_statisticsTimeRange == CURRENT_TIMESTEP )
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
int currentTimeStep = eclipseView -> currentTimeStep ();
if ( eclipseView -> cellResult () -> hasStaticResult ())
{
currentTimeStep = 0 ;
}
m_visibleCellStatistics -> meanCellScalarValues ( currentTimeStep , histData . mean );
m_visibleCellStatistics -> minMaxCellScalarValues ( currentTimeStep , histData . min , histData . max );
m_visibleCellStatistics -> p10p90CellScalarValues ( currentTimeStep , histData . p10 , histData . p90 );
m_visibleCellStatistics -> sumCellScalarValues ( currentTimeStep , histData . sum );
m_visibleCellStatistics -> mobileVolumeWeightedMean ( currentTimeStep , histData . weightedMean );
histData . histogram = & ( m_visibleCellStatistics -> cellScalarValuesHistogram ( currentTimeStep ));
2017-11-15 20:45:56 +01:00
}
}
}
2017-11-16 12:51:08 +01:00
else if ( eclipseView -> cellResult () -> isFlowDiagOrInjectionFlooding ())
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
if ( m_statisticsTimeRange == CURRENT_TIMESTEP || m_statisticsTimeRange == ALL_TIMESTEPS ) // All timesteps is ignored
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
int currentTimeStep = eclipseView -> currentTimeStep ();
2017-11-15 20:45:56 +01:00
2017-11-16 12:51:08 +01:00
if ( m_statisticsCellRange == ALL_CELLS )
{
RigFlowDiagResults * fldResults = eclipseView -> cellResult () -> flowDiagSolution () -> flowDiagResults ();
RigFlowDiagResultAddress resAddr = eclipseView -> cellResult () -> flowDiagResAddress ();
2017-11-16 11:43:24 +01:00
2017-11-16 12:51:08 +01:00
fldResults -> minMaxScalarValues ( resAddr , currentTimeStep , & histData . min , & histData . max );
fldResults -> p10p90ScalarValues ( resAddr , currentTimeStep , & histData . p10 , & histData . p90 );
fldResults -> meanScalarValue ( resAddr , currentTimeStep , & histData . mean );
fldResults -> sumScalarValue ( resAddr , currentTimeStep , & histData . sum );
2017-11-16 14:59:55 +01:00
fldResults -> mobileVolumeWeightedMean ( resAddr , currentTimeStep , & histData . weightedMean );
2017-11-15 20:45:56 +01:00
2017-11-16 12:51:08 +01:00
histData . histogram = & ( fldResults -> scalarValuesHistogram ( resAddr , currentTimeStep ));
}
else if ( m_statisticsCellRange == VISIBLE_CELLS )
{
updateVisCellStatsIfNeeded ();
2017-11-15 20:45:56 +01:00
2017-11-16 12:51:08 +01:00
m_visibleCellStatistics -> meanCellScalarValues ( currentTimeStep , histData . mean );
m_visibleCellStatistics -> minMaxCellScalarValues ( currentTimeStep , histData . min , histData . max );
m_visibleCellStatistics -> p10p90CellScalarValues ( currentTimeStep , histData . p10 , histData . p90 );
m_visibleCellStatistics -> sumCellScalarValues ( currentTimeStep , histData . sum );
m_visibleCellStatistics -> mobileVolumeWeightedMean ( currentTimeStep , histData . weightedMean );
histData . histogram = & ( m_visibleCellStatistics -> cellScalarValuesHistogram ( currentTimeStep ));
}
2017-11-15 20:45:56 +01:00
}
}
}
}
return histData ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-11-16 14:13:50 +01:00
Rim3dOverlayInfoConfig :: HistogramData Rim3dOverlayInfoConfig :: histogramData ( RimGeoMechView * geoMechView )
{
HistogramData histData ;
if ( geoMechView )
{
RimGeoMechCase * geoMechCase = geoMechView -> geoMechCase ();
RigGeoMechCaseData * caseData = geoMechCase ? geoMechCase -> geoMechData () : nullptr ;
bool isResultsInfoRelevant = caseData && geoMechView -> hasUserRequestedAnimation () && geoMechView -> cellResultResultDefinition () -> hasResult ();
if ( isResultsInfoRelevant )
{
RigFemResultAddress resAddress = geoMechView -> cellResultResultDefinition () -> resultAddress ();
if ( m_statisticsCellRange == ALL_CELLS )
{
if ( m_statisticsTimeRange == ALL_TIMESTEPS )
{
caseData -> femPartResults () -> meanScalarValue ( resAddress , & histData . mean );
caseData -> femPartResults () -> minMaxScalarValues ( resAddress , & histData . min , & histData . max );
caseData -> femPartResults () -> p10p90ScalarValues ( resAddress , & histData . p10 , & histData . p90 );
caseData -> femPartResults () -> sumScalarValue ( resAddress , & histData . sum );
histData . histogram = & ( caseData -> femPartResults () -> scalarValuesHistogram ( resAddress ));
}
else if ( m_statisticsTimeRange == CURRENT_TIMESTEP )
{
int timeStepIdx = geoMechView -> currentTimeStep ();
caseData -> femPartResults () -> meanScalarValue ( resAddress , timeStepIdx , & histData . mean );
caseData -> femPartResults () -> minMaxScalarValues ( resAddress , timeStepIdx , & histData . min , & histData . max );
caseData -> femPartResults () -> p10p90ScalarValues ( resAddress , timeStepIdx , & histData . p10 , & histData . p90 );
caseData -> femPartResults () -> sumScalarValue ( resAddress , timeStepIdx , & histData . sum );
histData . histogram = & ( caseData -> femPartResults () -> scalarValuesHistogram ( resAddress , timeStepIdx ));
}
}
else if ( m_statisticsCellRange == VISIBLE_CELLS )
{
this -> updateVisCellStatsIfNeeded ();
if ( m_statisticsTimeRange == ALL_TIMESTEPS )
{
// TODO: Only valid if we have no dynamic property filter
m_visibleCellStatistics -> meanCellScalarValues ( histData . mean );
m_visibleCellStatistics -> minMaxCellScalarValues ( histData . min , histData . max );
m_visibleCellStatistics -> p10p90CellScalarValues ( histData . p10 , histData . p90 );
m_visibleCellStatistics -> sumCellScalarValues ( histData . sum );
histData . histogram = & ( m_visibleCellStatistics -> cellScalarValuesHistogram ());
}
else if ( m_statisticsTimeRange == CURRENT_TIMESTEP )
{
int timeStepIdx = geoMechView -> currentTimeStep ();
m_visibleCellStatistics -> meanCellScalarValues ( timeStepIdx , histData . mean );
m_visibleCellStatistics -> minMaxCellScalarValues ( timeStepIdx , histData . min , histData . max );
m_visibleCellStatistics -> p10p90CellScalarValues ( timeStepIdx , histData . p10 , histData . p90 );
m_visibleCellStatistics -> sumCellScalarValues ( timeStepIdx , histData . sum );
histData . histogram = & ( m_visibleCellStatistics -> cellScalarValuesHistogram ( timeStepIdx ));
}
}
}
}
return histData ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString Rim3dOverlayInfoConfig :: caseInfoText ( RimEclipseView * eclipseView )
2017-11-15 20:45:56 +01:00
{
QString infoText ;
2017-11-16 14:13:50 +01:00
if ( eclipseView )
2017-11-15 20:45:56 +01:00
{
2018-11-06 12:47:54 +01:00
QString caseName = eclipseView -> eclipseCase () -> caseUserDescription ();
2019-01-11 13:56:35 +01:00
RimEclipseContourMapView * contourMap = dynamic_cast < RimEclipseContourMapView *> ( eclipseView );
2018-11-09 09:04:40 +01:00
if ( contourMap && contourMap -> contourMapProjection ())
2017-11-15 20:45:56 +01:00
{
2018-11-15 21:40:10 +01:00
QString totCellCount = QString :: number ( contourMap -> contourMapProjection () -> numberOfCells ());
cvf :: uint validCellCount = contourMap -> contourMapProjection () -> numberOfValidCells ();
2018-11-06 12:47:54 +01:00
QString activeCellCountText = QString :: number ( validCellCount );
2018-11-21 09:32:04 +01:00
QString iSize = QString :: number ( contourMap -> contourMapProjection () -> numberOfElementsIJ (). x ());
QString jSize = QString :: number ( contourMap -> contourMapProjection () -> numberOfElementsIJ (). y ());
2018-11-09 09:04:40 +01:00
QString aggregationType = contourMap -> contourMapProjection () -> resultAggregationText ();
2018-11-09 15:25:35 +01:00
QString weightingParameterString ;
if ( contourMap -> contourMapProjection () -> weightingParameter () != "None" )
{
weightingParameterString += QString ( " (Weight: %1)" ). arg ( contourMap -> contourMapProjection () -> weightingParameter ());
}
2018-11-06 12:47:54 +01:00
infoText += QString (
2018-11-09 09:04:40 +01:00
"<p><b>-- Contour Map: %1 --</b><p> "
"<b>Sample Count. Total:</b> %2 <b>Valid Results:</b> %3 <br>"
2018-11-13 14:45:21 +01:00
"<b>Projection Type:</b> %4%5<br>" ). arg ( caseName , totCellCount , activeCellCountText , aggregationType , weightingParameterString );
2018-11-06 12:47:54 +01:00
}
else if ( eclipseView -> mainGrid ())
{
QString totCellCount = QString :: number ( eclipseView -> mainGrid () -> globalCellArray (). size ());
2017-11-15 20:45:56 +01:00
size_t mxActCellCount = eclipseView -> eclipseCase () -> eclipseCaseData () -> activeCellInfo ( RiaDefines :: MATRIX_MODEL ) -> reservoirActiveCellCount ();
size_t frActCellCount = eclipseView -> eclipseCase () -> eclipseCaseData () -> activeCellInfo ( RiaDefines :: FRACTURE_MODEL ) -> reservoirActiveCellCount ();
2018-11-06 12:47:54 +01:00
QString activeCellCountText ;
2017-11-15 20:45:56 +01:00
if ( frActCellCount > 0 ) activeCellCountText += "Matrix : " ;
activeCellCountText += QString :: number ( mxActCellCount );
if ( frActCellCount > 0 ) activeCellCountText += " Fracture : " + QString :: number ( frActCellCount );
2018-11-06 12:47:54 +01:00
QString iSize = QString :: number ( eclipseView -> mainGrid () -> cellCountI ());
QString jSize = QString :: number ( eclipseView -> mainGrid () -> cellCountJ ());
QString kSize = QString :: number ( eclipseView -> mainGrid () -> cellCountK ());
2017-11-15 20:45:56 +01:00
2018-11-06 12:47:54 +01:00
QString zScale = QString :: number ( eclipseView -> scaleZ ());
infoText += QString (
"<p><b>-- %1 --</b><p> "
"<b>Cell count. Total:</b> %2 <b>Active:</b> %3 <br>"
"<b>Main Grid I,J,K:</b> %4, %5, %6 <b>Z-Scale:</b> %7<br>" ). arg ( caseName , totCellCount , activeCellCountText , iSize , jSize , kSize , zScale );
2017-11-15 20:45:56 +01:00
}
}
return infoText ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-11-16 14:13:50 +01:00
QString Rim3dOverlayInfoConfig :: caseInfoText ( RimGeoMechView * geoMechView )
{
QString infoText ;
if ( geoMechView )
{
2019-01-16 10:51:43 +01:00
RimGeoMechCase * geoMechCase = geoMechView -> geoMechCase ();
RigGeoMechCaseData * caseData = geoMechCase ? geoMechCase -> geoMechData () : nullptr ;
2018-02-18 18:56:43 +01:00
RigFemPartCollection * femParts = caseData ? caseData -> femParts () : nullptr ;
2017-11-16 14:13:50 +01:00
if ( femParts )
{
QString caseName = geoMechCase -> caseUserDescription ();
2019-01-16 10:51:43 +01:00
RimGeoMechContourMapView * contourMap = dynamic_cast < RimGeoMechContourMapView *> ( geoMechView );
2017-11-16 14:13:50 +01:00
2019-01-16 10:51:43 +01:00
if ( contourMap && contourMap -> contourMapProjection ())
{
QString totCellCount = QString :: number ( contourMap -> contourMapProjection () -> numberOfCells ());
cvf :: uint validCellCount = contourMap -> contourMapProjection () -> numberOfValidCells ();
QString activeCellCountText = QString :: number ( validCellCount );
QString iSize = QString :: number ( contourMap -> contourMapProjection () -> numberOfElementsIJ (). x ());
QString jSize = QString :: number ( contourMap -> contourMapProjection () -> numberOfElementsIJ (). y ());
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 );
}
else
{
QString cellCount = QString ( "%1" ). arg ( femParts -> totalElementCount ());
QString zScale = QString :: number ( geoMechView -> scaleZ ());
infoText = QString (
"<p><b>-- %1 --</b><p>"
"<b>Cell count:</b> %2 <b>Z-Scale:</b> %3<br>" ). arg ( caseName , cellCount , zScale );
}
2017-11-16 14:13:50 +01:00
}
}
return infoText ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-12-05 11:24:11 +01:00
QString Rim3dOverlayInfoConfig :: resultInfoText ( const HistogramData & histData , RimEclipseView * eclipseView , bool showVolumeWeightedMean )
2017-11-15 20:45:56 +01:00
{
QString infoText ;
2019-01-11 13:56:35 +01:00
RimEclipseContourMapView * contourMap = dynamic_cast < RimEclipseContourMapView *> ( eclipseView );
2018-11-06 12:47:54 +01:00
if ( contourMap )
{
2018-11-15 21:40:10 +01:00
bool isResultsInfoRelevant = contourMap -> contourMapProjection () -> numberOfValidCells () > 0u ;
2018-11-06 12:47:54 +01:00
if ( isResultsInfoRelevant )
{
QString propName = eclipseView -> cellResult () -> resultVariableUiShortName ();
2018-11-09 11:43:16 +01:00
if ( ! contourMap -> contourMapProjection () -> isColumnResult ())
{
infoText += QString ( "<b>Cell Property:</b> %1 " ). arg ( propName );
}
2018-11-06 13:39:23 +01:00
infoText += QString ( "<br><b>Statistics:</b> Current Time Step and Visible Cells" );
2018-11-06 12:47:54 +01:00
infoText += QString ( "<table border=0 cellspacing=5 >"
"<tr> <td>Min</td> <td>Mean</td> <td>Max</td> <td>Sum</td> </tr>"
"<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> </tr>"
"</table>" ). arg ( histData . min ). arg ( histData . mean ). arg ( histData . max ). arg ( histData . sum );
}
}
else if ( eclipseView )
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
bool isResultsInfoRelevant = eclipseView -> hasUserRequestedAnimation () && eclipseView -> cellResult () -> hasResult ();
2017-11-15 20:45:56 +01:00
2017-11-16 12:51:08 +01:00
if ( eclipseView -> cellResult () -> isTernarySaturationSelected ())
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
QString propName = eclipseView -> cellResult () -> resultVariableUiShortName ();
infoText += QString ( "<b>Cell Property:</b> %1 " ). arg ( propName );
2017-11-15 20:45:56 +01:00
}
2017-11-16 12:51:08 +01:00
if ( isResultsInfoRelevant )
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
QString propName = eclipseView -> cellResult () -> resultVariableUiShortName ();
QString timeRangeText = m_statisticsTimeRange (). uiText ();
if ( eclipseView -> cellResult () -> isFlowDiagOrInjectionFlooding ())
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
timeRangeText = caf :: AppEnum < StatisticsTimeRangeType >:: uiText ( CURRENT_TIMESTEP );
}
infoText += QString ( "<b>Cell Property:</b> %1 " ). arg ( propName );
infoText += QString ( "<br><b>Statistics:</b> " ) + timeRangeText + " and " + m_statisticsCellRange (). uiText ();
infoText += QString ( "<table border=0 cellspacing=5 >"
2018-06-26 08:48:58 +02:00
"<tr> <td>Min</td> <td>P90</td> <td>Mean</td> <td>P10</td> <td>Max</td> <td>Sum</td> </tr>"
2017-11-16 12:51:08 +01:00
"<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5</td> <td> %6</td> </tr>"
"</table>" ). arg ( histData . min ). arg ( histData . p10 ). arg ( histData . mean ). arg ( histData . p90 ). arg ( histData . max ). arg ( histData . sum );
if ( eclipseView -> faultResultSettings () -> hasValidCustomResult ())
{
QString faultMapping ;
bool isShowingGrid = eclipseView -> faultCollection () -> isGridVisualizationMode ();
if ( ! isShowingGrid )
2017-11-15 20:45:56 +01:00
{
2017-11-16 12:51:08 +01:00
if ( eclipseView -> faultCollection () -> faultResult () == RimFaultInViewCollection :: FAULT_BACK_FACE_CULLING )
{
faultMapping = "Cells behind fault" ;
}
else if ( eclipseView -> faultCollection () -> faultResult () == RimFaultInViewCollection :: FAULT_FRONT_FACE_CULLING )
{
faultMapping = "Cells in front of fault" ;
}
else
{
faultMapping = "Cells in front and behind fault" ;
}
2017-11-15 20:45:56 +01:00
}
else
{
faultMapping = "Cells in front and behind fault" ;
}
2017-11-16 12:51:08 +01:00
infoText += QString ( "<b>Fault results: </b> %1<br>" ). arg ( faultMapping );
infoText += QString ( "<b>Fault Property:</b> %1 <br>" ). arg ( eclipseView -> faultResultSettings () -> customFaultResult () -> resultVariableUiShortName ());
}
2017-11-15 20:45:56 +01:00
}
2017-11-16 12:51:08 +01:00
if ( eclipseView -> hasUserRequestedAnimation () && eclipseView -> cellEdgeResult () -> hasResult ())
{
double min , max ;
QString cellEdgeName = eclipseView -> cellEdgeResult () -> resultVariableUiShortName ();
eclipseView -> cellEdgeResult () -> minMaxCellEdgeValues ( min , max );
infoText += QString ( "<b>Cell Edge Property:</b> %1 " ). arg ( cellEdgeName );
infoText += QString ( "<table border=0 cellspacing=5 >"
"<tr> <td>Min</td> <td></td> <td></td> <td></td> <td>Max</td> </tr>"
"<tr> <td>%1</td> <td></td> <td></td> <td></td> <td> %2</td></tr>"
"</table>" ). arg ( min ). arg ( max );
}
2017-11-15 20:45:56 +01:00
2017-12-05 11:24:11 +01:00
if ( showVolumeWeightedMean && histData . weightedMean != HUGE_VAL )
2017-11-16 12:51:08 +01:00
{
infoText += QString ( "<b>Mobile Volume Weighted Mean:</b> %1" ). arg ( histData . weightedMean );
}
2017-11-16 11:43:24 +01:00
}
2017-11-15 20:45:56 +01:00
return infoText ;
}
2017-11-16 10:39:54 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-11-16 14:13:50 +01:00
QString Rim3dOverlayInfoConfig :: resultInfoText ( const HistogramData & histData , RimGeoMechView * geoMechView )
2017-11-16 10:39:54 +01:00
{
2017-11-16 14:13:50 +01:00
QString infoText ;
2017-11-16 10:39:54 +01:00
2017-11-16 14:13:50 +01:00
if ( geoMechView )
{
RimGeoMechCase * geoMechCase = geoMechView -> geoMechCase ();
RigGeoMechCaseData * caseData = geoMechCase ? geoMechCase -> geoMechData () : nullptr ;
bool isResultsInfoRelevant = caseData && geoMechView -> hasUserRequestedAnimation () && geoMechView -> cellResultResultDefinition () -> hasResult ();
if ( isResultsInfoRelevant )
{
QString resultPos ;
QString fieldName = geoMechView -> cellResultResultDefinition () -> resultFieldUiName ();
QString compName = geoMechView -> cellResultResultDefinition () -> resultComponentUiName ();
switch ( geoMechView -> cellResultResultDefinition () -> resultPositionType ())
{
case RIG_NODAL :
resultPos = "Nodal" ;
break ;
case RIG_ELEMENT_NODAL :
resultPos = "Element nodal" ;
break ;
case RIG_INTEGRATION_POINT :
resultPos = "Integration point" ;
break ;
2018-01-10 16:32:59 +01:00
case RIG_ELEMENT :
resultPos = "Element" ;
break ;
2017-11-16 14:13:50 +01:00
default :
break ;
}
2018-01-11 10:19:22 +01:00
if ( compName == "" )
{
infoText += QString ( "<b>Cell result:</b> %1, %2" ). arg ( resultPos ). arg ( fieldName );
}
else
{
infoText += QString ( "<b>Cell result:</b> %1, %2, %3" ). arg ( resultPos ). arg ( fieldName ). arg ( compName );
}
2017-11-16 14:13:50 +01:00
infoText += QString ( "<br><b>Statistics:</b> " ) + m_statisticsTimeRange (). uiText () + " and " + m_statisticsCellRange (). uiText ();
infoText += QString ( "<table border=0 cellspacing=5 >"
2018-06-26 08:48:58 +02:00
"<tr> <td>Min</td> <td>P90</td> <td>Mean</td> <td>P10</td> <td>Max</td> <td>Sum</td> </tr>"
2017-11-16 14:13:50 +01:00
"<tr> <td>%1</td> <td> %2</td> <td> %3</td> <td> %4</td> <td> %5</td> <td> %6</td> </tr>"
"</table>" ). arg ( histData . min ). arg ( histData . p10 ). arg ( histData . mean ). arg ( histData . p90 ). arg ( histData . max ). arg ( histData . sum );
}
}
return infoText ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2017-11-29 13:34:55 +01:00
void Rim3dOverlayInfoConfig :: showStatisticsInfoDialog ( bool raise )
2017-11-16 14:13:50 +01:00
{
if ( m_viewDef )
2017-11-16 10:39:54 +01:00
{
2017-11-17 08:30:23 +01:00
// Show dialog before setting data due to text edit auto height setting
m_gridStatisticsDialog -> resize ( 600 , 800 );
m_gridStatisticsDialog -> show ();
2017-11-16 10:39:54 +01:00
m_gridStatisticsDialog -> setLabel ( "Grid statistics" );
2017-11-29 13:34:55 +01:00
m_gridStatisticsDialog -> updateFromRimView ( m_viewDef );
2017-11-17 08:30:23 +01:00
2017-11-29 13:34:55 +01:00
if ( raise )
{
m_gridStatisticsDialog -> raise ();
}
2017-11-16 10:39:54 +01:00
}
}
2012-09-11 09:22:36 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig :: update3DInfo ()
{
2014-08-01 13:35:52 +02:00
this -> updateUiIconFromToggleField ();
2013-04-26 14:47:34 +02:00
2015-04-29 22:19:49 +02:00
if ( ! m_viewDef ) return ;
if ( ! m_viewDef -> viewer ()) return ;
2017-10-18 10:43:27 +02:00
2018-02-15 13:00:33 +01:00
if ( ! this -> m_active ())
2013-04-26 14:47:34 +02:00
{
2015-04-29 22:19:49 +02:00
m_viewDef -> viewer () -> showInfoText ( false );
m_viewDef -> viewer () -> showHistogram ( false );
m_viewDef -> viewer () -> showAnimationProgress ( false );
2017-10-18 10:43:27 +02:00
2018-03-06 16:05:01 +01:00
update3DInfoIn2dViews ();
2013-04-26 14:47:34 +02:00
return ;
}
2012-09-11 09:22:36 +02:00
2018-02-15 13:00:33 +01:00
m_viewDef -> viewer () -> showInfoText ( m_showCaseInfo () || m_showResultInfo ());
2015-04-29 22:19:49 +02:00
m_viewDef -> viewer () -> showHistogram ( false );
2018-02-15 13:00:33 +01:00
m_viewDef -> viewer () -> showAnimationProgress ( m_showAnimProgress ());
2017-10-18 10:43:27 +02:00
2015-11-06 10:18:55 +01:00
m_isVisCellStatUpToDate = false ;
2012-09-11 09:22:36 +02:00
2017-10-27 17:12:25 +02:00
if ( hasInvalidStatisticsCombination ())
2015-11-12 11:53:22 +01:00
{
displayPropertyFilteredStatisticsMessage ( true );
m_statisticsTimeRange = CURRENT_TIMESTEP ;
}
2015-05-21 10:05:33 +02:00
RimEclipseView * reservoirView = dynamic_cast < RimEclipseView *> ( m_viewDef . p ());
2017-11-16 10:39:54 +01:00
if ( reservoirView )
{
updateEclipse3DInfo ( reservoirView );
// Update statistics dialog
2017-11-29 13:34:55 +01:00
m_gridStatisticsDialog -> updateFromRimView ( reservoirView );
2017-11-16 10:39:54 +01:00
}
2017-11-16 14:13:50 +01:00
2015-04-29 22:19:49 +02:00
RimGeoMechView * geoMechView = dynamic_cast < RimGeoMechView *> ( m_viewDef . p ());
2017-11-16 14:13:50 +01:00
if ( geoMechView )
{
2018-02-15 13:00:33 +01:00
m_showVolumeWeightedMean = false ;
2017-11-20 09:24:19 +01:00
2017-11-16 14:13:50 +01:00
updateGeoMech3DInfo ( geoMechView );
// Update statistics dialog
2017-11-29 13:34:55 +01:00
m_gridStatisticsDialog -> updateFromRimView ( geoMechView );
2017-11-16 14:13:50 +01:00
}
2018-02-15 13:00:33 +01:00
2018-03-06 16:05:01 +01:00
update3DInfoIn2dViews ();
2015-04-29 22:19:49 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf :: PdmFieldHandle * Rim3dOverlayInfoConfig :: objectToggleField ()
{
2018-02-15 13:00:33 +01:00
return & m_active ;
2015-04-29 22:19:49 +02:00
}
2017-01-03 13:14:07 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig :: defineUiOrdering ( QString uiConfigName , caf :: PdmUiOrdering & uiOrdering )
{
caf :: PdmUiGroup * visGroup = uiOrdering . addNewGroup ( "Visibility" );
2018-11-06 13:39:23 +01:00
RimEclipseView * eclipseView = dynamic_cast < RimEclipseView *> ( m_viewDef . p ());
2019-01-11 13:56:35 +01:00
RimEclipseContourMapView * contourMap = dynamic_cast < RimEclipseContourMapView *> ( eclipseView );
2018-11-06 13:39:23 +01:00
RimGeoMechView * geoMechView = dynamic_cast < RimGeoMechView *> ( m_viewDef . p ());
2018-02-15 13:00:33 +01:00
visGroup -> add ( & m_showAnimProgress );
visGroup -> add ( & m_showCaseInfo );
visGroup -> add ( & m_showResultInfo );
2018-11-06 13:39:23 +01:00
if ( ! geoMechView && ! contourMap )
2017-11-20 09:24:19 +01:00
{
2018-02-15 13:00:33 +01:00
visGroup -> add ( & m_showVolumeWeightedMean );
2017-11-20 09:24:19 +01:00
}
2018-11-06 13:39:23 +01:00
if ( ! contourMap )
{
visGroup -> add ( & m_showHistogram );
}
2017-01-03 13:14:07 +01:00
2018-11-06 13:39:23 +01:00
if ( contourMap )
2017-01-03 13:14:07 +01:00
{
2018-11-06 13:39:23 +01:00
m_statisticsTimeRange = Rim3dOverlayInfoConfig :: CURRENT_TIMESTEP ;
m_statisticsCellRange = Rim3dOverlayInfoConfig :: VISIBLE_CELLS ;
2017-01-03 13:14:07 +01:00
}
2018-11-06 13:39:23 +01:00
else
{
caf :: PdmUiGroup * statGroup = uiOrdering . addNewGroup ( "Statistics Options" );
2017-01-03 13:14:07 +01:00
2018-11-06 13:39:23 +01:00
if ( ! eclipseView || ! eclipseView -> cellResult () -> isFlowDiagOrInjectionFlooding ())
{
statGroup -> add ( & m_statisticsTimeRange );
}
statGroup -> add ( & m_statisticsCellRange );
}
2017-03-21 13:47:53 +01:00
uiOrdering . skipRemainingFields ( true );
2017-01-03 13:14:07 +01:00
}
2015-04-29 22:19:49 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-01-15 14:52:22 +01:00
void Rim3dOverlayInfoConfig :: setReservoirView ( RimGridView * ownerReservoirView )
2015-04-29 22:19:49 +02:00
{
m_viewDef = ownerReservoirView ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-11 17:44:00 +01:00
void Rim3dOverlayInfoConfig :: updateEclipse3DInfo ( RimEclipseView * eclipseView )
2015-04-29 22:19:49 +02:00
{
2017-11-15 20:45:56 +01:00
HistogramData histData ;
2015-11-06 13:22:54 +01:00
2018-02-15 13:00:33 +01:00
if ( m_showHistogram () || m_showResultInfo ())
2015-11-06 13:22:54 +01:00
{
2017-11-16 12:51:08 +01:00
histData = histogramData ();
2015-11-06 13:22:54 +01:00
}
2015-11-11 17:44:00 +01:00
QString infoText ;
2018-02-15 13:00:33 +01:00
if ( m_showCaseInfo ())
2012-09-11 09:22:36 +02:00
{
2017-11-16 12:51:08 +01:00
infoText = caseInfoText ();
2015-11-11 17:44:00 +01:00
}
2012-09-11 09:22:36 +02:00
2018-02-15 13:00:33 +01:00
if ( m_showResultInfo ())
2015-11-11 17:44:00 +01:00
{
2018-01-26 15:52:59 +01:00
infoText += resultInfoText ( histData );
2015-11-11 17:44:00 +01:00
}
2012-09-11 09:22:36 +02:00
2015-11-11 17:44:00 +01:00
if ( ! infoText . isEmpty ())
{
eclipseView -> viewer () -> setInfoText ( infoText );
2012-09-11 09:22:36 +02:00
}
2018-02-15 13:00:33 +01:00
if ( m_showHistogram ())
2012-09-11 09:22:36 +02:00
{
2017-11-15 20:45:56 +01:00
bool isResultsInfoRelevant = eclipseView -> hasUserRequestedAnimation () && eclipseView -> cellResult () -> hasResult ();
if ( isResultsInfoRelevant && histData . histogram )
2012-09-11 09:22:36 +02:00
{
2015-11-11 17:44:00 +01:00
eclipseView -> viewer () -> showHistogram ( true );
2017-11-15 20:45:56 +01:00
eclipseView -> viewer () -> setHistogram ( histData . min , histData . max , * histData . histogram );
eclipseView -> viewer () -> setHistogramPercentiles ( histData . p10 , histData . p90 , histData . mean );
2012-09-11 09:22:36 +02:00
}
}
}
2013-04-26 14:47:34 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-04-29 22:19:49 +02:00
void Rim3dOverlayInfoConfig :: updateGeoMech3DInfo ( RimGeoMechView * geoMechView )
2013-04-26 14:47:34 +02:00
{
2017-11-16 14:13:50 +01:00
HistogramData histData ;
2015-11-06 10:18:55 +01:00
2018-02-15 13:00:33 +01:00
if ( m_showResultInfo () || m_showHistogram ())
2015-11-06 10:18:55 +01:00
{
2017-11-16 14:13:50 +01:00
histData = histogramData ( geoMechView );
2015-11-06 10:18:55 +01:00
}
// Compose text
2015-11-11 17:44:00 +01:00
QString infoText ;
2018-02-15 13:00:33 +01:00
if ( m_showCaseInfo ())
2015-04-29 22:19:49 +02:00
{
2017-11-16 14:13:50 +01:00
infoText = caseInfoText ( geoMechView );
2015-11-11 17:44:00 +01:00
}
2018-02-15 13:00:33 +01:00
if ( m_showResultInfo ())
2015-11-11 17:44:00 +01:00
{
2017-11-16 14:13:50 +01:00
infoText += resultInfoText ( histData , geoMechView );
2015-11-11 17:44:00 +01:00
}
2015-06-02 10:37:05 +02:00
2015-11-11 17:44:00 +01:00
if ( ! infoText . isEmpty ())
{
2015-04-29 22:19:49 +02:00
geoMechView -> viewer () -> setInfoText ( infoText );
}
2015-04-20 09:02:33 +02:00
2015-11-06 10:18:55 +01:00
// Populate histogram
2018-02-15 13:00:33 +01:00
if ( m_showHistogram ())
2015-04-29 22:19:49 +02:00
{
2017-11-16 14:13:50 +01:00
RimGeoMechCase * geoMechCase = geoMechView -> geoMechCase ();
RigGeoMechCaseData * caseData = geoMechCase ? geoMechCase -> geoMechData () : nullptr ;
bool isResultsInfoRelevant = caseData && geoMechView -> hasUserRequestedAnimation () && geoMechView -> cellResultResultDefinition () -> hasResult ();
2015-11-06 10:18:55 +01:00
if ( isResultsInfoRelevant )
2015-06-19 14:38:31 +02:00
{
geoMechView -> viewer () -> showHistogram ( true );
2017-11-16 14:13:50 +01:00
geoMechView -> viewer () -> setHistogram ( histData . min , histData . max , * histData . histogram );
geoMechView -> viewer () -> setHistogramPercentiles ( histData . p10 , histData . p90 , histData . mean );
2015-11-06 10:18:55 +01:00
}
}
}
2015-06-02 10:37:05 +02:00
2018-03-06 16:05:01 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig :: update3DInfoIn2dViews () const
{
RimCase * rimCase ;
firstAncestorOrThisOfType ( rimCase );
if ( rimCase )
{
for ( Rim2dIntersectionView * view : rimCase -> intersectionViewCollection () -> views ())
{
view -> update3dInfo ();
}
}
}
2017-11-28 15:07:46 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString Rim3dOverlayInfoConfig :: timeStepText ( RimEclipseView * eclipseView )
{
int currTimeStepIndex = eclipseView -> currentTimeStep ();
std :: vector < QDateTime > timeSteps = eclipseView -> currentGridCellResults () -> allTimeStepDatesFromEclipseReader ();
2017-11-29 07:13:16 +01:00
QString dateTimeString ;
2017-11-29 11:54:53 +01:00
if ( currTimeStepIndex >= 0 && currTimeStepIndex < ( int ) timeSteps . size ())
2017-11-29 07:13:16 +01:00
{
QString dateFormat = RimTools :: createTimeFormatStringFromDates ( timeSteps );
2018-10-01 20:50:43 +02:00
QString dateString = RiaQDateTimeTools :: toStringUsingApplicationLocale ( timeSteps [ currTimeStepIndex ], dateFormat );
2017-11-29 07:13:16 +01:00
dateTimeString = QString ( "Time Step: %1/%2 %3" ). arg ( QString :: number ( currTimeStepIndex ),
QString :: number ( timeSteps . size () - 1 ),
2018-10-01 20:50:43 +02:00
dateString );
2017-11-29 07:13:16 +01:00
}
2017-11-28 15:07:46 +01:00
return QString ( "<p><b><center>-- %1 --</center></b>" ). arg ( dateTimeString ) +
QString ( "<center>------------------------------------------------</center>" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString Rim3dOverlayInfoConfig :: timeStepText ( RimGeoMechView * geoMechView )
{
int currTimeStepIndex = geoMechView -> currentTimeStep ();
2018-04-23 16:35:19 +02:00
QStringList timeSteps ;
if ( geoMechView -> geoMechCase ()) timeSteps = geoMechView -> geoMechCase () -> timeStepStrings ();
2017-11-28 15:07:46 +01:00
2017-11-29 07:13:16 +01:00
QString dateTimeString ;
if ( currTimeStepIndex >= 0 && currTimeStepIndex < timeSteps . size ())
{
dateTimeString = QString ( "Time Step: %1/%2 %3" ). arg ( QString :: number ( currTimeStepIndex ),
QString :: number ( timeSteps . size () - 1 ),
timeSteps [ currTimeStepIndex ]);
}
2017-11-28 15:07:46 +01:00
return QString ( "<p><b><center>-- %1 --</center></b>" ). arg ( dateTimeString ) +
QString ( "<center>------------------------------------------------</center>" );
}
2015-11-06 10:18:55 +01:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void Rim3dOverlayInfoConfig :: updateVisCellStatsIfNeeded ()
{
RimEclipseView * eclipseView = dynamic_cast < RimEclipseView *> ( m_viewDef . p ());
RimGeoMechView * geoMechView = dynamic_cast < RimGeoMechView *> ( m_viewDef . p ());
2015-11-04 15:44:09 +01:00
2015-11-06 10:18:55 +01:00
if ( ! m_isVisCellStatUpToDate )
{
cvf :: ref < RigStatisticsCalculator > calc ;
if ( geoMechView )
{
2016-10-18 07:31:02 +02:00
RigFemResultAddress resAddress = geoMechView -> cellResultResultDefinition () -> resultAddress ();
2015-11-06 10:18:55 +01:00
calc = new RigFemNativeVisibleCellsStatCalc ( geoMechView -> geoMechCase () -> geoMechData (),
2017-10-18 10:43:27 +02:00
resAddress ,
geoMechView -> currentTotalCellVisibility (). p ());
2015-06-02 10:37:05 +02:00
}
2015-11-06 10:18:55 +01:00
else if ( eclipseView )
{
2017-10-18 11:58:51 +02:00
if ( eclipseView -> cellResult () -> isFlowDiagOrInjectionFlooding ())
2017-01-03 13:14:07 +01:00
{
RigFlowDiagResultAddress resAddr = eclipseView -> cellResult () -> flowDiagResAddress ();
RigFlowDiagResults * fldResults = eclipseView -> cellResult () -> flowDiagSolution () -> flowDiagResults ();
2017-10-18 10:43:27 +02:00
calc = new RigFlowDiagVisibleCellsStatCalc ( fldResults ,
resAddr ,
eclipseView -> currentTotalCellVisibility (). p ());
2017-01-03 13:14:07 +01:00
}
else
{
2019-01-23 14:24:12 +01:00
RigEclipseResultAddress scalarIndex = eclipseView -> cellResult () -> eclipseResultAddress ();
2017-09-13 10:39:20 +02:00
calc = new RigEclipseNativeVisibleCellsStatCalc ( eclipseView -> currentGridCellResults (),
2019-01-22 08:54:00 +01:00
scalarIndex ,
eclipseView -> currentTotalCellVisibility (). p ());
2017-01-03 13:14:07 +01:00
}
2015-11-06 10:18:55 +01:00
}
m_visibleCellStatistics = new RigStatisticsDataCache ( calc . p ());
m_isVisCellStatUpToDate = true ;
2015-04-29 22:19:49 +02:00
}
2015-04-20 09:02:33 +02:00
}
2015-11-12 11:53:22 +01:00
2017-10-19 07:44:21 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2015-11-12 11:53:22 +01:00
void Rim3dOverlayInfoConfig :: displayPropertyFilteredStatisticsMessage ( bool showSwitchToCurrentTimestep )
{
static bool isShowing = false ;
QString switchString ;
if ( showSwitchToCurrentTimestep )
{
switchString = QString ( "<br>"
2017-10-18 10:43:27 +02:00
"Switching to statistics for <b>Current Time Step</b>" );
2015-11-12 11:53:22 +01:00
}
if ( ! isShowing )
{
isShowing = true ;
QMessageBox :: information ( m_viewDef -> viewer () -> layoutWidget (),
2017-10-18 10:43:27 +02:00
QString ( "ResInsight" ),
QString ( "Statistics not available<br>"
"<br>"
"Statistics calculations of <b>Visible Cells</b> for <b>All Time Steps</b> is not supported<br>"
"when you have an active Property filter on a time varying result.<br>" )
+ switchString );
2015-11-12 11:53:22 +01:00
isShowing = false ;
}
2017-10-19 07:44:21 +02:00
}
2017-10-27 17:12:25 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool Rim3dOverlayInfoConfig :: hasInvalidStatisticsCombination ()
{
if ( m_viewDef -> propertyFilterCollection ()
&& m_viewDef -> propertyFilterCollection () -> hasActiveDynamicFilters ()
&& m_statisticsCellRange () == VISIBLE_CELLS
&& m_statisticsTimeRange () == ALL_TIMESTEPS )
{
RimEclipseView * eclipseView = dynamic_cast < RimEclipseView *> ( m_viewDef . p ());
if ( ! ( eclipseView && eclipseView -> cellResult () -> isFlowDiagOrInjectionFlooding ())) // If isFlowDiagOrInjFlooding then skip this check as ALL_TIMESTEPS is overridden to CURRENT behind the scenes
{
return true ;
}
}
return false ;
}