Skip to content

Commit

Permalink
#12181 Grid Cell Curve: Allow stacking of grid cell curves in summary…
Browse files Browse the repository at this point in the history
… plot

* Add stacking to grid cell curves in summary plot
* Add spacing in label text "Cell I J K"
* Add padlock icons and do not delete locked curves
* Show padlock icons only when summary plot is automated
  • Loading branch information
magnesj authored Feb 24, 2025
1 parent f4c31e0 commit 85abd0c
Show file tree
Hide file tree
Showing 16 changed files with 247 additions and 110 deletions.
1 change: 1 addition & 0 deletions ApplicationExeCode/Resources/ResInsight.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@
<file>decline-curve.svg</file>
<file>regression-curve.svg</file>
<file>padlock.svg</file>
<file>padlock-unlocked.svg</file>
<file>warning.svg</file>
<file>cloud-and-server.svg</file>
<file>Cloud.svg</file>
Expand Down
10 changes: 10 additions & 0 deletions ApplicationExeCode/Resources/padlock-unlocked.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 9 additions & 10 deletions ApplicationExeCode/Resources/padlock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#include "RimSummaryMultiPlot.h"
#include "RimSummaryMultiPlotCollection.h"
#include "RimSummaryPlot.h"
#include "RimTools.h"
#include "Tools/RimAutomationSettings.h"

#include "Riu3dSelectionManager.h"
#include "RiuPlotMainWindowTools.h"
Expand Down Expand Up @@ -123,6 +125,9 @@ RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot()
QString refFromProjectToView = caf::PdmReferenceHelper::referenceFromRootToObject( app->project(), summaryPlot );
app->setCacheDataObject( lastUsedSummaryPlotKey, refFromProjectToView );

auto automationSettings = RimTools::automationSettings();
automationSettings->setDestinationPlot( summaryPlot );

return summaryPlot;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ RimEclipseGeometrySelectionItem::RimEclipseGeometrySelectionItem()
CAF_PDM_InitFieldNoDefault( &m_gridIndex, "GridIndex", "Grid Index" );
CAF_PDM_InitFieldNoDefault( &m_cellIndex, "CellIndex", "Cell Index" );

CAF_PDM_InitFieldNoDefault( &m_ijkText, "CellText", "IJK" );
CAF_PDM_InitFieldNoDefault( &m_ijkText, "CellText", "Cell I J K" );
m_ijkText.registerGetMethod( this, &RimEclipseGeometrySelectionItem::ijkTextFromCell );
m_ijkText.registerSetMethod( this, &RimEclipseGeometrySelectionItem::setCellFromIjkText );
}
Expand Down
101 changes: 89 additions & 12 deletions ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

#include "RimGridTimeHistoryCurve.h"

#include <memory>
#include "Tools/Summary/RiaSummaryTools.h"

#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
Expand All @@ -37,12 +37,16 @@
#include "RimReservoirCellResultsStorage.h"
#include "RimSummaryPlot.h"
#include "RimSummaryTimeAxisProperties.h"
#include "RimTools.h"
#include "Tools/RimAutomationSettings.h"

#include "Riu3dSelectionManager.h"
#include "RiuFemTimeHistoryResultAccessor.h"
#include "RiuPlotCurve.h"
#include "RiuPlotMainWindowTools.h"

#include "cafPdmUiTreeAttributes.h"

CAF_PDM_SOURCE_INIT( RimGridTimeHistoryCurve, "GridTimeHistoryCurve" );

//--------------------------------------------------------------------------------------------------
Expand All @@ -56,6 +60,8 @@ RimGridTimeHistoryCurve::RimGridTimeHistoryCurve()
m_geometrySelectionText.registerGetMethod( this, &RimGridTimeHistoryCurve::geometrySelectionText );
m_geometrySelectionText.uiCapability()->setUiReadOnly( true );

CAF_PDM_InitField( &m_isLocked, "IsLocked", false, "Lock Curve" );

CAF_PDM_InitFieldNoDefault( &m_eclipseResultDefinition, "EclipseResultDefinition", "Eclipse Result Definition" );
m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden( true );

