Skip to content

Commit

Permalink
Misc UI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Jan 14, 2025
1 parent cc18060 commit 32be40c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,8 @@ void RimContourMapProjection::defineEditorAttribute( const caf::PdmFieldHandle*
if ( myAttr )
{
myAttr->m_minimum = 0.2;
myAttr->m_maximum = 2.0;
myAttr->m_sliderTickCount = 9;
myAttr->m_maximum = 20.0;
myAttr->m_sliderTickCount = 20;
myAttr->m_delaySliderUpdateUntilRelease = true;
}
}
Expand Down
48 changes: 9 additions & 39 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ RimEclipseCaseEnsemble::RimEclipseCaseEnsemble()
m_caseCollection->uiCapability()->setUiName( "Cases" );
m_caseCollection->uiCapability()->setUiIconFromResourceString( ":/Cases16x16.png" );

CAF_PDM_InitFieldNoDefault( &m_selectedCase, "SelectedCase", "Selected Case" );

CAF_PDM_InitFieldNoDefault( &m_viewCollection, "ViewCollection", "Views" );
m_viewCollection = new RimEclipseViewCollection;

Expand Down Expand Up @@ -168,43 +166,6 @@ RimEclipseView* RimEclipseCaseEnsemble::addViewForCase( RimEclipseCase* eclipseC
return m_viewCollection->addView( eclipseCase );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimEclipseCaseEnsemble::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
QList<caf::PdmOptionItemInfo> options;

if ( fieldNeedingOptions == &m_selectedCase )
{
for ( auto eclCase : cases() )
{
options.push_back( caf::PdmOptionItemInfo( eclCase->caseUserDescription(), eclCase, false, eclCase->uiIconProvider() ) );
}

return options;
}

return options;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCaseEnsemble::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
{
if ( changedField == &m_selectedCase )
{
for ( auto view : m_viewCollection->views() )
{
view->setEclipseCase( m_selectedCase() );
view->loadDataAndUpdate();
view->updateGridBoxData();
view->updateAnnotationItems();
}
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -240,3 +201,12 @@ void RimEclipseCaseEnsemble::addStatisticsContourMap( RimStatisticsContourMap* s
m_statisticsContourMaps.push_back( statisticsContourMap );
statisticsContourMap->setName( QString( "Statistics Contour Map #%1" ).arg( m_statisticsContourMaps.size() ) );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimEclipseCaseEnsemble::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( nameField() );
uiOrdering.skipRemainingFields();
}
6 changes: 2 additions & 4 deletions ApplicationLibCode/ProjectDataModel/RimEclipseCaseEnsemble.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ class RimEclipseCaseEnsemble : public RimNamedObject
RimEclipseCase* findByDescription( const QString& description ) const;

std::vector<RimEclipseCase*> cases() const;

std::set<RimEclipseCase*> casesInViews() const;
std::set<RimEclipseCase*> casesInViews() const;

void addView( RimEclipseView* view );
RimEclipseView* addViewForCase( RimEclipseCase* eclipseCase );
Expand All @@ -68,9 +67,8 @@ class RimEclipseCaseEnsemble : public RimNamedObject
void addStatisticsContourMap( RimStatisticsContourMap* statisticsContourMap );

protected:
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
void appendMenuItems( caf::CmdFeatureMenuBuilder& menuBuilder ) const override;
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;

private:
caf::PdmField<int> m_groupId;
Expand Down
41 changes: 26 additions & 15 deletions ApplicationLibCode/ProjectDataModel/RimStatisticsContourMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ RimStatisticsContourMap::RimStatisticsContourMap()
CAF_PDM_InitField( &m_boundingBoxExpPercent, "BoundingBoxExpPercent", 5.0, "Bounding Box Expansion (%)" );
m_boundingBoxExpPercent.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );

CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 0.9, "Sample Spacing Factor" );
CAF_PDM_InitField( &m_relativeSampleSpacing, "SampleSpacing", 2.0, "Sample Spacing Factor" );
m_relativeSampleSpacing.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );

CAF_PDM_InitFieldNoDefault( &m_resultAggregation, "ResultAggregation", "Result Aggregation" );
Expand All @@ -97,7 +97,12 @@ RimStatisticsContourMap::RimStatisticsContourMap()
m_resultDefinition->setResultType( RiaDefines::ResultCatType::DYNAMIC_NATIVE );
m_resultDefinition->setResultVariable( "SOIL" );

CAF_PDM_InitField( &m_uiDataSourceCase, "UiDataSourceCase", RiaResultNames::undefinedResultName(), "UI Data Source Case" );
CAF_PDM_InitField( &m_primaryCase,
"PrimaryCase",
RiaResultNames::undefinedResultName(),
"Primary Case",
"",
"Eclipse Case used for wells and faults shown in views, initializing available result list, timesteps, etc." );

