Use sliders to manipulate surface plane extent

This commit is contained in:
Magne Sjaastad
2024-08-22 18:55:59 +02:00
parent 0518e594ce
commit a89fe80de3
3 changed files with 43 additions and 7 deletions

View File

@@ -54,9 +54,7 @@ void RicNewDepthSurfaceFeature::onActionTriggered( bool isChecked )
bb.expand( 0.1 * bb.extent().z() );
auto lowerDepthLimit = -bb.max().z();
auto upperDepthLimit = -bb.min().z();
surface->setDepthSliderLimits( lowerDepthLimit, upperDepthLimit );
surface->setAreaOfInterest( bb.min(), bb.max() );
}
surface->loadDataIfRequired();

View File

@@ -48,11 +48,14 @@ RimDepthSurface::RimDepthSurface()
CAF_PDM_InitField( &m_depthUpperLimit, "DepthUpperLimit", 100000.0, "Upper Limit" );
m_depthUpperLimit.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
m_minX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
m_maxX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
m_minY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
m_maxY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
m_minX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_maxX.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_minY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_maxY.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
m_depth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_areaOfInterestMin, "AreaOfInterestMin", "Area Of Interest Min" );
CAF_PDM_InitFieldNoDefault( &m_areaOfInterestMax, "AreaOfInterestMax", "Area Of Interest Max" );
}
//--------------------------------------------------------------------------------------------------
@@ -106,6 +109,19 @@ void RimDepthSurface::setDepthSliderLimits( double lower, double upper )
m_depthUpperLimit = upper;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimDepthSurface::setAreaOfInterest( cvf::Vec3d min, cvf::Vec3d max )
{
m_areaOfInterestMin = min;
m_areaOfInterestMax = max;
auto lowerDepthLimit = -max.z();
auto upperDepthLimit = -min.z();
setDepthSliderLimits( lowerDepthLimit, upperDepthLimit );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -135,6 +151,24 @@ void RimDepthSurface::defineEditorAttribute( const caf::PdmFieldHandle* field, Q
attr->m_maximum = m_depthUpperLimit;
}
}
if ( field == &m_minX || field == &m_maxX )
{
if ( auto attr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
attr->m_minimum = m_areaOfInterestMin().x();
attr->m_maximum = m_areaOfInterestMax().x();
}
}
if ( field == &m_minY || field == &m_maxY )
{
if ( auto attr = dynamic_cast<caf::PdmUiDoubleSliderEditorAttribute*>( attribute ) )
{
attr->m_minimum = m_areaOfInterestMin().y();
attr->m_maximum = m_areaOfInterestMax().y();
}
}
}
//--------------------------------------------------------------------------------------------------

View File

@@ -34,6 +34,7 @@ public:
void setPlaneExtent( double minX, double minY, double maxX, double maxY );
void setDepth( double depth );
void setDepthSliderLimits( double lower, double upper );
void setAreaOfInterest( cvf::Vec3d min, cvf::Vec3d max );
private:
bool updateSurfaceData() override;
@@ -54,6 +55,9 @@ private:
caf::PdmField<double> m_depthLowerLimit;
caf::PdmField<double> m_depthUpperLimit;
caf::PdmField<cvf::Vec3d> m_areaOfInterestMin;
caf::PdmField<cvf::Vec3d> m_areaOfInterestMax;
std::vector<unsigned> m_triangleIndices;
std::vector<cvf::Vec3d> m_vertices;
};