mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#3777 Annotations. Use Bounding box to decide whether to draw an object or not
This commit is contained in:
@@ -38,6 +38,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaGitDiff.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaQIconTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaFieldHandleTools.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaBoundingBoxTools.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -76,6 +77,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaGitDiff.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaQIconTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaCellDividingTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaFieldHandleTools.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RiaBoundingBoxTools.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
34
ApplicationCode/Application/Tools/RiaBoundingBoxTools.cpp
Normal file
34
ApplicationCode/Application/Tools/RiaBoundingBoxTools.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
// 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 "RiaBoundingBoxTools.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::BoundingBox RiaBoundingBoxTools::inflate(const cvf::BoundingBox& boundingBox, double factor)
|
||||
{
|
||||
cvf::Vec3d center = boundingBox.center();
|
||||
cvf::Vec3d sizes = boundingBox.extent() * factor;
|
||||
|
||||
cvf::Vec3d newMin(center.x() - sizes.x() / 2.0, center.y() - sizes.y() / 2.0, center.z() - sizes.z() / 2.0);
|
||||
cvf::Vec3d newMax(center.x() + sizes.x() / 2.0, center.y() + sizes.y() / 2.0, center.z() + sizes.z() / 2.0);
|
||||
return cvf::BoundingBox(newMin, newMax);
|
||||
}
|
||||
34
ApplicationCode/Application/Tools/RiaBoundingBoxTools.h
Normal file
34
ApplicationCode/Application/Tools/RiaBoundingBoxTools.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2011- Statoil ASA
|
||||
// Copyright (C) 2013- Ceetron Solutions AS
|
||||
// Copyright (C) 2011-2012 Ceetron AS
|
||||
//
|
||||
// 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 <cvfBoundingBox.h>
|
||||
|
||||
//==================================================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==================================================================================================
|
||||
class RiaBoundingBoxTools
|
||||
{
|
||||
public:
|
||||
static cvf::BoundingBox inflate(const cvf::BoundingBox& boundingBox, double factor);
|
||||
};
|
||||
@@ -52,21 +52,22 @@ RivAnnotationsPartMgr::~RivAnnotationsPartMgr()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivAnnotationsPartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform)
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::BoundingBox& boundingBox)
|
||||
{
|
||||
createAnnotationPartManagers();
|
||||
|
||||
for (auto& partMgr : m_textAnnotationPartMgrs)
|
||||
{
|
||||
partMgr->appendDynamicGeometryPartsToModel(model, displayCoordTransform);
|
||||
partMgr->appendDynamicGeometryPartsToModel(model, displayCoordTransform, boundingBox);
|
||||
}
|
||||
for (auto& partMgr : m_reachCircleAnnotationPartMgrs)
|
||||
{
|
||||
partMgr->appendDynamicGeometryPartsToModel(model, displayCoordTransform);
|
||||
partMgr->appendDynamicGeometryPartsToModel(model, displayCoordTransform, boundingBox);
|
||||
}
|
||||
for (auto& partMgr : m_polylineAnnotationPartMgrs)
|
||||
{
|
||||
partMgr->appendDynamicGeometryPartsToModel(model, displayCoordTransform);
|
||||
partMgr->appendDynamicGeometryPartsToModel(model, displayCoordTransform, boundingBox);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ public:
|
||||
~RivAnnotationsPartMgr() override;
|
||||
|
||||
void appendGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayCoordTransform);
|
||||
const caf::DisplayCoordTransform* displayCoordTransform,
|
||||
const cvf::BoundingBox& boundingBox);
|
||||
|
||||
void clearGeometryCache();
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include "RivPolylineAnnotationPartMgr.h"
|
||||
|
||||
#include "RiaBoundingBoxTools.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimAnnotationCollection.h"
|
||||
#include "RimPolylinesAnnotation.h"
|
||||
@@ -65,27 +67,17 @@ void RivPolylineAnnotationPartMgr::buildPolylineAnnotationParts(const caf::Displ
|
||||
|
||||
if (!m_rimAnnotation->isEmpty() && m_rimAnnotation->isActive())
|
||||
{
|
||||
const auto& pointsInDomain = m_rimAnnotation->polyLinesData();
|
||||
auto lineColor = m_rimAnnotation->appearance()->color();
|
||||
auto isDashedLine = m_rimAnnotation->appearance()->isDashed();
|
||||
auto lineThickness = m_rimAnnotation->appearance()->thickness();
|
||||
|
||||
auto linesInDisplayCoords = pointsInDomain->polyLines();
|
||||
auto* collection = annotationCollection();
|
||||
if (!collection) return;
|
||||
|
||||
for (auto& line : linesInDisplayCoords)
|
||||
{
|
||||
for ( cvf::Vec3d& point : line)
|
||||
{
|
||||
if (collection && collection->snapAnnotations())
|
||||
{
|
||||
point.z() = collection->annotationPlaneZ();
|
||||
}
|
||||
point = displayXf->transformToDisplayCoord(point);
|
||||
}
|
||||
}
|
||||
auto linesInDomain = getPolylinesPointsInDomain(collection->snapAnnotations(), collection->annotationPlaneZ());
|
||||
auto linesInDisplay = transformPolylinesPointsToDisplay(linesInDomain, displayXf);
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(linesInDisplayCoords);
|
||||
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(linesInDisplay);
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
//part->setName("RivAnnotationPartMgr: text " + cvfString);
|
||||
part->setDrawable(drawableGeo.p());
|
||||
@@ -105,6 +97,70 @@ void RivPolylineAnnotationPartMgr::buildPolylineAnnotationParts(const caf::Displ
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::vector<RivPolylineAnnotationPartMgr::Vec3d>>
|
||||
RivPolylineAnnotationPartMgr::getPolylinesPointsInDomain(bool snapToPlaneZ, double planeZ)
|
||||
{
|
||||
auto polylines = m_rimAnnotation->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<Vec3d> polyline;
|
||||
for (const auto& pt : pts)
|
||||
{
|
||||
polyline.push_back(displayXf->transformToDisplayCoord(pt));
|
||||
}
|
||||
pointsInDisplay.push_back(polyline);
|
||||
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -127,11 +183,15 @@ RimAnnotationInViewCollection* RivPolylineAnnotationPartMgr::annotationCollectio
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivPolylineAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform * displayXf)
|
||||
const caf::DisplayCoordTransform * displayXf,
|
||||
const cvf::BoundingBox& boundingBox)
|
||||
{
|
||||
if (m_rimAnnotation.isNull()) return;
|
||||
if (m_rimAnnotation->isEmpty()) return;
|
||||
|
||||
// Check bounding box
|
||||
if (!isPolylinesInBoundingBox(boundingBox)) return;
|
||||
|
||||
buildPolylineAnnotationParts(displayXf);
|
||||
|
||||
if ( m_part.notNull() )
|
||||
|
||||
@@ -21,10 +21,15 @@
|
||||
#include "cvfBase.h"
|
||||
#include "cvfAssert.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class BoundingBox;
|
||||
class Part;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
@@ -42,14 +47,23 @@ class RimAnnotationInViewCollection;
|
||||
|
||||
class RivPolylineAnnotationPartMgr : public cvf::Object
|
||||
{
|
||||
using Vec3d = cvf::Vec3d;
|
||||
|
||||
public:
|
||||
RivPolylineAnnotationPartMgr(Rim3dView* view, RimPolylinesAnnotation* annotation);
|
||||
~RivPolylineAnnotationPartMgr() override;
|
||||
|
||||
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform * displayXf);
|
||||
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform * displayXf,
|
||||
const cvf::BoundingBox& boundingBox);
|
||||
private:
|
||||
void buildPolylineAnnotationParts(const caf::DisplayCoordTransform* displayXf);
|
||||
void buildPolylineAnnotationParts(const caf::DisplayCoordTransform* displayXf);
|
||||
|
||||
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);
|
||||
|
||||
bool isPolylinesInBoundingBox(const cvf::BoundingBox& boundingBox);
|
||||
|
||||
void clearAllGeometry();
|
||||
RimAnnotationInViewCollection* annotationCollection() const;
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "RivReachCircleAnnotationPartMgr.h"
|
||||
|
||||
#include "RiaBoundingBoxTools.h"
|
||||
|
||||
#include "Rim3dView.h"
|
||||
#include "RimAnnotationInViewCollection.h"
|
||||
#include "RimReachCircleAnnotation.h"
|
||||
@@ -66,31 +68,16 @@ void RivReachCircleAnnotationPartMgr::buildParts(const caf::DisplayCoordTransfor
|
||||
|
||||
Vec3d centerPositionInDomain = m_rimAnnotation->centerPoint();
|
||||
|
||||
{
|
||||
auto* collection = annotationCollection();
|
||||
if (collection && collection->snapAnnotations())
|
||||
{
|
||||
centerPositionInDomain.z() = collection->annotationPlaneZ();
|
||||
}
|
||||
}
|
||||
|
||||
Vec3d centerPosition = displayXf->transformToDisplayCoord(centerPositionInDomain);
|
||||
double radius = m_rimAnnotation->radius();
|
||||
auto lineColor = m_rimAnnotation->appearance()->color();
|
||||
auto isDashedLine = m_rimAnnotation->appearance()->isDashed();
|
||||
auto lineThickness = m_rimAnnotation->appearance()->thickness();
|
||||
|
||||
// Circle part
|
||||
auto* collection = annotationCollection();
|
||||
if(collection)
|
||||
{
|
||||
int numPoints = 36;
|
||||
std::vector<Vec3d> points;
|
||||
for (int i = 0; i < numPoints; i++)
|
||||
{
|
||||
double rad = 2 * cvf::PI_D * (double)i / (double)numPoints;
|
||||
Vec3d pt(centerPosition.x() + cos(rad) * radius, centerPosition.y() + sin(rad) * radius , centerPosition.z());
|
||||
points.push_back(pt);
|
||||
}
|
||||
points.push_back(points.front());
|
||||
std::vector<Vec3d> pointsInDomain = computeCirclePointsInDomain(collection->snapAnnotations(), collection->annotationPlaneZ());
|
||||
std::vector<Vec3d> points = transformCirclePointsToDisplay(pointsInDomain, displayXf);
|
||||
|
||||
cvf::ref<cvf::DrawableGeo> drawableGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(points);
|
||||
|
||||
@@ -99,7 +86,7 @@ void RivReachCircleAnnotationPartMgr::buildParts(const caf::DisplayCoordTransfor
|
||||
|
||||
caf::MeshEffectGenerator effgen(lineColor);
|
||||
effgen.setLineWidth(lineThickness);
|
||||
if (isDashedLine) effgen.setLineStipple(true);
|
||||
if (isDashedLine) effgen.setLineStipple(true); // Currently, dashed lines are not supported
|
||||
cvf::ref<cvf::Effect> eff = effgen.generateUnCachedEffect();
|
||||
|
||||
part->setEffect(eff.p());
|
||||
@@ -111,12 +98,13 @@ void RivReachCircleAnnotationPartMgr::buildParts(const caf::DisplayCoordTransfor
|
||||
|
||||
// Center point part
|
||||
{
|
||||
auto centerPos = m_rimAnnotation->centerPoint();
|
||||
double symbolSize = 20;
|
||||
double xMin = centerPosition.x() - symbolSize / 2.0;
|
||||
double xMin = centerPos.x() - symbolSize / 2.0;
|
||||
double xMax = xMin + symbolSize;
|
||||
double yMin = centerPosition.y() - symbolSize / 2.0;
|
||||
double yMin = centerPos.y() - symbolSize / 2.0;
|
||||
double yMax = yMin + symbolSize;
|
||||
double z = centerPosition.z();
|
||||
double z = centerPos.z();
|
||||
std::vector<Vec3d> line1 = { {xMin, yMin, z}, {xMax, yMax, z} };
|
||||
std::vector<Vec3d> line2 = { {xMax, yMin, z}, {xMin, yMax, z} };
|
||||
std::vector<std::vector<Vec3d>> symbol = { line1, line2 };
|
||||
@@ -150,11 +138,15 @@ void RivReachCircleAnnotationPartMgr::clearAllGeometry()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivReachCircleAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayXf)
|
||||
const caf::DisplayCoordTransform* displayXf,
|
||||
const cvf::BoundingBox& boundingBox)
|
||||
{
|
||||
if (m_rimAnnotation.isNull()) return;
|
||||
if (!m_rimAnnotation->isActive()) return;
|
||||
|
||||
// Check bounding box
|
||||
if (!isCircleInBoundingBox(boundingBox)) return;
|
||||
|
||||
if (!validateAnnotation(m_rimAnnotation)) return;
|
||||
|
||||
buildParts(displayXf, false, 0.0);
|
||||
@@ -170,6 +162,60 @@ bool RivReachCircleAnnotationPartMgr::validateAnnotation(const RimReachCircleAnn
|
||||
return m_rimAnnotation->centerPoint() != cvf::Vec3d::ZERO && m_rimAnnotation->radius() > 0.0;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivReachCircleAnnotationPartMgr::isCircleInBoundingBox(const cvf::BoundingBox& boundingBox)
|
||||
{
|
||||
auto coll = annotationCollection();
|
||||
if (!coll) return false;
|
||||
|
||||
auto effectiveBoundingBox = RiaBoundingBoxTools::inflate(boundingBox, 3);
|
||||
auto points = computeCirclePointsInDomain(coll->snapAnnotations(), coll->annotationPlaneZ());
|
||||
for (const auto& pt : points)
|
||||
{
|
||||
if (effectiveBoundingBox.contains(pt)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<cvf::Vec3d> RivReachCircleAnnotationPartMgr::computeCirclePointsInDomain(bool snapToPlaneZ, double planeZ)
|
||||
{
|
||||
int numPoints = 36;
|
||||
auto centerPos = m_rimAnnotation->centerPoint();
|
||||
auto radius = m_rimAnnotation->radius();
|
||||
|
||||
if (snapToPlaneZ)
|
||||
{
|
||||
centerPos.z() = planeZ;
|
||||
}
|
||||
|
||||
std::vector<Vec3d> points;
|
||||
for (int i = 0; i < numPoints; i++)
|
||||
{
|
||||
double rad = 2 * cvf::PI_D * (double)i / (double)numPoints;
|
||||
Vec3d pt(centerPos.x() + cos(rad) * radius, centerPos.y() + sin(rad) * radius, centerPos.z());
|
||||
points.push_back(pt);
|
||||
}
|
||||
points.push_back(points.front());
|
||||
return points;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<RivReachCircleAnnotationPartMgr::Vec3d>
|
||||
RivReachCircleAnnotationPartMgr::transformCirclePointsToDisplay(const std::vector<Vec3d>& pointsInDomain,
|
||||
const caf::DisplayCoordTransform* displayXf)
|
||||
{
|
||||
std::vector<Vec3d> pointsInDisplay;
|
||||
for (const auto& pt : pointsInDomain) pointsInDisplay.push_back(displayXf->transformToDisplayCoord(pt));
|
||||
return pointsInDisplay;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,8 +25,11 @@
|
||||
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class BoundingBox;
|
||||
class Part;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
@@ -49,13 +52,20 @@ public:
|
||||
RivReachCircleAnnotationPartMgr(Rim3dView* view, RimReachCircleAnnotation* annotation);
|
||||
~RivReachCircleAnnotationPartMgr() override;
|
||||
|
||||
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, const caf::DisplayCoordTransform* displayXf);
|
||||
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform* displayXf,
|
||||
const cvf::BoundingBox& boundingBox);
|
||||
|
||||
private:
|
||||
void buildParts(const caf::DisplayCoordTransform* displayXf, bool doFlatten, double xOffset);
|
||||
|
||||
void clearAllGeometry();
|
||||
bool validateAnnotation(const RimReachCircleAnnotation* annotation) const;
|
||||
bool isCircleInBoundingBox(const cvf::BoundingBox& boundingBox);
|
||||
|
||||
std::vector<Vec3d> computeCirclePointsInDomain(bool snapToPlaneZ, double planeZ);
|
||||
std::vector<Vec3d> transformCirclePointsToDisplay(const std::vector<Vec3d>& pointsInDomain,
|
||||
const caf::DisplayCoordTransform* displayXf);
|
||||
|
||||
RimAnnotationInViewCollection* annotationCollection() const;
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "RivTextAnnotationPartMgr.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaBoundingBoxTools.h"
|
||||
#include "RiaColorTools.h"
|
||||
#include "RiaPreferences.h"
|
||||
|
||||
@@ -71,17 +72,11 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
|
||||
|
||||
cvf::ref<RivTextAnnotationSourceInfo> sourceInfo = new RivTextAnnotationSourceInfo(m_rimAnnotation);
|
||||
|
||||
cvf::Vec3d anchorPositionInDomain = m_rimAnnotation->anchorPoint();
|
||||
cvf::Vec3d labelPositionInDomain = m_rimAnnotation->labelPoint();
|
||||
auto collection = annotationCollection();
|
||||
if (!collection) return;
|
||||
|
||||
{
|
||||
auto* collection = annotationCollection();
|
||||
if (collection && collection->snapAnnotations())
|
||||
{
|
||||
anchorPositionInDomain.z() = collection->annotationPlaneZ();
|
||||
labelPositionInDomain.z() = collection->annotationPlaneZ();
|
||||
}
|
||||
}
|
||||
cvf::Vec3d anchorPositionInDomain = getAnchorPointInDomain(collection->snapAnnotations(), collection->annotationPlaneZ());
|
||||
cvf::Vec3d labelPositionInDomain = getLabelPointInDomain(collection->snapAnnotations(), collection->annotationPlaneZ());
|
||||
|
||||
cvf::Vec3d anchorPosition = displayXf->transformToDisplayCoord(anchorPositionInDomain);
|
||||
cvf::Vec3d labelPosition = displayXf->transformToDisplayCoord(labelPositionInDomain);
|
||||
@@ -140,6 +135,48 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getAnchorPointInDomain(bool snapToPlaneZ, double planeZ)
|
||||
{
|
||||
auto pt = m_rimAnnotation->anchorPoint();
|
||||
|
||||
if (snapToPlaneZ)
|
||||
{
|
||||
pt.z() = planeZ;
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getLabelPointInDomain(bool snapToPlaneZ, double planeZ)
|
||||
{
|
||||
auto pt = m_rimAnnotation->labelPoint();
|
||||
|
||||
if (snapToPlaneZ)
|
||||
{
|
||||
pt.z() = planeZ;
|
||||
}
|
||||
return pt;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RivTextAnnotationPartMgr::isTextInBoundingBox(const cvf::BoundingBox& boundingBox)
|
||||
{
|
||||
auto coll = annotationCollection();
|
||||
if (!coll) return false;
|
||||
|
||||
auto effectiveBoundingBox = RiaBoundingBoxTools::inflate(boundingBox, 3);
|
||||
if (effectiveBoundingBox.contains(getAnchorPointInDomain(coll->snapAnnotations(), coll->annotationPlaneZ())) ||
|
||||
effectiveBoundingBox.contains(getLabelPointInDomain(coll->snapAnnotations(), coll->annotationPlaneZ()))) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -153,11 +190,15 @@ void RivTextAnnotationPartMgr::clearAllGeometry()
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivTextAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform * displayXf)
|
||||
const caf::DisplayCoordTransform * displayXf,
|
||||
const cvf::BoundingBox& boundingBox)
|
||||
{
|
||||
if (m_rimAnnotation.isNull()) return;
|
||||
if (!m_rimAnnotation->isActive()) return;
|
||||
|
||||
// Check bounding box
|
||||
if (!isTextInBoundingBox(boundingBox)) return;
|
||||
|
||||
if (!validateAnnotation(m_rimAnnotation)) return;
|
||||
|
||||
buildParts(displayXf, false, 0.0);
|
||||
|
||||
@@ -23,8 +23,11 @@
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
|
||||
#include <cvfVector3.h>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class BoundingBox;
|
||||
class Part;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
@@ -43,18 +46,26 @@ class RimSimWellInViewCollection;
|
||||
|
||||
class RivTextAnnotationPartMgr : public cvf::Object
|
||||
{
|
||||
using Vec3d = cvf::Vec3d;
|
||||
|
||||
public:
|
||||
RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotation* annotation);
|
||||
~RivTextAnnotationPartMgr() override;
|
||||
|
||||
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
|
||||
const caf::DisplayCoordTransform * displayXf);
|
||||
const caf::DisplayCoordTransform * displayXf,
|
||||
const cvf::BoundingBox& boundingBox);
|
||||
|
||||
private:
|
||||
void buildParts(const caf::DisplayCoordTransform * displayXf,
|
||||
bool doFlatten,
|
||||
double xOffset);
|
||||
|
||||
Vec3d getAnchorPointInDomain(bool snapToPlaneZ, double planeZ);
|
||||
Vec3d getLabelPointInDomain(bool snapToPlaneZ, double planeZ);
|
||||
|
||||
bool isTextInBoundingBox(const cvf::BoundingBox& boundingBox);
|
||||
|
||||
void clearAllGeometry();
|
||||
bool validateAnnotation(const RimTextAnnotation* annotation) const;
|
||||
|
||||
|
||||
@@ -687,7 +687,7 @@ void Rim3dView::addAnnotationsToModel(cvf::ModelBasicList* wellPathModelBasicLis
|
||||
else
|
||||
{
|
||||
cvf::ref<caf::DisplayCoordTransform> transForm = displayCoordTransform();
|
||||
m_annotationsPartManager->appendGeometryPartsToModel(wellPathModelBasicList, transForm.p());
|
||||
m_annotationsPartManager->appendGeometryPartsToModel(wellPathModelBasicList, transForm.p(), ownerCase()->allCellsBoundingBox());
|
||||
}
|
||||
|
||||
wellPathModelBasicList->updateBoundingBoxesRecursive();
|
||||
|
||||
Reference in New Issue
Block a user