Create multiple RFT plots based on the selected RFT plot

Show a dialog with all available RFT wells, and let the user select from this list. Create a copy of the RFT plot, and replace well name in the copy.
This commit is contained in:
Magne Sjaastad 2023-11-03 14:25:52 +01:00
parent 7c2df03fc5
commit 4f25fb4463
9 changed files with 400 additions and 43 deletions

View File

@ -31,6 +31,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewRftSegmentWellLogPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPhaseRftSegmentPlotFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogCalculatedCurveFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateRftPlotsFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicCreateRftPlotsFeatureUi.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -66,6 +68,8 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewRftSegmentWellLogPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewMultiPhaseRftSegmentPlotFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogCalculatedCurveFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateRftPlotsFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicCreateRftPlotsFeatureUi.cpp
)
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -0,0 +1,167 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 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 "RicCreateRftPlotsFeature.h"
#include "RiaLogging.h"
#include "RicCreateRftPlotsFeatureUi.h"
#include "RifReaderRftInterface.h"
#include "RimMainPlotCollection.h"
#include "RimRftPlotCollection.h"
#include "RimSummaryCase.h"
#include "RimSummaryCaseCollection.h"
#include "RimWellLogPlotNameConfig.h"
#include "RimWellLogTrack.h"
#include "RimWellPlotTools.h"
#include "RimWellRftPlot.h"
#include "RiuPlotMainWindowTools.h"
#include "cafPdmUiPropertyViewDialog.h"
#include "cafSelectionManager.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicCreateRftPlotsFeature, "RicCreateRftPlotsFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateRftPlotsFeature::onActionTriggered( bool isChecked )
{
auto sourcePlot = dynamic_cast<RimWellRftPlot*>( caf::SelectionManager::instance()->selectedItem() );
if ( !sourcePlot ) return;
RimRftPlotCollection* rftPlotColl = RimMainPlotCollection::current()->rftPlotCollection();
if ( !rftPlotColl ) return;
std::set<QString> wellsWithRftData;
auto dataSource = sourcePlot->dataSource();
if ( auto summaryCollection = std::get_if<RimSummaryCaseCollection*>( &dataSource ) )
{
wellsWithRftData = ( *summaryCollection )->wellsWithRftData();
}
else if ( auto summaryCase = std::get_if<RimSummaryCase*>( &dataSource ) )
{
RifReaderRftInterface* reader = ( *summaryCase )->rftReader();
if ( reader )
{
wellsWithRftData = reader->wellNames();
}
}
if ( wellsWithRftData.empty() ) return;
RicCreateRftPlotsFeatureUi ui;
ui.setAllWellNames( { wellsWithRftData.begin(), wellsWithRftData.end() } );
caf::PdmUiPropertyViewDialog propertyDialog( nullptr, &ui, "Select RFT wells", "" );
if ( propertyDialog.exec() != QDialog::Accepted ) return;
for ( const auto& wellName : ui.selectedWellNames() )
{
appendRftPlotForWell( wellName, rftPlotColl, sourcePlot );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateRftPlotsFeature::appendRftPlotForWell( const QString& wellName, RimRftPlotCollection* rftPlotColl, RimWellRftPlot* sourcePlot )
{
if ( !rftPlotColl )
{
RiaLogging::error( "Missing RFT plot collection, no RFT plot created." );
return;
}
if ( !sourcePlot )
{
RiaLogging::error( "Missing source RFT plot, no RFT plot created." );
return;
}
// Create a RFT plot based on wellName, and reuse the data source selection in sourcePlot
auto rftPlot =
dynamic_cast<RimWellRftPlot*>( sourcePlot->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) );
if ( !rftPlot ) return;
rftPlot->setSimWellOrWellPathName( wellName );
rftPlotColl->addPlot( rftPlot );
rftPlot->resolveReferencesRecursively();
rftPlot->applyInitialSelections( sourcePlot->dataSource() );
const auto generatedName = rftPlot->simWellOrWellPathName(); // We may have been given a default well name
const QString plotName = QString( RimWellRftPlot::plotNameFormatString() ).arg( generatedName );
rftPlot->nameConfig()->setCustomName( plotName );
rftPlot->loadDataAndUpdate();
rftPlotColl->updateConnectedEditors();
RiuPlotMainWindowTools::showPlotMainWindow();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateRftPlotsFeature::appendRftPlotForWell( const QString& wellName, RimRftPlotCollection* rftPlotColl )
{
if ( !rftPlotColl )
{
RiaLogging::error( "Missing RFT plot collection, no RFT plot created." );
return;
}
// Create a default RFT plot based on well name, and toggle on all available data sources in this RFT plot
auto rftPlot = new RimWellRftPlot();
rftPlot->setSimWellOrWellPathName( wellName );
auto plotTrack = new RimWellLogTrack();
rftPlot->addPlot( plotTrack );
plotTrack->setDescription( QString( "Track %1" ).arg( rftPlot->plotCount() ) );
rftPlotColl->addPlot( rftPlot );
rftPlot->applyInitialSelections( {} );
const auto generatedName = rftPlot->simWellOrWellPathName(); // We may have been given a default well name
const QString plotName = QString( RimWellRftPlot::plotNameFormatString() ).arg( generatedName );
rftPlot->nameConfig()->setCustomName( plotName );
rftPlot->setNamingMethod( RiaDefines::ObjectNamingMethod::CUSTOM );
rftPlot->loadDataAndUpdate();
rftPlotColl->updateConnectedEditors();
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::onObjectAppended( rftPlot, plotTrack );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateRftPlotsFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setText( "Create Multiple RFT Plots" );
actionToSetup->setIcon( QIcon( ":/FlowCharPlot16x16.png" ) );
}

View File

@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 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 <QString>
#include <vector>
class RimRftPlotCollection;
class RimWellRftPlot;
//==================================================================================================
///
//==================================================================================================
class RicCreateRftPlotsFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;
static void appendRftPlotForWell( const QString& wellName, RimRftPlotCollection* rftPlotColl );
private:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
void appendRftPlotForWell( const QString& wellName, RimRftPlotCollection* rftPlotColl, RimWellRftPlot* sourcePlot );
};

View File

@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 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 "RicCreateRftPlotsFeatureUi.h"
#include "cafPdmUiTreeSelectionEditor.h"
CAF_PDM_SOURCE_INIT( RicCreateRftPlotsFeatureUi, "RicCreateRftPlotsFeatureUi" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicCreateRftPlotsFeatureUi::RicCreateRftPlotsFeatureUi()
{
CAF_PDM_InitObject( "RicCreateRftPlotsFeatureUi" );
CAF_PDM_InitFieldNoDefault( &m_selectedWellNames, "SelectedWellNames", "Well Names" );
m_selectedWellNames.uiCapability()->setUiEditorTypeName( caf::PdmUiTreeSelectionEditor::uiEditorTypeName() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicCreateRftPlotsFeatureUi::setAllWellNames( const std::vector<QString>& wellNames )
{
m_allWellNames = wellNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QString> RicCreateRftPlotsFeatureUi::selectedWellNames() const
{
return m_selectedWellNames();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RicCreateRftPlotsFeatureUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;
if ( fieldNeedingOptions == &m_selectedWellNames )
{
for ( const auto& wellName : m_allWellNames )
{
options.append( caf::PdmOptionItemInfo( wellName, wellName ) );
}
}
return options;
}

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 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 "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <QString>
#include <vector>
//==================================================================================================
///
//==================================================================================================
class RicCreateRftPlotsFeatureUi : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RicCreateRftPlotsFeatureUi();
void setAllWellNames( const std::vector<QString>& wellNames );
std::vector<QString> selectedWellNames() const;
protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
private:
caf::PdmField<std::vector<QString>> m_selectedWellNames;
std::vector<QString> m_allWellNames;
};

View File

@ -18,16 +18,12 @@
#include "RicNewRftPlotFeature.h"
#include "RicCreateRftPlotsFeature.h"
#include "RimMainPlotCollection.h"
#include "RimRftPlotCollection.h"
#include "RimSimWellInView.h"
#include "RimWellLogPlot.h"
#include "RimWellLogPlotNameConfig.h"
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellRftPlot.h"
#include "RiuPlotMainWindowTools.h"
#include "cafSelectionManagerTools.h"
@ -42,7 +38,7 @@ CAF_CMD_SOURCE_INIT( RicNewRftPlotFeature, "RicNewRftPlotFeature" );
//--------------------------------------------------------------------------------------------------
bool RicNewRftPlotFeature::isCommandEnabled() const
{
RimRftPlotCollection* simWell = caf::firstAncestorOfTypeFromSelectedObject<RimRftPlotCollection>();
auto* simWell = caf::firstAncestorOfTypeFromSelectedObject<RimRftPlotCollection>();
if ( simWell ) return true;
if ( selectedWellName().isEmpty() )
@ -63,28 +59,7 @@ void RicNewRftPlotFeature::onActionTriggered( bool isChecked )
{
QString wellName = selectedWellName();
RimWellRftPlot* rftPlot = new RimWellRftPlot();
rftPlot->setSimWellOrWellPathName( wellName );
RimWellLogTrack* plotTrack = new RimWellLogTrack();
rftPlot->addPlot( plotTrack );
plotTrack->setDescription( QString( "Track %1" ).arg( rftPlot->plotCount() ) );
rftPlotColl->addPlot( rftPlot );
rftPlot->applyInitialSelections();
wellName = rftPlot->simWellOrWellPathName(); // We may have been given a default well name
QString plotName = QString( RimWellRftPlot::plotNameFormatString() ).arg( wellName );
rftPlot->nameConfig()->setCustomName( plotName );
rftPlot->setNamingMethod( RiaDefines::ObjectNamingMethod::CUSTOM );
rftPlot->loadDataAndUpdate();
rftPlotColl->updateConnectedEditors();
RiuPlotMainWindowTools::showPlotMainWindow();
RiuPlotMainWindowTools::onObjectAppended( rftPlot, plotTrack );
RicCreateRftPlotsFeature::appendRftPlotForWell( wellName, rftPlotColl );
}
}
@ -102,11 +77,11 @@ void RicNewRftPlotFeature::setupActionLook( QAction* actionToSetup )
//--------------------------------------------------------------------------------------------------
QString RicNewRftPlotFeature::selectedWellName()
{
RimSimWellInView* simWell = caf::firstAncestorOfTypeFromSelectedObject<RimSimWellInView>();
auto* simWell = caf::firstAncestorOfTypeFromSelectedObject<RimSimWellInView>();
if ( simWell ) return simWell->name();
RimWellPath* rimWellPath = caf::firstAncestorOfTypeFromSelectedObject<RimWellPath>();
auto* rimWellPath = caf::firstAncestorOfTypeFromSelectedObject<RimWellPath>();
if ( rimWellPath ) return rimWellPath->name();
return QString();
return {};
}

View File

@ -242,7 +242,7 @@ QString RimWellRftPlot::associatedSimWellName() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellRftPlot::applyInitialSelections()
void RimWellRftPlot::applyInitialSelections( std::variant<RimSummaryCase*, RimSummaryCaseCollection*> dataSource )
{
std::map<QString, QStringList> wellSources = findWellSources();
if ( m_wellPathNameOrSimWellName() == "None" && !wellSources.empty() )
@ -250,22 +250,49 @@ void RimWellRftPlot::applyInitialSelections()
m_wellPathNameOrSimWellName = wellSources.begin()->first;
}
RimSummaryCaseCollection* ensemble = nullptr;
RimSummaryCase* summaryCase = nullptr;
if ( auto summaryCollection = std::get_if<RimSummaryCaseCollection*>( &dataSource ) )
{
ensemble = *summaryCollection;
}
else if ( auto sumCase = std::get_if<RimSummaryCase*>( &dataSource ) )
{
summaryCase = *sumCase;
}
bool summaryOrEnsembleSelected = ( summaryCase || ensemble );
std::vector<RifDataSourceForRftPlt> sourcesToSelect;
const QString simWellName = associatedSimWellName();
for ( RimEclipseResultCase* const rftCase : RimWellPlotTools::rftCasesForWell( simWellName ) )
if ( !summaryOrEnsembleSelected )
{
sourcesToSelect.push_back( RifDataSourceForRftPlt( RifDataSourceForRftPlt::SourceType::RFT_SIM_WELL_DATA, rftCase ) );
}
for ( RimEclipseResultCase* const rftCase : RimWellPlotTools::rftCasesForWell( simWellName ) )
{
sourcesToSelect.push_back( RifDataSourceForRftPlt( RifDataSourceForRftPlt::SourceType::RFT_SIM_WELL_DATA, rftCase ) );
}
for ( RimEclipseResultCase* const gridCase : RimWellPlotTools::gridCasesForWell( simWellName ) )
{
sourcesToSelect.push_back( RifDataSourceForRftPlt( RifDataSourceForRftPlt::SourceType::GRID_MODEL_CELL_DATA, gridCase ) );
}
for ( RimEclipseResultCase* const gridCase : RimWellPlotTools::gridCasesForWell( simWellName ) )
{
sourcesToSelect.push_back( RifDataSourceForRftPlt( RifDataSourceForRftPlt::SourceType::GRID_MODEL_CELL_DATA, gridCase ) );
}
for ( RimSummaryCaseCollection* const ensemble : RimWellPlotTools::rftEnsemblesForWell( simWellName ) )
for ( RimSummaryCaseCollection* const ensemble : RimWellPlotTools::rftEnsemblesForWell( simWellName ) )
{
sourcesToSelect.push_back( RifDataSourceForRftPlt( ensemble ) );
}
for ( auto singleCase : RiaSummaryTools::singleTopLevelSummaryCases() )
{
sourcesToSelect.push_back( RifDataSourceForRftPlt( singleCase, nullptr, nullptr ) );
}
}
else
{
sourcesToSelect.push_back( RifDataSourceForRftPlt( ensemble ) );
if ( summaryCase ) sourcesToSelect.push_back( RifDataSourceForRftPlt( summaryCase, nullptr, nullptr ) );
if ( ensemble ) sourcesToSelect.push_back( RifDataSourceForRftPlt( ensemble ) );
}
std::vector<RimWellLogLasFile*> wellLogFiles = RimWellPlotTools::wellLogFilesContainingPressure( m_wellPathNameOrSimWellName );
@ -1514,6 +1541,23 @@ RimWellRftEnsembleCurveSet* RimWellRftPlot::findEnsembleCurveSet( RimSummaryCase
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::variant<RimSummaryCase*, RimSummaryCaseCollection*> RimWellRftPlot::dataSource() const
{
// Return the first selected ensemble, if any
// If no ensemble is selected, return the first selected summary case, if any
for ( const auto& source : m_selectedSources() )
{
if ( source.ensemble() ) return source.ensemble();
if ( source.summaryCase() ) return source.summaryCase();
}
return {};
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -38,6 +38,7 @@
#include <map>
#include <set>
#include <utility>
#include <variant>
class RimEclipseCase;
class RimEclipseResultCase;
@ -83,7 +84,8 @@ public:
int branchIndex() const;
void applyInitialSelections();
std::variant<RimSummaryCase*, RimSummaryCaseCollection*> dataSource() const;
void applyInitialSelections( std::variant<RimSummaryCase*, RimSummaryCaseCollection*> dataSource );
static const char* plotNameFormatString();

View File

@ -168,6 +168,7 @@
#include "RimWellPathFracture.h"
#include "RimWellPathFractureCollection.h"
#include "RimWellPltPlot.h"
#include "RimWellRftPlot.h"
#ifdef USE_QTCHARTS
#include "RimEnsembleFractureStatisticsPlotCollection.h"
@ -631,6 +632,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
{
menuBuilder << "RicDuplicateSummaryTableFeature";
}
else if ( dynamic_cast<RimWellRftPlot*>( firstUiItem ) )
{
menuBuilder << "RicCreateRftPlotsFeature";
}
else if ( dynamic_cast<RimWellLogPlot*>( firstUiItem ) && !dynamic_cast<RimWellPltPlot*>( firstUiItem ) )
{
menuBuilder << "RicPasteWellLogPlotFeature";