From 415a119f4120ebc1cfdbda368114e2823be65188 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 6 Mar 2023 14:34:22 +0100 Subject: [PATCH] RFT segment plot adjustments (#9912) * Delete RFT plot when associated case is deleted * Rename * Hide track/curves with no data --- .../Commands/RicCloseSummaryCaseFeature.cpp | 21 +++ .../Commands/RicDeleteItemFeature.cpp | 95 +++++++------ .../Commands/RicDeleteItemFeature.h | 9 ++ .../RicSummaryPlotEditorUi.cpp | 8 +- .../RicNewMultiPhaseRftSegmentPlotFeature.cpp | 13 +- .../RicNewRftSegmentWellLogPlotFeature.cpp | 20 +-- .../RicNewWellBoreStabilityPlotFeature.cpp | 2 +- .../RicNewWellLogPlotFeatureImpl.cpp | 11 ++ .../RicNewWellLogPlotFeatureImpl.h | 3 +- .../Flow/RimWellAllocationPlot.cpp | 4 +- .../GridCrossPlots/RimGridCrossPlot.cpp | 2 +- .../RimGridCrossPlotDataSet.cpp | 4 +- .../ProjectDataModel/RimDepthTrackPlot.cpp | 11 ++ .../ProjectDataModel/RimDepthTrackPlot.h | 2 + .../RimGridTimeHistoryCurve.cpp | 2 +- .../ProjectDataModel/RimPlotCurve.cpp | 38 ++++- .../ProjectDataModel/RimPlotCurve.h | 11 +- .../Summary/RimAsciiDataCurve.cpp | 2 +- .../Summary/RimSummaryCurve.cpp | 2 +- .../Summary/RimSummaryCurveCollection.cpp | 2 +- .../Summary/RimSummaryCurvesData.cpp | 6 +- .../Summary/RimSummaryPlot.cpp | 14 +- .../WellLog/RimWellLogCurve.cpp | 16 +++ .../WellLog/RimWellLogCurve.h | 3 + .../RimWellLogCurveCommonDataSource.cpp | 13 +- .../WellLog/RimWellLogExtractionCurve.cpp | 2 +- .../WellLog/RimWellLogFileCurve.cpp | 2 +- .../WellLog/RimWellLogRftCurve.cpp | 132 ++++++++++-------- .../WellLog/RimWellLogTrack.cpp | 56 ++++++-- .../WellLog/RimWellLogTrack.h | 5 + .../RigWellLogCurveData.cpp | 11 ++ .../ReservoirDataModel/RigWellLogCurveData.h | 2 + 32 files changed, 355 insertions(+), 169 deletions(-) diff --git a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp index 44ede1b634..6a7cd29394 100644 --- a/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp +++ b/ApplicationLibCode/Commands/RicCloseSummaryCaseFeature.cpp @@ -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 plotsToUpdate; + std::set wellLogPlotsToDelete; for ( RimSummaryCase* summaryCase : cases ) { @@ -70,6 +74,23 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases( std::vector 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 ); diff --git a/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp b/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp index c81ca8ebc2..8adf89cce1 100644 --- a/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationLibCode/Commands/RicDeleteItemFeature.cpp @@ -44,12 +44,12 @@ bool RicDeleteItemFeature::isCommandEnabled() for ( caf::PdmUiItem* item : items ) { - caf::PdmObject* currentPdmObject = dynamic_cast( item ); + auto* currentPdmObject = dynamic_cast( item ); if ( !currentPdmObject ) return false; if ( !currentPdmObject->isDeletable() ) return false; - caf::PdmChildArrayFieldHandle* childArrayFieldHandle = dynamic_cast( currentPdmObject->parentField() ); + auto* childArrayFieldHandle = dynamic_cast( currentPdmObject->parentField() ); if ( !childArrayFieldHandle ) return false; } @@ -63,68 +63,75 @@ void RicDeleteItemFeature::onActionTriggered( bool isChecked ) { std::vector items; caf::SelectionManager::instance()->selectedItems( items ); - assert( items.size() > 0 ); for ( caf::PdmUiItem* item : items ) { - caf::PdmObject* currentPdmObject = dynamic_cast( item ); + auto* currentPdmObject = dynamic_cast( item ); if ( !currentPdmObject ) continue; - if ( !currentPdmObject->isDeletable() ) continue; + deleteObject( currentPdmObject ); + } +} - caf::PdmChildArrayFieldHandle* childArrayFieldHandle = dynamic_cast( currentPdmObject->parentField() ); - if ( !childArrayFieldHandle ) continue; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicDeleteItemFeature::deleteObject( caf::PdmObject* objectToDelete ) +{ + if ( !objectToDelete || !objectToDelete->isDeletable() ) return; - int indexAfter = -1; + auto* childArrayFieldHandle = dynamic_cast( objectToDelete->parentField() ); + if ( !childArrayFieldHandle ) return; - std::vector childObjects; - childArrayFieldHandle->children( &childObjects ); + int indexToObject = -1; - for ( size_t i = 0; i < childObjects.size(); i++ ) + std::vector childObjects; + childArrayFieldHandle->children( &childObjects ); + + for ( size_t i = 0; i < childObjects.size(); i++ ) + { + if ( childObjects[i] == objectToDelete ) { - if ( childObjects[i] == currentPdmObject ) - { - indexAfter = static_cast( i ); - } + indexToObject = static_cast( 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; } } diff --git a/ApplicationLibCode/Commands/RicDeleteItemFeature.h b/ApplicationLibCode/Commands/RicDeleteItemFeature.h index 399b113ffe..7ffa01baed 100644 --- a/ApplicationLibCode/Commands/RicDeleteItemFeature.h +++ b/ApplicationLibCode/Commands/RicDeleteItemFeature.h @@ -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; }; diff --git a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp index 62138a1a60..9aea38cbbb 100644 --- a/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp +++ b/ApplicationLibCode/Commands/SummaryPlotCommands/RicSummaryPlotEditorUi.cpp @@ -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 ); } } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp index ad7dac0cfe..56bd81989c 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewMultiPhaseRftSegmentPlotFeature.cpp @@ -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::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(); } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp index c9ba39e4e4..0c8c826db5 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewRftSegmentWellLogPlotFeature.cpp @@ -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::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(); } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp index f269773c0f..6b78985856 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellBoreStabilityPlotFeature.cpp @@ -341,7 +341,7 @@ void RicNewWellBoreStabilityPlotFeature::createStabilityCurvesTrack( RimWellBore curve->setSmoothingThreshold( 0.002 ); if ( resultNames[i] == RiaResultNames::wbsSHMkResult() ) { - curve->setCurveVisibility( false ); + curve->setCheckState( false ); } } diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp index c889cd9e2f..db0345340f 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.cpp @@ -104,6 +104,17 @@ RimWellLogPlot* RicNewWellLogPlotFeatureImpl::createHorizontalWellLogPlot() return plot; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogTrack* RicNewWellLogPlotFeatureImpl::createWellLogTrackWithAutoUpdate() +{ + auto track = new RimWellLogTrack(); + track->setAutoCheckStateBasedOnCurveData( true ); + + return track; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h index be942886d6..0f14d50f2e 100644 --- a/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h +++ b/ApplicationLibCode/Commands/WellLogCommands/RicNewWellLogPlotFeatureImpl.h @@ -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( "" ) ); diff --git a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index 92c54bead0..524926514a 100644 --- a/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -217,7 +217,7 @@ void RimWellAllocationPlot::updateFromWell() { for ( auto c : t->curves() ) { - if ( !c->isCurveVisible() ) + if ( !c->isChecked() ) { uncheckedCurveNames.insert( c->curveName() ); } @@ -462,7 +462,7 @@ void RimWellAllocationPlot::addStackedCurve( const QString& tracerNa plotTrack->addCurve( curve ); curve->loadDataAndUpdate( true ); - curve->setCurveVisibility( showCurve ); + curve->setCheckState( showCurve ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp index 22cf4adef5..9b2b5cee0d 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlot.cpp @@ -968,7 +968,7 @@ std::vector RimGridCrossPlot::visibleCurves() const { for ( auto curve : dataSet->curves() ) { - if ( curve->isCurveVisible() ) + if ( curve->isChecked() ) { plotCurves.push_back( curve ); } diff --git a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp index 9e3557fbbc..20f6622c8e 100644 --- a/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp +++ b/ApplicationLibCode/ProjectDataModel/GridCrossPlots/RimGridCrossPlotDataSet.cpp @@ -705,7 +705,7 @@ size_t RimGridCrossPlotDataSet::visibleCurveCount() const size_t visibleCurves = 0; for ( auto curve : m_crossPlotCurves ) { - if ( curve && curve->isCurveVisible() ) visibleCurves++; + if ( curve && curve->isChecked() ) visibleCurves++; } return visibleCurves; } @@ -718,7 +718,7 @@ size_t RimGridCrossPlotDataSet::sampleCount() const size_t sampleCount = 0; for ( auto curve : m_crossPlotCurves ) { - if ( curve && curve->isCurveVisible() ) sampleCount += curve->sampleCount(); + if ( curve && curve->isChecked() ) sampleCount += curve->sampleCount(); } return sampleCount; } diff --git a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp index 72aca24a2f..699ea95964 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.cpp @@ -1530,6 +1530,17 @@ RiuPlotAxis RimDepthTrackPlot::annotationAxis( RiaDefines::Orientation depthOrie return RiuPlotAxis( oppositeAxis ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDepthTrackPlot::updateTrackVisibility() +{ + for ( auto& track : m_plots ) + { + track->updateCheckStateBasedOnCurveData(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.h b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.h index b215235c23..f3a5f7bdf8 100644 --- a/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.h +++ b/ApplicationLibCode/ProjectDataModel/RimDepthTrackPlot.h @@ -172,6 +172,8 @@ public: static RiuPlotAxis valueAxis( RiaDefines::Orientation depthOrientation ); static RiuPlotAxis annotationAxis( RiaDefines::Orientation depthOrientation ); + void updateTrackVisibility(); + protected: QImage snapshotWindowContent() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp index 6c6b33bf25..3bfece8b12 100644 --- a/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp @@ -383,7 +383,7 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate( bool updateParentPlot ) { this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); - if ( isCurveVisible() && m_plotCurve ) + if ( isChecked() && m_plotCurve ) { std::vector values; diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp index 09e822859d..92e520570f 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.cpp @@ -60,6 +60,8 @@ RimPlotCurve::RimPlotCurve() CAF_PDM_InitField( &m_showCurve, "Show", true, "Show curve" ); m_showCurve.uiCapability()->setUiHidden( true ); + CAF_PDM_InitField( &m_autoCheckStateBasedOnCurveData, "AutoCheckStateBasedOnCurveData", false, "Hide Curve If No Curve Data" ); + CAF_PDM_InitFieldNoDefault( &m_curveName, "CurveName", "" ); auto templateText = QString( "%1, %2" ).arg( RiaDefines::namingVariableCase() ).arg( RiaDefines::namingVariableResultName() ); @@ -158,6 +160,10 @@ void RimPlotCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, co if ( m_showCurve() ) loadDataAndUpdate( false ); visibilityChanged.send( m_showCurve() ); } + else if ( changedField == &m_autoCheckStateBasedOnCurveData ) + { + updateCheckStateBasedOnCurveData(); + } else if ( changedField == &m_curveName ) { updateCurveNameAndUpdatePlotLegendAndTitle(); @@ -359,7 +365,7 @@ cvf::Color3f RimPlotCurve::color() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimPlotCurve::isCurveVisible() const +bool RimPlotCurve::isChecked() const { return m_showCurve; } @@ -367,9 +373,27 @@ bool RimPlotCurve::isCurveVisible() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPlotCurve::setCurveVisibility( bool visible ) +void RimPlotCurve::setCheckState( bool isChecked ) { - m_showCurve = visible; + m_showCurve = isChecked; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::setAutoCheckStateBasedOnCurveData( bool enable ) +{ + m_autoCheckStateBasedOnCurveData = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimPlotCurve::updateCheckStateBasedOnCurveData() +{ + if ( !m_autoCheckStateBasedOnCurveData ) return; + + setCheckState( isAnyCurveDataPresent() ); } //-------------------------------------------------------------------------------------------------- @@ -861,6 +885,14 @@ void RimPlotCurve::updateAxisInPlot( RiuPlotAxis plotAxis ) if ( m_plotCurve ) m_plotCurve->setYAxis( plotAxis ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimPlotCurve::isAnyCurveDataPresent() const +{ + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h index 77551e0397..d920aba7b3 100644 --- a/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationLibCode/ProjectDataModel/RimPlotCurve.h @@ -79,8 +79,14 @@ public: void setFillStyle( Qt::BrushStyle brushStyle ); void setFillColor( const cvf::Color3f& fillColor ); - bool isCurveVisible() const; - void setCurveVisibility( bool visible ); + bool isChecked() const; + void setCheckState( bool isChecked ); + + // The check state of the curve (m_showCurve) can automatically be updated based on presens of curve data. The virtual method + // isAnyCurveDataPresent() can be overridden. Similar concept is used in RimWellLogTrack + void setAutoCheckStateBasedOnCurveData( bool enable ); + void updateCheckStateBasedOnCurveData(); + virtual bool isAnyCurveDataPresent() const; void updateCurveName(); void updateCurveNameAndUpdatePlotLegendAndTitle(); @@ -184,6 +190,7 @@ private: protected: caf::PdmField m_showCurve; + caf::PdmField m_autoCheckStateBasedOnCurveData; caf::PdmField m_curveName; caf::PdmField m_curveNameTemplateText; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp index 726bc0ede8..e6be15e7e6 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimAsciiDataCurve.cpp @@ -127,7 +127,7 @@ void RimAsciiDataCurve::onLoadDataAndUpdate( bool updateParentPlot ) { this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); - if ( isCurveVisible() ) + if ( isChecked() ) { std::vector dateTimes = this->timeSteps(); std::vector values = this->yValues(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 9f0efbfb14..8c9559737e 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -598,7 +598,7 @@ void RimSummaryCurve::onLoadDataAndUpdate( bool updateParentPlot ) setZIndexFromCurveInfo(); - if ( isCurveVisible() ) + if ( isChecked() ) { std::vector curveValuesY = this->valuesY(); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index 1251162666..e682f954e2 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -178,7 +178,7 @@ void RimSummaryCurveCollection::reattachPlotCurves() { for ( RimSummaryCurve* curve : m_curves ) { - if ( curve->isCurveVisible() ) curve->reattach(); + if ( curve->isChecked() ) curve->reattach(); } } diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp index 0790e00f90..ceee441e35 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurvesData.cpp @@ -43,7 +43,7 @@ void RimSummaryCurvesData::populateTimeHistoryCurvesData( std::vectorisCurveVisible() ) continue; + if ( !curve->isChecked() ) continue; QString curveCaseName = curve->caseName(); CurveData curveData = { curve->curveExportDescription(), RifEclipseSummaryAddress(), curve->yValues() }; @@ -63,7 +63,7 @@ void RimSummaryCurvesData::populateAsciiDataCurvesData( std::vectorisCurveVisible() ) continue; + if ( !curve->isChecked() ) continue; CurveData curveData = { curve->curveExportDescription(), RifEclipseSummaryAddress(), curve->yValues() }; @@ -188,7 +188,7 @@ void RimSummaryCurvesData::populateSummaryCurvesData( std::vectorsummaryCaseY() ? curve->summaryCaseY()->isObservedData() : false; - if ( !curve->isCurveVisible() ) continue; + if ( !curve->isChecked() ) continue; if ( isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_OBSERVED ) ) continue; if ( !isObservedCurve && ( curveType != SummaryCurveType::CURVE_TYPE_GRID ) ) continue; if ( !curve->summaryCaseY() ) continue; diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index 584bfc9097..eece1ee530 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -1171,7 +1171,7 @@ std::vector RimSummaryPlot::visibleSummaryCurvesForAxis( RiuPl { for ( RimSummaryCurve* curve : m_summaryCurveCollection->curves() ) { - if ( curve->isCurveVisible() ) + if ( curve->isChecked() ) { curves.push_back( curve ); } @@ -1184,7 +1184,7 @@ std::vector RimSummaryPlot::visibleSummaryCurvesForAxis( RiuPl { for ( RimSummaryCurve* curve : m_summaryCurveCollection->curves() ) { - if ( curve->isCurveVisible() && curve->axisY() == plotAxis ) + if ( curve->isChecked() && curve->axisY() == plotAxis ) { curves.push_back( curve ); } @@ -1197,7 +1197,7 @@ std::vector RimSummaryPlot::visibleSummaryCurvesForAxis( RiuPl { for ( RimSummaryCurve* curve : curveSet->curves() ) { - if ( curve->isCurveVisible() && curve->axisY() == plotAxis ) + if ( curve->isChecked() && curve->axisY() == plotAxis ) { curves.push_back( curve ); } @@ -1254,7 +1254,7 @@ std::vector RimSummaryPlot::visibleTimeHistoryCurvesFo for ( const auto& c : m_gridTimeHistoryCurves ) { - if ( c->isCurveVisible() ) + if ( c->isChecked() ) { if ( c->yAxis() == plotAxis || plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { @@ -1275,7 +1275,7 @@ std::vector RimSummaryPlot::visibleAsciiDataCurvesForAxis( R for ( const auto& c : m_asciiDataCurves ) { - if ( c->isCurveVisible() ) + if ( c->isChecked() ) { if ( c->yAxis() == plotAxis || plotAxis.axis() == RiaDefines::PlotAxis::PLOT_AXIS_BOTTOM ) { @@ -2041,7 +2041,7 @@ std::vector RimSummaryPlot::visibleCurvesForLegend() for ( auto c : summaryCurves() ) { - if ( !c->isCurveVisible() ) continue; + if ( !c->isChecked() ) continue; if ( !c->showInLegend() ) continue; curves.push_back( c ); } @@ -2815,7 +2815,7 @@ void RimSummaryPlot::updateCurveNames() { for ( auto c : summaryCurves() ) { - if ( c->isCurveVisible() ) + if ( c->isChecked() ) { c->updateCurveNameNoLegendUpdate(); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.cpp index 23847f7c58..b0ef4b5c46 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.cpp @@ -179,6 +179,14 @@ void RimWellLogCurve::setPropertyAndDepthsAndErrors( const std::vector& } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogCurve::clearCurveData() +{ + m_curveData->clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -458,3 +466,11 @@ RiuPlotAxis RimWellLogCurve::valueAxis() const return depthTrackPlot->valueAxis(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogCurve::isAnyCurveDataPresent() const +{ + return !m_curveData->propertyValues().empty(); +} diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.h index 3c776b50ee..bcf090dc7f 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurve.h @@ -48,6 +48,7 @@ public: bool depthValueRangeInData( double* minimumValue, double* maximumValue ) const; const RigWellLogCurveData* curveData() const; + bool isAnyCurveDataPresent() const override; void updateCurveAppearance() override; @@ -105,6 +106,8 @@ protected: const std::vector& depthValues, const std::vector& errorValues ); + void clearCurveData(); + bool isVerticalCurve() const; RiuPlotAxis depthAxis() const; RiuPlotAxis valueAxis() const; diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp index 472683cb0a..9e1154e023 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogCurveCommonDataSource.cpp @@ -328,10 +328,6 @@ void RimWellLogCurveCommonDataSource::analyseCurvesAndTracks( const std::vector< // Check to see if the parameters are unique for ( RimWellLogCurve* curve : curves ) { - if ( !curve->isCurveVisible() ) - { - continue; - } auto* extractionCurve = dynamic_cast( curve ); auto* fileCurve = dynamic_cast( curve ); auto* flowRateCurve = dynamic_cast( curve ); @@ -521,10 +517,6 @@ void RimWellLogCurveCommonDataSource::applyDataSourceChanges( const std::vector< std::set plots; for ( RimWellLogCurve* curve : curves ) { - if ( !curve->isCurveVisible() ) - { - continue; - } auto* fileCurve = dynamic_cast( curve ); auto* extractionCurve = dynamic_cast( curve ); auto* measurementCurve = dynamic_cast( curve ); @@ -719,6 +711,11 @@ void RimWellLogCurveCommonDataSource::applyDataSourceChanges() parentPlot->descendantsIncludingThisOfType( tracks ); this->applyDataSourceChanges( curves, tracks ); + + for ( auto& track : tracks ) + { + track->updateCheckStateBasedOnCurveData(); + } } } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp index 0a4dd9c221..3bf3622197 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogExtractionCurve.cpp @@ -344,7 +344,7 @@ void RimWellLogExtractionCurve::fieldChangedByUi( const caf::PdmFieldHandle* cha //-------------------------------------------------------------------------------------------------- void RimWellLogExtractionCurve::onLoadDataAndUpdate( bool updateParentPlot ) { - if ( isCurveVisible() ) + if ( isChecked() ) { bool isUsingPseudoLength = false; performDataExtraction( &isUsingPseudoLength ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp index 6e33604e80..3860978a93 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogFileCurve.cpp @@ -78,7 +78,7 @@ void RimWellLogFileCurve::onLoadDataAndUpdate( bool updateParentPlot ) { this->RimPlotCurve::updateCurvePresentation( updateParentPlot ); - if ( isCurveVisible() ) + if ( isChecked() ) { RimWellLogPlot* wellLogPlot; firstAncestorOrThisOfType( wellLogPlot ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp index 2afe20a283..f296baadb6 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogRftCurve.cpp @@ -648,7 +648,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) DerivedMDSource derivedMDSource = DerivedMDSource::NO_SOURCE; - if ( isCurveVisible() ) + if ( m_autoCheckStateBasedOnCurveData() || isChecked() ) { RimDepthTrackPlot* wellLogPlot; firstAncestorOrThisOfType( wellLogPlot ); @@ -666,6 +666,7 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) if ( values.empty() || values.size() != tvDepthVector.size() ) { + clearCurveData(); this->detach( true ); return; } @@ -747,78 +748,81 @@ void RimWellLogRftCurve::onLoadDataAndUpdate( bool updateParentPlot ) displayUnit = wellLogPlot->depthUnit(); } - if ( wellLogPlot->depthType() == RiaDefines::DepthTypeEnum::MEASURED_DEPTH ) + if ( m_plotCurve ) { - m_plotCurve->setPerPointLabels( perPointLabels ); - - auto propertyValues = this->curveData()->propertyValuesByIntervals(); - auto depthValues = this->curveData()->depthValuesByIntervals( RiaDefines::DepthTypeEnum::MEASURED_DEPTH, displayUnit ); - - if ( !errors.empty() ) + if ( wellLogPlot->depthType() == RiaDefines::DepthTypeEnum::MEASURED_DEPTH ) { - setPropertyAndDepthsAndErrors( propertyValues, depthValues, errors ); - } - else - { - setPropertyAndDepthValuesToPlotCurve( propertyValues, depthValues ); - } + m_plotCurve->setPerPointLabels( perPointLabels ); - m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); + auto propertyValues = this->curveData()->propertyValuesByIntervals(); + auto depthValues = this->curveData()->depthValuesByIntervals( RiaDefines::DepthTypeEnum::MEASURED_DEPTH, displayUnit ); - RimWellLogTrack* wellLogTrack; - firstAncestorOrThisOfType( wellLogTrack ); - CVF_ASSERT( wellLogTrack ); - - RiuQwtPlotWidget* viewer = wellLogTrack->viewer(); - if ( viewer ) - { - QString text; - - if ( derivedMDSource != DerivedMDSource::NO_SOURCE ) + if ( !errors.empty() ) { - if ( derivedMDSource == DerivedMDSource::WELL_PATH ) - { - text = "WELL/" + wellLogPlot->depthAxisTitle(); - } - else - { - text = "OBS/" + wellLogPlot->depthAxisTitle(); - } - } - else // Standard depth title set from plot - { - text = wellLogPlot->depthAxisTitle(); - } - - viewer->setAxisTitleText( wellLogPlot->depthAxis(), text ); - } - } - else - { - m_plotCurve->setPerPointLabels( perPointLabels ); - - auto propertyValues = this->curveData()->propertyValuesByIntervals(); - auto depthValues = this->curveData()->depthValuesByIntervals( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH, displayUnit ); - bool useLogarithmicScale = false; - - if ( !errors.empty() ) - { - setPropertyAndDepthsAndErrors( propertyValues, depthValues, errors ); - } - else - { - if ( isVerticalCurve() ) - { - m_plotCurve->setSamplesFromXValuesAndYValues( propertyValues, depthValues, useLogarithmicScale ); + setPropertyAndDepthsAndErrors( propertyValues, depthValues, errors ); } else { - m_plotCurve->setSamplesFromXValuesAndYValues( depthValues, propertyValues, useLogarithmicScale ); + setPropertyAndDepthValuesToPlotCurve( propertyValues, depthValues ); + } + + m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); + + RimWellLogTrack* wellLogTrack; + firstAncestorOrThisOfType( wellLogTrack ); + CVF_ASSERT( wellLogTrack ); + + RiuQwtPlotWidget* viewer = wellLogTrack->viewer(); + if ( viewer ) + { + QString text; + + if ( derivedMDSource != DerivedMDSource::NO_SOURCE ) + { + if ( derivedMDSource == DerivedMDSource::WELL_PATH ) + { + text = "WELL/" + wellLogPlot->depthAxisTitle(); + } + else + { + text = "OBS/" + wellLogPlot->depthAxisTitle(); + } + } + else // Standard depth title set from plot + { + text = wellLogPlot->depthAxisTitle(); + } + + viewer->setAxisTitleText( wellLogPlot->depthAxis(), text ); } } - } + else + { + m_plotCurve->setPerPointLabels( perPointLabels ); - m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); + auto propertyValues = this->curveData()->propertyValuesByIntervals(); + auto depthValues = this->curveData()->depthValuesByIntervals( RiaDefines::DepthTypeEnum::TRUE_VERTICAL_DEPTH, displayUnit ); + bool useLogarithmicScale = false; + + if ( !errors.empty() ) + { + setPropertyAndDepthsAndErrors( propertyValues, depthValues, errors ); + } + else + { + if ( isVerticalCurve() ) + { + m_plotCurve->setSamplesFromXValuesAndYValues( propertyValues, depthValues, useLogarithmicScale ); + } + else + { + m_plotCurve->setSamplesFromXValuesAndYValues( depthValues, propertyValues, useLogarithmicScale ); + } + } + } + + m_plotCurve->setLineSegmentStartStopIndices( this->curveData()->polylineStartStopIndices() ); + } if ( updateParentPlot ) { @@ -847,6 +851,10 @@ void RimWellLogRftCurve::defineUiOrdering( QString uiConfigName, caf::PdmUiOrder curveDataGroup->add( &m_rftDataType ); curveDataGroup->add( &m_scaleFactor ); + caf::PdmUiGroup* automationGroup = uiOrdering.addNewGroup( "Automation" ); + automationGroup->setCollapsedByDefault(); + automationGroup->add( &m_autoCheckStateBasedOnCurveData ); + if ( m_rftDataType() == RimWellLogRftCurve::RftDataType::RFT_DATA ) { curveDataGroup->add( &m_wellLogChannelName ); diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp index e34172f755..e6aecd8777 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.cpp @@ -270,6 +270,8 @@ RimWellLogTrack::RimWellLogTrack() CAF_PDM_InitFieldNoDefault( &m_wellPathComponentSource, "AttributesWellPathSource", "Well Path" ); CAF_PDM_InitFieldNoDefault( &m_wellPathAttributeCollection, "AttributesCollection", "Well Attributes" ); + CAF_PDM_InitField( &m_autoCheckStateBasedOnCurveData, "AutoCheckStateBasedOnCurveData", false, "Hide Track if No Curve Data" ); + CAF_PDM_InitField( &m_overburdenHeight, "OverburdenHeight", 0.0, "Overburden Height" ); m_overburdenHeight.uiCapability()->setUiHidden( true ); CAF_PDM_InitField( &m_underburdenHeight, "UnderburdenHeight", 0.0, "Underburden Height" ); @@ -379,7 +381,7 @@ void RimWellLogTrack::calculatePropertyValueZoomRange() double minCurveValue = HUGE_VAL; double maxCurveValue = -HUGE_VAL; - if ( curve->isCurveVisible() ) + if ( curve->isChecked() ) { visibleCurves++; if ( curve->propertyValueRangeInData( &minCurveValue, &maxCurveValue ) ) @@ -443,7 +445,7 @@ void RimWellLogTrack::calculateDepthZoomRange() double minCurveDepth = HUGE_VAL; double maxCurveDepth = -HUGE_VAL; - if ( curve->isCurveVisible() && curve->depthValueRangeInData( &minCurveDepth, &maxCurveDepth ) ) + if ( curve->isChecked() && curve->depthValueRangeInData( &minCurveDepth, &maxCurveDepth ) ) { if ( minCurveDepth < minDepth ) { @@ -759,6 +761,10 @@ void RimWellLogTrack::fieldChangedByUi( const caf::PdmFieldHandle* changedField, updateParentLayout(); RiuPlotMainWindowTools::refreshToolbars(); } + else if ( changedField == &m_autoCheckStateBasedOnCurveData ) + { + updateCheckStateBasedOnCurveData(); + } } //-------------------------------------------------------------------------------------------------- @@ -954,7 +960,7 @@ QString RimWellLogTrack::asciiDataForPlotExport() const for ( RimWellLogCurve* curve : m_curves() ) { - if ( !curve->isCurveVisible() ) continue; + if ( !curve->isChecked() ) continue; const RigWellLogCurveData* curveData = curve->curveData(); if ( !curveData ) continue; @@ -1281,6 +1287,36 @@ bool RimWellLogTrack::isEmptyVisiblePropertyRange() const 1.0e-6 * std::max( 1.0, std::max( m_visiblePropertyValueRangeMax(), m_visiblePropertyValueRangeMin() ) ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::setAutoCheckStateBasedOnCurveData( bool enable ) +{ + m_autoCheckStateBasedOnCurveData = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogTrack::updateCheckStateBasedOnCurveData() +{ + bool curveDataPresent = false; + for ( const auto& curve : curves() ) + { + curve->updateCheckStateBasedOnCurveData(); + curve->updateCurveVisibility(); + + if ( curve->isAnyCurveDataPresent() ) curveDataPresent = true; + } + + // As the visibility of a curve might have changed, update the legend + updateLegend(); + + if ( !m_autoCheckStateBasedOnCurveData ) return; + + setShowWindow( curveDataPresent ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1999,6 +2035,10 @@ void RimWellLogTrack::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering else uiOrdering.add( &m_colSpan ); + caf::PdmUiGroup* automationGroup = uiOrdering.addNewGroup( "Automation" ); + automationGroup->setCollapsedByDefault(); + automationGroup->add( &m_autoCheckStateBasedOnCurveData ); + caf::PdmUiGroup* annotationGroup = uiOrdering.addNewGroup( "Regions/Annotations" ); annotationGroup->setCollapsedByDefault(); @@ -2373,11 +2413,11 @@ void RimWellLogTrack::computeAndSetPropertyValueRangeMinForLogarithmicScale() double pos = HUGE_VAL; double neg = -HUGE_VAL; - for ( size_t cIdx = 0; cIdx < m_curves.size(); cIdx++ ) + for ( const auto& curve : m_curves ) { - if ( m_curves[cIdx]->isCurveVisible() && m_curves[cIdx]->curveData() ) + if ( curve->isChecked() && curve->curveData() ) { - RigStatisticsCalculator::posNegClosestToZero( m_curves[cIdx]->curveData()->propertyValuesByIntervals(), pos, neg ); + RigStatisticsCalculator::posNegClosestToZero( curve->curveData()->propertyValuesByIntervals(), pos, neg ); } } @@ -2415,7 +2455,7 @@ std::map> RimWellLogTrack::visibleStackedCurv std::map> stackedCurves; for ( RimWellLogCurve* curve : m_curves ) { - if ( curve && curve->isCurveVisible() ) + if ( curve && curve->isChecked() ) { RimWellFlowRateCurve* wfrCurve = dynamic_cast( curve ); if ( wfrCurve != nullptr ) // Flow rate curves are always stacked @@ -2449,7 +2489,7 @@ std::vector RimWellLogTrack::visibleCurves() const for ( RimWellLogCurve* curve : m_curves.children() ) { - if ( curve->isCurveVisible() ) + if ( curve->isChecked() ) { curvesVector.push_back( curve ); } diff --git a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h index c7e6bd8c23..2290d1525e 100644 --- a/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h +++ b/ApplicationLibCode/ProjectDataModel/WellLog/RimWellLogTrack.h @@ -236,6 +236,9 @@ public: void updateAxesVisibility( RiaDefines::Orientation orientation, bool isFirstTrack, bool isLastTrack ); void updateDepthMarkerLine(); + void setAutoCheckStateBasedOnCurveData( bool enable ); + void updateCheckStateBasedOnCurveData(); + protected: // RimViewWindow overrides void deleteViewWidget() override; @@ -361,6 +364,8 @@ private: caf::PdmField m_underburdenHeight; caf::PdmChildField m_ensembleWellLogCurveSet; + caf::PdmField m_autoCheckStateBasedOnCurveData; + std::vector> m_wellPathAttributePlotObjects; bool m_formationsForCaseWithSimWellOnly; diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.cpp b/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.cpp index b190e81644..dcfcc2de10 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.cpp @@ -47,6 +47,17 @@ RigWellLogCurveData::~RigWellLogCurveData() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigWellLogCurveData::clear() +{ + m_propertyValues.clear(); + m_depths.clear(); + m_intervalsOfContinousValidValues.clear(); + m_propertyValueUnitString.clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.h b/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.h index 8299a24dbe..1e1dbbc923 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.h +++ b/ApplicationLibCode/ReservoirDataModel/RigWellLogCurveData.h @@ -41,6 +41,8 @@ public: RigWellLogCurveData(); ~RigWellLogCurveData() override; + void clear(); + void setDepthUnit( RiaDefines::DepthUnitType depthUnit ); void setValuesAndDepths( const std::vector& propertyValues,