ResInsight/ApplicationLibCode/Application/RiaSummaryCurveDefinition.cpp

268 lines
9.5 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil ASA
2019-06-13 10:32:47 -05: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.
2019-06-13 10:32:47 -05:00
//
// 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.
2019-06-13 10:32:47 -05:00
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaSummaryCurveDefinition.h"
#include "RifSummaryReaderInterface.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
2020-04-21 01:56:27 -05:00
#include "cafAssert.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition()
: m_summaryCase( nullptr )
, m_ensemble( nullptr )
, m_isEnsembleCurve( false )
{
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCase* summaryCase,
const RifEclipseSummaryAddress& summaryAddress,
bool isEnsembleCurve )
: m_summaryCase( summaryCase )
, m_summaryAddress( summaryAddress )
, m_isEnsembleCurve( isEnsembleCurve )
{
Updates after 2020.10.1 release (#7104) * Set version to 2020.10.1-RC03 * #6780 Flow Vector Result: Check if data exists before using * #7031 Delta Summary Case: Fix crash when updating case name * #7036 Well Picks : Skip import of empty lines * #7003 Python: Guard nullpointer access for summary methods * #7014 Python: Resize the result container before assigning data * #7042 File Import Dialog : Sort by numbers instead of text * Set version to 2020.10.1-RC04 * #7008 Python: Avoid terminating process as part of open/closeProject When running scripts, a project file can be opened. If other operations are issued after, the process monitor window was disconnected from the script process, and no text output from the script was visible in the process monitor text window. New behavior : Never terminate a process automatically. Never terminate process as part of open/close project. If a process is left unresponsive, the user is now responsible for manual termination of this process. * #7045 Contour map : Disable clipping of smoothed contour lines * #7046 Cross Plot : Avoid reset of curve visibility when color legend visibility changes * #7048 Grid Cross Plot: Fix inverted Y-axis for user-defined min/max range * #7055 Contour Map: Label format it should match the legend format * #7059 Well Targets : Fix index of of bound crash when building well path * Set version to 2020.10.1-RC05 * #6814 Correlation Report: Missing update of plots when changing ensemble * Set version to 2020.10.1-RC06 * #7055 Contour Map: Label format it should match the legend format * #7068 Fix missing import surface File -> Import Surface * Set version to 2020.10.1-RC07 * Prepare for release of 2020.10.1 * #5641 Avoid unnecessary regeneration of contour map * Move clearGeometry to a scheduleGeometryRegen override * Trigger update of contour maps following legend changes * Make legend config changed signal more fine grained for Contour Maps * Set version to 2020.10.1-RC08 * Prepare for release of 2020.10.1 * Set dev version after patch release Co-authored-by: Gaute Lindkvist <lindkvis@gmail.com>
2020-12-10 03:44:23 -06:00
if ( summaryCase )
{
RimSummaryCaseCollection* ensemble = nullptr;
summaryCase->firstAncestorOfType( ensemble );
m_ensemble = ensemble;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveDefinition::RiaSummaryCurveDefinition( RimSummaryCaseCollection* ensemble,
const RifEclipseSummaryAddress& summaryAddress )
: m_summaryCase( nullptr )
, m_summaryAddress( summaryAddress )
, m_ensemble( ensemble )
, m_isEnsembleCurve( true )
{
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
RimSummaryCase* RiaSummaryCurveDefinition::summaryCase() const
{
return m_summaryCase;
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const
{
return m_ensemble;
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
const RifEclipseSummaryAddress& RiaSummaryCurveDefinition::summaryAddress() const
{
return m_summaryAddress;
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
bool RiaSummaryCurveDefinition::isEnsembleCurve() const
{
return m_isEnsembleCurve;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::setSummaryAddress( const RifEclipseSummaryAddress& address )
{
m_summaryAddress = address;
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinition::resultValues( const RiaSummaryCurveDefinition& curveDefinition,
gsl::not_null<std::vector<double>*> values )
{
if ( !curveDefinition.summaryAddress().isValid() ) return;
if ( !curveDefinition.summaryCase() ) return;
2019-06-13 10:32:47 -05:00
RifSummaryReaderInterface* reader = curveDefinition.summaryCase()->summaryReader();
if ( !reader ) return;
reader->values( curveDefinition.summaryAddress(), values );
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
const std::vector<time_t>& RiaSummaryCurveDefinition::timeSteps( const RiaSummaryCurveDefinition& curveDefinition )
{
static std::vector<time_t> dummy;
if ( !curveDefinition.summaryAddress().isValid() ) return dummy;
if ( !curveDefinition.summaryCase() ) return dummy;
RifSummaryReaderInterface* reader = curveDefinition.summaryCase()->summaryReader();
if ( !reader ) return dummy;
return reader->timeSteps( curveDefinition.summaryAddress() );
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
QString RiaSummaryCurveDefinition::curveDefinitionText() const
{
QString caseName;
if ( summaryCase() )
caseName = summaryCase()->displayCaseName();
else if ( ensemble() )
2019-06-13 10:32:47 -05:00
caseName = ensemble()->name();
return RiaSummaryCurveDefinition::curveDefinitionText( caseName, summaryAddress() );
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
QString RiaSummaryCurveDefinition::curveDefinitionText( const QString& caseName,
const RifEclipseSummaryAddress& summaryAddress )
{
QString txt;
txt += caseName;
txt += ", ";
txt += QString::fromStdString( summaryAddress.uiText() );
return txt;
}
//--------------------------------------------------------------------------------------------------
2019-06-13 10:32:47 -05:00
///
//--------------------------------------------------------------------------------------------------
bool RiaSummaryCurveDefinition::operator<( const RiaSummaryCurveDefinition& other ) const
{
if ( m_ensemble != other.ensemble() )
{
2019-02-04 04:22:38 -06:00
QString ensembleName;
QString otherEnsembleName;
if ( m_ensemble )
2019-02-04 04:22:38 -06:00
{
ensembleName = m_ensemble->name();
}
if ( other.ensemble() )
{
2019-02-04 04:22:38 -06:00
otherEnsembleName = other.ensemble()->name();
}
// First check if names are different to ensure stable alphabetic sort
if ( ensembleName != otherEnsembleName )
2019-02-04 04:22:38 -06:00
{
return ensembleName < otherEnsembleName;
}
// Use pointer address, sorting will be be unstable
return m_ensemble < other.ensemble();
}
if ( m_summaryCase != other.summaryCase() )
{
2019-02-04 04:22:38 -06:00
QString summaryCaseName;
QString otherSummaryCaseName;
if ( m_summaryCase )
{
summaryCaseName = m_summaryCase->displayCaseName();
2019-02-04 04:22:38 -06:00
}
if ( other.summaryCase() )
2019-02-04 04:22:38 -06:00
{
otherSummaryCaseName = other.summaryCase()->displayCaseName();
2019-02-04 04:22:38 -06:00
}
// First check if names are different to ensure stable alphabetic sort
if ( summaryCaseName != otherSummaryCaseName )
2019-02-04 04:22:38 -06:00
{
return summaryCaseName < otherSummaryCaseName;
}
// Use pointer address, sorting will be be unstable
return m_summaryCase < other.summaryCase();
}
2019-02-04 04:22:38 -06:00
if ( m_summaryAddress != other.summaryAddress() )
{
return ( m_summaryAddress < other.summaryAddress() );
}
return m_isEnsembleCurve < other.isEnsembleCurve();
}
2020-04-21 01:56:27 -05:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryCurveDefinitionAnalyser::setCurveDefinitions( const std::vector<RiaSummaryCurveDefinition>& curveDefs )
2020-04-21 01:56:27 -05:00
{
m_singleSummaryCases.clear();
m_ensembles.clear();
m_quantityNames.clear();
m_summaryAdresses.clear();
2020-04-21 01:56:27 -05:00
for ( const auto& curveDef : curveDefs )
{
bool valid = false;
if ( curveDef.ensemble() && curveDef.isEnsembleCurve() )
{
m_ensembles.insert( curveDef.ensemble() );
valid = true;
}
else if ( curveDef.summaryCase() )
2020-04-21 01:56:27 -05:00
{
m_singleSummaryCases.insert( curveDef.summaryCase() );
if ( curveDef.summaryCase()->ensemble() )
{
m_ensembles.insert( curveDef.summaryCase()->ensemble() );
}
valid = true;
2020-04-21 01:56:27 -05:00
}
2020-04-21 01:56:27 -05:00
if ( valid )
{
const RifEclipseSummaryAddress& address = curveDef.summaryAddress();
2020-04-21 01:56:27 -05:00
m_quantityNames.insert( address.quantityName() );
m_summaryAdresses.insert( address );
2020-04-21 01:56:27 -05:00
}
}
}