mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-08 07:03:25 -06:00
Improve drag and drop features and right click commands (#8854)
This commit is contained in:
parent
172f891be9
commit
f54399960d
@ -7,6 +7,10 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromCurveFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForObjectsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForObjectsFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryCasesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryCasesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryAddressesFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryAddressesFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@ -18,6 +22,10 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFromCurveFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForObjectsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForObjectsFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryCasesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryCasesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryPlotsForSummaryAddressesFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAppendSummaryCurvesForSummaryAddressesFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
@ -0,0 +1,89 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicAppendSummaryCurvesForSummaryAddressesFeature.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RicAppendSummaryPlotsForObjectsFeature.h"
|
||||
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryAddressCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicAppendSummaryCurvesForSummaryAddressesFeature, "RicAppendSummaryCurvesForSummaryAddressesFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAppendSummaryCurvesForSummaryAddressesFeature::isCommandEnabled()
|
||||
{
|
||||
return !selectedAddresses().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryCurvesForSummaryAddressesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
|
||||
auto summaryMultiPlot = dynamic_cast<RimSummaryMultiPlot*>( app->activePlotWindow() );
|
||||
if ( !summaryMultiPlot ) return;
|
||||
|
||||
auto addresses = selectedAddresses();
|
||||
if ( addresses.empty() ) return;
|
||||
|
||||
for ( auto plot : summaryMultiPlot->summaryPlots() )
|
||||
{
|
||||
plot->handleDroppedObjects( addresses );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryCurvesForSummaryAddressesFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
QString objectType = "Addresses";
|
||||
|
||||
auto text = QString( "Append Curves For " ) + objectType;
|
||||
actionToSetup->setText( text );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<caf::PdmObjectHandle*> RicAppendSummaryCurvesForSummaryAddressesFeature::selectedAddresses()
|
||||
{
|
||||
std::vector<RimSummaryAddress*> 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() );
|
||||
|
||||
return generalObjects;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObjectHandle;
|
||||
}
|
||||
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicAppendSummaryCurvesForSummaryAddressesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static std::vector<caf::PdmObjectHandle*> selectedAddresses();
|
||||
};
|
@ -0,0 +1,88 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicAppendSummaryCurvesForSummaryCasesFeature.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RicAppendSummaryPlotsForObjectsFeature.h"
|
||||
|
||||
#include "RimSummaryAddressCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicAppendSummaryCurvesForSummaryCasesFeature, "RicAppendSummaryCurvesForSummaryCasesFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAppendSummaryCurvesForSummaryCasesFeature::isCommandEnabled()
|
||||
{
|
||||
return !selectedCases().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryCurvesForSummaryCasesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
|
||||
auto summaryMultiPlot = dynamic_cast<RimSummaryMultiPlot*>( app->activePlotWindow() );
|
||||
if ( !summaryMultiPlot ) return;
|
||||
|
||||
auto cases = selectedCases();
|
||||
if ( cases.empty() ) return;
|
||||
|
||||
for ( auto plot : summaryMultiPlot->summaryPlots() )
|
||||
{
|
||||
plot->handleDroppedObjects( cases );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryCurvesForSummaryCasesFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
QString objectType = "Cases";
|
||||
|
||||
auto text = QString( "Append Curves For " ) + objectType;
|
||||
actionToSetup->setText( text );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryCurve16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
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() );
|
||||
|
||||
return generalObjects;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObjectHandle;
|
||||
}
|
||||
|
||||
#include <vector>
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicAppendSummaryCurvesForSummaryCasesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static std::vector<caf::PdmObjectHandle*> selectedCases();
|
||||
};
|
@ -22,6 +22,7 @@
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaStdStringTools.h"
|
||||
#include "RiaSummaryAddressAnalyzer.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RicSummaryPlotBuilder.h"
|
||||
|
||||
@ -48,6 +49,56 @@ bool RicAppendSummaryPlotsForObjectsFeature::isCommandEnabled()
|
||||
return !selectedCollections().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryPlotsForObjectsFeature::appendPlots( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryAddressCollection*>& sumAddressCollections )
|
||||
{
|
||||
if ( sumAddressCollections.empty() ) return;
|
||||
|
||||
isSelectionCompatibleWithPlot( sumAddressCollections, summaryMultiPlot );
|
||||
|
||||
auto selectionType = sumAddressCollections.front()->contentType();
|
||||
auto sourcePlots = summaryMultiPlot->summaryPlots();
|
||||
auto plotsForOneInstance = plotsForOneInstanceOfObjectType( sourcePlots, selectionType );
|
||||
|
||||
for ( auto summaryAdrCollection : sumAddressCollections )
|
||||
{
|
||||
auto duplicatedPlots = RicSummaryPlotBuilder::duplicateSummaryPlots( plotsForOneInstance );
|
||||
|
||||
for ( auto duplicatedPlot : duplicatedPlots )
|
||||
{
|
||||
if ( summaryAdrCollection->contentType() == RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE )
|
||||
{
|
||||
summaryMultiPlot->addPlot( duplicatedPlot );
|
||||
|
||||
auto summaryCase = RiaSummaryTools::summaryCaseById( summaryAdrCollection->caseId() );
|
||||
for ( auto c : duplicatedPlot->summaryCurves() )
|
||||
{
|
||||
c->setSummaryCaseY( summaryCase );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
auto adrMods = RimSummaryAddressModifier::createAddressModifiersForPlot( duplicatedPlot );
|
||||
for ( auto adrMod : adrMods )
|
||||
{
|
||||
auto sourceAddress = adrMod.address();
|
||||
auto modifiedAdr = modifyAddress( sourceAddress, summaryAdrCollection );
|
||||
|
||||
adrMod.setAddress( modifiedAdr );
|
||||
}
|
||||
summaryMultiPlot->addPlot( duplicatedPlot );
|
||||
|
||||
duplicatedPlot->resolveReferencesRecursively();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
summaryMultiPlot->loadDataAndUpdate();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -65,33 +116,7 @@ void RicAppendSummaryPlotsForObjectsFeature::onActionTriggered( bool isChecked )
|
||||
auto summaryMultiPlot = dynamic_cast<RimSummaryMultiPlot*>( app->activePlotWindow() );
|
||||
if ( !summaryMultiPlot ) return;
|
||||
|
||||
isSelectionCompatibleWithPlot( sumAddressCollections, summaryMultiPlot );
|
||||
|
||||
auto selectionType = sumAddressCollections.front()->contentType();
|
||||
auto sourcePlots = summaryMultiPlot->summaryPlots();
|
||||
std::vector<RimSummaryPlot*> plotsForOneInstance = plotsForOneInstanceOfObjectType( sourcePlots, selectionType );
|
||||
|
||||
for ( auto summaryAdrCollection : sumAddressCollections )
|
||||
{
|
||||
auto duplicatedPlots = RicSummaryPlotBuilder::duplicateSummaryPlots( plotsForOneInstance );
|
||||
for ( auto duplicatedPlot : duplicatedPlots )
|
||||
{
|
||||
auto adrMods = RimSummaryAddressModifier::createAddressModifiersForPlot( duplicatedPlot );
|
||||
for ( auto adrMod : adrMods )
|
||||
{
|
||||
auto sourceAddress = adrMod.address();
|
||||
auto modifiedAdr = modifyAddress( sourceAddress, summaryAdrCollection );
|
||||
|
||||
adrMod.setAddress( modifiedAdr );
|
||||
}
|
||||
|
||||
summaryMultiPlot->addPlot( duplicatedPlot );
|
||||
|
||||
duplicatedPlot->resolveReferencesRecursively();
|
||||
}
|
||||
}
|
||||
|
||||
summaryMultiPlot->loadDataAndUpdate();
|
||||
appendPlots( summaryMultiPlot, sumAddressCollections );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -249,6 +274,7 @@ std::vector<RimSummaryPlot*> RicAppendSummaryPlotsForObjectsFeature::plotsForOne
|
||||
std::string wellNameToMatch;
|
||||
std::string groupNameToMatch;
|
||||
int regionToMatch = -1;
|
||||
int caseIdToMatch = -1;
|
||||
|
||||
RiaSummaryAddressAnalyzer myAnalyser;
|
||||
for ( auto sourcePlot : sourcePlots )
|
||||
@ -269,25 +295,45 @@ std::vector<RimSummaryPlot*> RicAppendSummaryPlotsForObjectsFeature::plotsForOne
|
||||
{
|
||||
if ( !myAnalyser.regionNumbers().empty() ) regionToMatch = *( myAnalyser.regionNumbers().begin() );
|
||||
}
|
||||
else if ( objectType == RimSummaryAddressCollection::CollectionContentType::SUMMARY_CASE )
|
||||
{
|
||||
auto curves = sourcePlots.back()->summaryCurves();
|
||||
if ( !curves.empty() )
|
||||
{
|
||||
caseIdToMatch = curves.front()->summaryCaseY()->caseId();
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto sourcePlot : sourcePlots )
|
||||
{
|
||||
auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( sourcePlot );
|
||||
|
||||
bool isMatching = false;
|
||||
for ( const auto& a : addresses )
|
||||
|
||||
if ( caseIdToMatch != -1 )
|
||||
{
|
||||
if ( !wellNameToMatch.empty() && a.wellName() == wellNameToMatch )
|
||||
auto curves = sourcePlot->summaryCurves();
|
||||
for ( auto c : curves )
|
||||
{
|
||||
isMatching = true;
|
||||
if ( c->summaryCaseY()->caseId() == caseIdToMatch ) isMatching = true;
|
||||
}
|
||||
else if ( !groupNameToMatch.empty() && a.groupName() == groupNameToMatch )
|
||||
}
|
||||
else
|
||||
{
|
||||
auto addresses = RimSummaryAddressModifier::createEclipseSummaryAddress( sourcePlot );
|
||||
|
||||
for ( const auto& a : addresses )
|
||||
{
|
||||
isMatching = true;
|
||||
}
|
||||
else if ( regionToMatch != -1 && a.regionNumber() == regionToMatch )
|
||||
{
|
||||
isMatching = true;
|
||||
if ( !wellNameToMatch.empty() && a.wellName() == wellNameToMatch )
|
||||
{
|
||||
isMatching = true;
|
||||
}
|
||||
else if ( !groupNameToMatch.empty() && a.groupName() == groupNameToMatch )
|
||||
{
|
||||
isMatching = true;
|
||||
}
|
||||
else if ( regionToMatch != -1 && a.regionNumber() == regionToMatch )
|
||||
{
|
||||
isMatching = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,19 +40,20 @@ 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 );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
|
||||
RifEclipseSummaryAddress modifyAddress( const RifEclipseSummaryAddress& sourceAddress,
|
||||
RimSummaryAddressCollection* summaryAddressCollection );
|
||||
|
||||
static RifEclipseSummaryAddress modifyAddress( const RifEclipseSummaryAddress& sourceAddress,
|
||||
RimSummaryAddressCollection* summaryAddressCollection );
|
||||
};
|
||||
|
@ -0,0 +1,101 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicAppendSummaryPlotsForSummaryAddressesFeature.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RicAppendSummaryPlotsForObjectsFeature.h"
|
||||
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryAddressCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicAppendSummaryPlotsForSummaryAddressesFeature, "RicAppendSummaryPlotsForSummaryAddressesFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryPlotsForSummaryAddressesFeature::appendPlotsForAddresses( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryAddress*>& addresses )
|
||||
{
|
||||
if ( !summaryMultiPlot ) return;
|
||||
if ( addresses.empty() ) return;
|
||||
|
||||
for ( auto adr : addresses )
|
||||
{
|
||||
auto* plot = new RimSummaryPlot();
|
||||
plot->enableAutoPlotTitle( true );
|
||||
plot->handleDroppedObjects( { adr } );
|
||||
|
||||
summaryMultiPlot->addPlot( plot );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAppendSummaryPlotsForSummaryAddressesFeature::isCommandEnabled()
|
||||
{
|
||||
return !selectedAddresses().empty();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryPlotsForSummaryAddressesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
|
||||
auto summaryMultiPlot = dynamic_cast<RimSummaryMultiPlot*>( app->activePlotWindow() );
|
||||
if ( !summaryMultiPlot ) return;
|
||||
|
||||
auto addresses = selectedAddresses();
|
||||
if ( addresses.empty() ) return;
|
||||
|
||||
appendPlotsForAddresses( summaryMultiPlot, addresses );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryPlotsForSummaryAddressesFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
QString objectType = "Addresses";
|
||||
|
||||
auto text = QString( "Append Plots For " ) + objectType;
|
||||
actionToSetup->setText( text );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryAddress*> RicAppendSummaryPlotsForSummaryAddressesFeature::selectedAddresses()
|
||||
{
|
||||
std::vector<RimSummaryAddress*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimSummaryAddress;
|
||||
class RimSummaryMultiPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicAppendSummaryPlotsForSummaryAddressesFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void appendPlotsForAddresses( RimSummaryMultiPlot* summaryMultiPlot,
|
||||
const std::vector<RimSummaryAddress*>& addresses );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
||||
private:
|
||||
static std::vector<RimSummaryAddress*> selectedAddresses();
|
||||
};
|
@ -0,0 +1,107 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicAppendSummaryPlotsForSummaryCasesFeature.h"
|
||||
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RicAppendSummaryPlotsForObjectsFeature.h"
|
||||
|
||||
#include "RimSummaryAddressCollection.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryPlotsForSummaryCasesFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
RiaGuiApplication* app = RiaGuiApplication::instance();
|
||||
|
||||
auto summaryMultiPlot = dynamic_cast<RimSummaryMultiPlot*>( app->activePlotWindow() );
|
||||
if ( !summaryMultiPlot ) return;
|
||||
|
||||
auto cases = selectedCases();
|
||||
if ( cases.empty() ) return;
|
||||
|
||||
appendPlotsForCases( summaryMultiPlot, cases );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAppendSummaryPlotsForSummaryCasesFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
QString objectType = "Cases";
|
||||
|
||||
auto text = QString( "Append Plots For " ) + objectType;
|
||||
actionToSetup->setText( text );
|
||||
actionToSetup->setIcon( QIcon( ":/SummaryPlotLight16x16.png" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RimSummaryCase*> RicAppendSummaryPlotsForSummaryCasesFeature::selectedCases()
|
||||
{
|
||||
std::vector<RimSummaryCase*> objects;
|
||||
caf::SelectionManager::instance()->objectsByType( &objects );
|
||||
|
||||
return objects;
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimSummaryCase;
|
||||
class RimSummaryMultiPlot;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
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();
|
||||
};
|
@ -362,7 +362,7 @@ RimSummaryMultiPlot*
|
||||
plotWindow->setAsPlotMdiWindow();
|
||||
plotCollection->addSummaryMultiPlot( plotWindow );
|
||||
|
||||
plotWindow->addPlot( objects );
|
||||
plotWindow->handleDroppedObjects( objects );
|
||||
|
||||
plotCollection->updateAllRequiredEditors();
|
||||
plotWindow->loadDataAndUpdate();
|
||||
|
@ -787,6 +787,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicNewSummaryMultiPlotFeature";
|
||||
menuBuilder << "RicNewSummaryCrossPlotFeature";
|
||||
menuBuilder << "RicAppendSummaryCurvesForSummaryCasesFeature";
|
||||
menuBuilder << "RicAppendSummaryPlotsForSummaryCasesFeature";
|
||||
menuBuilder.addSeparator();
|
||||
menuBuilder << "RicImportGridModelFromSummaryCaseFeature";
|
||||
|
||||
@ -1102,6 +1104,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
|
||||
if ( dynamic_cast<RimSummaryCase*>( firstUiItem ) || dynamic_cast<RimSummaryCaseCollection*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicAppendSummaryCurvesForSummaryCasesFeature";
|
||||
menuBuilder << "RicAppendSummaryPlotsForSummaryCasesFeature";
|
||||
menuBuilder << "RicCreateMultiPlotFromSelectionFeature";
|
||||
menuBuilder << "RicCreatePlotFromTemplateByShortcutFeature";
|
||||
}
|
||||
@ -1199,6 +1203,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
else if ( dynamic_cast<RimSummaryAddress*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicNewSummaryMultiPlotFromDataVectorFeature";
|
||||
menuBuilder << "RicAppendSummaryCurvesForSummaryAddressesFeature";
|
||||
menuBuilder << "RicAppendSummaryPlotsForSummaryAddressesFeature";
|
||||
}
|
||||
#ifdef USE_ODB_API
|
||||
else if ( dynamic_cast<RimWellIASettings*>( firstUiItem ) )
|
||||
|
@ -45,7 +45,8 @@ public:
|
||||
GROUP_FOLDER,
|
||||
REGION_FOLDER,
|
||||
BLOCK,
|
||||
BLOCK_FOLDER
|
||||
BLOCK_FOLDER,
|
||||
SUMMARY_CASE
|
||||
};
|
||||
|
||||
public:
|
||||
|
@ -23,6 +23,11 @@
|
||||
#include "RiaSummaryAddressAnalyzer.h"
|
||||
#include "RiaSummaryStringTools.h"
|
||||
|
||||
#include "PlotBuilderCommands/RicAppendSummaryPlotsForObjectsFeature.h"
|
||||
#include "PlotBuilderCommands/RicAppendSummaryPlotsForSummaryAddressesFeature.h"
|
||||
#include "PlotBuilderCommands/RicAppendSummaryPlotsForSummaryCasesFeature.h"
|
||||
#include "PlotBuilderCommands/RicSummaryPlotBuilder.h"
|
||||
|
||||
#include "RifEclEclipseSummary.h"
|
||||
#include "RifEclipseRftAddress.h"
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
@ -34,6 +39,7 @@
|
||||
#include "RimPlotAxisProperties.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryAddress.h"
|
||||
#include "RimSummaryAddressCollection.h"
|
||||
#include "RimSummaryAddressModifier.h"
|
||||
#include "RimSummaryCase.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
@ -55,6 +61,7 @@
|
||||
#include "qwt_scale_engine.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
namespace caf
|
||||
@ -166,20 +173,29 @@ void RimSummaryMultiPlot::insertPlot( RimPlot* plot, size_t index )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimSummaryMultiPlot::addPlot( const std::vector<caf::PdmObjectHandle*>& objects )
|
||||
void RimSummaryMultiPlot::handleDroppedObjects( const std::vector<caf::PdmObjectHandle*>& objects )
|
||||
{
|
||||
if ( objects.empty() ) return;
|
||||
|
||||
auto* addr = dynamic_cast<RimSummaryAddress*>( objects[0] );
|
||||
if ( addr )
|
||||
std::vector<RimSummaryAddress*> addresses;
|
||||
std::vector<RimSummaryAddressCollection*> addressCollections;
|
||||
std::vector<RimSummaryCase*> cases;
|
||||
|
||||
for ( auto o : objects )
|
||||
{
|
||||
auto* plot = new RimSummaryPlot();
|
||||
plot->enableAutoPlotTitle( true );
|
||||
auto address = dynamic_cast<RimSummaryAddress*>( o );
|
||||
if ( address ) addresses.push_back( address );
|
||||
|
||||
plot->handleDroppedObjects( objects );
|
||||
auto adrColl = dynamic_cast<RimSummaryAddressCollection*>( o );
|
||||
if ( adrColl ) addressCollections.push_back( adrColl );
|
||||
|
||||
addPlot( plot );
|
||||
auto summaryCase = dynamic_cast<RimSummaryCase*>( o );
|
||||
if ( summaryCase ) cases.push_back( summaryCase );
|
||||
}
|
||||
|
||||
RicAppendSummaryPlotsForSummaryAddressesFeature::appendPlotsForAddresses( this, addresses );
|
||||
RicAppendSummaryPlotsForObjectsFeature::appendPlots( this, addressCollections );
|
||||
RicAppendSummaryPlotsForSummaryCasesFeature::appendPlotsForCases( this, cases );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -84,7 +84,7 @@ public:
|
||||
|
||||
void syncAxisRanges();
|
||||
|
||||
void addPlot( const std::vector<caf::PdmObjectHandle*>& objects );
|
||||
void handleDroppedObjects( const std::vector<caf::PdmObjectHandle*>& objects );
|
||||
|
||||
void summaryPlotItemInfos( QList<caf::PdmOptionItemInfo>* optionInfos ) const;
|
||||
|
||||
|
@ -739,11 +739,14 @@ void RiuMultiPlotBook::dropEvent( QDropEvent* event )
|
||||
RimSummaryMultiPlot* multiPlot = dynamic_cast<RimSummaryMultiPlot*>( m_plotDefinition.p() );
|
||||
if ( multiPlot )
|
||||
{
|
||||
multiPlot->addPlot( objects );
|
||||
multiPlot->handleDroppedObjects( objects );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RiuMultiPlotBook::eventFilter( QObject* obj, QEvent* event )
|
||||
{
|
||||
if ( event->type() == QEvent::Wheel )
|
||||
|
Loading…
Reference in New Issue
Block a user