#8849 Data Sources : Add append curves to plot based on selection

This commit is contained in:
Magne Sjaastad 2022-04-28 09:03:40 +02:00
parent 5d9f7b165c
commit b030e617c6
8 changed files with 157 additions and 22 deletions

View File

@ -6,6 +6,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFromDataVectorFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForObjectsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForObjectsFeature.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFromDataVectorFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForObjectsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForObjectsFeature.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -0,0 +1,95 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022 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 "RicAppendSummaryCurvesForObjectsFeature.h"
#include "RiaGuiApplication.h"
#include "RicAppendSummaryPlotsForObjectsFeature.h"
#include "RimSummaryMultiPlot.h"
#include "RimSummaryPlot.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicAppendSummaryCurvesForObjectsFeature, "RicAppendSummaryCurvesForObjectsFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicAppendSummaryCurvesForObjectsFeature::isCommandEnabled()
{
return !RicAppendSummaryPlotsForObjectsFeature::selectedCollections().empty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendSummaryCurvesForObjectsFeature::onActionTriggered( bool isChecked )
{
// - Select a set of objects in Data Source (wells, groups, regions, ..)
// - Use context menu to activate action
// - For each plots, append curves using handleDroppedObjects() on RimSummaryPlot
auto sumAddressCollections = RicAppendSummaryPlotsForObjectsFeature::selectedCollections();
if ( sumAddressCollections.empty() ) return;
RiaGuiApplication* app = RiaGuiApplication::instance();
auto summaryMultiPlot = dynamic_cast<RimSummaryMultiPlot*>( app->activePlotWindow() );
if ( !summaryMultiPlot ) return;
RicAppendSummaryPlotsForObjectsFeature::isSelectionCompatibleWithPlot( sumAddressCollections, summaryMultiPlot );
auto selectionType = sumAddressCollections.front()->contentType();
auto sourcePlots = summaryMultiPlot->summaryPlots();
auto plotsForOneInstance =
RicAppendSummaryPlotsForObjectsFeature::plotsForOneInstanceOfObjectType( sourcePlots, selectionType );
std::vector<caf::PdmObjectHandle*> pdmObjects;
for ( auto summaryAdrCollection : sumAddressCollections )
{
pdmObjects.push_back( summaryAdrCollection );
}
for ( auto plot : sourcePlots )
{
plot->handleDroppedObjects( pdmObjects );
}
summaryMultiPlot->loadDataAndUpdate();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicAppendSummaryCurvesForObjectsFeature::setupActionLook( QAction* actionToSetup )
{
QString objectType = "Objects";
auto addresses = RicAppendSummaryPlotsForObjectsFeature::selectedCollections();
if ( !addresses.empty() )
{
auto firstAdr = addresses.front();
objectType = caf::AppEnum<RimSummaryAddressCollection::CollectionContentType>::uiText( firstAdr->contentType() );
}
auto text = QString( "Append Curves For " ) + objectType;
actionToSetup->setText( text );
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
}

View File

@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2022 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 "cafCmdFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicAppendSummaryCurvesForObjectsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@ -106,18 +106,7 @@ void RicAppendSummaryPlotsForObjectsFeature::setupActionLook( QAction* actionToS
if ( !addresses.empty() )
{
auto firstAdr = addresses.front();
if ( firstAdr->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL )
{
objectType = "Wells";
}
else if ( firstAdr->contentType() == RimSummaryAddressCollection::CollectionContentType::GROUP )
{
objectType = "Groups";
}
else if ( firstAdr->contentType() == RimSummaryAddressCollection::CollectionContentType::REGION )
{
objectType = "Regions";
}
objectType = caf::AppEnum<RimSummaryAddressCollection::CollectionContentType>::uiText( firstAdr->contentType() );
}
auto text = QString( "Append Plots For " ) + objectType;
@ -136,9 +125,7 @@ std::vector<RimSummaryAddressCollection*> RicAppendSummaryPlotsForObjectsFeature
if ( sumAddressCollections.size() == 1 )
{
auto coll = sumAddressCollections[0];
if ( coll->contentType() == RimSummaryAddressCollection::CollectionContentType::WELL_FOLDER ||
coll->contentType() == RimSummaryAddressCollection::CollectionContentType::GROUP_FOLDER ||
coll->contentType() == RimSummaryAddressCollection::CollectionContentType::REGION_FOLDER )
if ( coll->isFolder() )
{
// If a folder is selected, return all sub items in folder
auto childObjects = coll->subFolders();

View File

@ -37,21 +37,22 @@ class RicAppendSummaryPlotsForObjectsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
public:
static std::vector<RimSummaryAddressCollection*> selectedCollections();
static std::vector<RimSummaryPlot*>
plotsForOneInstanceOfObjectType( const std::vector<RimSummaryPlot*>& sourcePlots,
RimSummaryAddressCollection::CollectionContentType objectType );
static bool isSelectionCompatibleWithPlot( const std::vector<RimSummaryAddressCollection*>& selection,
RimSummaryMultiPlot* summaryMultiPlot );
protected:
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
private:
static std::vector<RimSummaryAddressCollection*> selectedCollections();
static bool isSelectionCompatibleWithPlot( const std::vector<RimSummaryAddressCollection*>& selection,
RimSummaryMultiPlot* summaryMultiPlot );
RifEclipseSummaryAddress modifyAddress( const RifEclipseSummaryAddress& sourceAddress,
RimSummaryAddressCollection* summaryAddressCollection );
static std::vector<RimSummaryPlot*>
plotsForOneInstanceOfObjectType( const std::vector<RimSummaryPlot*>& sourcePlots,
RimSummaryAddressCollection::CollectionContentType objectType );
};

View File

@ -1113,6 +1113,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "RicNewMultiPlotFeature";
menuBuilder << "RicAppendSummaryPlotsForObjectsFeature";
menuBuilder << "RicAppendSummaryCurvesForObjectsFeature";
// Work in progress -- End

View File

@ -292,6 +292,20 @@ bool RimSummaryAddressCollection::isEnsemble() const
return m_ensembleId >= 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimSummaryAddressCollection::isFolder() const
{
if ( contentType() == CollectionContentType::WELL_FOLDER || contentType() == CollectionContentType::GROUP_FOLDER ||
contentType() == CollectionContentType::REGION_FOLDER || contentType() == CollectionContentType::BLOCK_FOLDER )
{
return true;
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -58,6 +58,7 @@ public:
bool isEmpty() const;
bool isEnsemble() const;
bool isFolder() const;
bool canBeDragged() const;