Remove obsolete template commands (#8851)

* Remove obsolete template commands

Use first object in object list when creating plots for templates and a case is selected. (use first well in well list, first group in group list, ...)

* Always create the reference string
This commit is contained in:
Magne Sjaastad
2022-04-28 18:28:24 +02:00
committed by GitHub
parent b030e617c6
commit 172f891be9
13 changed files with 136 additions and 311 deletions

View File

@@ -18,25 +18,11 @@
#include "RicCreateMultiPlotFromSelectionFeature.h"
#include "RiaGuiApplication.h"
#include "RiaSummaryTools.h"
#include "RicSummaryPlotTemplateTools.h"
#include "PlotTemplates/RimPlotTemplateFileItem.h"
#include "RimMainPlotCollection.h"
#include "RimProject.h"
#include "RimSummaryAddressCollection.h"
#include "RimSummaryCase.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryMultiPlotCollection.h"
#include "RiuPlotMainWindow.h"
#include "RiuPlotMainWindowTools.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicCreateMultiPlotFromSelectionFeature, "RicCreateMultiPlotFromSelectionFeature" );
@@ -54,67 +40,9 @@ bool RicCreateMultiPlotFromSelectionFeature::isCommandEnabled()
//--------------------------------------------------------------------------------------------------
void RicCreateMultiPlotFromSelectionFeature::onActionTriggered( bool isChecked )
{
QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
auto sumCases = RicSummaryPlotTemplateTools::selectedSummaryCases();
auto sumCaseCollections = RicSummaryPlotTemplateTools::selectedSummaryCaseCollections();
QString fileName = RicSummaryPlotTemplateTools::selectPlotTemplatePath();
auto summaryAddressCollections = RicSummaryPlotTemplateTools::selectedSummaryAddressCollections();
std::vector<QString> wellNames;
std::vector<QString> groupNames;
std::vector<QString> regions;
std::set<RimSummaryCase*> caseSet;
std::set<RimSummaryCaseCollection*> caseCollectionSet;
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 )
{
sumCaseCollections.push_back( sumCaseCollection );
}
auto proj = RimProject::current();
auto collections = proj->mainPlotCollection()->summaryMultiPlotCollection();
auto newSummaryPlot = RicSummaryPlotTemplateTools::createMultiPlotFromTemplateFile( fileName );
if ( !newSummaryPlot ) return;
collections->addSummaryMultiPlot( newSummaryPlot );
newSummaryPlot->resolveReferencesRecursively();
RicSummaryPlotTemplateTools::setValuesForPlaceholders( newSummaryPlot,
sumCases,
sumCaseCollections,
wellNames,
groupNames,
regions );
newSummaryPlot->initAfterReadRecursively();
newSummaryPlot->loadDataAndUpdate();
collections->updateConnectedEditors();
auto newSummaryPlot = RicSummaryPlotTemplateTools::create( fileName );
RiuPlotMainWindowTools::selectAsCurrentItem( newSummaryPlot );
}