Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure imported element properties goes to the selected case. #10985

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 28 additions & 12 deletions ApplicationLibCode/Commands/RicImportElementPropertyFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include "RiuFileDialogTools.h"

#include "cafSelectionManagerTools.h"

#include <QAction>
#include <QFileInfo>

Expand All @@ -38,14 +40,37 @@ CAF_CMD_SOURCE_INIT( RicImportElementPropertyFeature, "RicImportElementPropertyF
//--------------------------------------------------------------------------------------------------
void RicImportElementPropertyFeature::onActionTriggered( bool isChecked )
{
importElementProperties();
std::vector<caf::PdmUiItem*> uiItems;
caf::SelectionManager::instance()->selectedItems( uiItems );

RimGeoMechCase* geomCase = nullptr;

if ( !uiItems.empty() )
{
geomCase = dynamic_cast<RimGeoMechCase*>( uiItems[0] );
}

if ( geomCase == nullptr )
{
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
if ( !activeView ) return;

RimGeoMechView* activeGmv = dynamic_cast<RimGeoMechView*>( 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" );
Expand All @@ -65,16 +90,7 @@ void RicImportElementPropertyFeature::importElementProperties()

app->setLastUsedDialogDirectory( "ELM_PROPS", defaultDir );

Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
if ( !activeView ) return;

RimGeoMechView* activeGmv = dynamic_cast<RimGeoMechView*>( activeView );
if ( !activeGmv ) return;

if ( activeGmv->geoMechCase() )
{
activeGmv->geoMechCase()->addElementPropertyFiles( filePaths );
}
pCase->addElementPropertyFiles( filePaths );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@

#include "cafCmdFeature.h"

class RimGeoMechCase;

//==================================================================================================
///
//==================================================================================================
class RicImportElementPropertyFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

static void importElementProperties();
static void importElementProperties( RimGeoMechCase* pCase );

protected:
void onActionTriggered( bool isChecked ) override;
Expand Down
10 changes: 5 additions & 5 deletions ApplicationLibCode/ProjectDataModel/GeoMech/RimGeoMechCase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ void RimGeoMechCase::reloadSelectedElementPropertyFiles()
//--------------------------------------------------------------------------------------------------
void RimGeoMechCase::importElementPropertyFile()
{
RicImportElementPropertyFeature::importElementProperties();
RicImportElementPropertyFeature::importElementProperties( this );
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -1125,15 +1125,15 @@ void RimGeoMechCase::defineEditorAttribute( const caf::PdmFieldHandle* field, QS
{
if ( field == &m_importElementPropertyFileCommand )
{
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute )->m_buttonText = "Import Element Property";
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute )->m_buttonText = "Import New Element Property";
}
if ( field == &m_reloadElementPropertyFileCommand )
{
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute )->m_buttonText = "Reload Element Property";
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute )->m_buttonText = "Reload Selected Properties";
}
if ( field == &m_closeElementPropertyFileCommand )
{
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute )->m_buttonText = "Close Element Property";
dynamic_cast<caf::PdmUiPushButtonEditorAttribute*>( attribute )->m_buttonText = "Close Selected Properties";
}

if ( field == &m_biotFixedCoefficient )
Expand All @@ -1160,7 +1160,7 @@ QList<caf::PdmOptionItemInfo> 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 )
Expand Down