mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Add annotation label support to surface intersection lines
This commit is contained in:
@@ -32,6 +32,8 @@
|
||||
#include "RigSurfaceResampler.h"
|
||||
#include "RigTexturedSection.h"
|
||||
|
||||
#include "RivAnnotationSourceInfo.h"
|
||||
#include "RivObjectSourceInfo.h"
|
||||
#include "RivPartPriority.h"
|
||||
#include "RivPolylineGenerator.h"
|
||||
#include "RivPolylinePartMgr.h"
|
||||
@@ -213,19 +215,22 @@ void RivSeismicSectionPartMgr::appendSurfaceIntersectionLines( cvf::ModelBasicLi
|
||||
surface->loadDataIfRequired();
|
||||
if ( !surface->surfaceData() ) continue;
|
||||
|
||||
std::vector<cvf::Vec3d> completePolyLine;
|
||||
cvf::Part* firstPart = nullptr;
|
||||
|
||||
auto texSection = m_section->texturedSection();
|
||||
for ( int i = 0; i < texSection->partsCount(); i++ )
|
||||
{
|
||||
const auto& texturePart = texSection->part( i );
|
||||
|
||||
std::vector<cvf::Vec3d> polyLine;
|
||||
std::vector<cvf::Vec3d> polyLineForSection;
|
||||
|
||||
// Each part of the seismic section is a rectangle, use two corners of the rectangle to create a polyline
|
||||
polyLine.push_back( texturePart.rect[0] );
|
||||
polyLine.push_back( texturePart.rect[1] );
|
||||
polyLineForSection.push_back( texturePart.rect[0] );
|
||||
polyLineForSection.push_back( texturePart.rect[1] );
|
||||
|
||||
bool closePolyLine = false;
|
||||
auto polyLineDisplayCoords = projectPolyLineOntoSurface( polyLine, surface, displayCoordTransform );
|
||||
auto polyLineDisplayCoords = projectPolyLineOntoSurface( polyLineForSection, surface, displayCoordTransform );
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> drawableGeo =
|
||||
RivPolylineGenerator::createLineAlongPolylineDrawable( polyLineDisplayCoords, closePolyLine );
|
||||
@@ -251,6 +256,24 @@ void RivSeismicSectionPartMgr::appendSurfaceIntersectionLines( cvf::ModelBasicLi
|
||||
part->setPriority( RivPartPriority::PartType::MeshLines );
|
||||
|
||||
model->addPart( part.p() );
|
||||
|
||||
if ( !firstPart ) firstPart = part.p();
|
||||
for ( const auto& coords : polyLineDisplayCoords )
|
||||
{
|
||||
completePolyLine.insert( completePolyLine.end(), coords.begin(), coords.end() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( firstPart )
|
||||
{
|
||||
// Add annotation info to be used to display label in Rim3dView::onViewNavigationChanged()
|
||||
// Set the source info on one part only, as this data is only used for display of labels
|
||||
auto annoObj = new RivAnnotationSourceInfo( surface->fullName().toStdString(), completePolyLine );
|
||||
annoObj->setLabelPositionStrategyHint( RivAnnotationTools::LabelPositionStrategy::RIGHT );
|
||||
annoObj->setShowColor( true );
|
||||
annoObj->setColor( surface->color() );
|
||||
|
||||
firstPart->setSourceInfo( annoObj );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,14 @@ Rim3dView::Rim3dView()
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_fontSize, "FontSize", "Font Size" );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_annotationStrategy, "AnnotationStrategy", "Annotation Strategy" );
|
||||
CAF_PDM_InitField( &m_annotationCountHint, "AnnotationCountHint", 5, "Annotation Count Hint" );
|
||||
CAF_PDM_InitField( &m_useCustomAnnotationStrategy,
|
||||
"UseCustomAnnotationStrategy",
|
||||
false,
|
||||
"Use Custom Annotation Strategy",
|
||||
"Specify the strategy to be applied on all screen space annotations." );
|
||||
|
||||
m_seismicVizModel = new cvf::ModelBasicList;
|
||||
m_seismicVizModel->setName( "SeismicSectionModel" );
|
||||
|
||||
@@ -509,6 +517,14 @@ void Rim3dView::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOr
|
||||
gridGroup->add( &meshMode );
|
||||
gridGroup->add( &surfaceMode );
|
||||
|
||||
caf::PdmUiGroup* annotationGroup = uiOrdering.addNewGroup( "Annotations" );
|
||||
annotationGroup->add( &m_useCustomAnnotationStrategy );
|
||||
annotationGroup->add( &m_annotationStrategy );
|
||||
annotationGroup->add( &m_annotationCountHint );
|
||||
m_annotationStrategy.uiCapability()->setUiReadOnly( !m_useCustomAnnotationStrategy );
|
||||
m_annotationCountHint.uiCapability()->setUiReadOnly(
|
||||
!m_useCustomAnnotationStrategy || ( m_annotationStrategy() != RivAnnotationTools::LabelPositionStrategy::COUNT_HINT ) );
|
||||
|
||||
uiOrdering.skipRemainingFields( true );
|
||||
}
|
||||
|
||||
@@ -678,6 +694,8 @@ void Rim3dView::updateDisplayModelForCurrentTimeStepAndRedraw()
|
||||
restoreComparisonView();
|
||||
}
|
||||
|
||||
updateScreenSpaceModel();
|
||||
|
||||
nativeOrOverrideViewer()->update();
|
||||
}
|
||||
|
||||
@@ -742,6 +760,8 @@ void Rim3dView::createDisplayModelAndRedraw()
|
||||
viewer()->setMainScene( nullptr, true );
|
||||
viewer()->removeAllFrames( true );
|
||||
}
|
||||
|
||||
updateScreenSpaceModel();
|
||||
}
|
||||
|
||||
if ( RiuMainWindow::instance() )
|
||||
@@ -899,6 +919,14 @@ bool Rim3dView::isLightingDisabled() const
|
||||
return m_disableLighting();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::onViewNavigationChanged()
|
||||
{
|
||||
updateScreenSpaceModel();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1022,6 +1050,14 @@ void Rim3dView::fieldChangedByUi( const caf::PdmFieldHandle* changedField, const
|
||||
{
|
||||
createDisplayModelAndRedraw();
|
||||
}
|
||||
else if ( changedField == &m_annotationCountHint || changedField == &m_annotationStrategy || changedField == &m_useCustomAnnotationStrategy )
|
||||
{
|
||||
if ( m_viewer )
|
||||
{
|
||||
updateScreenSpaceModel();
|
||||
m_viewer->update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -1637,6 +1673,36 @@ void Rim3dView::appendAnnotationsToModel()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void Rim3dView::updateScreenSpaceModel()
|
||||
{
|
||||
if ( !m_viewer || !m_viewer->mainCamera() ) return;
|
||||
|
||||
if ( m_screenSpaceModel.isNull() )
|
||||
{
|
||||
m_screenSpaceModel = new cvf::ModelBasicList;
|
||||
m_screenSpaceModel->setName( "ScreenSpaceModel" );
|
||||
}
|
||||
m_screenSpaceModel->removeAllParts();
|
||||
|
||||
// Build annotation parts and put into screen space model
|
||||
cvf::Collection<cvf::Part> partCollection;
|
||||
m_viewer->currentScene()->allParts( &partCollection );
|
||||
|
||||
RivAnnotationTools annoTool;
|
||||
if ( m_useCustomAnnotationStrategy )
|
||||
{
|
||||
annoTool.setOverrideLabelPositionStrategy( m_annotationStrategy() );
|
||||
annoTool.setCountHint( m_annotationCountHint() );
|
||||
}
|
||||
|
||||
annoTool.addAnnotationLabels( partCollection, m_viewer->mainCamera(), m_screenSpaceModel.p() );
|
||||
|
||||
nativeOrOverrideViewer()->addStaticModelOnce( m_screenSpaceModel.p(), isUsingOverrideViewer() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -19,10 +19,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "RiaDefines.h"
|
||||
|
||||
#include "RimNameConfig.h"
|
||||
#include "RimViewWindow.h"
|
||||
|
||||
#include "RiuViewerToViewInterface.h"
|
||||
|
||||
#include "RivAnnotationTools.h"
|
||||
#include "RivCellSetEnum.h"
|
||||
|
||||
#include "cafAppEnum.h"
|
||||
@@ -247,6 +250,8 @@ protected:
|
||||
|
||||
virtual cvf::Transform* scaleTransform() = 0;
|
||||
|
||||
void onViewNavigationChanged() override;
|
||||
|
||||
protected:
|
||||
caf::PdmFieldHandle* userDescriptionField() override;
|
||||
caf::PdmFieldHandle* backgroundColorField();
|
||||
@@ -272,6 +277,7 @@ protected:
|
||||
cvf::ref<cvf::ModelBasicList> m_seismicVizModel;
|
||||
cvf::ref<RivWellPathsPartMgr> m_wellPathsPartManager;
|
||||
cvf::ref<cvf::ModelBasicList> m_highlightVizModel;
|
||||
cvf::ref<cvf::ModelBasicList> m_screenSpaceModel;
|
||||
|
||||
caf::PdmField<double> m_scaleZ;
|
||||
caf::PdmField<double> m_customScaleZ;
|
||||
@@ -306,6 +312,7 @@ private:
|
||||
void appendMeasurementToModel();
|
||||
void appendCellFiltersToModel();
|
||||
void appendAnnotationsToModel();
|
||||
void updateScreenSpaceModel();
|
||||
|
||||
// Pure private methods : Override viewer and comparison view
|
||||
|
||||
@@ -332,6 +339,10 @@ private:
|
||||
caf::PdmField<bool> m_showZScaleLabel;
|
||||
caf::PdmPtrField<Rim3dView*> m_comparisonView;
|
||||
|
||||
caf::PdmField<bool> m_useCustomAnnotationStrategy;
|
||||
caf::PdmField<caf::AppEnum<RivAnnotationTools::LabelPositionStrategy>> m_annotationStrategy;
|
||||
caf::PdmField<int> m_annotationCountHint;
|
||||
|
||||
caf::PdmField<caf::FontTools::RelativeSizeEnum> m_fontSize;
|
||||
|
||||
// 3D display model data
|
||||
|
||||
Reference in New Issue
Block a user