mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
GeoMech: show deformations in grid view (#8123)
Enable support in geomech view to show grid deformations
This commit is contained in:
@@ -79,3 +79,19 @@ void RimGeoMechPart::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
if ( ownerView ) ownerView->scheduleCreateDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechPart::setDisplacements( std::vector<cvf::Vec3f>& displacements )
|
||||
{
|
||||
m_displacements = displacements;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<cvf::Vec3f> RimGeoMechPart::displacements() const
|
||||
{
|
||||
return m_displacements;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimGeoMechPart : public RimCheckableNamedObject
|
||||
{
|
||||
CAF_PDM_HEADER_INIT;
|
||||
@@ -34,9 +38,14 @@ public:
|
||||
void setPartId( int partId );
|
||||
int partId() const;
|
||||
|
||||
void setDisplacements( std::vector<cvf::Vec3f>& displacements );
|
||||
const std::vector<cvf::Vec3f> displacements() const;
|
||||
|
||||
protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
|
||||
private:
|
||||
caf::PdmField<int> m_partId;
|
||||
|
||||
std::vector<cvf::Vec3f> m_displacements;
|
||||
};
|
||||
|
||||
@@ -36,6 +36,9 @@ CAF_PDM_SOURCE_INIT( RimGeoMechPartCollection, "GeoMechPartCollection" );
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechPartCollection::RimGeoMechPartCollection()
|
||||
: m_case( nullptr )
|
||||
, m_currentDisplacementTimeStep( -1 )
|
||||
, m_displacementsUsed( false )
|
||||
, m_currentScaleFactor( 1.0 )
|
||||
{
|
||||
CAF_PDM_InitScriptableObject( "Parts", ":/GeoMechCase24x24.png", "", "" );
|
||||
|
||||
@@ -90,6 +93,18 @@ std::vector<RimGeoMechPart*> RimGeoMechPartCollection::parts() const
|
||||
return m_parts.childObjects();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimGeoMechPart* RimGeoMechPartCollection::part( int partId ) const
|
||||
{
|
||||
for ( const auto& part : m_parts )
|
||||
{
|
||||
if ( part->partId() == partId ) return part;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -103,10 +118,88 @@ bool RimGeoMechPartCollection::shouldBeVisibleInTree() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechPartCollection::isPartEnabled( int partId ) const
|
||||
{
|
||||
for ( const auto& part : m_parts )
|
||||
{
|
||||
if ( part->partId() == partId ) return part->isChecked();
|
||||
}
|
||||
RimGeoMechPart* thepart = part( partId );
|
||||
if ( thepart ) return thepart->isChecked();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechPartCollection::setCurrentDisplacementSettings( int currentTimeStep, bool showDisplacement, double scaleFactor )
|
||||
{
|
||||
m_currentDisplacementTimeStep = currentTimeStep;
|
||||
m_displacementsUsed = showDisplacement;
|
||||
m_currentScaleFactor = scaleFactor;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RimGeoMechPartCollection::currentDisplacementTimeStep() const
|
||||
{
|
||||
return m_currentDisplacementTimeStep;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechPartCollection::setDisplacementsForPart( int partId, std::vector<cvf::Vec3f> displacements )
|
||||
{
|
||||
RimGeoMechPart* thepart = part( partId );
|
||||
if ( thepart ) thepart->setDisplacements( displacements );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<cvf::Vec3f> RimGeoMechPartCollection::displacements( int partId ) const
|
||||
{
|
||||
RimGeoMechPart* thepart = part( partId );
|
||||
if ( thepart ) return thepart->displacements();
|
||||
|
||||
return std::vector<cvf::Vec3f>();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechPartCollection::isDisplacementsUsed() const
|
||||
{
|
||||
return m_displacementsUsed;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechPartCollection::shouldRebuildPartVisualization( int currentTimeStep, bool showDisplacement, double scaleFactor )
|
||||
{
|
||||
// if show flag has changed, we need to rebuild grid viz.
|
||||
bool retVal = m_displacementsUsed != showDisplacement;
|
||||
|
||||
// if scaling or timestep has changed, we need to rebuild grid if the displacement should be visible
|
||||
if ( showDisplacement )
|
||||
retVal = retVal || ( m_currentDisplacementTimeStep != currentTimeStep ) ||
|
||||
( std::abs( m_currentScaleFactor - scaleFactor ) > 0.0001 );
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechPartCollection::shouldReloadDisplacements( int currentTimeStep, bool showDisplacement, double scaleFactor )
|
||||
{
|
||||
// no need to reload something we are not showing
|
||||
if ( !showDisplacement ) return false;
|
||||
|
||||
// if we have no displacements at all, we need to reload.
|
||||
for ( const auto& part : m_parts )
|
||||
{
|
||||
if ( part->displacements().size() == 0 ) return true;
|
||||
}
|
||||
|
||||
// if timestep has changed we need to reload
|
||||
return m_currentDisplacementTimeStep != currentTimeStep;
|
||||
}
|
||||
|
||||
@@ -21,6 +21,10 @@
|
||||
#include "cafPdmField.h"
|
||||
#include "cafPdmObject.h"
|
||||
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
class RimGeoMechPart;
|
||||
class RimGeoMechCase;
|
||||
|
||||
@@ -34,13 +38,29 @@ public:
|
||||
|
||||
void syncWithCase( RimGeoMechCase* geoCase );
|
||||
|
||||
bool shouldRebuildPartVisualization( int currentTimeStep, bool showDisplacement, double scaleFactor );
|
||||
bool shouldReloadDisplacements( int currentTimeStep, bool showDisplacement, double scaleFactor );
|
||||
bool shouldBeVisibleInTree() const;
|
||||
|
||||
bool isPartEnabled( int partId ) const;
|
||||
|
||||
void setDisplacementsForPart( int partId, std::vector<cvf::Vec3f> displacements );
|
||||
const std::vector<cvf::Vec3f> displacements( int partId ) const;
|
||||
|
||||
void setCurrentDisplacementSettings( int currentTimeStep, bool showDisplacement, double scaleFactor );
|
||||
bool isDisplacementsUsed() const;
|
||||
int currentDisplacementTimeStep() const;
|
||||
double currentScaleFactor() const;
|
||||
|
||||
std::vector<RimGeoMechPart*> parts() const;
|
||||
|
||||
private:
|
||||
RimGeoMechPart* part( int partId ) const;
|
||||
|
||||
caf::PdmChildArrayField<RimGeoMechPart*> m_parts;
|
||||
RimGeoMechCase* m_case;
|
||||
|
||||
int m_currentDisplacementTimeStep;
|
||||
double m_currentScaleFactor;
|
||||
bool m_displacementsUsed;
|
||||
};
|
||||
|
||||
@@ -102,6 +102,9 @@ RimGeoMechView::RimGeoMechView( void )
|
||||
m_partsCollection = new RimGeoMechPartCollection();
|
||||
m_partsCollection.uiCapability()->setUiHidden( true );
|
||||
|
||||
CAF_PDM_InitField( &m_showDisplacement, "ShowDisplacement", false, "Show Displacement", "", "", "" );
|
||||
CAF_PDM_InitField( &m_displacementScaling, "DisplacementScaling", 1.0, "Scaling Factor", "", "", "" );
|
||||
|
||||
m_scaleTransform = new cvf::Transform();
|
||||
m_vizLogic = new RivGeoMechVizLogic( this );
|
||||
m_tensorPartMgr = new RivTensorResultPartMgr( this );
|
||||
@@ -257,6 +260,8 @@ void RimGeoMechView::onCreateDisplayModel()
|
||||
theParts->part( i )->setEnabled( m_partsCollection()->isPartEnabled( i ) );
|
||||
}
|
||||
|
||||
updateElementDisplacements();
|
||||
|
||||
// Remove all existing animation frames from the viewer.
|
||||
// The parts are still cached in the RivReservoir geometry and friends
|
||||
|
||||
@@ -343,6 +348,31 @@ RimPropertyFilterCollection* RimGeoMechView::nativePropertyFilterCollection()
|
||||
return m_propertyFilterCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimGeoMechView::updateElementDisplacements()
|
||||
{
|
||||
if ( !m_partsCollection->shouldRebuildPartVisualization( m_currentTimeStep, m_showDisplacement, m_displacementScaling ) )
|
||||
return;
|
||||
|
||||
if ( m_partsCollection->shouldReloadDisplacements( m_currentTimeStep, m_showDisplacement, m_displacementScaling ) )
|
||||
{
|
||||
for ( auto part : m_partsCollection->parts() )
|
||||
{
|
||||
std::string errmsg;
|
||||
std::vector<cvf::Vec3f> displacements;
|
||||
m_geomechCase->geoMechData()->readDisplacements( &errmsg, part->partId(), m_currentTimeStep, &displacements );
|
||||
part->setDisplacements( displacements );
|
||||
}
|
||||
}
|
||||
// store current settings so that we know if we need to rebuild later if any of them changes
|
||||
m_partsCollection->setCurrentDisplacementSettings( m_currentTimeStep, m_showDisplacement, m_displacementScaling );
|
||||
|
||||
// tell geometry generator to regenerate grid
|
||||
m_vizLogic->scheduleGeometryRegenOfVisiblePartMgrs( m_currentTimeStep );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -350,6 +380,8 @@ void RimGeoMechView::onUpdateDisplayModelForCurrentTimeStep()
|
||||
{
|
||||
onUpdateLegends();
|
||||
|
||||
updateElementDisplacements();
|
||||
|
||||
if ( this->isTimeStepDependentDataVisibleInThisOrComparisonView() )
|
||||
{
|
||||
if ( nativeOrOverrideViewer() )
|
||||
@@ -800,6 +832,11 @@ bool RimGeoMechView::isTimeStepDependentDataVisible() const
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ( m_showDisplacement ) || m_partsCollection->isDisplacementsUsed() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -819,6 +856,11 @@ void RimGeoMechView::fieldChangedByUi( const caf::PdmFieldHandle* changedField,
|
||||
const QVariant& newValue )
|
||||
{
|
||||
RimGridView::fieldChangedByUi( changedField, oldValue, newValue );
|
||||
|
||||
if ( ( changedField == &m_showDisplacement ) || ( ( changedField == &m_displacementScaling ) && m_showDisplacement() ) )
|
||||
{
|
||||
this->createDisplayModelAndRedraw();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -955,6 +997,10 @@ void RimGeoMechView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering&
|
||||
|
||||
caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup( "View Name" );
|
||||
nameConfig()->uiOrdering( uiConfigName, *nameGroup );
|
||||
|
||||
auto displacementGroup = uiOrdering.addNewGroup( "Displacements" );
|
||||
displacementGroup->add( &m_showDisplacement );
|
||||
displacementGroup->add( &m_displacementScaling );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1002,3 +1048,19 @@ const RimGeoMechPartCollection* RimGeoMechView::partsCollection() const
|
||||
{
|
||||
return m_partsCollection();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RimGeoMechView::displacementScaleFactor() const
|
||||
{
|
||||
return m_displacementScaling;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimGeoMechView::showDisplacements() const
|
||||
{
|
||||
return m_showDisplacement;
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class Rim3dOverlayInfoConfig;
|
||||
class RimCellRangeFilterCollection;
|
||||
class RimGeoMechCase;
|
||||
class RimGeoMechCellColors;
|
||||
class RimGeoMechPartCollection;
|
||||
class RimGeoMechPropertyFilterCollection;
|
||||
class RimGeoMechResultDefinition;
|
||||
class RimRegularLegendConfig;
|
||||
@@ -105,6 +106,9 @@ public:
|
||||
|
||||
void convertCameraPositionFromOldProjectFiles();
|
||||
|
||||
double displacementScaleFactor() const;
|
||||
bool showDisplacements() const;
|
||||
|
||||
protected:
|
||||
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;
|
||||
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
|
||||
@@ -133,14 +137,18 @@ private:
|
||||
|
||||
void updateTensorLegendTextAndRanges( RimRegularLegendConfig* legendConfig, int timeStepIndex );
|
||||
|
||||
void updateElementDisplacements();
|
||||
|
||||
caf::PdmChildField<RimTensorResults*> m_tensorResults;
|
||||
caf::PdmChildField<RimGeoMechPropertyFilterCollection*> m_propertyFilterCollection;
|
||||
caf::PdmPointer<RimGeoMechPropertyFilterCollection> m_overridePropertyFilterCollection;
|
||||
caf::PdmChildField<RimGeoMechPartCollection*> m_partsCollection;
|
||||
caf::PdmPointer<RimGeoMechCase> m_geomechCase;
|
||||
caf::PdmField<bool> m_showDisplacement;
|
||||
caf::PdmField<double> m_displacementScaling;
|
||||
|
||||
caf::PdmPointer<RimGeoMechCase> m_geomechCase;
|
||||
cvf::ref<RivGeoMechVizLogic> m_vizLogic;
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
cvf::ref<RivGeoMechVizLogic> m_vizLogic;
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
|
||||
cvf::ref<RivTensorResultPartMgr> m_tensorPartMgr;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user