CAF_PDM_InitFieldNoDefault( &m_computeStatisticsButton, "ComputeStatisticsButton", "" );
caf::PdmUiPushButtonEditor::configureEditorLabelLeft( &m_computeStatisticsButton );
Expand All @@ -117,20 +122,22 @@ void RimStatisticsContourMap::defineUiOrdering( QString uiConfigName, caf::PdmUi
{
auto selCase = ensemble()->cases().front();
setEclipseCase( selCase );
m_uiDataSourceCase = selCase->caseUserDescription();
m_primaryCase = selCase->caseUserDescription();
}

uiOrdering.add( nameField() );
uiOrdering.add( &m_resultAggregation );
uiOrdering.add( &m_uiDataSourceCase );

auto genGrp = uiOrdering.addNewGroup( "General" );

genGrp->add( &m_resultAggregation );
genGrp->add( &m_primaryCase );
genGrp->add( &m_relativeSampleSpacing );
genGrp->add( &m_boundingBoxExpPercent );

auto tsGroup = uiOrdering.addNewGroup( "Time Step Selection" );
tsGroup->setCollapsedByDefault();
tsGroup->add( &m_selectedTimeSteps );

uiOrdering.add( &m_relativeSampleSpacing );
uiOrdering.add( &m_boundingBoxExpPercent );

if ( !isColumnResult() )
{
auto resultDefinitionGroup = uiOrdering.addNewGroup( "Result Definition" );
Expand All @@ -146,6 +153,7 @@ void RimStatisticsContourMap::defineUiOrdering( QString uiConfigName, caf::PdmUi
void RimStatisticsContourMap::setEclipseCase( RimEclipseCase* eclipseCase )
{
m_resultDefinition->setEclipseCase( eclipseCase );
if ( eclipseCase ) m_primaryCase = eclipseCase->caseUserDescription();

for ( auto& view : m_views )
{
Expand Down Expand Up @@ -192,7 +200,7 @@ void RimStatisticsContourMap::fieldChangedByUi( const caf::PdmFieldHandle* chang
}
}
}
else if ( &m_uiDataSourceCase == changedField )
else if ( &m_primaryCase == changedField )
{
switchToSelectedSourceCase();

Expand All @@ -211,7 +219,7 @@ void RimStatisticsContourMap::fieldChangedByUi( const caf::PdmFieldHandle* chang
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimStatisticsContourMap::switchToSelectedSourceCase()
{
RimEclipseCase* sourceResultCase = ensemble()->findByDescription( m_uiDataSourceCase );
RimEclipseCase* sourceResultCase = ensemble()->findByDescription( m_primaryCase );
if ( sourceResultCase == nullptr )
{
setEclipseCase( nullptr );
Expand Down Expand Up @@ -254,7 +262,7 @@ QList<caf::PdmOptionItemInfo> RimStatisticsContourMap::calculateValueOptions( co
}
return options;
}
else if ( &m_uiDataSourceCase == fieldNeedingOptions )
else if ( &m_primaryCase == fieldNeedingOptions )
{
QStringList sourceCaseNames;
sourceCaseNames += RiaResultNames::undefinedResultName();
Expand Down Expand Up @@ -286,8 +294,8 @@ void RimStatisticsContourMap::defineEditorAttribute( const caf::PdmFieldHandle*
if ( auto myAttr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
myAttr->m_minimum = 0.2;
myAttr->m_maximum = 2.0;
myAttr->m_sliderTickCount = 9;
myAttr->m_maximum = 20.0;
myAttr->m_sliderTickCount = 20;
myAttr->m_delaySliderUpdateUntilRelease = true;
}
}
Expand Down Expand Up @@ -517,9 +525,12 @@ std::vector<int> RimStatisticsContourMap::selectedTimeSteps() const
auto steps = m_selectedTimeSteps();
if ( m_selectedTimeSteps().empty() )
{
for ( int i = 0; i < (int)eclipseCase()->timeStepStrings().size(); i++ )
if ( eclipseCase() )
{
steps.push_back( i );
for ( int i = 0; i < (int)eclipseCase()->timeStepStrings().size(); i++ )
{
steps.push_back( i );
}
}
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class RimStatisticsContourMap : public RimNamedObject
caf::PdmChildField<RimEclipseResultDefinition*> m_resultDefinition;
caf::PdmField<bool> m_computeStatisticsButton;

caf::PdmField<QString> m_uiDataSourceCase;
caf::PdmField<QString> m_primaryCase;

std::unique_ptr<RigContourMapGrid> m_contourMapGrid;
std::map<size_t, std::map<StatisticsType, std::vector<double>>> m_timeResults;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ std::pair<bool, std::vector<double>>
}
else
{
// TODO: this was RimEclipseCellColors->hasStaticResult()
if ( resultAddress.resultCatType() == RiaDefines::ResultCatType::STATIC_NATIVE && timeStep > 0 ) timeStep = 0;

resultData.ensureKnownResultLoaded( resultAddress );
Expand Down

0 comments on commit 32be40c

Please sign in to comment.