Allow drag'n'drop of realizations into summary plots

Improve "Create Summary Case Group" feature to not delete selected realizations from the source collection.
This commit is contained in:
Jon Jenssen 2022-03-07 17:02:16 +01:00 committed by jonjenssen
parent 93f754102d
commit 85d3f98f91
5 changed files with 142 additions and 83 deletions

View File

@ -18,6 +18,8 @@
#include "RicCreateSummaryCaseCollectionFeature.h" #include "RicCreateSummaryCaseCollectionFeature.h"
#include "RiaSummaryTools.h"
#include "RimSummaryCase.h" #include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h" #include "RimSummaryCaseCollection.h"
#include "RimSummaryCaseMainCollection.h" #include "RimSummaryCaseMainCollection.h"
@ -38,11 +40,9 @@ RimSummaryCaseCollection* RicCreateSummaryCaseCollectionFeature::groupSummaryCas
const QString& groupName, const QString& groupName,
bool isEnsemble ) bool isEnsemble )
{ {
RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr; RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection();
if ( !cases.empty() ) if ( !cases.empty() )
{ {
cases[0]->firstAncestorOrThisOfTypeAsserted( summaryCaseMainCollection );
auto newGroup = summaryCaseMainCollection->addCaseCollection( cases, groupName, isEnsemble ); auto newGroup = summaryCaseMainCollection->addCaseCollection( cases, groupName, isEnsemble );
summaryCaseMainCollection->updateConnectedEditors(); summaryCaseMainCollection->updateConnectedEditors();
@ -84,7 +84,17 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered( bool isChecked )
caf::SelectionManager::instance()->objectsByType( &selection ); caf::SelectionManager::instance()->objectsByType( &selection );
if ( selection.size() == 0 ) return; if ( selection.size() == 0 ) return;
groupSummaryCases( selection, "" ); std::vector<RimSummaryCase*> duplicates;
for ( const auto sumCase : selection )
{
auto copy =
dynamic_cast<RimSummaryCase*>( sumCase->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
duplicates.push_back( copy );
}
groupSummaryCases( duplicates, "" );
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -92,6 +102,6 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered( bool isChecked )
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RicCreateSummaryCaseCollectionFeature::setupActionLook( QAction* actionToSetup ) void RicCreateSummaryCaseCollectionFeature::setupActionLook( QAction* actionToSetup )
{ {
actionToSetup->setText( "Group Summary Cases" ); actionToSetup->setText( "Create Summary Case Group" );
actionToSetup->setIcon( QIcon( ":/SummaryGroup16x16.png" ) ); actionToSetup->setIcon( QIcon( ":/SummaryGroup16x16.png" ) );
} }

View File

@ -1005,10 +1005,13 @@ void RimSummaryCaseCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiT
} }
m_dataVectorFolders->updateUiTreeOrdering( uiTreeOrdering ); m_dataVectorFolders->updateUiTreeOrdering( uiTreeOrdering );
auto subnode = uiTreeOrdering.add( "Realizations", ":/Folder.png" ); if ( !m_cases.empty() )
for ( auto& smcase : m_cases )
{ {
subnode->add( smcase ); auto subnode = uiTreeOrdering.add( "Realizations", ":/Folder.png" );
for ( auto& smcase : m_cases )
{
subnode->add( smcase );
}
} }
uiTreeOrdering.skipRemainingChildren( true ); uiTreeOrdering.skipRemainingChildren( true );

View File

@ -36,7 +36,6 @@
#include "RimSummaryPlotNameHelper.h" #include "RimSummaryPlotNameHelper.h"
#include "RimSummaryPlotSourceStepping.h" #include "RimSummaryPlotSourceStepping.h"
#include "PlotBuilderCommands/RicSummaryPlotBuilder.h"
#include "RiuSummaryVectorSelectionUi.h" #include "RiuSummaryVectorSelectionUi.h"
#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiComboBoxEditor.h"

View File

@ -1823,6 +1823,115 @@ bool RimSummaryPlot::autoPlotTitle() const
return m_useAutoPlotTitle; return m_useAutoPlotTitle;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimSummaryPlot::handleSummaryCaseDrop( RimSummaryCase* summaryCase )
{
int newCurves = 0;
std::map<RifEclipseSummaryAddress, std::set<RimSummaryCase*>> dataVectorMap;
for ( auto& curve : summaryCurves() )
{
const auto curveAddress = curve->summaryAddressY();
dataVectorMap[curveAddress].insert( curve->summaryCaseY() );
}
for ( const auto& [addr, cases] : dataVectorMap )
{
if ( cases.count( summaryCase ) > 0 ) continue;
addNewCurveY( addr, summaryCase );
newCurves++;
}
return newCurves;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimSummaryPlot::handleAddressCollectionDrop( RimSummaryAddressCollection* addressCollection )
{
int newCurves = 0;
auto droppedName = addressCollection->name().toStdString();
if ( addressCollection->isEnsemble() ) return 0;
auto summaryCase = RiaSummaryTools::summaryCaseById( addressCollection->caseId() );
if ( summaryCase )
{
if ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL )
{
std::map<std::string, std::set<std::string>> dataVectorMap;
for ( auto& curve : summaryCurves() )
{
const auto curveAddress = curve->summaryAddressY();
if ( curveAddress.category() == RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL )
{
dataVectorMap[curveAddress.quantityName()].insert( curveAddress.wellName() );
}
}
for ( auto& [vectorName, wellNames] : dataVectorMap )
{
if ( wellNames.count( droppedName ) > 0 ) continue;
addNewCurveY( RifEclipseSummaryAddress::wellAddress( vectorName, droppedName ), summaryCase );
newCurves++;
}
}
else if ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL_GROUP )
{
std::map<std::string, std::set<std::string>> dataVectorMap;
for ( auto& curve : summaryCurves() )
{
const auto curveAddress = curve->summaryAddressY();
if ( curveAddress.category() == RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_GROUP )
{
dataVectorMap[curveAddress.quantityName()].insert( curveAddress.wellGroupName() );
}
}
for ( auto& [vectorName, wellGroupNames] : dataVectorMap )
{
if ( wellGroupNames.count( droppedName ) > 0 ) continue;
addNewCurveY( RifEclipseSummaryAddress::wellGroupAddress( vectorName, droppedName ), summaryCase );
newCurves++;
}
}
else if ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::REGION )
{
std::map<std::string, std::set<int>> dataVectorMap;
for ( auto& curve : summaryCurves() )
{
const auto curveAddress = curve->summaryAddressY();
if ( curveAddress.category() == RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION )
{
dataVectorMap[curveAddress.quantityName()].insert( curveAddress.regionNumber() );
}
}
int droppedRegion = std::stoi( droppedName );
for ( auto& [vectorName, regionNumbers] : dataVectorMap )
{
if ( regionNumbers.count( droppedRegion ) > 0 ) continue;
addNewCurveY( RifEclipseSummaryAddress::regionAddress( vectorName, droppedRegion ), summaryCase );
newCurves++;
}
}
}
return newCurves;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -1832,6 +1941,13 @@ void RimSummaryPlot::handleDroppedObjects( const std::vector<caf::PdmObjectHandl
for ( auto obj : objects ) for ( auto obj : objects )
{ {
auto summaryCase = dynamic_cast<RimSummaryCase*>( obj );
if ( summaryCase )
{
newCurves += handleSummaryCaseDrop( summaryCase );
continue;
}
auto summaryAdr = dynamic_cast<RimSummaryAddress*>( obj ); auto summaryAdr = dynamic_cast<RimSummaryAddress*>( obj );
if ( summaryAdr ) if ( summaryAdr )
{ {
@ -1843,7 +1959,6 @@ void RimSummaryPlot::handleDroppedObjects( const std::vector<caf::PdmObjectHandl
addNewEnsembleCurveY( summaryAdr->address(), ensemble ); addNewEnsembleCurveY( summaryAdr->address(), ensemble );
newCurves++; newCurves++;
} }
continue; continue;
} }
@ -1859,79 +1974,7 @@ void RimSummaryPlot::handleDroppedObjects( const std::vector<caf::PdmObjectHandl
auto addressCollection = dynamic_cast<RimSummaryAddressCollection*>( obj ); auto addressCollection = dynamic_cast<RimSummaryAddressCollection*>( obj );
if ( addressCollection ) if ( addressCollection )
{ {
auto droppedName = addressCollection->name().toStdString(); newCurves += handleAddressCollectionDrop( addressCollection );
if ( addressCollection->isEnsemble() ) continue;
auto summaryCase = RiaSummaryTools::summaryCaseById( addressCollection->caseId() );
if ( summaryCase )
{
if ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL )
{
std::map<std::string, std::set<std::string>> dataVectorMap;
for ( auto& curve : summaryCurves() )
{
const auto curveAddress = curve->summaryAddressY();
if ( curveAddress.category() == RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL )
{
dataVectorMap[curveAddress.quantityName()].insert( curveAddress.wellName() );
}
}
for ( auto& [vectorName, wellNames] : dataVectorMap )
{
if ( wellNames.count( droppedName ) > 0 ) continue;
addNewCurveY( RifEclipseSummaryAddress::wellAddress( vectorName, droppedName ), summaryCase );
newCurves++;
}
}
else if ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL_GROUP )
{
std::map<std::string, std::set<std::string>> dataVectorMap;
for ( auto& curve : summaryCurves() )
{
const auto curveAddress = curve->summaryAddressY();
if ( curveAddress.category() == RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_WELL_GROUP )
{
dataVectorMap[curveAddress.quantityName()].insert( curveAddress.wellGroupName() );
}
}
for ( auto& [vectorName, wellGroupNames] : dataVectorMap )
{
if ( wellGroupNames.count( droppedName ) > 0 ) continue;
addNewCurveY( RifEclipseSummaryAddress::wellGroupAddress( vectorName, droppedName ), summaryCase );
newCurves++;
}
}
else if ( addressCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::REGION )
{
std::map<std::string, std::set<int>> dataVectorMap;
for ( auto& curve : summaryCurves() )
{
const auto curveAddress = curve->summaryAddressY();
if ( curveAddress.category() == RifEclipseSummaryAddress::SummaryVarCategory::SUMMARY_REGION )
{
dataVectorMap[curveAddress.quantityName()].insert( curveAddress.regionNumber() );
}
}
int droppedRegion = std::stoi( droppedName );
for ( auto& [vectorName, regionNumbers] : dataVectorMap )
{
if ( regionNumbers.count( droppedRegion ) > 0 ) continue;
addNewCurveY( RifEclipseSummaryAddress::regionAddress( vectorName, droppedRegion ), summaryCase );
newCurves++;
}
}
}
continue; continue;
} }
} }

View File

@ -41,6 +41,7 @@
class PdmUiTreeOrdering; class PdmUiTreeOrdering;
class RimAsciiDataCurve; class RimAsciiDataCurve;
class RimGridTimeHistoryCurve; class RimGridTimeHistoryCurve;
class RimSummaryAddressCollection;
class RimSummaryCase; class RimSummaryCase;
class RimSummaryCaseCollection; class RimSummaryCaseCollection;
class RimSummaryCurve; class RimSummaryCurve;
@ -276,6 +277,9 @@ private:
bool updateStackedCurveDataForAxis( RiuPlotAxis plotAxis ); bool updateStackedCurveDataForAxis( RiuPlotAxis plotAxis );
bool updateStackedCurveDataForRelevantAxes(); bool updateStackedCurveDataForRelevantAxes();
int handleSummaryCaseDrop( RimSummaryCase* summaryCase );
int handleAddressCollectionDrop( RimSummaryAddressCollection* addrColl );
private: private:
#ifdef USE_QTCHARTS #ifdef USE_QTCHARTS
caf::PdmField<bool> m_useQtChartsPlot; caf::PdmField<bool> m_useQtChartsPlot;