diff --git a/ApplicationCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp index 7f0477569b..2e8a743f4b 100644 --- a/ApplicationCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Surfaces/RivSurfaceIntersectionGeometryGenerator.cpp @@ -155,6 +155,7 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays() const std::vector& nativeVertices = m_usedSurfaceData->vertices(); const std::vector& nativeTriangleIndices = m_usedSurfaceData->triangleIndices(); cvf::Vec3d displayModelOffset = m_hexGrid->displayOffset(); + double depthOffset = m_surfaceInView->depthOffset(); m_triVxToCellCornerWeights.reserve( nativeTriangleIndices.size() * 24 ); outputTriangleVertices.reserve( nativeTriangleIndices.size() * 24 ); @@ -187,6 +188,10 @@ void RivSurfaceIntersectionGeometryGenerator::calculateArrays() cvf::Vec3d p1 = nativeVertices[nativeTriangleIndices[ntVxIdx + 1]]; cvf::Vec3d p2 = nativeVertices[nativeTriangleIndices[ntVxIdx + 2]]; + p0.z() = p0.z() - depthOffset; + p1.z() = p1.z() - depthOffset; + p2.z() = p2.z() - depthOffset; + cvf::BoundingBox triangleBBox; triangleBBox.add( p0 ); triangleBBox.add( p1 ); diff --git a/ApplicationCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp b/ApplicationCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp index 1ca6d4a364..c41dbcc5e8 100644 --- a/ApplicationCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Surfaces/RivSurfacePartMgr.cpp @@ -377,7 +377,9 @@ void RivSurfacePartMgr::generateNativePartGeometry() m_surfaceInView->firstAncestorOrThisOfTypeAsserted( ownerCase ); cvf::Vec3d displayModOffsett = ownerCase->displayModelOffset(); - m_usedSurfaceData = m_surfaceInView->surface()->surfaceData(); + m_usedSurfaceData = m_surfaceInView->surface()->surfaceData(); + double depthOffset = m_surfaceInView->depthOffset(); + displayModOffsett.z() = displayModOffsett.z() + depthOffset; const std::vector& vertices = m_usedSurfaceData->vertices(); cvf::ref cvfVertices = new cvf::Vec3fArray( vertices.size() ); diff --git a/ApplicationCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp b/ApplicationCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp index a73bc6f0fd..eb55c8a638 100644 --- a/ApplicationCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp +++ b/ApplicationCode/ProjectDataModel/Surfaces/RimSurfaceInView.cpp @@ -27,6 +27,8 @@ #include "RivHexGridIntersectionTools.h" #include "RivSurfacePartMgr.h" +#include "cafPdmUiDoubleSliderEditor.h" + CAF_PDM_SOURCE_INIT( RimSurfaceInView, "SurfaceInView" ); //-------------------------------------------------------------------------------------------------- @@ -42,6 +44,9 @@ RimSurfaceInView::RimSurfaceInView() CAF_PDM_InitFieldNoDefault( &m_surface, "SurfaceRef", "Surface", "", "", "" ); m_surface.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_depthOffset, "DepthOffset", 0.0, "Depth Offset", "", "", "" ); + m_depthOffset.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleSliderEditor::uiEditorTypeName() ); } //-------------------------------------------------------------------------------------------------- @@ -77,6 +82,14 @@ void RimSurfaceInView::setSurface( RimSurface* surf ) m_surface = surf; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimSurfaceInView::depthOffset() const +{ + return m_depthOffset; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -102,15 +115,25 @@ void RimSurfaceInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField const QVariant& oldValue, const QVariant& newValue ) { + bool scheduleRedraw = false; + if ( changedField == &m_isActive || changedField == &m_useSeparateDataSource || changedField == &m_separateDataSource ) { - RimGridView* ownerView; - this->firstAncestorOrThisOfTypeAsserted( ownerView ); - ownerView->scheduleCreateDisplayModelAndRedraw(); + scheduleRedraw = true; } else if ( changedField == &m_showInactiveCells ) { - m_surfacePartMgr = nullptr; + clearGeometry(); + scheduleRedraw = true; + } + else if ( changedField == &m_depthOffset ) + { + clearGeometry(); + scheduleRedraw = true; + } + + if ( scheduleRedraw ) + { RimGridView* ownerView; this->firstAncestorOrThisOfTypeAsserted( ownerView ); ownerView->scheduleCreateDisplayModelAndRedraw(); @@ -123,13 +146,29 @@ void RimSurfaceInView::fieldChangedByUi( const caf::PdmFieldHandle* changedField void RimSurfaceInView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) { uiOrdering.add( &m_name ); - uiOrdering.add( &m_showInactiveCells ); + uiOrdering.add( &m_depthOffset ); this->defineSeparateDataSourceUi( uiConfigName, uiOrdering ); } //-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSurfaceInView::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + auto doubleSliderAttrib = dynamic_cast( attribute ); + if ( doubleSliderAttrib ) + { + if ( field == &m_depthOffset ) + { + doubleSliderAttrib->m_minimum = -2000; + doubleSliderAttrib->m_maximum = 2000; + } + } +} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/Surfaces/RimSurfaceInView.h b/ApplicationCode/ProjectDataModel/Surfaces/RimSurfaceInView.h index a91307d238..eca8644026 100644 --- a/ApplicationCode/ProjectDataModel/Surfaces/RimSurfaceInView.h +++ b/ApplicationCode/ProjectDataModel/Surfaces/RimSurfaceInView.h @@ -43,9 +43,16 @@ public: RimSurface* surface() const; void setSurface( RimSurface* surf ); + double depthOffset() const; + void clearGeometry(); RivSurfacePartMgr* surfacePartMgr(); +protected: + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + private: virtual RimIntersectionResultsDefinitionCollection* findSeparateResultsCollection() override; @@ -56,5 +63,7 @@ private: caf::PdmProxyValueField m_name; caf::PdmPtrField m_surface; + caf::PdmField m_depthOffset; + cvf::ref m_surfacePartMgr; };