mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 07:03:25 -06:00
Merge pull request #8578 from OPM/summaryplot_fromdatavector
Summary Plot: create new plot from data vector tree nodes
This commit is contained in:
parent
4ed5250d3b
commit
208ae7692b
@ -31,6 +31,7 @@
|
||||
#include "RimSummaryCalculationCollection.h"
|
||||
#include "RimSummaryCalculationVariable.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryCrossPlot.h"
|
||||
#include "RimSummaryCrossPlotCollection.h"
|
||||
@ -257,3 +258,21 @@ RimSummaryCase* RiaSummaryTools::summaryCaseById( int caseId )
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCaseCollection* RiaSummaryTools::ensembleById( int ensembleId )
|
||||
{
|
||||
auto ensembles = RimProject::current()->summaryGroups();
|
||||
|
||||
for ( auto ensemble : ensembles )
|
||||
{
|
||||
if ( ensemble->ensembleId() == ensembleId )
|
||||
{
|
||||
return ensemble;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ class RimSummaryCrossPlot;
|
||||
class RimSummaryCrossPlotCollection;
|
||||
class RimSummaryCaseMainCollection;
|
||||
class RimSummaryCase;
|
||||
class RimSummaryCaseCollection;
|
||||
|
||||
class RifEclipseSummaryAddress;
|
||||
|
||||
@ -70,5 +71,6 @@ public:
|
||||
std::vector<double>& values,
|
||||
RiaQDateTimeTools::DateTimePeriod period );
|
||||
|
||||
static RimSummaryCase* summaryCaseById( int caseId );
|
||||
static RimSummaryCase* summaryCaseById( int caseId );
|
||||
static RimSummaryCaseCollection* ensembleById( int ensembleId );
|
||||
};
|
||||
|
@ -2,12 +2,14 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPlotFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotBuilder.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromDataVectorFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPlotFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicSummaryPlotBuilder.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryMultiPlotFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromDataVectorFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
@ -0,0 +1,120 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicNewSummaryPlotFromDataVectorFeature.h"
|
||||
|
||||
#include "RiaSummaryTools.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
|
||||
#include "RicSummaryPlotBuilder.h"
|
||||
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include "cafSelectionManagerTools.h"
|
||||
#include "cvfAssert.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicNewSummaryPlotFromDataVectorFeature, "RicNewSummaryPlotFromDataVectorFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicNewSummaryPlotFromDataVectorFeature::isCommandEnabled()
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> selectedItems;
|
||||
caf::SelectionManager::instance()->selectedItems( selectedItems );
|
||||
|
||||
std::vector<RimSummaryAddress*> selectedAddressItems = caf::selectedObjectsByType<RimSummaryAddress*>();
|
||||
|
||||
unsigned int nEnsembles = 0;
|
||||
|
||||
for ( auto adr : selectedAddressItems )
|
||||
{
|
||||
if ( adr->isEnsemble() ) nEnsembles++;
|
||||
}
|
||||
|
||||
bool bOk = ( selectedAddressItems.size() > 0 );
|
||||
if ( nEnsembles > 0 )
|
||||
{
|
||||
bOk = bOk && ( nEnsembles == selectedItems.size() );
|
||||
}
|
||||
bOk = bOk && ( selectedAddressItems.size() == selectedItems.size() );
|
||||
|
||||
return bOk;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSummaryPlotFromDataVectorFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<RimSummaryAddress*> selectedAddressItems = caf::selectedObjectsByType<RimSummaryAddress*>();
|
||||
std::set<int> caseIds;
|
||||
std::set<int> ensembleIds;
|
||||
std::vector<RimSummaryCase*> selectedCases;
|
||||
std::set<RifEclipseSummaryAddress> eclipseAddresses;
|
||||
std::vector<RimSummaryCaseCollection*> selectedEnsembles;
|
||||
|
||||
bool isEnsemble = false;
|
||||
|
||||
for ( auto adr : selectedAddressItems )
|
||||
{
|
||||
eclipseAddresses.insert( adr->address() );
|
||||
caseIds.insert( adr->caseId() );
|
||||
ensembleIds.insert( adr->ensembleId() );
|
||||
isEnsemble = isEnsemble || adr->isEnsemble();
|
||||
}
|
||||
|
||||
if ( isEnsemble )
|
||||
{
|
||||
for ( auto id : ensembleIds )
|
||||
{
|
||||
selectedEnsembles.push_back( RiaSummaryTools::ensembleById( id ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( auto id : caseIds )
|
||||
{
|
||||
selectedCases.push_back( RiaSummaryTools::summaryCaseById( id ) );
|
||||
}
|
||||
}
|
||||
|
||||
auto newPlot = RicSummaryPlotBuilder::createPlot( eclipseAddresses, selectedCases, selectedEnsembles );
|
||||
|
||||
auto plotCollection = RiaSummaryTools::summaryPlotCollection();
|
||||
newPlot->setAsPlotMdiWindow();
|
||||
|
||||
plotCollection->addPlot( newPlot );
|
||||
|
||||
newPlot->loadDataAndUpdate();
|
||||
|
||||
plotCollection->updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewSummaryPlotFromDataVectorFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "New Summary Plot" );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicfCommandObject.h"
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicNewSummaryPlotFromDataVectorFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
// Overrides
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- Statoil ASA
|
||||
// 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
|
||||
|
@ -118,6 +118,7 @@
|
||||
#include "RimStimPlanModelTemplate.h"
|
||||
#include "RimStimPlanModelTemplateCollection.h"
|
||||
#include "RimStreamlineInViewCollection.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
@ -1184,6 +1185,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicNewSimWellFractureFeature";
|
||||
menuBuilder << "RicNewSimWellIntersectionFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimSummaryAddress*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicNewSummaryPlotFromDataVectorFeature";
|
||||
}
|
||||
#ifdef USE_ODB_API
|
||||
else if ( dynamic_cast<RimWellIASettings*>( firstUiItem ) )
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user