mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add edit button to grid calculation expressions
Implement add calculation from grid cell result
This commit is contained in:
parent
17f09878d2
commit
bcc00adea1
@ -20,6 +20,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEclipseShowOnlyFaultFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicRenameCaseFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@ -44,6 +45,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEclipseShowOnlyFaultFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicRenameCaseFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicImportRoffCaseFeature.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicAddGridCalculationFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
@ -0,0 +1,57 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RicAddGridCalculationFeature.h"
|
||||
#include "RicShowGridCalculatorFeature.h"
|
||||
|
||||
#include "RimEclipseResultAddress.h"
|
||||
|
||||
#include "cafSelectionManager.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicAddGridCalculationFeature, "RicAddGridCalculationFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicAddGridCalculationFeature::isCommandEnabled()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddGridCalculationFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
auto address = caf::SelectionManager::instance()->selectedItemOfType<RimEclipseResultAddress>();
|
||||
if ( address )
|
||||
{
|
||||
RicShowGridCalculatorFeature::addCalculationAndShowDialog( *address );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicAddGridCalculationFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Add Grid Calculation" );
|
||||
actionToSetup->setIcon( QIcon( ":/Calculator.svg" ) );
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicAddGridCalculationFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
};
|
@ -23,6 +23,7 @@
|
||||
#include "RiaGuiApplication.h"
|
||||
|
||||
#include "RimGridCalculationCollection.h"
|
||||
#include "RimGridCalculationVariable.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCalculationCollection.h"
|
||||
|
||||
@ -32,6 +33,31 @@
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicShowGridCalculatorFeature, "RicShowGridCalculatorFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicShowGridCalculatorFeature::addCalculationAndShowDialog( const RimEclipseResultAddress& address )
|
||||
{
|
||||
RimProject* proj = RimProject::current();
|
||||
RimGridCalculationCollection* calcColl = proj->gridCalculationCollection();
|
||||
|
||||
auto calculation = calcColl->addCalculation();
|
||||
|
||||
for ( auto& v : calculation->allVariables() )
|
||||
{
|
||||
if ( auto gridVariable = dynamic_cast<RimGridCalculationVariable*>( v ) )
|
||||
{
|
||||
gridVariable->setEclipseResultAddress( address );
|
||||
}
|
||||
}
|
||||
|
||||
RicGridCalculatorDialog* dialog = RicShowGridCalculatorFeature::gridCalculatorDialog( true );
|
||||
dialog->setCalculationAndUpdateUi( calculation );
|
||||
|
||||
dialog->show();
|
||||
dialog->raise();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "cafCmdFeature.h"
|
||||
|
||||
class RicGridCalculatorDialog;
|
||||
class RimEclipseResultAddress;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -30,10 +31,12 @@ class RicShowGridCalculatorFeature : public caf::CmdFeature
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
public:
|
||||
static void addCalculationAndShowDialog( const RimEclipseResultAddress& address );
|
||||
|
||||
private:
|
||||
static RicGridCalculatorDialog* gridCalculatorDialog( bool createIfNotPresent );
|
||||
static void hideGridCalculatorDialog();
|
||||
|
||||
protected:
|
||||
bool isCommandEnabled() override;
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
|
@ -131,6 +131,7 @@ set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimMultipleEclipseResults.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPressureDepthData.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultDefinitionTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimResultSelectionUi.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
@ -261,6 +262,7 @@ set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimMultipleEclipseResults.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimPressureDepthData.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultDefinitionTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RimResultSelectionUi.cpp
|
||||
)
|
||||
|
||||
if(RESINSIGHT_USE_QT_CHARTS)
|
||||
|
@ -56,6 +56,7 @@
|
||||
#include "RimEclipseInputProperty.h"
|
||||
#include "RimEclipsePropertyFilter.h"
|
||||
#include "RimEclipsePropertyFilterCollection.h"
|
||||
#include "RimEclipseResultAddress.h"
|
||||
#include "RimEclipseResultCase.h"
|
||||
#include "RimEclipseStatisticsCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
@ -1121,6 +1122,10 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
menuBuilder << "RicOpenInTextEditorFeature";
|
||||
menuBuilder << "RicReloadPressureDepthDataFeature";
|
||||
}
|
||||
else if ( dynamic_cast<RimEclipseResultAddress*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicAddGridCalculationFeature";
|
||||
}
|
||||
|
||||
if ( dynamic_cast<Rim3dView*>( firstUiItem ) )
|
||||
{
|
||||
|
@ -345,6 +345,8 @@ void RimGridCalculation::onVariableUpdated( const SignalEmitter* emitter )
|
||||
if ( variable && variable->eclipseCase() )
|
||||
{
|
||||
m_destinationCase = variable->eclipseCase();
|
||||
|
||||
updateConnectedEditors();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,12 +26,19 @@
|
||||
#include "RigCaseCellResultsData.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseTools.h"
|
||||
#include "RimEclipseResultAddress.h"
|
||||
#include "RimGridCalculation.h"
|
||||
#include "RimResultSelectionUi.h"
|
||||
#include "RimTools.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
#include "RiuDragDrop.h"
|
||||
|
||||
#include "cafPdmUiPropertyViewDialog.h"
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimGridCalculationVariable, "RimGridCalculationVariable" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -47,6 +54,10 @@ RimGridCalculationVariable::RimGridCalculationVariable()
|
||||
CAF_PDM_InitField( &m_resultVariable, "ResultVariable", RiaResultNames::undefinedResultName(), "Variable" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseGridCase", "Grid Case" );
|
||||
CAF_PDM_InitField( &m_timeStep, "TimeStep", allTimeStepsValue(), "Time Step" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_button, "PushButton", "" );
|
||||
m_button.uiCapability()->setUiEditorTypeName( caf::PdmUiPushButtonEditor::uiEditorTypeName() );
|
||||
m_button.xmlCapability()->disableIO();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -72,6 +83,7 @@ void RimGridCalculationVariable::defineUiOrdering( QString uiConfigName, caf::Pd
|
||||
uiOrdering.add( &m_resultType );
|
||||
uiOrdering.add( &m_resultVariable );
|
||||
uiOrdering.add( &m_timeStep );
|
||||
uiOrdering.add( &m_button );
|
||||
|
||||
uiOrdering.skipRemainingFields();
|
||||
|
||||
@ -79,6 +91,46 @@ void RimGridCalculationVariable::defineUiOrdering( QString uiConfigName, caf::Pd
|
||||
m_timeStep.uiCapability()->setUiReadOnly( m_resultType == RiaDefines::ResultCatType::STATIC_NATIVE );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCalculationVariable::defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute )
|
||||
{
|
||||
auto attr = dynamic_cast<caf::PdmUiTableViewPushButtonEditorAttribute*>( attribute );
|
||||
if ( attr )
|
||||
{
|
||||
attr->registerPushButtonTextForFieldKeyword( m_button.keyword(), "Edit" );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCalculationVariable::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_button )
|
||||
{
|
||||
auto eclipseCase = m_eclipseCase();
|
||||
if ( !eclipseCase )
|
||||
{
|
||||
auto cases = RimEclipseCaseTools::eclipseCases();
|
||||
if ( !cases.empty() )
|
||||
{
|
||||
eclipseCase = cases.front();
|
||||
}
|
||||
}
|
||||
|
||||
RimResultSelectionUi selectionUi;
|
||||
selectionUi.setEclipseResultAddress( eclipseCase, m_resultType(), m_resultVariable );
|
||||
|
||||
caf::PdmUiPropertyViewDialog propertyDialog( Riu3DMainWindowTools::mainWindowWidget(), &selectionUi, "Select Result", "" );
|
||||
if ( propertyDialog.exec() == QDialog::Accepted )
|
||||
{
|
||||
setEclipseResultAddress( selectionUi.eclipseCase(), selectionUi.resultType(), selectionUi.resultVariable() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -139,7 +191,7 @@ RigCaseCellResultsData* RimGridCalculationVariable::currentGridCellResults() con
|
||||
QStringList RimGridCalculationVariable::getResultNamesForResultType( RiaDefines::ResultCatType resultCatType,
|
||||
const RigCaseCellResultsData* results )
|
||||
{
|
||||
if ( !results ) return QStringList();
|
||||
if ( !results ) return {};
|
||||
return results->resultNames( resultCatType );
|
||||
}
|
||||
|
||||
@ -191,21 +243,33 @@ void RimGridCalculationVariable::handleDroppedMimeData( const QMimeData* data, Q
|
||||
auto objects = RiuDragDrop::convertToObjects( data );
|
||||
if ( !objects.empty() )
|
||||
{
|
||||
auto address = dynamic_cast<RimEclipseResultAddress*>( objects.front() );
|
||||
if ( address ) setEclipseResultAddress( *address );
|
||||
if ( auto address = dynamic_cast<RimEclipseResultAddress*>( objects.front() ) )
|
||||
{
|
||||
setEclipseResultAddress( *address );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCalculationVariable::setEclipseResultAddress( const RimEclipseResultAddress& address )
|
||||
void RimGridCalculationVariable::setEclipseResultAddress( RimEclipseCase* eclipseCase,
|
||||
caf::AppEnum<RiaDefines::ResultCatType> resultType,
|
||||
const QString& resultName )
|
||||
{
|
||||
m_resultVariable = address.resultName();
|
||||
m_resultType = address.resultType();
|
||||
m_eclipseCase = address.eclipseCase();
|
||||
m_eclipseCase = eclipseCase;
|
||||
m_resultVariable = resultName;
|
||||
m_resultType = resultType;
|
||||
|
||||
eclipseResultChanged.send();
|
||||
|
||||
updateConnectedEditors();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGridCalculationVariable::setEclipseResultAddress( const RimEclipseResultAddress& resultAddress )
|
||||
{
|
||||
setEclipseResultAddress( resultAddress.eclipseCase(), resultAddress.resultType(), resultAddress.resultName() );
|
||||
}
|
||||
|
@ -54,19 +54,23 @@ public:
|
||||
static int allTimeStepsValue();
|
||||
|
||||
void handleDroppedMimeData( const QMimeData* data, Qt::DropAction action, caf::PdmFieldHandle* destinationField ) override;
|
||||
|
||||
void setEclipseResultAddress( const RimEclipseResultAddress& address );
|
||||
void setEclipseResultAddress( const RimEclipseResultAddress& resultAddress );
|
||||
|
||||
private:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
|
||||
void defineObjectEditorAttribute( QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
RigCaseCellResultsData* currentGridCellResults() const;
|
||||
QStringList getResultNamesForResultType( RiaDefines::ResultCatType resultCatType, const RigCaseCellResultsData* results );
|
||||
|
||||
RigCaseCellResultsData* currentGridCellResults() const;
|
||||
QStringList getResultNamesForResultType( RiaDefines::ResultCatType resultCatType, const RigCaseCellResultsData* results );
|
||||
|
||||
void setEclipseResultAddress( RimEclipseCase* eclipseCase, caf::AppEnum<RiaDefines::ResultCatType> resultType, const QString& resultName );
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimEclipseCase*> m_eclipseCase;
|
||||
caf::PdmField<caf::AppEnum<RiaDefines::ResultCatType>> m_resultType;
|
||||
caf::PdmField<QString> m_resultVariable;
|
||||
caf::PdmField<int> m_timeStep;
|
||||
caf::PdmField<bool> m_button;
|
||||
};
|
||||
|
121
ApplicationLibCode/ProjectDataModel/RimResultSelectionUi.cpp
Normal file
121
ApplicationLibCode/ProjectDataModel/RimResultSelectionUi.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "RimResultSelectionUi.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseCaseTools.h"
|
||||
#include "RimEclipseResultDefinition.h"
|
||||
|
||||
#include "cafPdmUiPushButtonEditor.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
|
||||
CAF_PDM_SOURCE_INIT( RimResultSelectionUi, "RimResultSelectionUi" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimResultSelectionUi::RimResultSelectionUi()
|
||||
|
||||
{
|
||||
CAF_PDM_InitObject( "RimResultSelectionUi", ":/octave.png" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "Case", "Case" );
|
||||
CAF_PDM_InitFieldNoDefault( &m_eclipseResult, "Result", "Result" );
|
||||
|
||||
m_eclipseResult = new RimEclipseResultDefinition();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultSelectionUi::setEclipseResultAddress( RimEclipseCase* eclipseCase,
|
||||
caf::AppEnum<RiaDefines::ResultCatType> resultType,
|
||||
const QString& resultName )
|
||||
{
|
||||
m_eclipseCase = eclipseCase;
|
||||
|
||||
m_eclipseResult->setEclipseCase( m_eclipseCase() );
|
||||
m_eclipseResult->setResultType( resultType );
|
||||
m_eclipseResult->setResultVariable( resultName );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimEclipseCase* RimResultSelectionUi::eclipseCase() const
|
||||
{
|
||||
return m_eclipseCase();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiaDefines::ResultCatType RimResultSelectionUi::resultType() const
|
||||
{
|
||||
return m_eclipseResult->resultType();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimResultSelectionUi::resultVariable() const
|
||||
{
|
||||
return m_eclipseResult->resultVariable();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultSelectionUi::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
|
||||
{
|
||||
uiOrdering.add( &m_eclipseCase );
|
||||
|
||||
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup( "Result" );
|
||||
m_eclipseResult->uiOrdering( uiConfigName, *group1 );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimResultSelectionUi::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue )
|
||||
{
|
||||
if ( changedField == &m_eclipseCase )
|
||||
{
|
||||
m_eclipseResult->setEclipseCase( m_eclipseCase() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QList<caf::PdmOptionItemInfo> RimResultSelectionUi::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
|
||||
{
|
||||
QList<caf::PdmOptionItemInfo> options;
|
||||
|
||||
if ( fieldNeedingOptions == &m_eclipseCase )
|
||||
{
|
||||
auto cases = RimEclipseCaseTools::eclipseCases();
|
||||
for ( auto* c : cases )
|
||||
{
|
||||
options.push_back( caf::PdmOptionItemInfo( c->caseUserDescription(), c, false, c->uiIconProvider() ) );
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
55
ApplicationLibCode/ProjectDataModel/RimResultSelectionUi.h
Normal file
55
ApplicationLibCode/ProjectDataModel/RimResultSelectionUi.h
Normal file
@ -0,0 +1,55 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2023- Equinor ASA
|
||||
//
|
||||
// ResInsight is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
// FITNESS FOR A PARTICULAR PURPOSE.
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include "cafPdmChildField.h"
|
||||
#include "cafPdmObject.h"
|
||||
#include "cafPdmPtrField.h"
|
||||
|
||||
class RimEclipseResultDefinition;
|
||||
class RimEclipseCase;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
///
|
||||
//==================================================================================================
|
||||
class RimResultSelectionUi : public caf::PdmObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
|
||||
public:
|
||||
RimResultSelectionUi();
|
||||
|
||||
void setEclipseResultAddress( RimEclipseCase* eclipseCase, caf::AppEnum<RiaDefines::ResultCatType> resultType, const QString& resultName );
|
||||
|
||||
RimEclipseCase* eclipseCase() const;
|
||||
RiaDefines::ResultCatType resultType() const;
|
||||
QString resultVariable() const;
|
||||
|
||||
private:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
|
||||
|
||||
private:
|
||||
caf::PdmPtrField<RimEclipseCase*> m_eclipseCase;
|
||||
caf::PdmChildField<RimEclipseResultDefinition*> m_eclipseResult;
|
||||
};
|
Loading…
Reference in New Issue
Block a user