From 83fbf3ab1ae8e0375f79c1968b71d395350c02c3 Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Wed, 13 Sep 2023 01:50:50 +0200 Subject: [PATCH] Work in progress --- .../RicNewFaultReactModelingFeature.cpp | 1 + .../RicRunFaultReactModelingFeature.cpp | 10 ++- .../RicRunFaultReactModelingFeature.h | 1 + .../Faults/RimFaultReactivationModel.cpp | 71 +++++++++++++------ .../Faults/RimFaultReactivationModel.h | 11 ++- .../RimFaultReactivationModelCollection.cpp | 11 +++ .../RimFaultReactivationModelCollection.h | 2 + .../RimContextCommandBuilder.cpp | 1 + .../ProjectDataModel/RimEclipseView.cpp | 2 + 9 files changed, 86 insertions(+), 24 deletions(-) diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactModelingFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactModelingFeature.cpp index f061674a4e..1f4adc7724 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactModelingFeature.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactModelingFeature.cpp @@ -113,6 +113,7 @@ void RicNewFaultReactModelingFeature::onActionTriggered( bool isChecked ) auto model = eclView->faultReactivationModelCollection()->addNewModel( rimFault, target1, target2, baseDir ); if ( model != nullptr ) { + model->updateTimeSteps(); view->updateAllRequiredEditors(); Riu3DMainWindowTools::selectAsCurrentItem( model ); } diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.cpp index 3782d3ed76..8734bbe349 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.cpp @@ -39,6 +39,14 @@ CAF_CMD_SOURCE_INIT( RicRunFaultReactModelingFeature, "RicRunFaultReactModelingFeature" ); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicRunFaultReactModelingFeature::isCommandEnabled() const +{ + return RiaPreferencesGeoMech::current()->validateFRMSettings(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -97,7 +105,7 @@ void RicRunFaultReactModelingFeature::onActionTriggered( bool isChecked ) runProgress.incrementProgress(); runProgress.setProgressDescription( "Running Abaqus modeling." ); - QString command = RiaPreferencesGeoMech::current()->geomechWIACommand(); + QString command = RiaPreferencesGeoMech::current()->geomechFRMCommand(); QStringList parameters = model->commandParameters(); RimProcess process; diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.h index 8a06d513b4..aed3193c61 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.h +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.h @@ -30,6 +30,7 @@ class RicRunFaultReactModelingFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; protected: + bool isCommandEnabled() const override; void onActionTriggered( bool isChecked ) override; void setupActionLook( QAction* actionToSetup ) override; }; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp index c5916f1955..85c0a91f3c 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp @@ -48,6 +48,7 @@ #include "cvfTextureImage.h" #include +#include CAF_PDM_SOURCE_INIT( RimFaultReactivationModel, "FaultReactivationModel" ); @@ -94,10 +95,10 @@ RimFaultReactivationModel::RimFaultReactivationModel() CAF_PDM_InitField( &m_numberOfCellsVertMid, "NumberOfCellsVertMid", 20, "Vertical Number of Cells, Middle Part" ); CAF_PDM_InitField( &m_numberOfCellsVertLow, "NumberOfCellsVertLow", 20, "Vertical Number of Cells, Lower Part" ); - CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Time Step Filter" ); - m_timeStepFilter.uiCapability()->setUiTreeHidden( true ); - m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden( true ); - m_timeStepFilter = new RimTimeStepFilter(); + // CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Time Step Filter" ); + // m_timeStepFilter.uiCapability()->setUiTreeHidden( true ); + // m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden( true ); + // m_timeStepFilter = new RimTimeStepFilter(); CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" ); m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); @@ -126,7 +127,6 @@ RimFaultReactivationModel::~RimFaultReactivationModel() //-------------------------------------------------------------------------------------------------- void RimFaultReactivationModel::initAfterRead() { - updateTimeSteps(); updateVisualization(); } @@ -234,8 +234,6 @@ caf::PickEventHandler* RimFaultReactivationModel::pickEventHandler() const //-------------------------------------------------------------------------------------------------- void RimFaultReactivationModel::updateVisualization() { - // if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps(); - auto view = firstAncestorOrThisOfType(); if ( !view ) return; @@ -302,8 +300,6 @@ cvf::ref RimFaultReactivationModel::polyLinesData() const //-------------------------------------------------------------------------------------------------- QList RimFaultReactivationModel::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) { - if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps(); - QList options; if ( fieldNeedingOptions == &m_fault ) @@ -365,7 +361,7 @@ bool RimFaultReactivationModel::showModel() const //-------------------------------------------------------------------------------------------------- void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { - if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps(); + // if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps(); auto genGrp = uiOrdering.addNewGroup( "General" ); genGrp->add( &m_userDescription ); @@ -397,8 +393,8 @@ void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::Pdm gridModelGrp->add( &m_numberOfCellsVertMid ); gridModelGrp->add( &m_numberOfCellsVertLow ); - caf::PdmUiGroup* timeStepFilterGroup = uiOrdering.addNewGroup( "Time Steps" ); - m_timeStepFilter->uiOrdering( uiConfigName, *timeStepFilterGroup ); + // caf::PdmUiGroup* timeStepFilterGroup = uiOrdering.addNewGroup( "Time Steps" ); + // m_timeStepFilter->uiOrdering( uiConfigName, *timeStepFilterGroup ); auto appModelGrp = modelGrp->addNewGroup( "Appearance" ); appModelGrp->add( &m_modelPart1Color ); @@ -468,6 +464,12 @@ void RimFaultReactivationModel::defineEditorAttribute( const caf::PdmFieldHandle RimEclipseCase* RimFaultReactivationModel::eclipseCase() { auto eCase = firstAncestorOrThisOfType(); + + if ( eCase == nullptr ) + { + eCase = dynamic_cast( RiaApplication::instance()->activeGridView()->ownerCase() ); + } + return eCase; } @@ -507,7 +509,9 @@ void RimFaultReactivationModel::updateTimeSteps() timeSteps.push_back( std::make_pair( timeStepStrings[i], timeStepDates[i] ) ); } - m_timeStepFilter->setTimeStepsFromFile( timeSteps ); + // auto selection = m_timeStepFilter->filteredTimeSteps(); + // m_timeStepFilter->setTimeStepsFromFile( timeSteps ); + // m_timeStepFilter->filteredTimeSteps() = selection; } //-------------------------------------------------------------------------------------------------- @@ -515,14 +519,14 @@ void RimFaultReactivationModel::updateTimeSteps() //-------------------------------------------------------------------------------------------------- std::vector RimFaultReactivationModel::selectedTimeSteps() const { - auto steps = m_timeStepFilter->filteredTimeSteps(); + // auto steps = m_timeStepFilter->filteredTimeSteps(); std::vector selectedSteps; - for ( const auto& step : m_timeStepFilter->allTimeSteps() ) - { - selectedSteps.push_back( step.second ); - } + // for ( const auto& step : m_timeStepFilter->allTimeSteps() ) + //{ + // selectedSteps.push_back( step.second ); + // } return selectedSteps; } @@ -532,7 +536,13 @@ std::vector RimFaultReactivationModel::selectedTimeSteps() const //-------------------------------------------------------------------------------------------------- QStringList RimFaultReactivationModel::commandParameters() const { - return QStringList(); + QStringList retlist; + + retlist << baseDir(); + retlist << inputFilename(); + retlist << outputOdbFilename(); + + return retlist; } //-------------------------------------------------------------------------------------------------- @@ -540,7 +550,8 @@ QStringList RimFaultReactivationModel::commandParameters() const //-------------------------------------------------------------------------------------------------- QString RimFaultReactivationModel::outputOdbFilename() const { - return baseDir() + "faultreactivation.odb"; + QDir directory( baseDir() ); + return directory.absoluteFilePath( baseFilename() + ".odb" ); } //-------------------------------------------------------------------------------------------------- @@ -548,5 +559,23 @@ QString RimFaultReactivationModel::outputOdbFilename() const //-------------------------------------------------------------------------------------------------- QString RimFaultReactivationModel::inputFilename() const { - return baseDir() + "faultreactivation.inp"; + QDir directory( baseDir() ); + return directory.absoluteFilePath( baseFilename() + ".inp" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultReactivationModel::baseFilename() const +{ + QString tmp = m_userDescription(); + + if ( tmp.isEmpty() ) return "faultReactivation"; + + tmp.replace( ' ', '_' ); + tmp.replace( '/', '_' ); + tmp.replace( '\\', '_' ); + tmp.replace( ':', '_' ); + + return tmp; } diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h index 5b8cf466f2..fa93a36a69 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h @@ -20,6 +20,7 @@ #include "RimCheckableNamedObject.h" #include "RimPolylinePickerInterface.h" #include "RimPolylinesDataInterface.h" +#include "RimTimeStepFilter.h" #include "cafFilePath.h" #include "cafPdmChildArrayField.h" @@ -31,6 +32,7 @@ #include "cvfColor3.h" #include "cvfVector3.h" +#include #include #include @@ -56,6 +58,8 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly { CAF_PDM_HEADER_INIT; + using TimeStepFilterEnum = caf::AppEnum; + public: RimFaultReactivationModel(); ~RimFaultReactivationModel() override; @@ -97,6 +101,8 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly QString outputOdbFilename() const; QString inputFilename() const; + void updateTimeSteps(); + protected: caf::PdmFieldHandle* userDescriptionField() override; QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override; @@ -109,7 +115,7 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly void initAfterRead() override; - void updateTimeSteps(); + QString baseFilename() const; private: std::shared_ptr m_pickTargetsEventHandler; @@ -144,5 +150,6 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly cvf::ref m_faultPlane; cvf::ref m_modelPlane; - caf::PdmChildField m_timeStepFilter; + caf::PdmField m_timeStepFilter; + caf::PdmField> m_selectedTimeSteps; }; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModelCollection.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModelCollection.cpp index 82fc498747..4ba6a0870e 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModelCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModelCollection.cpp @@ -186,3 +186,14 @@ void RimFaultReactivationModelCollection::appendPartsToModel( Rim3dView* model->updateBoundingBoxesRecursive(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultReactivationModelCollection::syncTimeSteps() +{ + for ( auto& frm : m_models ) + { + frm->updateTimeSteps(); + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModelCollection.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModelCollection.h index 0089a6b0e7..1be362fa81 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModelCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModelCollection.h @@ -65,6 +65,8 @@ class RimFaultReactivationModelCollection : public RimCheckableNamedObject caf::DisplayCoordTransform* transform, const cvf::BoundingBox& boundingBox ); + void syncTimeSteps(); + protected: caf::PdmFieldHandle* userDescriptionField() override; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 7fd2bd0b98..d7787ea8c9 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -480,6 +480,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if ( dynamic_cast( firstUiItem ) ) { + menuBuilder << "RicRunFaultReactModelingFeature"; menuBuilder << "RicExportInpFileFeature"; } else if ( dynamic_cast( firstUiItem ) ) diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp index 3f114746d7..66b72eadd7 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp @@ -1115,6 +1115,8 @@ void RimEclipseView::onLoadDataAndUpdate() m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection(); + m_faultReactivationModelCollection->syncTimeSteps(); + scheduleCreateDisplayModelAndRedraw(); }