mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#9126 Improve plot and curve handling for ensembles
Add append plots and append curves to context menu of ensembles Make sure we create an unique color when adding multiple ensembles
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "RimSummaryAddressCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
@@ -77,12 +78,21 @@ void RicAppendSummaryCurvesForSummaryCasesFeature::setupActionLook( QAction* act
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmObjectHandle*> RicAppendSummaryCurvesForSummaryCasesFeature::selectedCases()
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
// Make the object type general to match the expected type for handleDroppedObjects();
|
||||
std::vector<caf::PdmObjectHandle*> generalObjects;
|
||||
generalObjects.insert( generalObjects.begin(), objects.begin(), objects.end() );
|
||||
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
generalObjects.insert( generalObjects.begin(), objects.begin(), objects.end() );
|
||||
}
|
||||
{
|
||||
std::vector<RimSummaryCaseCollection*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
generalObjects.insert( generalObjects.begin(), objects.begin(), objects.end() );
|
||||
}
|
||||
|
||||
return generalObjects;
|
||||
}
|
||||
|
||||
@@ -77,9 +77,21 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* s
|
||||
summaryMultiPlot->addPlot( duplicatedPlot );
|
||||
|
||||
auto summaryCase = RiaSummaryTools::summaryCaseById( summaryAdrCollection->caseId() );
|
||||
for ( auto c : duplicatedPlot->summaryCurves() )
|
||||
if ( summaryCase )
|
||||
{
|
||||
c->setSummaryCaseY( summaryCase );
|
||||
for ( auto c : duplicatedPlot->summaryCurves() )
|
||||
{
|
||||
c->setSummaryCaseY( summaryCase );
|
||||
}
|
||||
}
|
||||
|
||||
auto ensemble = RiaSummaryTools::ensembleById( summaryAdrCollection->ensembleId() );
|
||||
if ( ensemble )
|
||||
{
|
||||
for ( auto c : duplicatedPlot->curveSets() )
|
||||
{
|
||||
c->setSummaryCaseCollection( ensemble );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -102,6 +114,51 @@ void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* s
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles )
|
||||
{
|
||||
auto addressCollectionsToBeDeleted =
|
||||
RicAppendSummaryPlotsForObjectsFeature::createAddressCollections( cases, ensembles );
|
||||
RicAppendSummaryPlotsForObjectsFeature::appendPlots( summaryMultiPlot, addressCollectionsToBeDeleted );
|
||||
|
||||
for ( auto obj : addressCollectionsToBeDeleted )
|
||||
{
|
||||
delete obj;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryAddressCollection*>
|
||||
RicAppendSummaryPlotsForObjectsFeature::createAddressCollections( const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles )
|
||||
{
|
||||
std::vector<RimSummaryAddressCollection*> addresses;
|
||||
|
||||
for ( auto c : cases )
|
||||
{
|
||||
auto myColl = new RimSummaryAddressCollection;
|
||||
myColl->setContentType( RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE );
|
||||
myColl->setCaseId( c->caseId() );
|
||||
addresses.push_back( myColl );
|
||||
}
|
||||
|
||||
for ( auto c : ensembles )
|
||||
{
|
||||
auto myColl = new RimSummaryAddressCollection;
|
||||
myColl->setContentType( RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE );
|
||||
myColl->setEnsembleId( c->ensembleId() );
|
||||
addresses.push_back( myColl );
|
||||
}
|
||||
|
||||
return addresses;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -276,8 +333,9 @@ std::vector<RimSummaryPlot*> RicAppendSummaryPlotsForObjectsFeature::plotsForOne
|
||||
|
||||
std::string wellNameToMatch;
|
||||
std::string groupNameToMatch;
|
||||
int regionToMatch = -1;
|
||||
int caseIdToMatch = -1;
|
||||
int regionToMatch = -1;
|
||||
int caseIdToMatch = -1;
|
||||
int ensembleIdToMatch = -1;
|
||||
|
||||
RiaSummaryAddressAnalyzer myAnalyser;
|
||||
for ( auto sourcePlot : sourcePlots )
|
||||
@@ -307,6 +365,11 @@ std::vector<RimSummaryPlot*> RicAppendSummaryPlotsForObjectsFeature::plotsForOne
|
||||
{
|
||||
caseIdToMatch = curves.front()->summaryCaseY()->caseId();
|
||||
}
|
||||
auto curveSets = sourcePlots.back()->curveSets();
|
||||
if ( !curveSets.empty() )
|
||||
{
|
||||
ensembleIdToMatch = curveSets.front()->ensembleId();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,6 +385,14 @@ std::vector<RimSummaryPlot*> RicAppendSummaryPlotsForObjectsFeature::plotsForOne
|
||||
if ( c->summaryCaseY()->caseId() == caseIdToMatch ) isMatching = true;
|
||||
}
|
||||
}
|
||||
else if ( ensembleIdToMatch != -1 )
|
||||
{
|
||||
auto curveSets = sourcePlot->curveSets();
|
||||
for ( auto c : curveSets )
|
||||
{
|
||||
if ( c->summaryCaseCollection()->ensembleId() == ensembleIdToMatch ) isMatching = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( sourcePlot );
|
||||
|
||||
@@ -29,6 +29,8 @@ class RimSummaryAddressCollection;
|
||||
class RimSummaryMultiPlot;
|
||||
class RifEclipseSummaryAddress;
|
||||
class RimSummaryPlot;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -39,21 +41,31 @@ class RicAppendSummaryPlotsForObjectsFeature : public caf::CmdFeature
|
||||
|
||||
public:
|
||||
static std::vector<RimSummaryAddressCollection*> selectedCollections();
|
||||
|
||||
static std::vector<RimSummaryPlot*>
|
||||
plotsForOneInstanceOfObjectType( const std::vector<RimSummaryPlot*>& sourcePlots,
|
||||
RimSummaryAddressCollection::CollectionContentType objectType );
|
||||
plotsForOneInstanceOfObjectType( const std::vector<RimSummaryPlot*>& sourcePlots,
|
||||
RimSummaryAddressCollection::CollectionContentType objectType );
|
||||
|
||||
static bool isSelectionCompatibleWithPlot( const std::vector<RimSummaryAddressCollection*>& selection,
|
||||
RimSummaryMultiPlot* summaryMultiPlot );
|
||||
|
||||
static void appendPlots( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryAddressCollection*>& selection );
|
||||
|
||||
static void appendPlots( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static std::vector<RimSummaryAddressCollection*>
|
||||
createAddressCollections( const std::vector<RimSummaryCase*>& cases,
|
||||
const std::vector<RimSummaryCaseCollection*>& ensembles );
|
||||
|
||||
static RifEclipseSummaryAddress modifyAddress( const RifEclipseSummaryAddress& sourceAddress,
|
||||
RimSummaryAddressCollection* summaryAddressCollection );
|
||||
};
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "RimSummaryAddressCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
@@ -32,39 +33,17 @@
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicAppendSummaryPlotsForSummaryCasesFeature, "RicAppendSummaryPlotsForSummaryCasesFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryPlotsForSummaryCasesFeature::appendPlotsForCases( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryCase*>& cases )
|
||||
{
|
||||
if ( !summaryMultiPlot ) return;
|
||||
if ( cases.empty() ) return;
|
||||
|
||||
std::vector<RimSummaryAddressCollection*> tmp;
|
||||
|
||||
for ( auto c : cases )
|
||||
{
|
||||
auto myColl = new RimSummaryAddressCollection;
|
||||
myColl->setContentType( RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE );
|
||||
myColl->setCaseId( c->caseId() );
|
||||
tmp.push_back( myColl );
|
||||
}
|
||||
|
||||
RicAppendSummaryPlotsForObjectsFeature::appendPlots( summaryMultiPlot, tmp );
|
||||
|
||||
for ( auto obj : tmp )
|
||||
{
|
||||
delete obj;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAppendSummaryPlotsForSummaryCasesFeature::isCommandEnabled()
|
||||
{
|
||||
return !selectedCases().empty();
|
||||
auto cases = selectedCases();
|
||||
auto ensembles = selectedEnsembles();
|
||||
|
||||
if ( cases.empty() && ensembles.empty() ) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -77,10 +56,10 @@ void RicAppendSummaryPlotsForSummaryCasesFeature::onActionTriggered( bool isChec
|
||||
auto summaryMultiPlot = dynamic_cast<RimSummaryMultiPlot*>( app->activePlotWindow() );
|
||||
if ( !summaryMultiPlot ) return;
|
||||
|
||||
auto cases = selectedCases();
|
||||
if ( cases.empty() ) return;
|
||||
auto cases = selectedCases();
|
||||
auto ensembles = selectedEnsembles();
|
||||
|
||||
appendPlotsForCases( summaryMultiPlot, cases );
|
||||
RicAppendSummaryPlotsForObjectsFeature::appendPlots( summaryMultiPlot, cases, ensembles );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -105,3 +84,14 @@ std::vector<RimSummaryCase*> RicAppendSummaryPlotsForSummaryCasesFeature::select
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCaseCollection*> RicAppendSummaryPlotsForSummaryCasesFeature::selectedEnsembles()
|
||||
{
|
||||
std::vector<RimSummaryCaseCollection*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimSummaryMultiPlot;
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@@ -32,14 +33,12 @@ class RicAppendSummaryPlotsForSummaryCasesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void appendPlotsForCases( RimSummaryMultiPlot* summaryMultiPlot, const std::vector<RimSummaryCase*>& cases );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static std::vector<RimSummaryCase*> selectedCases();
|
||||
static std::vector<RimSummaryCase*> selectedCases();
|
||||
static std::vector<RimSummaryCaseCollection*> selectedEnsembles();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user