Skip to content

Commit

Permalink
Add timestep selection
Browse files Browse the repository at this point in the history
Add import geomech model to context menu
  • Loading branch information
jonjenssen committed Sep 6, 2023
1 parent a4e3e26 commit 87ed075
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include "RimFaultInView.h"
#include "RimFaultInViewCollection.h"
#include "RimPolylineTarget.h"
#include "RimTimeStepFilter.h"
#include "RimTools.h"

#include "cafPdmUiDoubleSliderEditor.h"
Expand All @@ -46,6 +47,8 @@
#include "cvfPlane.h"
#include "cvfTextureImage.h"

#include <QDateTime>

CAF_PDM_SOURCE_INIT( RimFaultReactivationModel, "FaultReactivationModel" );

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -91,6 +94,11 @@ 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_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
m_targets.uiCapability()->setUiTreeChildrenHidden( true );
Expand Down Expand Up @@ -118,6 +126,7 @@ RimFaultReactivationModel::~RimFaultReactivationModel()
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModel::initAfterRead()
{
updateTimeSteps();
updateVisualization();
}

Expand Down Expand Up @@ -225,6 +234,8 @@ caf::PickEventHandler* RimFaultReactivationModel::pickEventHandler() const
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModel::updateVisualization()
{
// if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps();

auto view = firstAncestorOrThisOfType<Rim3dView>();
if ( !view ) return;

Expand Down Expand Up @@ -291,6 +302,8 @@ cvf::ref<RigPolyLinesData> RimFaultReactivationModel::polyLinesData() const
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimFaultReactivationModel::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps();

QList<caf::PdmOptionItemInfo> options;

if ( fieldNeedingOptions == &m_fault )
Expand Down Expand Up @@ -352,6 +365,8 @@ bool RimFaultReactivationModel::showModel() const
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps();

auto genGrp = uiOrdering.addNewGroup( "General" );
genGrp->add( &m_userDescription );
genGrp->add( &m_fault );
Expand Down Expand Up @@ -382,6 +397,9 @@ 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 );

auto appModelGrp = modelGrp->addNewGroup( "Appearance" );
appModelGrp->add( &m_modelPart1Color );
appModelGrp->add( &m_modelPart2Color );
Expand Down Expand Up @@ -449,12 +467,8 @@ void RimFaultReactivationModel::defineEditorAttribute( const caf::PdmFieldHandle
//--------------------------------------------------------------------------------------------------
RimEclipseCase* RimFaultReactivationModel::eclipseCase()
{
auto activeView = dynamic_cast<RimEclipseView*>( RiaApplication::instance()->activeGridView() );
if ( activeView )
{
return activeView->eclipseCase();
}
return nullptr;
auto eCase = firstAncestorOrThisOfType<RimEclipseCase>();
return eCase;
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -472,3 +486,43 @@ QString RimFaultReactivationModel::baseDir() const
{
return m_baseDir().path();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModel::updateTimeSteps()
{
const auto eCase = eclipseCase();
if ( eCase == nullptr ) return;

auto timeStepStrings = eCase->timeStepStrings();
auto timeStepDates = eCase->timeStepDates();

CVF_ASSERT( timeStepStrings.size() == timeStepDates.size() );

std::vector<std::pair<QString, QDateTime>> timeSteps;

for ( int i = 0; i < (int)timeStepStrings.size(); i++ )
{
timeSteps.push_back( std::make_pair( timeStepStrings[i], timeStepDates[i] ) );
}

m_timeStepFilter->setTimeStepsFromFile( timeSteps );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RimFaultReactivationModel::selectedTimeSteps() const
{
auto steps = m_timeStepFilter->filteredTimeSteps();

std::vector<QDateTime> selectedSteps;

for ( const auto& step : m_timeStepFilter->allTimeSteps() )
{
selectedSteps.push_back( step.second );
}

return selectedSteps;
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class RicPolylineTargetsPickEventHandler;
class RimEclipseCase;
class RimFaultInView;
class RimPolylineTarget;
class RimTimeStepFilter;
class RivFaultReactivationModelPartMgr;
class RigBasicPlane;
class RigFaultReactivationModel;
Expand Down Expand Up @@ -89,6 +90,8 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly
QString baseDir() const;
void setBaseDir( QString path );

std::vector<QDateTime> selectedTimeSteps() const;

protected:
caf::PdmFieldHandle* userDescriptionField() override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
Expand All @@ -101,6 +104,8 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly

void initAfterRead() override;

void updateTimeSteps();

private:
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;

Expand Down Expand Up @@ -133,4 +138,6 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly

cvf::ref<RigBasicPlane> m_faultPlane;
cvf::ref<RigFaultReactivationModel> m_modelPlane;

caf::PdmChildField<RimTimeStepFilter*> m_timeStepFilter;
};
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
#include "RimGeoMechCellColors.h"
#include "RimGeoMechContourMapView.h"
#include "RimGeoMechContourMapViewCollection.h"
#include "RimGeoMechModels.h"
#include "RimGeoMechPropertyFilter.h"
#include "RimGeoMechPropertyFilterCollection.h"
#include "RimGeoMechView.h"
Expand Down Expand Up @@ -271,6 +272,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicNewStatisticsCaseFeature";
}
else if ( dynamic_cast<RimGeoMechModels*>( firstUiItem ) )
{
menuBuilder << "RicImportGeoMechCaseFeature";
menuBuilder << "Separator";
}
else if ( dynamic_cast<RimEclipseStatisticsCase*>( firstUiItem ) )
{
menuBuilder << "RicNewViewFeature";
Expand Down
5 changes: 3 additions & 2 deletions ApplicationLibCode/ProjectDataModel/RimTimeStepFilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,15 @@ class RimTimeStepFilter : public caf::PdmObject
void setReadOnlyLastFrame( bool onlyLast );
bool readOnlyLastFrame() const;

std::vector<std::pair<QString, QDateTime>> allTimeSteps() const;

protected:
void initAfterRead() override;

private:
static QDateTime incrementDateTime( const QDateTime& dateTime, TimeStepFilterTypeEnum filterType, int interval );

std::vector<std::pair<QString, QDateTime>> allTimeSteps() const;
std::vector<int> filteredTimeStepIndicesFromUi() const;
std::vector<int> filteredTimeStepIndicesFromUi() const;

void updateFieldVisibility();
RimEclipseResultCase* parentEclipseResultCase() const;
Expand Down

0 comments on commit 87ed075

Please sign in to comment.