mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-26 07:00:17 -05:00
Move files
Fix includes
This commit is contained in:
1 parent
ea9a1b7d85
commit
04cd253fc6
46 files changed
+606
-329
No files matched your search
@@ -18,7 +18,7 @@
|
||||
|
||||
#include "RiaPreferencesSummary.h"
|
||||
|
||||
#include "PlotTemplateCommands/RicSummaryPlotTemplateTools.h"
|
||||
#include "Summary/RiaSummaryPlotTemplateTools.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
#include "ApplicationCommands/RicShowMainWindowFeature.h"
|
||||
|
||||
#include "PlotBuilderCommands/RicSummaryPlotBuilder.h"
|
||||
#include "Summary/RiaSummaryPlotTools.h"
|
||||
#include "SummaryPlotCommands/RicNewSummaryCurveFeature.h"
|
||||
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
||||
|
||||
@@ -199,7 +199,7 @@ bool RiaImportEclipseCaseTools::openEclipseCasesFromFile( const QStringList& fil
|
||||
|
||||
if ( !candidateCases.empty() && RiaGuiApplication::isRunning() && RiuPlotMainWindow::instance()->isVisible() )
|
||||
{
|
||||
RicSummaryPlotBuilder::createAndAppendDefaultSummaryMultiPlot( { candidateCases.front() }, {} );
|
||||
RiaSummaryPlotTools::createAndAppendDefaultSummaryMultiPlot( { candidateCases.front() }, {} );
|
||||
RiuPlotMainWindowTools::setExpanded( candidateCases.front() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryStringTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryPlotTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryPlotBuilder.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryPlotTemplateTools.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -16,6 +19,9 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryDefines.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryStringTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryPlotTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryPlotBuilder.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaSummaryPlotTemplateTools.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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 "RiaSummaryPlotBuilder.h"
|
||||
|
||||
#include "Summary/RiaSummaryAddressAnalyzer.h"
|
||||
#include "Summary/RiaSummaryPlotTools.h"
|
||||
#include "Summary/RiaSummaryTools.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaSummaryPlotBuilder::RiaSummaryPlotBuilder()
|
||||
: m_individualPlotPerDataSource( false )
|
||||
, m_graphCurveGrouping( RiaSummaryPlotBuilder::RicGraphCurveGrouping::NONE )
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryPlotBuilder::setDataSources( const std::vector<RimSummaryCase*>& summaryCases, const std::vector<RimSummaryEnsemble*>& ensembles )
|
||||
{
|
||||
m_summaryCases = summaryCases;
|
||||
m_ensembles = ensembles;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryPlotBuilder::setAddresses( const std::set<RifEclipseSummaryAddress>& addresses )
|
||||
{
|
||||
m_addresses = addresses;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryPlotBuilder::setIndividualPlotPerDataSource( bool enable )
|
||||
{
|
||||
m_individualPlotPerDataSource = enable;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryPlotBuilder::setGrouping( RicGraphCurveGrouping groping )
|
||||
{
|
||||
m_graphCurveGrouping = groping;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryPlot*> RiaSummaryPlotBuilder::createPlots() const
|
||||
{
|
||||
std::vector<RimSummaryPlot*> plots;
|
||||
|
||||
if ( m_individualPlotPerDataSource )
|
||||
{
|
||||
if ( m_graphCurveGrouping == RicGraphCurveGrouping::SINGLE_CURVES )
|
||||
{
|
||||
for ( const auto& adr : m_addresses )
|
||||
{
|
||||
for ( auto summaryCase : m_summaryCases )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( { adr }, { summaryCase }, {} );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
|
||||
for ( auto ensemble : m_ensembles )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( { adr }, {}, { ensemble } );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_graphCurveGrouping == RicGraphCurveGrouping::CURVES_FOR_OBJECT )
|
||||
{
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
analyzer.appendAddresses( m_addresses );
|
||||
|
||||
auto groups = analyzer.addressesGroupedByObject();
|
||||
for ( const auto& group : groups )
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> addresses;
|
||||
addresses.insert( group.begin(), group.end() );
|
||||
if ( addresses.empty() ) continue;
|
||||
|
||||
for ( auto summaryCase : m_summaryCases )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( addresses, { summaryCase }, {} );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
|
||||
for ( auto ensemble : m_ensembles )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( addresses, {}, { ensemble } );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_graphCurveGrouping == RicGraphCurveGrouping::NONE )
|
||||
{
|
||||
for ( auto summaryCase : m_summaryCases )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( m_addresses, { summaryCase }, {} );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
|
||||
for ( auto ensemble : m_ensembles )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( m_addresses, {}, { ensemble } );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
}
|
||||
}
|
||||
else // all data sources in same plot
|
||||
{
|
||||
if ( m_graphCurveGrouping == RicGraphCurveGrouping::SINGLE_CURVES )
|
||||
{
|
||||
for ( const auto& adr : m_addresses )
|
||||
{
|
||||
if ( !m_summaryCases.empty() )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( { adr }, m_summaryCases, {} );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
|
||||
if ( !m_ensembles.empty() )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( { adr }, {}, m_ensembles );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_graphCurveGrouping == RicGraphCurveGrouping::CURVES_FOR_OBJECT )
|
||||
{
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
analyzer.appendAddresses( m_addresses );
|
||||
|
||||
auto groups = analyzer.addressesGroupedByObject();
|
||||
for ( const auto& group : groups )
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> addresses;
|
||||
addresses.insert( group.begin(), group.end() );
|
||||
if ( addresses.empty() ) continue;
|
||||
|
||||
if ( !m_summaryCases.empty() )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( addresses, m_summaryCases, {} );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
|
||||
if ( !m_ensembles.empty() )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( addresses, {}, m_ensembles );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( m_graphCurveGrouping == RicGraphCurveGrouping::NONE )
|
||||
{
|
||||
if ( !m_summaryCases.empty() )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( m_addresses, m_summaryCases, {} );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
|
||||
if ( !m_ensembles.empty() )
|
||||
{
|
||||
auto plot = RiaSummaryPlotTools::createPlot( m_addresses, {}, m_ensembles );
|
||||
plots.push_back( plot );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return plots;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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
|
||||
|
||||
class RifEclipseSummaryAddress;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryEnsemble;
|
||||
class RimSummaryPlot;
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RiaSummaryPlotBuilder
|
||||
{
|
||||
public:
|
||||
enum class RicGraphCurveGrouping
|
||||
{
|
||||
SINGLE_CURVES,
|
||||
CURVES_FOR_OBJECT,
|
||||
NONE
|
||||
};
|
||||
|
||||
public:
|
||||
RiaSummaryPlotBuilder();
|
||||
|
||||
void setDataSources( const std::vector<RimSummaryCase*>& summaryCases, const std::vector<RimSummaryEnsemble*>& ensembles );
|
||||
|
||||
void setAddresses( const std::set<RifEclipseSummaryAddress>& addresses );
|
||||
|
||||
void setIndividualPlotPerDataSource( bool enable );
|
||||
void setGrouping( RicGraphCurveGrouping groping );
|
||||
|
||||
std::vector<RimSummaryPlot*> createPlots() const;
|
||||
|
||||
private:
|
||||
std::set<RifEclipseSummaryAddress> m_addresses;
|
||||
std::vector<RimSummaryCase*> m_summaryCases;
|
||||
std::vector<RimSummaryEnsemble*> m_ensembles;
|
||||
|
||||
bool m_individualPlotPerDataSource;
|
||||
|
||||
RicGraphCurveGrouping m_graphCurveGrouping;
|
||||
};
|
||||
@@ -0,0 +1,689 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- 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 "RiaSummaryPlotTemplateTools.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaPreferences.h"
|
||||
#include "Summary/RiaSummaryAddressAnalyzer.h"
|
||||
#include "Summary/RiaSummaryTools.h"
|
||||
|
||||
#include "PlotTemplateCommands/RicSelectPlotTemplateUi.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "PlotTemplates/RimPlotTemplateFileItem.h"
|
||||
#include "RimDialogData.h"
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimSummaryAddressCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryEnsemble.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryMultiPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QRegularExpression>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFile( const QString& fileName )
|
||||
{
|
||||
QFile importFile( fileName );
|
||||
if ( !importFile.open( QIODevice::ReadOnly | QIODevice::Text ) )
|
||||
{
|
||||
RiaLogging::error( QString( "Create Plot from Template : Could not open the file: %1" ).arg( fileName ) );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QTextStream stream( &importFile );
|
||||
|
||||
QString objectAsText = stream.readAll();
|
||||
|
||||
caf::PdmObjectHandle* obj =
|
||||
caf::PdmXmlObjectHandle::readUnknownObjectFromXmlString( objectAsText, caf::PdmDefaultObjectFactory::instance(), true );
|
||||
|
||||
return dynamic_cast<RimSummaryMultiPlot*>( obj );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileName )
|
||||
{
|
||||
auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases();
|
||||
auto sumEnsembles = RicSummaryPlotTemplateTools::selectedSummaryEnsembles();
|
||||
|
||||
auto summaryAddressCollections = RicSummaryPlotTemplateTools::selectedSummaryAddressCollections();
|
||||
|
||||
std::vector<QString> wellNames;
|
||||
std::vector<QString> groupNames;
|
||||
std::vector<QString> regions;
|
||||
std::set<RimSummaryCase*> caseSet;
|
||||
std::set<RimSummaryEnsemble*> caseCollectionSet;
|
||||
|
||||
if ( summaryAddressCollections.empty() )
|
||||
{
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
|
||||
if ( !sumCases.empty() )
|
||||
{
|
||||
auto firstCase = sumCases.front();
|
||||
|
||||
analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() );
|
||||
}
|
||||
else if ( !sumEnsembles.empty() )
|
||||
{
|
||||
auto caseCollection = sumEnsembles.front();
|
||||
|
||||
auto firstCase = caseCollection->firstSummaryCase();
|
||||
if ( firstCase != nullptr )
|
||||
{
|
||||
analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !analyzer.wellNames().empty() ) wellNames.push_back( QString::fromStdString( *( analyzer.wellNames().begin() ) ) );
|
||||
if ( !analyzer.groupNames().empty() ) groupNames.push_back( QString::fromStdString( *( analyzer.groupNames().begin() ) ) );
|
||||
if ( !analyzer.regionNumbers().empty() ) regions.push_back( QString::number( *( analyzer.regionNumbers().begin() ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( auto a : summaryAddressCollections )
|
||||
{
|
||||
if ( a->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL )
|
||||
{
|
||||
wellNames.push_back( a->name() );
|
||||
}
|
||||
else if ( a->contentType() == RimSummaryAddressCollection::CollectionContentType::GROUP )
|
||||
{
|
||||
groupNames.push_back( a->name() );
|
||||
}
|
||||
else if ( a->contentType() == RimSummaryAddressCollection::CollectionContentType::REGION )
|
||||
{
|
||||
regions.push_back( a->name() );
|
||||
}
|
||||
|
||||
auto sumCase = RiaSummaryTools::summaryCaseById( a->caseId() );
|
||||
if ( sumCase ) caseSet.insert( sumCase );
|
||||
|
||||
auto ensemble = RiaSummaryTools::ensembleById( a->ensembleId() );
|
||||
if ( ensemble ) caseCollectionSet.insert( ensemble );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto sumCase : caseSet )
|
||||
{
|
||||
sumCases.push_back( sumCase );
|
||||
}
|
||||
|
||||
for ( auto sumCaseCollection : caseCollectionSet )
|
||||
{
|
||||
sumEnsembles.push_back( sumCaseCollection );
|
||||
}
|
||||
|
||||
auto collections = RimMainPlotCollection::current()->summaryMultiPlotCollection();
|
||||
|
||||
auto newSummaryPlot = RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFile( fileName );
|
||||
if ( !newSummaryPlot ) return nullptr;
|
||||
|
||||
collections->addSummaryMultiPlot( newSummaryPlot );
|
||||
newSummaryPlot->resolveReferencesRecursively();
|
||||
|
||||
RicSummaryPlotTemplateTools::setValuesForPlaceholders( newSummaryPlot, sumCases, sumEnsembles, wellNames, groupNames, regions );
|
||||
newSummaryPlot->initAfterReadRecursively();
|
||||
newSummaryPlot->loadDataAndUpdate();
|
||||
|
||||
collections->updateConnectedEditors();
|
||||
|
||||
return newSummaryPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* RicSummaryPlotTemplateTools::create( const QString& fileName,
|
||||
const std::vector<RimSummaryCase*>& sumCases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles )
|
||||
{
|
||||
std::vector<QString> wellNames;
|
||||
std::vector<QString> groupNames;
|
||||
std::vector<QString> regions;
|
||||
|
||||
RiaSummaryAddressAnalyzer analyzer;
|
||||
|
||||
if ( !sumCases.empty() )
|
||||
{
|
||||
auto firstCase = sumCases.front();
|
||||
|
||||
analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() );
|
||||
}
|
||||
else if ( !ensembles.empty() )
|
||||
{
|
||||
auto caseCollection = ensembles.front();
|
||||
|
||||
auto firstCase = caseCollection->firstSummaryCase();
|
||||
if ( firstCase != nullptr )
|
||||
{
|
||||
analyzer.appendAddresses( firstCase->summaryReader()->allResultAddresses() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !analyzer.wellNames().empty() ) wellNames.push_back( QString::fromStdString( *( analyzer.wellNames().begin() ) ) );
|
||||
if ( !analyzer.groupNames().empty() ) groupNames.push_back( QString::fromStdString( *( analyzer.groupNames().begin() ) ) );
|
||||
if ( !analyzer.regionNumbers().empty() ) regions.push_back( QString::number( *( analyzer.regionNumbers().begin() ) ) );
|
||||
|
||||
auto collections = RimMainPlotCollection::current()->summaryMultiPlotCollection();
|
||||
|
||||
auto newSummaryPlot = RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFile( fileName );
|
||||
if ( !newSummaryPlot ) return nullptr;
|
||||
|
||||
collections->addSummaryMultiPlot( newSummaryPlot );
|
||||
newSummaryPlot->resolveReferencesRecursively();
|
||||
|
||||
RicSummaryPlotTemplateTools::setValuesForPlaceholders( newSummaryPlot, sumCases, ensembles, wellNames, groupNames, regions );
|
||||
newSummaryPlot->initAfterReadRecursively();
|
||||
newSummaryPlot->loadDataAndUpdate();
|
||||
collections->updateConnectedEditors();
|
||||
|
||||
return newSummaryPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryCase*>& selectedSummaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& selectedEnsembles,
|
||||
const std::vector<QString>& wellNames,
|
||||
const std::vector<QString>& groupNames,
|
||||
const std::vector<QString>& regions )
|
||||
|
||||
{
|
||||
auto plots = summaryMultiPlot->plots();
|
||||
for ( auto p : plots )
|
||||
{
|
||||
auto summaryPlot = dynamic_cast<RimSummaryPlot*>( p );
|
||||
if ( summaryPlot ) setValuesForPlaceholders( summaryPlot, selectedSummaryCases, selectedEnsembles, wellNames, groupNames, regions );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryPlotTemplateTools::setValuesForPlaceholders( RimSummaryPlot* summaryPlot,
|
||||
const std::vector<RimSummaryCase*>& selectedSummaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& selectedEnsembles,
|
||||
const std::vector<QString>& wellNames,
|
||||
const std::vector<QString>& groupNames,
|
||||
const std::vector<QString>& regions )
|
||||
{
|
||||
{
|
||||
// Replace single summary curves data sources
|
||||
|
||||
auto summaryCurves = summaryPlot->allCurves();
|
||||
for ( const auto& curve : summaryCurves )
|
||||
{
|
||||
auto summaryCaseHandle = curve->findField( RicSummaryPlotTemplateTools::summaryCaseFieldKeyword() );
|
||||
if ( summaryCaseHandle )
|
||||
{
|
||||
bool conversionOk = false;
|
||||
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCase();
|
||||
|
||||
auto referenceString = summaryCaseHandle->xmlCapability()->referenceString();
|
||||
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, referenceString, &conversionOk );
|
||||
|
||||
if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( selectedSummaryCases.size() ) )
|
||||
{
|
||||
auto summaryCaseY = selectedSummaryCases[static_cast<int>( indexValue )];
|
||||
curve->setSummaryCaseY( summaryCaseY );
|
||||
}
|
||||
}
|
||||
|
||||
auto summaryCaseXHandle = curve->findField( RicSummaryPlotTemplateTools::summaryCaseXFieldKeyword() );
|
||||
if ( summaryCaseXHandle )
|
||||
{
|
||||
bool conversionOk = false;
|
||||
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryCaseX();
|
||||
|
||||
auto referenceString = summaryCaseXHandle->xmlCapability()->referenceString();
|
||||
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, referenceString, &conversionOk );
|
||||
|
||||
if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( selectedSummaryCases.size() ) )
|
||||
{
|
||||
auto summaryCase = selectedSummaryCases[static_cast<int>( indexValue )];
|
||||
curve->setSummaryCaseX( summaryCase );
|
||||
}
|
||||
}
|
||||
|
||||
// Replace placeholders with object names from selection
|
||||
auto curveAdr = curve->summaryAddressY();
|
||||
setPlaceholderWellName( &curveAdr, wellNames );
|
||||
setPlaceholderGroupName( &curveAdr, groupNames );
|
||||
setPlaceholderRegion( &curveAdr, regions );
|
||||
curve->setSummaryAddressY( curveAdr );
|
||||
|
||||
if ( curve->axisTypeX() == RiaDefines::HorizontalAxisType::SUMMARY_VECTOR )
|
||||
{
|
||||
auto curveAdr = curve->summaryAddressX();
|
||||
setPlaceholderWellName( &curveAdr, wellNames );
|
||||
setPlaceholderGroupName( &curveAdr, groupNames );
|
||||
setPlaceholderRegion( &curveAdr, regions );
|
||||
curve->setSummaryAddressX( curveAdr );
|
||||
}
|
||||
}
|
||||
|
||||
for ( const auto& curveSet : summaryPlot->curveSets() )
|
||||
{
|
||||
const QString summaryGroupFieldKeyword = RicSummaryPlotTemplateTools::summaryGroupFieldKeyword();
|
||||
|
||||
auto fieldHandle = curveSet->findField( summaryGroupFieldKeyword );
|
||||
if ( fieldHandle )
|
||||
{
|
||||
bool conversionOk = false;
|
||||
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup();
|
||||
|
||||
auto referenceString = fieldHandle->xmlCapability()->referenceString();
|
||||
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, referenceString, &conversionOk );
|
||||
|
||||
if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( selectedEnsembles.size() ) )
|
||||
{
|
||||
auto ensembleCase = selectedEnsembles[static_cast<int>( indexValue )];
|
||||
curveSet->setSummaryEnsemble( ensembleCase );
|
||||
}
|
||||
}
|
||||
|
||||
// Replace placeholders with object names from selection
|
||||
auto adr = curveSet->curveAddress();
|
||||
auto curveAdrY = adr.summaryAddressY();
|
||||
setPlaceholderWellName( &curveAdrY, wellNames );
|
||||
setPlaceholderGroupName( &curveAdrY, groupNames );
|
||||
setPlaceholderRegion( &curveAdrY, regions );
|
||||
auto curveAdrX = adr.summaryAddressX();
|
||||
setPlaceholderWellName( &curveAdrX, wellNames );
|
||||
setPlaceholderGroupName( &curveAdrX, groupNames );
|
||||
setPlaceholderRegion( &curveAdrX, regions );
|
||||
curveSet->setCurveAddress( RiaSummaryCurveAddress( curveAdrX, curveAdrY ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot,
|
||||
const std::set<RifEclipseSummaryAddress>& selectedSummaryAddresses,
|
||||
const std::vector<caf::PdmObject*>& selectedSources )
|
||||
{
|
||||
QString text;
|
||||
|
||||
RiaSummaryAddressAnalyzer selectionAnalyzer;
|
||||
|
||||
selectionAnalyzer.appendAddresses( selectedSummaryAddresses );
|
||||
|
||||
if ( templatePlot )
|
||||
{
|
||||
std::set<QString> templateSources;
|
||||
RiaSummaryAddressAnalyzer templateAnalyzer;
|
||||
|
||||
{
|
||||
std::set<RifEclipseSummaryAddress> templateAddresses;
|
||||
|
||||
for ( const auto& curve : templatePlot->summaryCurves() )
|
||||
{
|
||||
auto adr = curve->summaryAddressY();
|
||||
templateAddresses.insert( adr );
|
||||
|
||||
auto fieldHandle = curve->findField( "SummaryCase" );
|
||||
if ( fieldHandle )
|
||||
{
|
||||
auto test = fieldHandle->xmlCapability()->referenceString();
|
||||
templateSources.insert( test );
|
||||
}
|
||||
}
|
||||
|
||||
templateAnalyzer.appendAddresses( templateAddresses );
|
||||
}
|
||||
|
||||
text += "<b> Requirements </b><br>";
|
||||
|
||||
if ( !templateSources.empty() )
|
||||
{
|
||||
QString itemText = "Source Cases";
|
||||
size_t requiredCount = templateSources.size();
|
||||
size_t selectedCount = selectedSources.size();
|
||||
text += htmlTextFromCount( itemText, requiredCount, selectedCount );
|
||||
}
|
||||
|
||||
if ( !templateAnalyzer.wellNames().empty() )
|
||||
{
|
||||
QString itemText = "Wells";
|
||||
size_t requiredCount = templateAnalyzer.wellNames().size();
|
||||
size_t selectedCount = selectionAnalyzer.wellNames().size();
|
||||
text += htmlTextFromCount( itemText, requiredCount, selectedCount );
|
||||
}
|
||||
|
||||
if ( !templateAnalyzer.groupNames().empty() )
|
||||
{
|
||||
QString itemText = "Groups";
|
||||
size_t requiredCount = templateAnalyzer.groupNames().size();
|
||||
size_t selectedCount = selectionAnalyzer.groupNames().size();
|
||||
text += htmlTextFromCount( itemText, requiredCount, selectedCount );
|
||||
}
|
||||
|
||||
if ( !templateAnalyzer.regionNumbers().empty() )
|
||||
{
|
||||
QString itemText = "Regions";
|
||||
size_t requiredCount = templateAnalyzer.regionNumbers().size();
|
||||
size_t selectedCount = selectionAnalyzer.regionNumbers().size();
|
||||
text += htmlTextFromCount( itemText, requiredCount, selectedCount );
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::htmlTextFromCount( const QString& itemText, size_t requiredItemCount, size_t selectionCount )
|
||||
{
|
||||
QString text;
|
||||
|
||||
QString colorString = "green";
|
||||
|
||||
if ( selectionCount < requiredItemCount )
|
||||
colorString = "red";
|
||||
else if ( selectionCount > requiredItemCount )
|
||||
colorString = "orange";
|
||||
|
||||
text += QString( "<b><font color='%1'>" ).arg( colorString );
|
||||
text += QString( "%1 : %2 selected (%3 required)\n" ).arg( itemText ).arg( selectionCount ).arg( requiredItemCount );
|
||||
text += "</font></b>";
|
||||
|
||||
text += "<br>";
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::selectPlotTemplatePath()
|
||||
{
|
||||
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
RicSelectPlotTemplateUi ui;
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog( plotwindow, &ui, "Select Plot Template", "" );
|
||||
propertyDialog.resize( QSize( 400, 600 ) );
|
||||
|
||||
if ( propertyDialog.exec() == QDialog::Accepted && !ui.selectedPlotTemplates().empty() )
|
||||
{
|
||||
QString fileName = ui.selectedPlotTemplates().front()->absoluteFilePath();
|
||||
|
||||
RiaPreferences::current()->setLastUsedPlotTemplatePath( fileName );
|
||||
RiaPreferences::current()->writePreferencesToApplicationStore();
|
||||
|
||||
return fileName;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RicSummaryPlotTemplateTools::selectDefaultPlotTemplates( std::vector<QString> currentSelection )
|
||||
{
|
||||
RiuPlotMainWindow* plotwindow = RiaGuiApplication::instance()->mainPlotWindow();
|
||||
RicSelectPlotTemplateUi ui;
|
||||
ui.setMultiSelectMode( true );
|
||||
ui.setInitialSelection( currentSelection );
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog( plotwindow, &ui, "Select Default Plot Templates", "" );
|
||||
propertyDialog.resize( QSize( 500, 600 ) );
|
||||
|
||||
std::vector<QString> selection;
|
||||
|
||||
if ( propertyDialog.exec() == QDialog::Accepted && !ui.selectedPlotTemplates().empty() )
|
||||
{
|
||||
for ( auto item : ui.selectedPlotTemplates() )
|
||||
{
|
||||
selection.push_back( item->absoluteFilePath() );
|
||||
}
|
||||
}
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RicSummaryPlotTemplateTools::selectedSummaryCases()
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryEnsemble*> RicSummaryPlotTemplateTools::selectedSummaryEnsembles()
|
||||
{
|
||||
std::vector<RimSummaryEnsemble*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryAddressCollection*> RicSummaryPlotTemplateTools::selectedSummaryAddressCollections()
|
||||
{
|
||||
std::vector<RimSummaryAddressCollection*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::summaryCaseFieldKeyword()
|
||||
{
|
||||
return "SummaryCase";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::summaryCaseXFieldKeyword()
|
||||
{
|
||||
return "SummaryCaseX";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::summaryGroupFieldKeyword()
|
||||
{
|
||||
return "SummaryGroup";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCase()
|
||||
{
|
||||
return "__CASE_NAME__";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::placeholderTextForSummaryCaseX()
|
||||
{
|
||||
return "__CASE_NAME_X__";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::placeholderTextForSummaryGroup()
|
||||
{
|
||||
return "__ENSEMBLE_NAME__";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::placeholderTextForWell()
|
||||
{
|
||||
return "__WELL_NAME__";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RicSummaryPlotTemplateTools::placeholderTextForGroup()
|
||||
{
|
||||
return "__GROUP__";
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseSummaryAddress RicSummaryPlotTemplateTools::firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
|
||||
const std::set<RifEclipseSummaryAddress>& allAddresses )
|
||||
{
|
||||
for ( const auto& a : allAddresses )
|
||||
{
|
||||
if ( sourceAddress.vectorName() == a.vectorName() )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RicSummaryPlotTemplateTools::findValueForKeyword( const QString& keyword, const QString& valueString, bool* ok )
|
||||
{
|
||||
// Example string : "CASE_NAME 1"
|
||||
// Will match the string specified by keyword, and return the value captured by the regexp
|
||||
|
||||
QString regexpString = QString( "%1 (\\d++)" ).arg( keyword );
|
||||
QRegularExpression rx( regexpString );
|
||||
|
||||
auto match = rx.match( valueString );
|
||||
if ( match.hasMatch() )
|
||||
{
|
||||
QString integerAsText = match.captured( 1 );
|
||||
|
||||
if ( !integerAsText.isEmpty() )
|
||||
{
|
||||
int integerValue = integerAsText.toInt();
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
*ok = true;
|
||||
}
|
||||
return integerValue;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
*ok = false;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryPlotTemplateTools::setPlaceholderWellName( RifEclipseSummaryAddress* summaryAddress, const std::vector<QString>& wellNames )
|
||||
{
|
||||
if ( wellNames.empty() ) return;
|
||||
|
||||
auto sourceWellName = QString::fromStdString( summaryAddress->wellName() );
|
||||
bool conversionOk = false;
|
||||
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForWell();
|
||||
|
||||
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, sourceWellName, &conversionOk );
|
||||
if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( wellNames.size() ) )
|
||||
{
|
||||
summaryAddress->setWellName( wellNames[indexValue].toStdString() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryPlotTemplateTools::setPlaceholderGroupName( RifEclipseSummaryAddress* summaryAddress, const std::vector<QString>& groupNames )
|
||||
{
|
||||
if ( groupNames.empty() ) return;
|
||||
|
||||
auto sourceGroupName = QString::fromStdString( summaryAddress->groupName() );
|
||||
bool conversionOk = false;
|
||||
const QString placeholderString = RicSummaryPlotTemplateTools::placeholderTextForGroup();
|
||||
|
||||
int indexValue = RicSummaryPlotTemplateTools::findValueForKeyword( placeholderString, sourceGroupName, &conversionOk );
|
||||
if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( groupNames.size() ) )
|
||||
{
|
||||
summaryAddress->setGroupName( groupNames[indexValue].toStdString() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicSummaryPlotTemplateTools::setPlaceholderRegion( RifEclipseSummaryAddress* summaryAddress, const std::vector<QString>& regions )
|
||||
{
|
||||
CAF_ASSERT( summaryAddress );
|
||||
if ( regions.empty() ) return;
|
||||
|
||||
int indexValue = summaryAddress->regionNumber();
|
||||
if ( indexValue < -1 )
|
||||
{
|
||||
indexValue = -( indexValue - 2 );
|
||||
|
||||
bool conversionOk = false;
|
||||
if ( conversionOk && indexValue >= 0 && indexValue < static_cast<int>( regions.size() ) )
|
||||
{
|
||||
summaryAddress->setRegion( regions[indexValue].toInt() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2019- 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 <QString>
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObject;
|
||||
}
|
||||
|
||||
class RimSummaryPlot;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryEnsemble;
|
||||
class RifEclipseSummaryAddress;
|
||||
class RimSummaryMultiPlot;
|
||||
class RimSummaryAddressCollection;
|
||||
class RimPlotTemplateFileItem;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicSummaryPlotTemplateTools
|
||||
{
|
||||
public:
|
||||
static RimSummaryMultiPlot* create( const QString& fileName );
|
||||
|
||||
static RimSummaryMultiPlot*
|
||||
create( const QString& fileName, const std::vector<RimSummaryCase*>& cases, const std::vector<RimSummaryEnsemble*>& ensembles );
|
||||
|
||||
static QString selectPlotTemplatePath();
|
||||
static std::vector<QString> selectDefaultPlotTemplates( std::vector<QString> currentSelection );
|
||||
|
||||
static QString summaryCaseFieldKeyword();
|
||||
static QString summaryCaseXFieldKeyword();
|
||||
static QString summaryGroupFieldKeyword();
|
||||
|
||||
static QString placeholderTextForSummaryCase();
|
||||
static QString placeholderTextForSummaryCaseX();
|
||||
static QString placeholderTextForSummaryGroup();
|
||||
static QString placeholderTextForWell();
|
||||
static QString placeholderTextForGroup();
|
||||
|
||||
private:
|
||||
static RimSummaryMultiPlot* createMultiPlotFromTemplateFile( const QString& fileName );
|
||||
|
||||
static std::vector<RimSummaryCase*> selectedSummaryCases();
|
||||
static std::vector<RimSummaryEnsemble*> selectedSummaryEnsembles();
|
||||
static std::vector<RimSummaryAddressCollection*> selectedSummaryAddressCollections();
|
||||
|
||||
static QString htmlTextFromPlotAndSelection( const RimSummaryPlot* templatePlot,
|
||||
|
||||
const std::set<RifEclipseSummaryAddress>& selectedSummaryAddresses,
|
||||
const std::vector<caf::PdmObject*>& selectedSources );
|
||||
|
||||
static QString htmlTextFromCount( const QString& itemText, size_t requiredItemCount, size_t selectionCount );
|
||||
|
||||
static void setValuesForPlaceholders( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryCase*>& selectedSummaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& selectedEnsembles,
|
||||
const std::vector<QString>& wellNames,
|
||||
const std::vector<QString>& groupNames,
|
||||
const std::vector<QString>& regions );
|
||||
|
||||
static void setValuesForPlaceholders( RimSummaryPlot* summaryPlot,
|
||||
const std::vector<RimSummaryCase*>& selectedSummaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& selectedEnsembles,
|
||||
const std::vector<QString>& wellNames,
|
||||
const std::vector<QString>& groupNames,
|
||||
const std::vector<QString>& regions );
|
||||
|
||||
static RifEclipseSummaryAddress firstAddressByQuantity( const RifEclipseSummaryAddress& sourceAddress,
|
||||
const std::set<RifEclipseSummaryAddress>& allAddresses );
|
||||
|
||||
static int findValueForKeyword( const QString& keyword, const QString& valueString, bool* ok );
|
||||
|
||||
static void setPlaceholderWellName( RifEclipseSummaryAddress* summaryAddress, const std::vector<QString>& wellNames );
|
||||
static void setPlaceholderGroupName( RifEclipseSummaryAddress* summaryAddress, const std::vector<QString>& groupNames );
|
||||
static void setPlaceholderRegion( RifEclipseSummaryAddress* summaryAddress, const std::vector<QString>& regions );
|
||||
};
|
||||
@@ -0,0 +1,564 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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 "RiaSummaryPlotTools.h"
|
||||
|
||||
#include "SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h"
|
||||
#include "SummaryPlotCommands/RicSummaryPlotFeatureImpl.h"
|
||||
|
||||
#include "RiaPreferencesSummary.h"
|
||||
#include "RiaSummaryPlotTemplateTools.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
|
||||
#include "RimEnsembleCurveSet.h"
|
||||
#include "RimEnsembleCurveSetCollection.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimMultiPlot.h"
|
||||
#include "RimMultiPlotCollection.h"
|
||||
#include "RimPlot.h"
|
||||
#include "RimSaturationPressurePlot.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
#include "RimSummaryCurveAppearanceCalculator.h"
|
||||
#include "RimSummaryEnsemble.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryMultiPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "RiuPlotMainWindowTools.h"
|
||||
|
||||
namespace RiaSummaryPlotTools
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::set<RifEclipseSummaryAddress> addressesForSource( caf::PdmObject* summarySource )
|
||||
{
|
||||
auto ensemble = dynamic_cast<RimSummaryEnsemble*>( summarySource );
|
||||
if ( ensemble )
|
||||
{
|
||||
return ensemble->ensembleSummaryAddresses();
|
||||
}
|
||||
|
||||
auto sumCase = dynamic_cast<RimSummaryCase*>( summarySource );
|
||||
if ( sumCase )
|
||||
{
|
||||
auto reader = sumCase ? sumCase->summaryReader() : nullptr;
|
||||
if ( reader )
|
||||
{
|
||||
return reader->allResultAddresses();
|
||||
}
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleCurveSet* createCurveSet( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& addr )
|
||||
{
|
||||
auto curveSet = new RimEnsembleCurveSet();
|
||||
|
||||
curveSet->setSummaryEnsemble( ensemble );
|
||||
curveSet->setSummaryAddressYAndStatisticsFlag( addr );
|
||||
|
||||
return curveSet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr )
|
||||
{
|
||||
auto curve = new RimSummaryCurve();
|
||||
|
||||
curve->setSummaryCaseY( summaryCase );
|
||||
curve->setSummaryAddressY( addr );
|
||||
|
||||
return curve;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimPlot*> duplicatePlots( const std::vector<RimPlot*>& sourcePlots )
|
||||
{
|
||||
std::vector<RimPlot*> plots;
|
||||
|
||||
for ( auto plot : sourcePlots )
|
||||
{
|
||||
auto copy = plot->copyObject<RimPlot>();
|
||||
{
|
||||
// TODO: Workaround for fixing the PdmPointer in RimEclipseResultDefinition
|
||||
// caf::PdmPointer<RimEclipseCase> m_eclipseCase;
|
||||
// This PdmPointer must be changed to a ptrField
|
||||
|
||||
auto saturationPressurePlotOriginal = dynamic_cast<RimSaturationPressurePlot*>( plot );
|
||||
auto saturationPressurePlotCopy = dynamic_cast<RimSaturationPressurePlot*>( copy );
|
||||
if ( saturationPressurePlotCopy && saturationPressurePlotOriginal )
|
||||
{
|
||||
RimSaturationPressurePlot::fixPointersAfterCopy( saturationPressurePlotOriginal, saturationPressurePlotCopy );
|
||||
}
|
||||
}
|
||||
|
||||
plots.push_back( copy );
|
||||
}
|
||||
|
||||
return plots;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryPlot*> duplicateSummaryPlots( const std::vector<RimSummaryPlot*>& sourcePlots )
|
||||
{
|
||||
std::vector<RimSummaryPlot*> plots;
|
||||
|
||||
for ( auto plot : sourcePlots )
|
||||
{
|
||||
auto copy = plot->copyObject<RimSummaryPlot>();
|
||||
if ( copy )
|
||||
{
|
||||
plots.push_back( copy );
|
||||
}
|
||||
}
|
||||
|
||||
return plots;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimMultiPlot* createAndAppendMultiPlot( const std::vector<RimPlot*>& plots )
|
||||
{
|
||||
RimMultiPlotCollection* plotCollection = RimMainPlotCollection::current()->multiPlotCollection();
|
||||
|
||||
auto* plotWindow = new RimMultiPlot;
|
||||
plotWindow->setMultiPlotTitle( QString( "Multi Plot %1" ).arg( plotCollection->multiPlots().size() + 1 ) );
|
||||
plotWindow->setAsPlotMdiWindow();
|
||||
plotCollection->addMultiPlot( plotWindow );
|
||||
|
||||
appendPlotsToMultiPlot( plotWindow, plots );
|
||||
|
||||
plotCollection->updateAllRequiredEditors();
|
||||
plotWindow->loadDataAndUpdate();
|
||||
|
||||
if ( !plots.empty() )
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plots[0] );
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow );
|
||||
}
|
||||
|
||||
return plotWindow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector<caf::PdmObjectHandle*>& objects )
|
||||
{
|
||||
RimSummaryMultiPlotCollection* plotCollection = RimMainPlotCollection::current()->summaryMultiPlotCollection();
|
||||
|
||||
auto* plotWindow = new RimSummaryMultiPlot;
|
||||
plotWindow->setMultiPlotTitle( QString( "Multi Plot %1" ).arg( plotCollection->multiPlots().size() + 1 ) );
|
||||
plotWindow->setAsPlotMdiWindow();
|
||||
plotCollection->addSummaryMultiPlot( plotWindow );
|
||||
|
||||
plotWindow->handleDroppedObjects( objects );
|
||||
|
||||
plotCollection->updateAllRequiredEditors();
|
||||
plotWindow->loadDataAndUpdate();
|
||||
|
||||
if ( plotWindow->summaryPlots().size() == 1 )
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow->summaryPlots()[0] );
|
||||
RiuPlotMainWindowTools::setExpanded( plotWindow->summaryPlots()[0] );
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plotWindow );
|
||||
RiuPlotMainWindowTools::setExpanded( plotWindow );
|
||||
}
|
||||
|
||||
return plotWindow;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void appendPlotsToMultiPlot( RimMultiPlot* multiPlot, const std::vector<RimPlot*>& plots )
|
||||
{
|
||||
for ( auto plot : plots )
|
||||
{
|
||||
// Remove the current window controller, as this will be managed by the multi plot
|
||||
// This must be done before adding the plot to the multi plot to ensure that the viewer widget is recreated
|
||||
plot->revokeMdiWindowStatus();
|
||||
|
||||
multiPlot->addPlot( plot );
|
||||
|
||||
plot->resolveReferencesRecursively();
|
||||
plot->setShowWindow( true );
|
||||
|
||||
plot->loadDataAndUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* createAndAppendDefaultSummaryMultiPlot( const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles,
|
||||
bool skipCreationOfPlotBasedOnPreferences )
|
||||
{
|
||||
RiaPreferencesSummary* prefs = RiaPreferencesSummary::current();
|
||||
|
||||
if ( skipCreationOfPlotBasedOnPreferences && prefs->defaultSummaryPlotType() == RiaPreferencesSummary::DefaultSummaryPlotType::NONE )
|
||||
return nullptr;
|
||||
|
||||
if ( prefs->defaultSummaryPlotType() == RiaPreferencesSummary::DefaultSummaryPlotType::PLOT_TEMPLATES )
|
||||
{
|
||||
RimSummaryMultiPlot* plotToSelect = nullptr;
|
||||
bool ensembleTemplates = ( !ensembles.empty() );
|
||||
for ( auto& filename : prefs->defaultSummaryPlotTemplates( ensembleTemplates ) )
|
||||
{
|
||||
plotToSelect = RicSummaryPlotTemplateTools::create( filename, cases, ensembles );
|
||||
}
|
||||
|
||||
if ( plotToSelect ) return plotToSelect;
|
||||
|
||||
if ( skipCreationOfPlotBasedOnPreferences )
|
||||
{
|
||||
return plotToSelect;
|
||||
}
|
||||
}
|
||||
|
||||
if ( skipCreationOfPlotBasedOnPreferences && prefs->defaultSummaryCurvesTextFilter().trimmed().isEmpty() ) return nullptr;
|
||||
|
||||
auto* plotCollection = RimMainPlotCollection::current()->summaryMultiPlotCollection();
|
||||
|
||||
auto* summaryMultiPlot = new RimSummaryMultiPlot();
|
||||
summaryMultiPlot->setAsPlotMdiWindow();
|
||||
plotCollection->addSummaryMultiPlot( summaryMultiPlot );
|
||||
|
||||
RimSummaryPlot* plot = new RimSummaryPlot();
|
||||
plot->setAsPlotMdiWindow();
|
||||
plot->enableAutoPlotTitle( true );
|
||||
|
||||
for ( auto sumCase : cases )
|
||||
{
|
||||
RicSummaryPlotFeatureImpl::addDefaultCurvesToPlot( plot, sumCase );
|
||||
}
|
||||
|
||||
for ( auto ensemble : ensembles )
|
||||
{
|
||||
RicNewSummaryEnsembleCurveSetFeature::addDefaultCurveSets( plot, ensemble );
|
||||
}
|
||||
|
||||
plot->applyDefaultCurveAppearances();
|
||||
plot->loadDataAndUpdate();
|
||||
|
||||
plotCollection->updateConnectedEditors();
|
||||
|
||||
appendPlotsToSummaryMultiPlot( summaryMultiPlot, { plot } );
|
||||
|
||||
summaryMultiPlot->setDefaultRangeAggregationSteppingDimension();
|
||||
|
||||
plotCollection->updateAllRequiredEditors();
|
||||
summaryMultiPlot->loadDataAndUpdate();
|
||||
summaryMultiPlot->updateAllRequiredEditors();
|
||||
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
|
||||
if ( !plot->curveSets().empty() )
|
||||
{
|
||||
RiuPlotMainWindowTools::setExpanded( plot->curveSets().front() );
|
||||
}
|
||||
else if ( !plot->summaryCurves().empty() )
|
||||
{
|
||||
RiuPlotMainWindowTools::setExpanded( plot->summaryCurves().front() );
|
||||
}
|
||||
|
||||
return summaryMultiPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlotNoAutoSettings( RimSummaryPlot* plot )
|
||||
{
|
||||
auto* plotCollection = RimMainPlotCollection::current()->summaryMultiPlotCollection();
|
||||
|
||||
auto* summaryMultiPlot = new RimSummaryMultiPlot();
|
||||
summaryMultiPlot->setColumnCount( RiaDefines::ColumnCount::COLUMNS_1 );
|
||||
summaryMultiPlot->setRowCount( RiaDefines::RowCount::ROWS_1 );
|
||||
summaryMultiPlot->setAsPlotMdiWindow();
|
||||
|
||||
if ( !plot->autoPlotTitle() )
|
||||
{
|
||||
// Move settings from the single summary plot to the multi plot, and disable auto titles
|
||||
summaryMultiPlot->setAutoPlotTitle( false );
|
||||
summaryMultiPlot->setAutoSubPlotTitle( false );
|
||||
summaryMultiPlot->setMultiPlotTitleVisible( true );
|
||||
summaryMultiPlot->setMultiPlotTitle( plot->description() );
|
||||
|
||||
plot->setPlotTitleVisible( false );
|
||||
plot->setDescription( "" );
|
||||
}
|
||||
|
||||
plotCollection->addSummaryMultiPlot( summaryMultiPlot );
|
||||
|
||||
appendPlotsToSummaryMultiPlot( summaryMultiPlot, { plot } );
|
||||
|
||||
plotCollection->updateAllRequiredEditors();
|
||||
summaryMultiPlot->loadDataAndUpdate();
|
||||
summaryMultiPlot->updateAllRequiredEditors();
|
||||
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
|
||||
|
||||
return summaryMultiPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector<RimSummaryPlot*>& plots )
|
||||
{
|
||||
auto* plotCollection = RimMainPlotCollection::current()->summaryMultiPlotCollection();
|
||||
|
||||
auto* summaryMultiPlot = new RimSummaryMultiPlot();
|
||||
summaryMultiPlot->setAsPlotMdiWindow();
|
||||
plotCollection->addSummaryMultiPlot( summaryMultiPlot );
|
||||
|
||||
appendPlotsToSummaryMultiPlot( summaryMultiPlot, plots );
|
||||
|
||||
summaryMultiPlot->setDefaultRangeAggregationSteppingDimension();
|
||||
|
||||
plotCollection->updateAllRequiredEditors();
|
||||
summaryMultiPlot->loadDataAndUpdate();
|
||||
summaryMultiPlot->updateAllRequiredEditors();
|
||||
summaryMultiPlot->zoomAll();
|
||||
|
||||
if ( !plots.empty() )
|
||||
{
|
||||
auto* plot = plots.front();
|
||||
if ( !plot->curveSets().empty() )
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plot->curveSets().front() );
|
||||
}
|
||||
else if ( !plot->summaryCurves().empty() )
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plot->summaryCurves().front() );
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( plot );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RiuPlotMainWindowTools::selectAsCurrentItem( summaryMultiPlot );
|
||||
}
|
||||
|
||||
return summaryMultiPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlot( RimSummaryPlot* plot )
|
||||
{
|
||||
std::vector<RimSummaryPlot*> plots{ plot };
|
||||
|
||||
return createAndAppendSummaryMultiPlot( plots );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* multiPlot, const std::vector<RimSummaryPlot*>& plots )
|
||||
{
|
||||
multiPlot->startBatchAddOperation();
|
||||
for ( auto plot : plots )
|
||||
{
|
||||
plot->revokeMdiWindowStatus();
|
||||
|
||||
multiPlot->addPlot( plot );
|
||||
|
||||
plot->resolveReferencesRecursively();
|
||||
plot->setShowWindow( true );
|
||||
}
|
||||
multiPlot->endBatchAddOperation();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* createPlot( const std::vector<RimSummaryCurve*>& summaryCurves )
|
||||
{
|
||||
auto* plot = new RimSummaryPlot();
|
||||
plot->enableAutoPlotTitle( true );
|
||||
|
||||
for ( auto& curve : summaryCurves )
|
||||
{
|
||||
plot->addCurveNoUpdate( curve );
|
||||
}
|
||||
|
||||
plot->applyDefaultCurveAppearances();
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* createPlot( const std::set<RifEclipseSummaryAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles )
|
||||
{
|
||||
auto* plot = new RimSummaryPlot();
|
||||
plot->enableAutoPlotTitle( true );
|
||||
|
||||
appendCurvesToPlot( plot, addresses, summaryCases, ensembles );
|
||||
|
||||
plot->applyDefaultCurveAppearances();
|
||||
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryPlot* createCrossPlot( const std::vector<RiaSummaryCurveAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles )
|
||||
{
|
||||
auto* summaryPlot = new RimSummaryPlot();
|
||||
summaryPlot->enableAutoPlotTitle( true );
|
||||
|
||||
for ( const auto& addr : addresses )
|
||||
{
|
||||
for ( const auto ensemble : ensembles )
|
||||
{
|
||||
if ( !ensemble ) continue;
|
||||
|
||||
auto curveSet = addNewEnsembleCurve( summaryPlot, addr, ensemble );
|
||||
curveSet->findOrAssignBottomAxisX( RiuPlotAxis::defaultBottomForSummaryVectors() );
|
||||
}
|
||||
|
||||
for ( const auto summaryCase : summaryCases )
|
||||
{
|
||||
if ( !summaryCase ) continue;
|
||||
|
||||
addNewSummaryCurve( summaryPlot, addr, summaryCase );
|
||||
}
|
||||
}
|
||||
|
||||
summaryPlot->applyDefaultCurveAppearances();
|
||||
summaryPlot->loadDataAndUpdate();
|
||||
summaryPlot->zoomAll();
|
||||
|
||||
return summaryPlot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void appendCurvesToPlot( RimSummaryPlot* summaryPlot,
|
||||
const std::set<RifEclipseSummaryAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles )
|
||||
{
|
||||
for ( const auto& addr : addresses )
|
||||
{
|
||||
for ( const auto ensemble : ensembles )
|
||||
{
|
||||
auto curveSet = createCurveSet( ensemble, addr );
|
||||
summaryPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
|
||||
curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() );
|
||||
}
|
||||
|
||||
for ( const auto summaryCase : summaryCases )
|
||||
{
|
||||
auto curve = createCurve( summaryCase, addr );
|
||||
summaryPlot->addCurveNoUpdate( curve );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEnsembleCurveSet* addNewEnsembleCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryEnsemble* ensemble )
|
||||
{
|
||||
auto* curveSet = new RimEnsembleCurveSet();
|
||||
|
||||
curveSet->setSummaryEnsemble( ensemble );
|
||||
curveSet->setCurveAddress( curveAddress );
|
||||
|
||||
cvf::Color3f curveColor =
|
||||
RimSummaryCurveAppearanceCalculator::computeTintedCurveColorForAddress( curveSet->summaryAddressY(),
|
||||
static_cast<int>(
|
||||
summaryPlot->ensembleCurveSetCollection()->curveSetCount() ) );
|
||||
|
||||
auto adr = curveSet->summaryAddressY();
|
||||
if ( adr.isHistoryVector() ) curveColor = RiaPreferencesSummary::current()->historyCurveContrastColor();
|
||||
|
||||
curveSet->setColor( curveColor );
|
||||
|
||||
summaryPlot->ensembleCurveSetCollection()->addCurveSet( curveSet );
|
||||
|
||||
curveSet->setLeftOrRightAxisY( RiuPlotAxis::defaultLeft() );
|
||||
curveSet->setBottomOrTopAxisX( RiuPlotAxis::defaultBottomForSummaryVectors() );
|
||||
|
||||
summaryPlot->curvesChanged.send();
|
||||
|
||||
return curveSet;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCurve* addNewSummaryCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryCase* summaryCase )
|
||||
{
|
||||
auto curve = new RimSummaryCurve();
|
||||
|
||||
curve->setSummaryCaseY( summaryCase );
|
||||
curve->setSummaryAddressY( curveAddress.summaryAddressY() );
|
||||
|
||||
curve->setSummaryCaseX( summaryCase );
|
||||
curve->setSummaryAddressX( curveAddress.summaryAddressX() );
|
||||
if ( curveAddress.summaryAddressX().category() != SummaryCategory::SUMMARY_TIME )
|
||||
{
|
||||
curve->setAxisTypeX( RiaDefines::HorizontalAxisType::SUMMARY_VECTOR );
|
||||
}
|
||||
|
||||
summaryPlot->addCurveNoUpdate( curve );
|
||||
|
||||
if ( curveAddress.summaryAddressX().category() != SummaryCategory::SUMMARY_TIME )
|
||||
{
|
||||
summaryPlot->findOrAssignPlotAxisX( curve );
|
||||
}
|
||||
|
||||
return curve;
|
||||
}
|
||||
} // namespace RiaSummaryPlotTools
|
||||
@@ -0,0 +1,88 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2021- 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
|
||||
|
||||
class RimPlot;
|
||||
class RimMultiPlot;
|
||||
class RifEclipseSummaryAddress;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryEnsemble;
|
||||
class RimSummaryPlot;
|
||||
class RimEnsembleCurveSet;
|
||||
class RimSummaryCurve;
|
||||
class RimSummaryMultiPlot;
|
||||
class RiaSummaryCurveAddress;
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObject;
|
||||
class PdmObjectHandle;
|
||||
} // namespace caf
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
namespace RiaSummaryPlotTools
|
||||
{
|
||||
|
||||
std::set<RifEclipseSummaryAddress> addressesForSource( caf::PdmObject* summarySource );
|
||||
|
||||
RimEnsembleCurveSet* createCurveSet( RimSummaryEnsemble* ensemble, const RifEclipseSummaryAddress& addr );
|
||||
RimSummaryCurve* createCurve( RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& addr );
|
||||
|
||||
std::vector<RimPlot*> duplicatePlots( const std::vector<RimPlot*>& plots );
|
||||
std::vector<RimSummaryPlot*> duplicateSummaryPlots( const std::vector<RimSummaryPlot*>& plots );
|
||||
|
||||
RimMultiPlot* createAndAppendMultiPlot( const std::vector<RimPlot*>& plots );
|
||||
void appendPlotsToMultiPlot( RimMultiPlot* multiPlot, const std::vector<RimPlot*>& plots );
|
||||
|
||||
RimSummaryMultiPlot* createAndAppendDefaultSummaryMultiPlot( const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles,
|
||||
bool skipCreationOfPlotBasedOnPreferences = true );
|
||||
|
||||
RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlotNoAutoSettings( RimSummaryPlot* plot );
|
||||
RimSummaryMultiPlot* createAndAppendSingleSummaryMultiPlot( RimSummaryPlot* plot );
|
||||
RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector<RimSummaryPlot*>& plots );
|
||||
RimSummaryMultiPlot* createAndAppendSummaryMultiPlot( const std::vector<caf::PdmObjectHandle*>& objects );
|
||||
void appendPlotsToSummaryMultiPlot( RimSummaryMultiPlot* multiPlot, const std::vector<RimSummaryPlot*>& plots );
|
||||
|
||||
RimSummaryPlot* createPlot( const std::vector<RimSummaryCurve*>& summaryCurves );
|
||||
|
||||
RimSummaryPlot* createPlot( const std::set<RifEclipseSummaryAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles );
|
||||
|
||||
RimSummaryPlot* createCrossPlot( const std::vector<RiaSummaryCurveAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles );
|
||||
|
||||
void appendCurvesToPlot( RimSummaryPlot* summaryPlot,
|
||||
const std::set<RifEclipseSummaryAddress>& addresses,
|
||||
const std::vector<RimSummaryCase*>& summaryCases,
|
||||
const std::vector<RimSummaryEnsemble*>& ensembles );
|
||||
|
||||
RimEnsembleCurveSet*
|
||||
addNewEnsembleCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryEnsemble* ensemble );
|
||||
|
||||
RimSummaryCurve* addNewSummaryCurve( RimSummaryPlot* summaryPlot, const RiaSummaryCurveAddress& curveAddress, RimSummaryCase* summaryCase );
|
||||
|
||||
}; // namespace RiaSummaryPlotTools
|
||||
Reference in new issue
Block a user