diff --git a/ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp index 2449949ee2..3560318b0b 100644 --- a/ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp @@ -28,6 +28,8 @@ #include "RiuFileDialogTools.h" +#include "cafSelectionManagerTools.h" + #include #include @@ -38,14 +40,37 @@ CAF_CMD_SOURCE_INIT( RicImportElementPropertyFeature, "RicImportElementPropertyF //-------------------------------------------------------------------------------------------------- void RicImportElementPropertyFeature::onActionTriggered( bool isChecked ) { - importElementProperties(); + std::vector uiItems; + caf::SelectionManager::instance()->selectedItems( uiItems ); + + RimGeoMechCase* geomCase = nullptr; + + if ( !uiItems.empty() ) + { + geomCase = dynamic_cast( uiItems[0] ); + } + + if ( geomCase == nullptr ) + { + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + if ( !activeView ) return; + + RimGeoMechView* activeGmv = dynamic_cast( activeView ); + if ( !activeGmv ) return; + + geomCase = activeGmv->geoMechCase(); + } + + importElementProperties( geomCase ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicImportElementPropertyFeature::importElementProperties() +void RicImportElementPropertyFeature::importElementProperties( RimGeoMechCase* pCase ) { + if ( pCase == nullptr ) return; + RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory( "ELM_PROPS" ); @@ -65,16 +90,7 @@ void RicImportElementPropertyFeature::importElementProperties() app->setLastUsedDialogDirectory( "ELM_PROPS", defaultDir ); - Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); - if ( !activeView ) return; - - RimGeoMechView* activeGmv = dynamic_cast( activeView ); - if ( !activeGmv ) return; - - if ( activeGmv->geoMechCase() ) - { - activeGmv->geoMechCase()->addElementPropertyFiles( filePaths ); - } + pCase->addElementPropertyFiles( filePaths ); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Commands/RicImportElementPropertyFeature.h b/ApplicationLibCode/Commands/RicImportElementPropertyFeature.h index 064c2a026e..acedefa6e4 100644 --- a/ApplicationLibCode/Commands/RicImportElementPropertyFeature.h +++ b/ApplicationLibCode/Commands/RicImportElementPropertyFeature.h @@ -20,6 +20,8 @@ #include "cafCmdFeature.h" +class RimGeoMechCase; + //================================================================================================== /// //================================================================================================== @@ -27,7 +29,7 @@ class RicImportElementPropertyFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; - static void importElementProperties(); + static void importElementProperties( RimGeoMechCase* pCase ); protected: void onActionTriggered( bool isChecked ) override; diff --git a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp index e1c5879a14..3c0373c1e7 100644 --- a/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp +++ b/ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp @@ -1067,7 +1067,7 @@ void RimGeoMechCase::reloadSelectedElementPropertyFiles() //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::importElementPropertyFile() { - RicImportElementPropertyFeature::importElementProperties(); + RicImportElementPropertyFeature::importElementProperties( this ); } //-------------------------------------------------------------------------------------------------- @@ -1125,15 +1125,15 @@ void RimGeoMechCase::defineEditorAttribute( const caf::PdmFieldHandle* field, QS { if ( field == &m_importElementPropertyFileCommand ) { - dynamic_cast( attribute )->m_buttonText = "Import Element Property"; + dynamic_cast( attribute )->m_buttonText = "Import New Element Property"; } if ( field == &m_reloadElementPropertyFileCommand ) { - dynamic_cast( attribute )->m_buttonText = "Reload Element Property"; + dynamic_cast( attribute )->m_buttonText = "Reload Selected Properties"; } if ( field == &m_closeElementPropertyFileCommand ) { - dynamic_cast( attribute )->m_buttonText = "Close Element Property"; + dynamic_cast( attribute )->m_buttonText = "Close Selected Properties"; } if ( field == &m_biotFixedCoefficient ) @@ -1160,7 +1160,7 @@ QList RimGeoMechCase::calculateValueOptions( const caf:: { for ( size_t i = 0; i < m_elementPropertyFileNames.v().size(); i++ ) { - options.push_back( caf::PdmOptionItemInfo( m_elementPropertyFileNames.v().at( i ).path(), (int)i, true ) ); + options.push_back( caf::PdmOptionItemInfo( m_elementPropertyFileNames.v().at( i ).path(), (int)i, false ) ); } } else if ( fieldNeedingOptions == &m_biotResultAddress || fieldNeedingOptions == &m_initialPermeabilityResultAddress )