Polygonfilter updates2 (#7286)

* Make sure all contourmap copies are getting the correct case set for cell filters when creating/copying maps.

* Rewrite polyline part manager to be more generic, not just linked to annotations.
* Add new partmgr for cell filters to draw polygon filter outlines in both eclipse and geomech views
* Show lines/spheres for polygon filter outline
* Add color edit for line and spheres
* Add support for z plane lock in poygon filter outline
* Add new flags for enabling filter and/or polyline display

* Add K range filter to polygon filter

* Enable picking automatically when creating a new polygon filter
This commit is contained in:
jonjenssen
2021-01-26 13:08:21 +01:00
committed by GitHub
parent 4866794f2b
commit 05aceef936
32 changed files with 1218 additions and 348 deletions

View File

@@ -49,7 +49,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RivContourMapProjectionPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationsPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivTextAnnotationPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylineAnnotationPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.h
@@ -58,6 +57,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTextLabelSourceInfo.h
${CMAKE_CURRENT_LIST_DIR}/RivDiskGeometryGenerator.h
${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.h
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.h
)
set (SOURCE_GROUP_SOURCE_FILES
@@ -105,7 +106,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RivContourMapProjectionPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivAnnotationsPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivTextAnnotationPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylineAnnotationPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.cpp
@@ -114,6 +114,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTextLabelSourceInfo.cpp
${CMAKE_CURRENT_LIST_DIR}/RivDiskGeometryGenerator.cpp
${CMAKE_CURRENT_LIST_DIR}/RivWellDiskPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivElementVectorResultPartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivPolylinePartMgr.cpp
${CMAKE_CURRENT_LIST_DIR}/RivCellFilterPartMgr.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@@ -27,10 +27,12 @@
#include "RimPolylinesFromFileAnnotationInView.h"
#include "RimUserDefinedPolylinesAnnotationInView.h"
#include "RivPolylineAnnotationPartMgr.h"
#include "RivPolylinePartMgr.h"
#include "RivReachCircleAnnotationPartMgr.h"
#include "RivTextAnnotationPartMgr.h"
#include "cafPdmObject.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -113,12 +115,12 @@ void RivAnnotationsPartMgr::createAnnotationPartManagers()
{
for ( auto annotation : userDefinedPolylineAnnotations )
{
auto* apm = new RivPolylineAnnotationPartMgr( m_rimView, annotation );
auto* apm = new RivPolylinePartMgr( m_rimView, annotation, coll );
m_polylineAnnotationPartMgrs.push_back( apm );
}
for ( auto annotation : polylineFromFileAnnotations )
{
auto* apm = new RivPolylineAnnotationPartMgr( m_rimView, annotation );
auto* apm = new RivPolylinePartMgr( m_rimView, annotation, coll );
m_polylineAnnotationPartMgrs.push_back( apm );
}
}

View File

@@ -37,12 +37,9 @@ class DisplayCoordTransform;
}
class Rim3dView;
class RimAnnotationInViewCollection;
class RivTextAnnotationPartMgr;
class RivReachCircleAnnotationPartMgr;
class RivPolylineAnnotationPartMgr;
class RimSimWellInView;
class RimSimWellInViewCollection;
class RivPolylinePartMgr;
class RivAnnotationsPartMgr : public cvf::Object
{
@@ -63,5 +60,5 @@ private:
caf::PdmPointer<Rim3dView> m_rimView;
cvf::Collection<RivTextAnnotationPartMgr> m_textAnnotationPartMgrs;
cvf::Collection<RivReachCircleAnnotationPartMgr> m_reachCircleAnnotationPartMgrs;
cvf::Collection<RivPolylineAnnotationPartMgr> m_polylineAnnotationPartMgrs;
cvf::Collection<RivPolylinePartMgr> m_polylineAnnotationPartMgrs;
};

View File

@@ -0,0 +1,89 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivCellFilterPartMgr.h"
#include "Rim3dView.h"
#include "RimCellFilterCollection.h"
#include "RimPolygonFilter.h"
#include "RivPolylinePartMgr.h"
#include "cafPdmObject.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivCellFilterPartMgr::RivCellFilterPartMgr( Rim3dView* view )
: m_rimView( view )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivCellFilterPartMgr::~RivCellFilterPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCellFilterPartMgr::appendGeometryPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& boundingBox )
{
createCellFilterPartManagers();
for ( auto& partMgr : m_cellFilterPartMgrs )
{
partMgr->appendDynamicGeometryPartsToModel( model, displayCoordTransform, boundingBox );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCellFilterPartMgr::createCellFilterPartManagers()
{
std::vector<RimCellFilterCollection*> colls;
m_rimView->descendantsIncludingThisOfType( colls );
if ( colls.empty() ) return;
auto coll = colls.front();
clearGeometryCache();
for ( auto filter : coll->filters() )
{
RimPolygonFilter* polyFilter = dynamic_cast<RimPolygonFilter*>( filter );
if ( polyFilter )
{
RivPolylinePartMgr* ppm = new RivPolylinePartMgr( m_rimView, polyFilter, coll );
m_cellFilterPartMgrs.push_back( ppm );
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivCellFilterPartMgr::clearGeometryCache()
{
m_cellFilterPartMgrs.clear();
}

View File

@@ -0,0 +1,60 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2021 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmPointer.h"
#include "cvfAssert.h"
#include "cvfCollection.h"
#include "cvfObject.h"
namespace cvf
{
class BoundingBox;
class Part;
class ModelBasicList;
class Transform;
class Font;
} // namespace cvf
namespace caf
{
class DisplayCoordTransform;
}
class Rim3dView;
class RivPolylinePartMgr;
class RivCellFilterPartMgr : public cvf::Object
{
public:
RivCellFilterPartMgr( Rim3dView* view );
~RivCellFilterPartMgr() override;
void appendGeometryPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayCoordTransform,
const cvf::BoundingBox& boundingBox );
void clearGeometryCache();
private:
void createCellFilterPartManagers();
private:
caf::PdmPointer<Rim3dView> m_rimView;
cvf::Collection<RivPolylinePartMgr> m_cellFilterPartMgrs;
};

View File

@@ -26,19 +26,13 @@
#include "RiaPreferences.h"
#include "Rim3dView.h"
#include "RimAnnotationInViewCollection.h"
#include "RimMeasurement.h"
#include "RimPolylinesFromFileAnnotationInView.h"
#include "RimProject.h"
#include "RimUserDefinedPolylinesAnnotationInView.h"
#include "RiuGuiTheme.h"
#include "RivPartPriority.h"
#include "RivPolylineAnnotationPartMgr.h"
#include "RivPolylineGenerator.h"
#include "RivReachCircleAnnotationPartMgr.h"
#include "RivTextAnnotationPartMgr.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"

View File

@@ -1,285 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivPolylineAnnotationPartMgr.h"
#include "RiaBoundingBoxTools.h"
#include "RiaGuiApplication.h"
#include "Rim3dView.h"
#include "RimAnnotationCollection.h"
#include "RimAnnotationInViewCollection.h"
#include "RimAnnotationLineAppearance.h"
#include "RimEclipseView.h"
#include "RimPolylinesAnnotation.h"
#include "RimPolylinesAnnotationInView.h"
#include "RigMainGrid.h"
#include "RigPolyLinesData.h"
#include "RivPartPriority.h"
#include "RivPolylineGenerator.h"
#include "RivPolylinesAnnotationSourceInfo.h"
#include "cafEffectGenerator.h"
#include "cafDisplayCoordTransform.h"
#include "cvfDrawableGeo.h"
#include "cvfDrawableText.h"
#include "cvfDrawableVectors.h"
#include "cvfGeometryBuilderTriangles.h"
#include "cvfGeometryUtils.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfTransform.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivPolylineAnnotationPartMgr::RivPolylineAnnotationPartMgr( Rim3dView* view, RimPolylinesAnnotationInView* annotationInView )
: m_rimView( view )
, m_rimAnnotationInView( annotationInView )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivPolylineAnnotationPartMgr::~RivPolylineAnnotationPartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPolylineAnnotationPartMgr::buildPolylineAnnotationParts( const caf::DisplayCoordTransform* displayXf )
{
clearAllGeometry();
auto rimAnnotation = m_rimAnnotationInView->sourceAnnotation();
if ( !rimAnnotation->isEmpty() && rimAnnotation->isActive() )
{
auto lineColor = rimAnnotation->appearance()->color();
auto isDashedLine = rimAnnotation->appearance()->isDashed();
auto lineThickness = rimAnnotation->appearance()->thickness();
auto* collection = annotationCollection();
if ( !collection ) return;
auto linesInDomain = getPolylinesPointsInDomain( collection->snapAnnotations(), collection->annotationPlaneZ() );
auto linesInDisplay = transformPolylinesPointsToDisplay( linesInDomain, displayXf );
// Line part
if ( rimAnnotation->showLines() )
{
cvf::ref<cvf::DrawableGeo> drawableGeo =
RivPolylineGenerator::createLineAlongPolylineDrawable( linesInDisplay, rimAnnotation->closePolyline() );
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "RivPolylineAnnotationPartMgr" );
part->setDrawable( drawableGeo.p() );
caf::MeshEffectGenerator effgen( lineColor );
effgen.setLineWidth( lineThickness );
if ( isDashedLine ) effgen.setLineStipple( true );
cvf::ref<cvf::Effect> eff = effgen.generateCachedEffect();
part->setEffect( eff.p() );
part->setPriority( RivPartPriority::PartType::MeshLines );
cvf::ref<RivPolylinesAnnotationSourceInfo> sourceInfo = new RivPolylinesAnnotationSourceInfo( rimAnnotation );
part->setSourceInfo( sourceInfo.p() );
m_linePart = part;
}
// Sphere part
if ( rimAnnotation->showSpheres() )
{
auto sphereColor = rimAnnotation->appearance()->sphereColor();
double sphereRadiusFactor = rimAnnotation->appearance()->sphereRadiusFactor();
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
cvf::ref<cvf::Vec3fArray> vecRes = new cvf::Vec3fArray;
cvf::ref<cvf::Color3fArray> colors = new cvf::Color3fArray;
size_t pointCount = 0;
for ( const auto& line : linesInDisplay )
pointCount += line.size();
vertices->reserve( pointCount );
vecRes->reserve( pointCount );
colors->reserve( pointCount );
for ( const auto& line : linesInDisplay )
{
for ( const auto& v : line )
{
vertices->add( cvf::Vec3f( v ) );
vecRes->add( cvf::Vec3f::X_AXIS );
colors->add( sphereColor );
}
}
cvf::ref<cvf::DrawableVectors> vectorDrawable;
if ( RiaGuiApplication::instance()->useShaders() )
{
// NOTE: Drawable vectors must be rendered using shaders when the rest of the application is rendered
// using shaders Drawing vectors using fixed function when rest of the application uses shaders causes
// visual artifacts
vectorDrawable = new cvf::DrawableVectors( "u_transformationMatrix", "u_color" );
}
else
{
vectorDrawable = new cvf::DrawableVectors();
}
vectorDrawable->setVectors( vertices.p(), vecRes.p() );
vectorDrawable->setColors( colors.p() );
cvf::GeometryBuilderTriangles builder;
double cellRadius = 15.0;
auto eclipseView = dynamic_cast<RimEclipseView*>( m_rimView.p() );
if ( eclipseView )
{
double characteristicCellSize = eclipseView->mainGrid()->characteristicIJCellSize();
cellRadius = sphereRadiusFactor * characteristicCellSize;
}
cvf::GeometryUtils::createSphere( cellRadius, 15, 15, &builder );
vectorDrawable->setGlyph( builder.trianglesUShort().p(), builder.vertices().p() );
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "RivPolylineAnnotationPartMgr" );
part->setDrawable( vectorDrawable.p() );
part->setEffect( new cvf::Effect() );
part->setPriority( RivPartPriority::PartType::MeshLines );
cvf::ref<RivPolylinesAnnotationSourceInfo> sourceInfo = new RivPolylinesAnnotationSourceInfo( rimAnnotation );
part->setSourceInfo( sourceInfo.p() );
m_spherePart = part;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<RivPolylineAnnotationPartMgr::Vec3d>>
RivPolylineAnnotationPartMgr::getPolylinesPointsInDomain( bool snapToPlaneZ, double planeZ )
{
auto polylines = m_rimAnnotationInView->sourceAnnotation()->polyLinesData()->polyLines();
if ( !snapToPlaneZ ) return polylines;
std::vector<std::vector<Vec3d>> polylinesInDisplay;
for ( const auto& pts : polylines )
{
std::vector<Vec3d> polyline;
for ( const auto& pt : pts )
{
auto ptInDisp = pt;
ptInDisp.z() = planeZ;
polyline.push_back( ptInDisp );
}
polylinesInDisplay.push_back( polyline );
}
return polylinesInDisplay;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>>
RivPolylineAnnotationPartMgr::transformPolylinesPointsToDisplay( const std::vector<std::vector<Vec3d>>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf )
{
std::vector<std::vector<Vec3d>> pointsInDisplay;
for ( const auto& pts : pointsInDomain )
{
std::vector<cvf::Vec3d> displayCoords = displayXf->transformToDisplayCoords( pts );
pointsInDisplay.push_back( displayCoords );
}
return pointsInDisplay;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivPolylineAnnotationPartMgr::isPolylinesInBoundingBox( const cvf::BoundingBox& boundingBox )
{
auto coll = annotationCollection();
if ( !coll ) return false;
auto effectiveBoundingBox = RiaBoundingBoxTools::inflate( boundingBox, 3 );
for ( const auto& pts : getPolylinesPointsInDomain( coll->snapAnnotations(), coll->annotationPlaneZ() ) )
{
for ( const auto& pt : pts )
{
if ( effectiveBoundingBox.contains( pt ) ) return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPolylineAnnotationPartMgr::clearAllGeometry()
{
m_linePart = nullptr;
m_spherePart = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationInViewCollection* RivPolylineAnnotationPartMgr::annotationCollection() const
{
std::vector<RimAnnotationInViewCollection*> colls;
m_rimView->descendantsIncludingThisOfType( colls );
return !colls.empty() ? colls.front() : nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPolylineAnnotationPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayXf,
const cvf::BoundingBox& boundingBox )
{
auto rimAnnotation = m_rimAnnotationInView->sourceAnnotation();
if ( !rimAnnotation ) return;
if ( rimAnnotation->isEmpty() ) return;
if ( !m_rimAnnotationInView->isVisible() ) return;
// Check bounding box
if ( !isPolylinesInBoundingBox( boundingBox ) ) return;
buildPolylineAnnotationParts( displayXf );
if ( m_linePart.notNull() )
{
model->addPart( m_linePart.p() );
}
if ( m_spherePart.notNull() )
{
model->addPart( m_spherePart.p() );
}
}

View File

@@ -0,0 +1,274 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2018- Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RivPolylinePartMgr.h"
#include "RiaBoundingBoxTools.h"
#include "RiaGuiApplication.h"
#include "Rim3dView.h"
#include "RimEclipseView.h"
#include "RimPolylinesDataInterface.h"
#include "RigMainGrid.h"
#include "RigPolyLinesData.h"
#include "RivPartPriority.h"
#include "RivPolylineGenerator.h"
#include "cafEffectGenerator.h"
#include "cafDisplayCoordTransform.h"
#include "cvfDrawableGeo.h"
#include "cvfDrawableText.h"
#include "cvfDrawableVectors.h"
#include "cvfGeometryBuilderTriangles.h"
#include "cvfGeometryUtils.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfTransform.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivPolylinePartMgr::RivPolylinePartMgr( Rim3dView* view,
RimPolylinesDataInterface* polylineInterface,
caf::PdmObject* collection )
: m_rimView( view )
, m_polylineInterface( polylineInterface )
, m_viewCollection( collection )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivPolylinePartMgr::~RivPolylinePartMgr()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivPolylinePartMgr::isPolylinesInBoundingBox( std::vector<std::vector<cvf::Vec3d>> polyline,
const cvf::BoundingBox& boundingBox )
{
auto effectiveBoundingBox = RiaBoundingBoxTools::inflate( boundingBox, 3 );
for ( const auto& pts : polyline )
{
for ( const auto& pt : pts )
{
if ( effectiveBoundingBox.contains( pt ) ) return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPolylinePartMgr::buildPolylineParts( const caf::DisplayCoordTransform* displayXf,
const cvf::BoundingBox& boundingBox )
{
auto polylineDef = m_polylineInterface->polyLinesData();
if ( polylineDef.isNull() || polylineDef->polyLines().size() == 0 )
{
clearAllGeometry();
return;
}
auto linesInDomain = getPolylinesPointsInDomain( polylineDef->lockToZPlane(), polylineDef->lockedZValue() );
if ( !isPolylinesInBoundingBox( linesInDomain, boundingBox ) ) return;
auto linesInDisplay = transformPolylinesPointsToDisplay( linesInDomain, displayXf );
clearAllGeometry();
// Line part
if ( polylineDef->showLines() )
{
cvf::ref<cvf::DrawableGeo> drawableGeo =
RivPolylineGenerator::createLineAlongPolylineDrawable( linesInDisplay, polylineDef->closePolyline() );
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "RivPolylinePartMgr" );
part->setDrawable( drawableGeo.p() );
caf::MeshEffectGenerator effgen( polylineDef->lineColor() );
effgen.setLineWidth( polylineDef->lineThickness() );
// if ( isDashedLine ) effgen.setLineStipple( true );
cvf::ref<cvf::Effect> eff = effgen.generateCachedEffect();
part->setEffect( eff.p() );
part->setPriority( RivPartPriority::PartType::MeshLines );
m_linePart = part;
}
// Sphere part
if ( polylineDef->showSpheres() )
{
auto sphereColor = polylineDef->sphereColor();
double sphereRadiusFactor = polylineDef->sphereRadiusFactor();
cvf::ref<cvf::Vec3fArray> vertices = new cvf::Vec3fArray;
cvf::ref<cvf::Vec3fArray> vecRes = new cvf::Vec3fArray;
cvf::ref<cvf::Color3fArray> colors = new cvf::Color3fArray;
size_t pointCount = 0;
for ( const auto& line : linesInDisplay )
pointCount += line.size();
vertices->reserve( pointCount );
vecRes->reserve( pointCount );
colors->reserve( pointCount );
for ( const auto& line : linesInDisplay )
{
for ( const auto& v : line )
{
vertices->add( cvf::Vec3f( v ) );
vecRes->add( cvf::Vec3f::X_AXIS );
colors->add( sphereColor );
}
}
cvf::ref<cvf::DrawableVectors> vectorDrawable;
if ( RiaGuiApplication::instance()->useShaders() )
{
// NOTE: Drawable vectors must be rendered using shaders when the rest of the application is rendered
// using shaders Drawing vectors using fixed function when rest of the application uses shaders causes
// visual artifacts
vectorDrawable = new cvf::DrawableVectors( "u_transformationMatrix", "u_color" );
}
else
{
vectorDrawable = new cvf::DrawableVectors();
}
vectorDrawable->setVectors( vertices.p(), vecRes.p() );
vectorDrawable->setColors( colors.p() );
double cellRadius = 15.0;
auto eclipseView = dynamic_cast<RimEclipseView*>( m_rimView.p() );
if ( eclipseView )
{
double characteristicCellSize = eclipseView->mainGrid()->characteristicIJCellSize();
cellRadius = sphereRadiusFactor * characteristicCellSize;
}
cvf::GeometryBuilderTriangles builder;
cvf::GeometryUtils::createSphere( cellRadius, 15, 15, &builder );
vectorDrawable->setGlyph( builder.trianglesUShort().p(), builder.vertices().p() );
cvf::ref<cvf::Part> part = new cvf::Part;
part->setName( "RivPolylinePartMgr" );
part->setDrawable( vectorDrawable.p() );
part->setEffect( new cvf::Effect() );
part->setPriority( RivPartPriority::PartType::MeshLines );
m_spherePart = part;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>> RivPolylinePartMgr::getPolylinesPointsInDomain( bool snapToPlaneZ, double planeZ )
{
auto polylines = m_polylineInterface->polyLinesData()->polyLines();
if ( !snapToPlaneZ ) return polylines;
std::vector<std::vector<cvf::Vec3d>> polylinesInDisplay;
for ( const auto& pts : polylines )
{
std::vector<cvf::Vec3d> polyline;
for ( const auto& pt : pts )
{
auto ptInDisp = pt;
ptInDisp.z() = planeZ;
polyline.push_back( ptInDisp );
}
polylinesInDisplay.push_back( polyline );
}
return polylinesInDisplay;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::vector<cvf::Vec3d>>
RivPolylinePartMgr::transformPolylinesPointsToDisplay( const std::vector<std::vector<cvf::Vec3d>>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf )
{
std::vector<std::vector<cvf::Vec3d>> pointsInDisplay;
for ( const auto& pts : pointsInDomain )
{
std::vector<cvf::Vec3d> displayCoords = displayXf->transformToDisplayCoords( pts );
pointsInDisplay.push_back( displayCoords );
}
return pointsInDisplay;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPolylinePartMgr::clearAllGeometry()
{
m_linePart = nullptr;
m_spherePart = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivPolylinePartMgr::collectionVisible()
{
if ( m_viewCollection && m_viewCollection->objectToggleField() )
{
caf::PdmField<bool>* field = dynamic_cast<caf::PdmField<bool>*>( m_viewCollection->objectToggleField() );
return field->value();
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivPolylinePartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayXf,
const cvf::BoundingBox& boundingBox )
{
if ( !collectionVisible() ) return;
// build the lines
buildPolylineParts( displayXf, boundingBox );
// add the things we should
if ( m_linePart.notNull() )
{
model->addPart( m_linePart.p() );
}
if ( m_spherePart.notNull() )
{
model->addPart( m_spherePart.p() );
}
}

View File

@@ -22,6 +22,7 @@
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
#include <vector>
@@ -34,41 +35,41 @@ class ModelBasicList;
class Transform;
class Font;
} // namespace cvf
namespace caf
{
class DisplayCoordTransform;
}
class Rim3dView;
class RimPolylinesAnnotationInView;
class RimAnnotationInViewCollection;
class RimPolylinesDataInterface;
class RivPolylineAnnotationPartMgr : public cvf::Object
class RivPolylinePartMgr : public cvf::Object
{
using Vec3d = cvf::Vec3d;
public:
RivPolylineAnnotationPartMgr( Rim3dView* view, RimPolylinesAnnotationInView* annotation );
~RivPolylineAnnotationPartMgr() override;
RivPolylinePartMgr( Rim3dView* view, RimPolylinesDataInterface* polylines, caf::PdmObject* collection );
~RivPolylinePartMgr() override;
void appendDynamicGeometryPartsToModel( cvf::ModelBasicList* model,
const caf::DisplayCoordTransform* displayXf,
const cvf::BoundingBox& boundingBox );
private:
void buildPolylineAnnotationParts( const caf::DisplayCoordTransform* displayXf );
bool isPolylinesInBoundingBox( std::vector<std::vector<cvf::Vec3d>> polyline, const cvf::BoundingBox& boundingBox );
void buildPolylineParts( const caf::DisplayCoordTransform* displayXf, const cvf::BoundingBox& boundingBox );
std::vector<std::vector<Vec3d>> getPolylinesPointsInDomain( bool snapToPlaneZ, double planeZ );
std::vector<std::vector<Vec3d>> transformPolylinesPointsToDisplay( const std::vector<std::vector<Vec3d>>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf );
std::vector<std::vector<cvf::Vec3d>> getPolylinesPointsInDomain( bool snapToPlaneZ, double planeZ );
std::vector<std::vector<cvf::Vec3d>>
transformPolylinesPointsToDisplay( const std::vector<std::vector<cvf::Vec3d>>& pointsInDomain,
const caf::DisplayCoordTransform* displayXf );
bool isPolylinesInBoundingBox( const cvf::BoundingBox& boundingBox );
bool collectionVisible();
void clearAllGeometry();
RimAnnotationInViewCollection* annotationCollection() const;
void clearAllGeometry();
caf::PdmPointer<Rim3dView> m_rimView;
caf::PdmPointer<RimPolylinesAnnotationInView> m_rimAnnotationInView;
cvf::ref<cvf::Part> m_linePart;
cvf::ref<cvf::Part> m_spherePart;
RimPolylinesDataInterface* m_polylineInterface;
caf::PdmObject* m_viewCollection;
caf::PdmPointer<Rim3dView> m_rimView;
cvf::ref<cvf::Part> m_linePart;
cvf::ref<cvf::Part> m_spherePart;
};