mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
RFT segment plot adjustments (#9912)
* Delete RFT plot when associated case is deleted * Rename * Hide track/curves with no data
This commit is contained in:
@@ -21,6 +21,8 @@
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaSummaryTools.h"
|
||||
|
||||
#include "RicDeleteItemFeature.h"
|
||||
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCase.h"
|
||||
@@ -28,6 +30,7 @@
|
||||
#include "RimSummaryMultiPlot.h"
|
||||
#include "RimSummaryMultiPlotCollection.h"
|
||||
#include "RimSummaryPlot.h"
|
||||
#include "RimWellLogPlot.h"
|
||||
|
||||
#include "RiuPlotMainWindow.h"
|
||||
|
||||
@@ -59,6 +62,7 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector<RimSummaryCase*
|
||||
RimSummaryCaseMainCollection* summaryCaseMainCollection = RiaSummaryTools::summaryCaseMainCollection();
|
||||
|
||||
std::set<RimSummaryMultiPlot*> plotsToUpdate;
|
||||
std::set<RimWellLogPlot*> wellLogPlotsToDelete;
|
||||
|
||||
for ( RimSummaryCase* summaryCase : cases )
|
||||
{
|
||||
@@ -70,6 +74,23 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector<RimSummaryCase*
|
||||
}
|
||||
plotsToUpdate.insert( multiPlot );
|
||||
}
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> referringObjects;
|
||||
summaryCase->objectsWithReferringPtrFields( referringObjects );
|
||||
|
||||
for ( auto object : referringObjects )
|
||||
{
|
||||
if ( !object ) continue;
|
||||
|
||||
RimWellLogPlot* wellLogPlot = nullptr;
|
||||
object->firstAncestorOrThisOfType( wellLogPlot );
|
||||
if ( wellLogPlot ) wellLogPlotsToDelete.insert( wellLogPlot );
|
||||
}
|
||||
}
|
||||
|
||||
for ( auto wellLogPlot : wellLogPlotsToDelete )
|
||||
{
|
||||
RicDeleteItemFeature::deleteObject( wellLogPlot );
|
||||
}
|
||||
|
||||
summaryCaseMainCollection->removeCases( cases );
|
||||
|
@@ -44,12 +44,12 @@ bool RicDeleteItemFeature::isCommandEnabled()
|
||||
|
||||
for ( caf::PdmUiItem* item : items )
|
||||
{
|
||||
caf::PdmObject* currentPdmObject = dynamic_cast<caf::PdmObject*>( item );
|
||||
auto* currentPdmObject = dynamic_cast<caf::PdmObject*>( item );
|
||||
if ( !currentPdmObject ) return false;
|
||||
|
||||
if ( !currentPdmObject->isDeletable() ) return false;
|
||||
|
||||
caf::PdmChildArrayFieldHandle* childArrayFieldHandle = dynamic_cast<caf::PdmChildArrayFieldHandle*>( currentPdmObject->parentField() );
|
||||
auto* childArrayFieldHandle = dynamic_cast<caf::PdmChildArrayFieldHandle*>( currentPdmObject->parentField() );
|
||||
if ( !childArrayFieldHandle ) return false;
|
||||
}
|
||||
|
||||
@@ -63,68 +63,75 @@ void RicDeleteItemFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
std::vector<caf::PdmUiItem*> items;
|
||||
caf::SelectionManager::instance()->selectedItems( items );
|
||||
assert( items.size() > 0 );
|
||||
|
||||
for ( caf::PdmUiItem* item : items )
|
||||
{
|
||||
caf::PdmObject* currentPdmObject = dynamic_cast<caf::PdmObject*>( item );
|
||||
auto* currentPdmObject = dynamic_cast<caf::PdmObject*>( item );
|
||||
if ( !currentPdmObject ) continue;
|
||||
|
||||
if ( !currentPdmObject->isDeletable() ) continue;
|
||||
deleteObject( currentPdmObject );
|
||||
}
|
||||
}
|
||||
|
||||
caf::PdmChildArrayFieldHandle* childArrayFieldHandle = dynamic_cast<caf::PdmChildArrayFieldHandle*>( currentPdmObject->parentField() );
|
||||
if ( !childArrayFieldHandle ) continue;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicDeleteItemFeature::deleteObject( caf::PdmObject* objectToDelete )
|
||||
{
|
||||
if ( !objectToDelete || !objectToDelete->isDeletable() ) return;
|
||||
|
||||
int indexAfter = -1;
|
||||
auto* childArrayFieldHandle = dynamic_cast<caf::PdmChildArrayFieldHandle*>( objectToDelete->parentField() );
|
||||
if ( !childArrayFieldHandle ) return;
|
||||
|
||||
std::vector<caf::PdmObjectHandle*> childObjects;
|
||||
childArrayFieldHandle->children( &childObjects );
|
||||
int indexToObject = -1;
|
||||
|
||||
for ( size_t i = 0; i < childObjects.size(); i++ )
|
||||
std::vector<caf::PdmObjectHandle*> childObjects;
|
||||
childArrayFieldHandle->children( &childObjects );
|
||||
|
||||
for ( size_t i = 0; i < childObjects.size(); i++ )
|
||||
{
|
||||
if ( childObjects[i] == objectToDelete )
|
||||
{
|
||||
if ( childObjects[i] == currentPdmObject )
|
||||
{
|
||||
indexAfter = static_cast<int>( i );
|
||||
}
|
||||
indexToObject = static_cast<int>( i );
|
||||
}
|
||||
}
|
||||
|
||||
// Did not find currently selected pdm object in the current list field
|
||||
assert( indexAfter != -1 );
|
||||
// Did not find object in the current list field
|
||||
if ( indexToObject == -1 ) return;
|
||||
|
||||
RicDeleteItemExec* executeCmd = new RicDeleteItemExec( caf::SelectionManager::instance()->notificationCenter() );
|
||||
auto* executeCmd = new RicDeleteItemExec( caf::SelectionManager::instance()->notificationCenter() );
|
||||
|
||||
RicDeleteItemExecData& data = executeCmd->commandData();
|
||||
data.m_rootObject = caf::PdmReferenceHelper::findRoot( childArrayFieldHandle );
|
||||
data.m_pathToField = caf::PdmReferenceHelper::referenceFromRootToField( data.m_rootObject, childArrayFieldHandle );
|
||||
data.m_indexToObject = indexAfter;
|
||||
RicDeleteItemExecData& data = executeCmd->commandData();
|
||||
data.m_rootObject = caf::PdmReferenceHelper::findRoot( childArrayFieldHandle );
|
||||
data.m_pathToField = caf::PdmReferenceHelper::referenceFromRootToField( data.m_rootObject, childArrayFieldHandle );
|
||||
data.m_indexToObject = indexToObject;
|
||||
|
||||
{
|
||||
QString desc;
|
||||
if ( objectToDelete->userDescriptionField() )
|
||||
{
|
||||
QString desc;
|
||||
if ( currentPdmObject->userDescriptionField() )
|
||||
{
|
||||
desc = currentPdmObject->userDescriptionField()->uiCapability()->uiValue().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
desc = currentPdmObject->uiName();
|
||||
}
|
||||
|
||||
data.m_description = desc + " (delete)";
|
||||
}
|
||||
|
||||
// When the delete feature is ready for redo/undo, activate by using the line below
|
||||
// Temporarily do not insert these object into undo/redo system as this requires a lot of testing
|
||||
// for reinserting objects.
|
||||
bool useUndoRedo = false;
|
||||
if ( useUndoRedo )
|
||||
{
|
||||
caf::CmdExecCommandManager::instance()->processExecuteCommand( executeCmd );
|
||||
desc = objectToDelete->userDescriptionField()->uiCapability()->uiValue().toString();
|
||||
}
|
||||
else
|
||||
{
|
||||
executeCmd->redo();
|
||||
delete executeCmd;
|
||||
desc = objectToDelete->uiName();
|
||||
}
|
||||
|
||||
data.m_description = desc + " (delete)";
|
||||
}
|
||||
|
||||
// When the delete feature is ready for redo/undo, activate by using the line below
|
||||
// Temporarily do not insert these object into undo/redo system as this requires a lot of testing
|
||||
// for reinserting objects.
|
||||
bool useUndoRedo = false;
|
||||
if ( useUndoRedo )
|
||||
{
|
||||
caf::CmdExecCommandManager::instance()->processExecuteCommand( executeCmd );
|
||||
}
|
||||
else
|
||||
{
|
||||
executeCmd->redo();
|
||||
delete executeCmd;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -21,6 +21,11 @@
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
namespace caf
|
||||
{
|
||||
class PdmObject;
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
@@ -28,8 +33,12 @@ class RicDeleteItemFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void deleteObject( caf::PdmObject* objectToDelete );
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
||||
|
@@ -681,7 +681,7 @@ void RicSummaryPlotEditorUi::updateTargetPlot()
|
||||
// Add edited curves to target plot
|
||||
for ( const auto& editedCurve : m_previewPlot->summaryCurves() )
|
||||
{
|
||||
if ( !editedCurve->isCurveVisible() )
|
||||
if ( !editedCurve->isChecked() )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -724,7 +724,7 @@ void RicSummaryPlotEditorUi::copyCurveAndAddToPlot( const RimSummaryCurve* curve
|
||||
|
||||
if ( forceVisible )
|
||||
{
|
||||
curveCopy->setCurveVisibility( true );
|
||||
curveCopy->setCheckState( true );
|
||||
}
|
||||
|
||||
plot->addCurveNoUpdate( curveCopy, false );
|
||||
@@ -747,7 +747,7 @@ void RicSummaryPlotEditorUi::copyEnsembleCurveAndAddToCurveSet( const RimSummary
|
||||
|
||||
if ( forceVisible )
|
||||
{
|
||||
curveCopy->setCurveVisibility( true );
|
||||
curveCopy->setCheckState( true );
|
||||
}
|
||||
|
||||
curveSet->addCurve( curveCopy );
|
||||
@@ -951,7 +951,7 @@ void RicSummaryPlotEditorUi::setInitialCurveVisibility( const RimSummaryPlot* ta
|
||||
auto curveDef = std::make_pair( curve->summaryCaseY(), curve->summaryAddressY() );
|
||||
if ( sourceCurveDefs.count( curveDef ) == 0 )
|
||||
{
|
||||
curve->setCurveVisibility( false );
|
||||
curve->setCheckState( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -80,7 +80,7 @@ void RicNewMultiPhaseRftSegmentPlotFeature::onActionTriggered( bool isChecked )
|
||||
if ( !wellNames.empty() ) wellName = *wellNames.begin();
|
||||
|
||||
appendTrackAndCurveForBranchType( plot,
|
||||
"Connection Rates",
|
||||
"Reservoir Rates",
|
||||
{ "CONGRAT", "CONORAT", "CONWRAT" },
|
||||
wellName,
|
||||
RiaDefines::RftBranchType::RFT_ANNULUS,
|
||||
@@ -90,7 +90,10 @@ void RicNewMultiPhaseRftSegmentPlotFeature::onActionTriggered( bool isChecked )
|
||||
for ( auto branchType :
|
||||
{ RiaDefines::RftBranchType::RFT_ANNULUS, RiaDefines::RftBranchType::RFT_DEVICE, RiaDefines::RftBranchType::RFT_TUBING } )
|
||||
{
|
||||
appendTrackAndCurveForBranchType( plot, "Segment Rates", { "SEGGRAT", "SEGORAT", "SEGWRAT" }, wellName, branchType, summaryCase );
|
||||
QString trackName = caf::AppEnum<RiaDefines::RftBranchType>::uiText( branchType );
|
||||
trackName += " Rates";
|
||||
|
||||
appendTrackAndCurveForBranchType( plot, trackName, { "SEGGRAT", "SEGORAT", "SEGWRAT" }, wellName, branchType, summaryCase );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +102,7 @@ void RicNewMultiPhaseRftSegmentPlotFeature::onActionTriggered( bool isChecked )
|
||||
RicNewRftSegmentWellLogPlotFeature::appendTopologyTrack( plot, wellName, summaryCase );
|
||||
|
||||
plot->loadDataAndUpdate();
|
||||
plot->updateTrackVisibility();
|
||||
|
||||
RiaPlotWindowRedrawScheduler::instance()->performScheduledUpdatesAndReplots();
|
||||
plot->updateLayout();
|
||||
@@ -116,12 +120,10 @@ void RicNewMultiPhaseRftSegmentPlotFeature::appendTrackAndCurveForBranchType( Ri
|
||||
RiaDefines::RftBranchType branchType,
|
||||
RimSummaryCase* summaryCase )
|
||||
{
|
||||
auto plotTrack = new RimWellLogTrack();
|
||||
auto plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate();
|
||||
plot->addPlot( plotTrack );
|
||||
plotTrack->setDescription( trackName );
|
||||
|
||||
plot->loadDataAndUpdate();
|
||||
|
||||
for ( const auto& resultName : resultNames )
|
||||
{
|
||||
auto curve = RicWellLogTools::addSummaryRftSegmentCurve( plotTrack, resultName, wellName, branchType, summaryCase );
|
||||
@@ -137,7 +139,6 @@ void RicNewMultiPhaseRftSegmentPlotFeature::appendTrackAndCurveForBranchType( Ri
|
||||
curve->setFillStyle( Qt::SolidPattern );
|
||||
|
||||
curve->setIsStacked( true );
|
||||
curve->loadDataAndUpdate( true );
|
||||
|
||||
curve->updateAllRequiredEditors();
|
||||
}
|
||||
|
@@ -79,9 +79,9 @@ void RicNewRftSegmentWellLogPlotFeature::onActionTriggered( bool isChecked )
|
||||
if ( !wellNames.empty() ) wellName = *wellNames.begin();
|
||||
|
||||
{
|
||||
RimWellLogTrack* plotTrack = new RimWellLogTrack();
|
||||
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate();
|
||||
plot->addPlot( plotTrack );
|
||||
plotTrack->setDescription( "Connection Rates" );
|
||||
plotTrack->setDescription( "Reservoir Rates" );
|
||||
|
||||
auto curve = createAndAddCurve( plotTrack, "CONGRAT", wellName, RiaDefines::RftBranchType::RFT_ANNULUS, summaryCase );
|
||||
curve->setScaleFactor( 1e-3 );
|
||||
@@ -92,8 +92,9 @@ void RicNewRftSegmentWellLogPlotFeature::onActionTriggered( bool isChecked )
|
||||
{ RiaDefines::RftBranchType::RFT_ANNULUS, RiaDefines::RftBranchType::RFT_DEVICE, RiaDefines::RftBranchType::RFT_TUBING } )
|
||||
{
|
||||
QString resultName = "SEGGRAT";
|
||||
QString trackName = "Segment Rates";
|
||||
auto curve = appendTrackAndCurveForBranchType( plot, trackName, resultName, wellName, branchType, summaryCase );
|
||||
QString trackName = caf::AppEnum<RiaDefines::RftBranchType>::uiText( branchType );
|
||||
trackName += " Rates";
|
||||
auto curve = appendTrackAndCurveForBranchType( plot, trackName, resultName, wellName, branchType, summaryCase );
|
||||
curve->setScaleFactor( 1e-3 );
|
||||
curve->setFillStyle( Qt::SolidPattern );
|
||||
}
|
||||
@@ -103,6 +104,7 @@ void RicNewRftSegmentWellLogPlotFeature::onActionTriggered( bool isChecked )
|
||||
appendTopologyTrack( plot, wellName, summaryCase );
|
||||
|
||||
plot->loadDataAndUpdate();
|
||||
plot->updateTrackVisibility();
|
||||
|
||||
RiaPlotWindowRedrawScheduler::instance()->performScheduledUpdatesAndReplots();
|
||||
plot->updateLayout();
|
||||
@@ -120,15 +122,12 @@ RimWellLogRftCurve* RicNewRftSegmentWellLogPlotFeature::appendTrackAndCurveForBr
|
||||
RiaDefines::RftBranchType branchType,
|
||||
RimSummaryCase* summaryCase )
|
||||
{
|
||||
RimWellLogTrack* plotTrack = new RimWellLogTrack();
|
||||
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate();
|
||||
plot->addPlot( plotTrack );
|
||||
plotTrack->setDescription( trackName );
|
||||
|
||||
plot->loadDataAndUpdate();
|
||||
|
||||
auto curve = createAndAddCurve( plotTrack, resultName, wellName, branchType, summaryCase );
|
||||
|
||||
curve->loadDataAndUpdate( true );
|
||||
curve->updateAllRequiredEditors();
|
||||
|
||||
return curve;
|
||||
@@ -231,7 +230,8 @@ void RicNewRftSegmentWellLogPlotFeature::appendTopologyTrack( RimWellLogPlot* pl
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicNewRftSegmentWellLogPlotFeature::appendPressureTrack( RimWellLogPlot* plot, const QString& wellName, RimSummaryCase* summaryCase )
|
||||
{
|
||||
auto track = new RimWellLogTrack();
|
||||
auto track = RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate();
|
||||
track->setAutoCheckStateBasedOnCurveData( true );
|
||||
track->setDescription( "Pressure" );
|
||||
|
||||
plot->addPlot( track );
|
||||
@@ -244,10 +244,12 @@ void RicNewRftSegmentWellLogPlotFeature::appendPressureTrack( RimWellLogPlot* pl
|
||||
auto color = RimRftTopologyCurve::colorForRftBranchType( branchType );
|
||||
curve->setColor( color );
|
||||
curve->setLineThickness( 3 );
|
||||
curve->setAutoCheckStateBasedOnCurveData( true );
|
||||
}
|
||||
|
||||
auto curve = createAndAddCurve( track, "PRESSURE", wellName, RiaDefines::RftBranchType::RFT_ANNULUS, summaryCase );
|
||||
curve->setLineThickness( 3 );
|
||||
curve->setAutoCheckStateBasedOnCurveData( true );
|
||||
|
||||
track->updateAllRequiredEditors();
|
||||
}
|
||||
|
@@ -341,7 +341,7 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore
|
||||
curve->setSmoothingThreshold( 0.002 );
|
||||
if ( resultNames[i] == RiaResultNames::wbsSHMkResult() )
|
||||
{
|
||||
curve->setCurveVisibility( false );
|
||||
curve->setCheckState( false );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -104,6 +104,17 @@ RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createHorizontalWellLogPlot()
|
||||
return plot;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimWellLogTrack* RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate()
|
||||
{
|
||||
auto track = new RimWellLogTrack();
|
||||
track->setAutoCheckStateBasedOnCurveData( true );
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@@ -38,7 +38,8 @@ public:
|
||||
const QString& plotDescription = QString( "" ),
|
||||
const RimWbsParameters* params = nullptr );
|
||||
|
||||
static RimWellLogPlot* createHorizontalWellLogPlot();
|
||||
static RimWellLogPlot* createHorizontalWellLogPlot();
|
||||
static RimWellLogTrack* createWellLogTrackWithAutoUpdate();
|
||||
|
||||
static RimWellLogPlot* createWellLogPlot( bool showAfterCreation = true, const QString& plotDescription = QString( "" ) );
|
||||
|
||||
|
Reference in New Issue
Block a user