From 1fde4a09b56e9bd4f1618fd8ffa9ed96f6c381ce Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Fri, 3 Apr 2020 10:31:41 +0200 Subject: [PATCH] Add button to import element properties for GeoMechCase. --- .../RicImportElementPropertyFeature.cpp | 8 ++++++ .../RicImportElementPropertyFeature.h | 2 ++ .../ProjectDataModel/RimGeoMechCase.cpp | 28 +++++++++++++++++-- .../ProjectDataModel/RimGeoMechCase.h | 2 ++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp index 4acae520f9..97292d4bfd 100644 --- a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp @@ -43,6 +43,14 @@ bool RicImportElementPropertyFeature::isCommandEnabled() /// //-------------------------------------------------------------------------------------------------- void RicImportElementPropertyFeature::onActionTriggered( bool isChecked ) +{ + importElementProperties(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportElementPropertyFeature::importElementProperties() { RiaApplication* app = RiaApplication::instance(); diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.h b/ApplicationCode/Commands/RicImportElementPropertyFeature.h index e32ff49fd2..5797b8b987 100644 --- a/ApplicationCode/Commands/RicImportElementPropertyFeature.h +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.h @@ -27,6 +27,8 @@ class RicImportElementPropertyFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; + static void importElementProperties(); + protected: bool isCommandEnabled() override; void onActionTriggered( bool isChecked ) override; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 732a40c109..baec4852de 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -23,6 +23,7 @@ #include "RiaLogging.h" #include "RiaPreferences.h" +#include "RicImportElementPropertyFeature.h" #include "RicfCommandObject.h" #include "RifOdbReader.h" @@ -49,6 +50,7 @@ #include "RimTools.h" #include "RimWellLogPlotCollection.h" +#include "cafCmdFeatureManager.h" #include "cafPdmFieldIOScriptability.h" #include "cafPdmObjectScriptability.h" #include "cafPdmUiDoubleValueEditor.h" @@ -121,6 +123,9 @@ RimGeoMechCase::RimGeoMechCase( void ) "" ); m_elementPropertyFileNameIndexUiSelection.xmlCapability()->disableIO(); + CAF_PDM_InitField( &m_importElementPropertyFileCommand, "importElementPropertyFileCommad", false, "", "", "", "" ); + caf::PdmUiPushButtonEditor::configureEditorForField( &m_importElementPropertyFileCommand ); + CAF_PDM_InitField( &m_closeElementPropertyFileCommand, "closeElementPropertyFileCommad", false, "", "", "", "" ); caf::PdmUiPushButtonEditor::configureEditorForField( &m_closeElementPropertyFileCommand ); @@ -746,6 +751,12 @@ void RimGeoMechCase::fieldChangedByUi( const caf::PdmFieldHandle* changedField, closeSelectedElementPropertyFiles(); updateConnectedEditors(); } + else if ( changedField == &m_importElementPropertyFileCommand ) + { + m_importElementPropertyFileCommand = false; + importElementPropertyFile(); + updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- @@ -923,6 +934,14 @@ void RimGeoMechCase::reloadSelectedElementPropertyFiles() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::importElementPropertyFile() +{ + RicImportElementPropertyFeature::importElementProperties(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -939,6 +958,7 @@ void RimGeoMechCase::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* elmPropGroup = uiOrdering.addNewGroup( "Element Properties" ); elmPropGroup->add( &m_elementPropertyFileNameIndexUiSelection ); + elmPropGroup->add( &m_importElementPropertyFileCommand ); elmPropGroup->add( &m_reloadElementPropertyFileCommand ); elmPropGroup->add( &m_closeElementPropertyFileCommand ); @@ -961,13 +981,17 @@ void RimGeoMechCase::defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute ) { + if ( field == &m_importElementPropertyFileCommand ) + { + dynamic_cast( attribute )->m_buttonText = "Import Element Property"; + } if ( field == &m_reloadElementPropertyFileCommand ) { - dynamic_cast( attribute )->m_buttonText = "Reload Case(s)"; + dynamic_cast( attribute )->m_buttonText = "Reload Element Property"; } if ( field == &m_closeElementPropertyFileCommand ) { - dynamic_cast( attribute )->m_buttonText = "Close Case(s)"; + dynamic_cast( attribute )->m_buttonText = "Close Element Property"; } if ( field == &m_biotFixedCoefficient ) diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index fc9bd7d99d..dad55e3836 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -119,6 +119,7 @@ private: void initAfterRead() override; static QString subStringOfDigits( const QString& timeStepString, int numberOfDigitsToFind ); + void importElementPropertyFile(); void closeSelectedElementPropertyFiles(); void reloadSelectedElementPropertyFiles(); std::vector allSpecialViews() const override; @@ -131,6 +132,7 @@ private: caf::PdmField m_frictionAngleDeg; caf::PdmField> m_elementPropertyFileNames; caf::PdmField> m_elementPropertyFileNameIndexUiSelection; + caf::PdmField m_importElementPropertyFileCommand; caf::PdmField m_closeElementPropertyFileCommand; caf::PdmField m_reloadElementPropertyFileCommand;