Expand Down Expand Up @@ -295,15 +301,31 @@ RimCase* RimGridTimeHistoryCurve::gridCase() const
return nullptr;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridTimeHistoryCurve::setLocked( bool locked )
{
m_isLocked = locked;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimGridTimeHistoryCurve::isLocked() const
{
return m_isLocked();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridTimeHistoryCurve::createCurveFromSelectionItem( const RiuSelectionItem* selectionItem, RimSummaryPlot* plot )
{
if ( !selectionItem || !plot ) return;

RimGridTimeHistoryCurve* newCurve = new RimGridTimeHistoryCurve();
bool updateResultDefinition = true;
auto newCurve = new RimGridTimeHistoryCurve();
bool updateResultDefinition = true;
newCurve->setFromSelectionItem( selectionItem, updateResultDefinition );
newCurve->setLineThickness( 2 );

Expand All @@ -320,6 +342,19 @@ void RimGridTimeHistoryCurve::createCurveFromSelectionItem( const RiuSelectionIt
RiuPlotMainWindowTools::selectAsCurrentItem( newCurve );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaDefines::PhaseType RimGridTimeHistoryCurve::phaseType() const
{
if ( m_eclipseResultDefinition )
{
return m_eclipseResultDefinition->resultPhaseType();
}

return RiaDefines::PhaseType::PHASE_NOT_APPLICABLE;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -359,6 +394,8 @@ void RimGridTimeHistoryCurve::onLoadDataAndUpdate( bool updateParentPlot )

if ( isChecked() && m_plotCurve )
{
updateResultDefinitionFromCase();

std::vector<double> values;

RimEclipseGeometrySelectionItem* eclTopItem = eclipseGeomSelectionItem();
Expand Down Expand Up @@ -530,6 +567,8 @@ void RimGridTimeHistoryCurve::defineUiOrdering( QString uiConfigName, caf::PdmUi
{
RimPlotCurve::updateFieldUiState();

uiOrdering.add( &m_isLocked );

caf::PdmUiGroup* dataSource = uiOrdering.addNewGroup( "Data Source" );
dataSource->add( &m_geometrySelectionText );
eclipseGeomSelectionItem()->uiOrdering( uiConfigName, *dataSource );
Expand All @@ -549,6 +588,9 @@ void RimGridTimeHistoryCurve::defineUiOrdering( QString uiConfigName, caf::PdmUi

uiOrdering.add( &m_plotAxis );

caf::PdmUiGroup* stackingGroup = uiOrdering.addNewGroup( "Stacking" );
RimStackablePlotCurve::stackingUiOrdering( *stackingGroup );

caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroup( "Appearance" );
RimPlotCurve::appearanceUiOrdering( *appearanceGroup );
appearanceGroup->setCollapsedByDefault();
Expand Down Expand Up @@ -576,6 +618,8 @@ void RimGridTimeHistoryCurve::initAfterRead()
//--------------------------------------------------------------------------------------------------
void RimGridTimeHistoryCurve::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
RimStackablePlotCurve::fieldChangedByUi( changedField, oldValue, newValue );

if ( changedField == &m_plotAxis )
{
updateQwtPlotAxis();
Expand All @@ -595,12 +639,39 @@ void RimGridTimeHistoryCurve::fieldChangedByUi( const caf::PdmFieldHandle* chang
//--------------------------------------------------------------------------------------------------
void RimGridTimeHistoryCurve::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField )
{
if ( m_eclipseDataSource() && m_eclipseResultDefinition() )
onLoadDataAndUpdate( true );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridTimeHistoryCurve::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
{
bool isUpdatedByAutomation = false;

if ( auto parentPlot = RiaSummaryTools::parentSummaryPlot( this ) )
{
m_eclipseResultDefinition->setEclipseCase( m_eclipseDataSource->eclipseCase() );
for ( auto plot : RimTools::automationSettings()->summaryPlots() )
{
if ( parentPlot == plot ) isUpdatedByAutomation = true;
}
}

onLoadDataAndUpdate( true );
// The padlock icon is only shown if the curve is updated by automation
if ( isUpdatedByAutomation )
{
QString iconResourceString = m_isLocked ? ":/padlock.svg" : ":/padlock-unlocked.svg";

if ( auto* treeItemAttribute = dynamic_cast<caf::PdmUiTreeViewItemAttribute*>( attribute ) )
{
auto tag = caf::PdmUiTreeViewItemAttribute::createTag();
tag->icon = caf::IconProvider( iconResourceString );

tag->clicked.connect( this, &RimGridTimeHistoryCurve::onPadlockClicked );

treeItemAttribute->tags.push_back( std::move( tag ) );
}
}
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -638,17 +709,13 @@ RimGeoMechGeometrySelectionItem* RimGridTimeHistoryCurve::geoMechGeomSelectionIt
//--------------------------------------------------------------------------------------------------
void RimGridTimeHistoryCurve::updateResultDefinitionFromCase()
{
if ( eclipseGeomSelectionItem() )
if ( eclipseGeomSelectionItem() && m_eclipseResultDefinition() )
{
CVF_ASSERT( m_eclipseResultDefinition() );

m_eclipseResultDefinition->setEclipseCase( eclipseGeomSelectionItem()->eclipseCase() );
}

if ( geoMechGeomSelectionItem() )
if ( geoMechGeomSelectionItem() && m_geoMechResultDefinition() )
{
CVF_ASSERT( m_geoMechResultDefinition() );

m_geoMechResultDefinition->setGeoMechCase( geoMechGeomSelectionItem()->geoMechCase() );
}
}
Expand Down Expand Up @@ -688,6 +755,16 @@ void RimGridTimeHistoryCurve::updateQwtPlotAxis()
if ( m_plotCurve ) updateYAxisInPlot( yAxis() );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimGridTimeHistoryCurve::onPadlockClicked( const SignalEmitter* emitter, size_t index )
{
m_isLocked = !m_isLocked();

updateConnectedEditors();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
16 changes: 13 additions & 3 deletions ApplicationLibCode/ProjectDataModel/RimGridTimeHistoryCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once

#include "RimPlotCurve.h"
#include "RimStackablePlotCurve.h"

#include "RiaDefines.h"

Expand All @@ -43,14 +43,16 @@ class RimSummaryPlot;
///
///
//==================================================================================================
class RimGridTimeHistoryCurve : public RimPlotCurve
class RimGridTimeHistoryCurve : public RimStackablePlotCurve
{
CAF_PDM_HEADER_INIT;

public:
RimGridTimeHistoryCurve();
~RimGridTimeHistoryCurve() override;

static void createCurveFromSelectionItem( const RiuSelectionItem* selectionItem, RimSummaryPlot* plot );

void setFromSelectionItem( const RiuSelectionItem* selectionItem, bool updateResultDefinition );
void setFromEclipseCellAndResult( RimEclipseCase* eclCase, size_t gridIdx, size_t i, size_t j, size_t k, const RigEclipseResultAddress& resAddr );
RiuPlotAxis yAxis() const;
Expand All @@ -64,7 +66,10 @@ class RimGridTimeHistoryCurve : public RimPlotCurve
QString caseName() const;
RimCase* gridCase() const;

static void createCurveFromSelectionItem( const RiuSelectionItem* selectionItem, RimSummaryPlot* plot );
void setLocked( bool locked );
bool isLocked() const;

RiaDefines::PhaseType phaseType() const override;

protected:
QString createCurveAutoName() override;
Expand All @@ -75,6 +80,7 @@ class RimGridTimeHistoryCurve : public RimPlotCurve
void initAfterRead() override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override;
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;

private:
RigMainGrid* mainGrid();
Expand All @@ -84,9 +90,13 @@ class RimGridTimeHistoryCurve : public RimPlotCurve
QString geometrySelectionText() const;
void updateQwtPlotAxis();

void onPadlockClicked( const SignalEmitter* emitter, size_t index );

std::unique_ptr<RiuFemTimeHistoryResultAccessor> femTimeHistoryResultAccessor() const;

private:
caf::PdmField<bool> m_isLocked;

caf::PdmProxyValueField<QString> m_geometrySelectionText;

caf::PdmChildField<RimEclipseResultDefinition*> m_eclipseResultDefinition;
Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibCode/ProjectDataModel/RimPlotCurve.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ class RimPlotCurve : public caf::PdmObject

std::vector<RimPlotRectAnnotation*> rectAnnotations() const;

void setSamplesFromXYValues( const std::vector<double>& xValues, const std::vector<double>& yValues, bool useLogarithmicScale );

protected:
virtual QString createCurveAutoName();

Expand All @@ -160,8 +162,6 @@ class RimPlotCurve : public caf::PdmObject
bool useLogarithmicScale,
RiaCurveDataTools::ErrorAxis errorAxis = RiaCurveDataTools::ErrorAxis::ERROR_ALONG_Y_AXIS );

void setSamplesFromXYValues( const std::vector<double>& xValues, const std::vector<double>& yValues, bool useLogarithmicScale );

void setSamplesFromDatesAndYValues( const std::vector<QDateTime>& dateTimes, const std::vector<double>& yValues, bool useLogarithmicScale );

void setSamplesFromTimeTAndYValues( const std::vector<time_t>& dateTimes, const std::vector<double>& yValues, bool useLogarithmicScale );
Expand Down
8 changes: 8 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,14 @@ RimPolygonCollection* RimTools::polygonCollection()
return RimProject::current()->activeOilField()->polygonCollection();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAutomationSettings* RimTools::automationSettings()
{
return RimProject::current()->automationSettings();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
6 changes: 4 additions & 2 deletions ApplicationLibCode/ProjectDataModel/RimTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class RimWellPath;
class RimSurfaceCollection;
class RimFaultInViewCollection;
class RimPolygonCollection;
class RimAutomationSettings;

//--------------------------------------------------------------------------------------------------
///
Expand Down Expand Up @@ -77,8 +78,9 @@ class RimTools
static RimWellPathCollection* wellPathCollection();
static RimWellPath* firstWellPath();

static RimSurfaceCollection* surfaceCollection();
static RimPolygonCollection* polygonCollection();
static RimSurfaceCollection* surfaceCollection();
static RimPolygonCollection* polygonCollection();
static RimAutomationSettings* automationSettings();

static void timeStepsForCase( RimCase* gridCase, QList<caf::PdmOptionItemInfo>* options );

Expand Down
Loading

0 comments on commit 85abd0c

Please sign in to comment.