Skip to content

Commit

Permalink
Add support for summary cross plot curves in summary plots
Browse files Browse the repository at this point in the history
  • Loading branch information
magnesj committed Sep 20, 2023
1 parent bcc5943 commit 10a7fa2
Show file tree
Hide file tree
Showing 44 changed files with 968 additions and 428 deletions.
2 changes: 2 additions & 0 deletions ApplicationLibCode/Application/CMakeLists_files.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.h
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand Down Expand Up @@ -72,6 +73,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RiaSeismicDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaLasDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaWellFlowDefines.cpp
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAddress.cpp
)

list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
Expand Down
53 changes: 53 additions & 0 deletions ApplicationLibCode/Application/RiaSummaryCurveAddress.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 Equinor ASA
//
// 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 "RiaSummaryCurveAddress.h"

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveAddress::RiaSummaryCurveAddress( const RifEclipseSummaryAddress& summaryAddressX, const RifEclipseSummaryAddress& summaryAddressY )
: m_summaryAddressX( summaryAddressX )
, m_summaryAddressY( summaryAddressY )
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaSummaryCurveAddress::RiaSummaryCurveAddress( const RifEclipseSummaryAddress& summaryAddressY )
: m_summaryAddressX( RifEclipseSummaryAddress::timeAddress() )
, m_summaryAddressY( summaryAddressY )
{
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress RiaSummaryCurveAddress::summaryAddressX() const
{
return m_summaryAddressX;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifEclipseSummaryAddress RiaSummaryCurveAddress::summaryAddressY() const
{
return m_summaryAddressY;
}
40 changes: 40 additions & 0 deletions ApplicationLibCode/Application/RiaSummaryCurveAddress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 Equinor ASA
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "RifEclipseSummaryAddress.h"

//==================================================================================================
///
//==================================================================================================
class RiaSummaryCurveAddress
{
public:
explicit RiaSummaryCurveAddress( const RifEclipseSummaryAddress& summaryAddressY );
explicit RiaSummaryCurveAddress( const RifEclipseSummaryAddress& summaryAddressX, const RifEclipseSummaryAddress& summaryAddressY );

RifEclipseSummaryAddress summaryAddressX() const;
RifEclipseSummaryAddress summaryAddressY() const;

auto operator<=>( const RiaSummaryCurveAddress& rhs ) const = default;

private:
RifEclipseSummaryAddress m_summaryAddressX;
RifEclipseSummaryAddress m_summaryAddressY;
};
12 changes: 12 additions & 0 deletions ApplicationLibCode/Application/RiaSummaryDefines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
/////////////////////////////////////////////////////////////////////////////////

#include "RiaSummaryDefines.h"
#include "cafAppEnum.h"

namespace caf
{
template <>
void caf::AppEnum<RiaDefines::HorizontalAxisType>::setUp()
{
addItem( RiaDefines::HorizontalAxisType::TIME, "TIME", "Time" );
addItem( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR, "SUMMARY_VECTOR", "Summary Vector" );
setDefault( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR );
}
} // namespace caf

//--------------------------------------------------------------------------------------------------
///
Expand Down
6 changes: 6 additions & 0 deletions ApplicationLibCode/Application/RiaSummaryDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ enum class FileType
STIMPLAN_SUMMARY
};

enum class HorizontalAxisType
{
TIME,
SUMMARY_VECTOR
};

QString summaryField();
QString summaryAquifer();
QString summaryNetwork();
Expand Down
48 changes: 48 additions & 0 deletions ApplicationLibCode/Application/Tools/RiaSummaryAddressAnalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ using namespace RifEclipseSummaryAddressDefines;
///
//--------------------------------------------------------------------------------------------------
RiaSummaryAddressAnalyzer::RiaSummaryAddressAnalyzer()
: m_onlyCrossPlotCurves( false )
{
}

Expand All @@ -57,6 +58,23 @@ void RiaSummaryAddressAnalyzer::appendAddresses( const std::set<RifEclipseSummar
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryAddressAnalyzer::appendAddresses( const std::vector<RiaSummaryCurveAddress>& addresses )
{
// RiaSummaryCurveAddress can be used to represent cross plot curves. Set the flag m_onlyCrossPlotCurves to true, and this will be set
// to false in analyzeSingleAddress if we detect a time curve

m_onlyCrossPlotCurves = true;

for ( const auto& adr : addresses )
{
analyzeSingleAddress( adr.summaryAddressX() );
analyzeSingleAddress( adr.summaryAddressY() );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -100,6 +118,14 @@ bool RiaSummaryAddressAnalyzer::isSingleQuantityIgnoreHistory() const
return false;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaSummaryAddressAnalyzer::onlyCrossPlotCurves() const
{
return m_onlyCrossPlotCurves;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand All @@ -110,6 +136,20 @@ std::string RiaSummaryAddressAnalyzer::quantityNameForTitle() const
return *quantities().begin();
}

if ( quantities().size() == 2 && m_onlyCrossPlotCurves )
{
// We have a cross plot with only one curve

std::string title;
for ( const auto& quantity : quantities() )
{
if ( !title.empty() ) title += " | ";
title += quantity;
}

return title;
}

if ( quantities().size() == 2 && quantityNamesWithHistory().size() == 1 )
{
return *quantityNamesWithHistory().begin();
Expand Down Expand Up @@ -429,6 +469,14 @@ void RiaSummaryAddressAnalyzer::computeQuantityNamesWithHistory() const
//--------------------------------------------------------------------------------------------------
void RiaSummaryAddressAnalyzer::analyzeSingleAddress( const RifEclipseSummaryAddress& address )
{
if ( address.category() == SummaryCategory::SUMMARY_TIME )
{
m_onlyCrossPlotCurves = false;

// A time address has no other information than SummaryCategory::SUMMARY_TIME
return;
}

const std::string& wellName = address.wellName();

if ( !wellName.empty() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include "RiaSummaryCurveAddress.h"
#include "RifEclipseSummaryAddress.h"

#include <set>
Expand All @@ -39,6 +40,7 @@ class RiaSummaryAddressAnalyzer

void appendAddresses( const std::set<RifEclipseSummaryAddress>& allAddresses );
void appendAddresses( const std::vector<RifEclipseSummaryAddress>& allAddresses );
void appendAddresses( const std::vector<RiaSummaryCurveAddress>& addresses );

void clear();

Expand All @@ -48,6 +50,8 @@ class RiaSummaryAddressAnalyzer

bool isSingleQuantityIgnoreHistory() const;

bool onlyCrossPlotCurves() const;

std::string quantityNameForTitle() const;

std::set<std::string> wellNames() const;
Expand Down Expand Up @@ -104,4 +108,6 @@ class RiaSummaryAddressAnalyzer
std::multimap<int, RifEclipseSummaryAddress> m_aquifers;

std::map<RifEclipseSummaryAddressDefines::SummaryCategory, std::set<std::string>> m_categories;

bool m_onlyCrossPlotCurves;
};
23 changes: 23 additions & 0 deletions ApplicationLibCode/Application/Tools/RiaSummaryTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,26 @@ QList<caf::PdmOptionItemInfo> RiaSummaryTools::optionsForSummaryCases( const std

return options;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryTools::copyCurveDataSources( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve )
{
curve.setSummaryAddressX( otherCurve.summaryAddressX() );
curve.setSummaryCaseX( otherCurve.summaryCaseX() );

curve.setSummaryAddressY( otherCurve.summaryAddressY() );
curve.setSummaryCaseY( otherCurve.summaryCaseY() );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaSummaryTools::copyCurveAxisData( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve )
{
curve.setAxisTypeX( otherCurve.axisTypeX() );
curve.setTopOrBottomAxisX( otherCurve.axisX() );

curve.setLeftOrRightAxisY( otherCurve.axisY() );
}
4 changes: 4 additions & 0 deletions ApplicationLibCode/Application/Tools/RiaSummaryTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class RimSummaryCaseCollection;
class RimSummaryTable;
class RimSummaryTableCollection;
class RimObservedDataCollection;
class RimSummaryCurve;

class RifEclipseSummaryAddress;

Expand Down Expand Up @@ -88,4 +89,7 @@ class RiaSummaryTools

static QList<caf::PdmOptionItemInfo> optionsForAllSummaryCases();
static QList<caf::PdmOptionItemInfo> optionsForSummaryCases( const std::vector<RimSummaryCase*>& cases );

static void copyCurveDataSources( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve );
static void copyCurveAxisData( RimSummaryCurve& curve, const RimSummaryCurve& otherCurve );
};
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,7 @@ RimSummaryDeclineCurve* RicCreateDeclineCurvesFeature::createDeclineCurveAndAddT
RimSummaryDeclineCurve* newCurve = new RimSummaryDeclineCurve();
CVF_ASSERT( newCurve );

newCurve->setSummaryCaseX( sourceCurve->summaryCaseX() );
newCurve->setSummaryAddressX( sourceCurve->summaryAddressX() );

newCurve->setSummaryCaseY( sourceCurve->summaryCaseY() );
newCurve->setSummaryAddressY( sourceCurve->summaryAddressY() );
RiaSummaryTools::copyCurveDataSources( *newCurve, *sourceCurve );

newCurve->setDeclineCurveType( declineCurveType );

Expand All @@ -105,6 +101,8 @@ RimSummaryDeclineCurve* RicCreateDeclineCurvesFeature::createDeclineCurveAndAddT

summaryPlot->addCurveAndUpdate( newCurve );

RiaSummaryTools::copyCurveAxisData( *newCurve, *sourceCurve );

newCurve->updateDefaultValues();
newCurve->loadDataAndUpdate( true );
newCurve->updateConnectedEditors();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,16 @@ RimSummaryRegressionAnalysisCurve*
RimSummaryRegressionAnalysisCurve* newCurve = new RimSummaryRegressionAnalysisCurve();
CVF_ASSERT( newCurve );

newCurve->setSummaryCaseX( sourceCurve->summaryCaseX() );
newCurve->setSummaryAddressX( sourceCurve->summaryAddressX() );

newCurve->setSummaryCaseY( sourceCurve->summaryCaseY() );
newCurve->setSummaryAddressY( sourceCurve->summaryAddressY() );
RiaSummaryTools::copyCurveDataSources( *newCurve, *sourceCurve );

newCurve->setColor( sourceCurve->color() );
newCurve->setSymbol( RiuPlotCurveSymbol::PointSymbolEnum::SYMBOL_RECT );
newCurve->setSymbolSkipDistance( 50 );

summaryPlot->addCurveAndUpdate( newCurve );

RiaSummaryTools::copyCurveAxisData( *newCurve, *sourceCurve );

newCurve->updateDefaultValues();
newCurve->loadDataAndUpdate( true );
newCurve->updateConnectedEditors();
Expand Down
Loading

0 comments on commit 10a7fa2

Please sign in to comment.