#3788 Annotations. Mirror global annotations into view annotation collection. Not thorougly testet yet

This commit is contained in:
Bjørn Erik Jensen
2018-12-03 13:14:04 +01:00
parent 918efd3a27
commit 11e2fe29d4
33 changed files with 1605 additions and 104 deletions

View File

@@ -25,8 +25,12 @@
#include "RiaApplication.h"
#include "Rim3dView.h"
#include "RimAnnotationInViewCollection.h"
#include "RimProject.h"
#include "RimUserDefinedPolylinesAnnotationInView.h"
#include "RimPolylinesFromFileAnnotationInView.h"
#include "RivTextAnnotationPartMgr.h"
#include "RivReachCircleAnnotationPartMgr.h"
#include "RivPolylineAnnotationPartMgr.h"
@@ -76,20 +80,31 @@ void RivAnnotationsPartMgr::appendGeometryPartsToModel(cvf::ModelBasicList*
//--------------------------------------------------------------------------------------------------
void RivAnnotationsPartMgr::createAnnotationPartManagers()
{
RimProject* proj = RiaApplication::instance()->project();
auto textAnnotations = proj->textAnnotations();
auto reachCircleAnnotations = proj->reachCircleAnnotations();
auto polylineAnnotations = proj->polylineAnnotations();
std::vector<RimAnnotationInViewCollection*> colls;
m_rimView->descendantsIncludingThisOfType(colls);
if (colls.empty()) return;
auto coll = colls.front();
auto localTextAnnotations = coll->textAnnotations();
auto textAnnotations = coll->globalTextAnnotations();
auto reachCircleAnnotations = coll->globalReachCircleAnnotations();
auto userDefinedPolylineAnnotations = coll->globalUserDefinedPolylineAnnotations();
auto polylineFromFileAnnotations = coll->globalPolylineFromFileAnnotations();
clearGeometryCache();
if (m_textAnnotationPartMgrs.size() != textAnnotations.size())
if (m_textAnnotationPartMgrs.size() != localTextAnnotations.size() + textAnnotations.size())
{
for (auto annotation : localTextAnnotations)
{
auto* apm = new RivTextAnnotationPartMgr(m_rimView, annotation);
m_textAnnotationPartMgrs.push_back(apm);
}
for (auto annotation : textAnnotations)
{
auto* apm = new RivTextAnnotationPartMgr(m_rimView, annotation);
m_textAnnotationPartMgrs.push_back(apm);
//m_mapFromViewToIndex[wellPath] = wppm;
}
}
if (m_reachCircleAnnotationPartMgrs.size() != reachCircleAnnotations.size())
@@ -98,16 +113,19 @@ void RivAnnotationsPartMgr::createAnnotationPartManagers()
{
auto* apm = new RivReachCircleAnnotationPartMgr(m_rimView, annotation);
m_reachCircleAnnotationPartMgrs.push_back(apm);
// m_mapFromViewToIndex[wellPath] = wppm;
}
}
if (m_polylineAnnotationPartMgrs.size() != polylineAnnotations.size())
if (m_polylineAnnotationPartMgrs.size() != userDefinedPolylineAnnotations.size() + polylineFromFileAnnotations.size())
{
for (auto annotation : polylineAnnotations)
for (auto annotation : userDefinedPolylineAnnotations)
{
auto* apm = new RivPolylineAnnotationPartMgr(m_rimView, annotation);
m_polylineAnnotationPartMgrs.push_back(apm);
}
for (auto annotation : polylineFromFileAnnotations)
{
auto* apm = new RivPolylineAnnotationPartMgr(m_rimView, annotation);
m_polylineAnnotationPartMgrs.push_back(apm);
// m_mapFromViewToIndex[wellPath] = wppm;
}
}

View File

@@ -23,6 +23,7 @@
#include "Rim3dView.h"
#include "RimAnnotationCollection.h"
#include "RimPolylinesAnnotation.h"
#include "RimPolylinesAnnotationInView.h"
#include "RimAnnotationInViewCollection.h"
#include "RimAnnotationLineAppearance.h"
@@ -45,8 +46,8 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivPolylineAnnotationPartMgr::RivPolylineAnnotationPartMgr(Rim3dView* view, RimPolylinesAnnotation* annotation)
: m_rimView(view), m_rimAnnotation(annotation)
RivPolylineAnnotationPartMgr::RivPolylineAnnotationPartMgr(Rim3dView* view, RimPolylinesAnnotationInView* annotationInView)
: m_rimView(view), m_rimAnnotationInView(annotationInView)
{
}
@@ -65,11 +66,12 @@ void RivPolylineAnnotationPartMgr::buildPolylineAnnotationParts(const caf::Displ
{
clearAllGeometry();
if (!m_rimAnnotation->isEmpty() && m_rimAnnotation->isActive())
auto rimAnnotation = m_rimAnnotationInView->sourceAnnotation();
if (!rimAnnotation->isEmpty() && rimAnnotation->isActive())
{
auto lineColor = m_rimAnnotation->appearance()->color();
auto isDashedLine = m_rimAnnotation->appearance()->isDashed();
auto lineThickness = m_rimAnnotation->appearance()->thickness();
auto lineColor = rimAnnotation->appearance()->color();
auto isDashedLine = rimAnnotation->appearance()->isDashed();
auto lineThickness = rimAnnotation->appearance()->thickness();
auto* collection = annotationCollection();
if (!collection) return;
@@ -90,7 +92,7 @@ void RivPolylineAnnotationPartMgr::buildPolylineAnnotationParts(const caf::Displ
part->setEffect(eff.p());
part->setPriority(RivPartPriority::PartType::MeshLines);
cvf::ref<RivPolylinesAnnotationSourceInfo> sourceInfo = new RivPolylinesAnnotationSourceInfo(m_rimAnnotation);
cvf::ref<RivPolylinesAnnotationSourceInfo> sourceInfo = new RivPolylinesAnnotationSourceInfo(rimAnnotation);
part->setSourceInfo(sourceInfo.p());
m_part = part;
@@ -103,7 +105,7 @@ void RivPolylineAnnotationPartMgr::buildPolylineAnnotationParts(const caf::Displ
std::vector<std::vector<RivPolylineAnnotationPartMgr::Vec3d>>
RivPolylineAnnotationPartMgr::getPolylinesPointsInDomain(bool snapToPlaneZ, double planeZ)
{
auto polylines = m_rimAnnotation->polyLinesData()->polyLines();
auto polylines = m_rimAnnotationInView->sourceAnnotation()->polyLinesData()->polyLines();
if (!snapToPlaneZ) return polylines;
std::vector<std::vector<Vec3d>> polylinesInDisplay;
@@ -186,8 +188,9 @@ void RivPolylineAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelB
const caf::DisplayCoordTransform * displayXf,
const cvf::BoundingBox& boundingBox)
{
if (m_rimAnnotation.isNull()) return;
if (m_rimAnnotation->isEmpty()) return;
auto rimAnnotation = m_rimAnnotationInView->sourceAnnotation();
if (rimAnnotation->isEmpty()) return;
if (!m_rimAnnotationInView->isVisible()) return;
// Check bounding box
if (!isPolylinesInBoundingBox(boundingBox)) return;

View File

@@ -41,7 +41,7 @@ namespace caf
}
class Rim3dView;
class RimPolylinesAnnotation;
class RimPolylinesAnnotationInView;
class RimAnnotationInViewCollection;
@@ -50,7 +50,7 @@ class RivPolylineAnnotationPartMgr : public cvf::Object
using Vec3d = cvf::Vec3d;
public:
RivPolylineAnnotationPartMgr(Rim3dView* view, RimPolylinesAnnotation* annotation);
RivPolylineAnnotationPartMgr(Rim3dView* view, RimPolylinesAnnotationInView* annotation);
~RivPolylineAnnotationPartMgr() override;
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
@@ -68,7 +68,7 @@ private:
void clearAllGeometry();
RimAnnotationInViewCollection* annotationCollection() const;
caf::PdmPointer<Rim3dView> m_rimView;
caf::PdmPointer<RimPolylinesAnnotation> m_rimAnnotation;
cvf::ref<cvf::Part> m_part;
caf::PdmPointer<Rim3dView> m_rimView;
caf::PdmPointer<RimPolylinesAnnotationInView> m_rimAnnotationInView;
cvf::ref<cvf::Part> m_part;
};

View File

@@ -27,6 +27,7 @@
#include "Rim3dView.h"
#include "RimAnnotationInViewCollection.h"
#include "RimReachCircleAnnotation.h"
#include "RimReachCircleAnnotationInView.h"
#include "RivPolylineGenerator.h"
#include "RivPartPriority.h"
@@ -44,8 +45,8 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivReachCircleAnnotationPartMgr::RivReachCircleAnnotationPartMgr(Rim3dView* view, RimReachCircleAnnotation* annotation)
: m_rimView(view), m_rimAnnotation(annotation)
RivReachCircleAnnotationPartMgr::RivReachCircleAnnotationPartMgr(Rim3dView* view, RimReachCircleAnnotationInView* annotationInView)
: m_rimView(view), m_rimAnnotationInView(annotationInView)
{
}
@@ -62,15 +63,16 @@ RivReachCircleAnnotationPartMgr::~RivReachCircleAnnotationPartMgr()
//--------------------------------------------------------------------------------------------------
void RivReachCircleAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform* displayXf, bool doFlatten, double xOffset)
{
auto rimAnnotation = m_rimAnnotationInView->sourceAnnotation();
clearAllGeometry();
cvf::ref<RivReachCircleAnnotationSourceInfo> sourceInfo = new RivReachCircleAnnotationSourceInfo(m_rimAnnotation);
cvf::ref<RivReachCircleAnnotationSourceInfo> sourceInfo = new RivReachCircleAnnotationSourceInfo(rimAnnotation);
Vec3d centerPositionInDomain = m_rimAnnotation->centerPoint();
Vec3d centerPositionInDomain = rimAnnotation->centerPoint();
auto lineColor = m_rimAnnotation->appearance()->color();
auto isDashedLine = m_rimAnnotation->appearance()->isDashed();
auto lineThickness = m_rimAnnotation->appearance()->thickness();
auto lineColor = rimAnnotation->appearance()->color();
auto isDashedLine = rimAnnotation->appearance()->isDashed();
auto lineThickness = rimAnnotation->appearance()->thickness();
// Circle part
auto* collection = annotationCollection();
@@ -98,7 +100,7 @@ void RivReachCircleAnnotationPartMgr::buildParts(const caf::DisplayCoordTransfor
// Center point part
{
auto centerPos = m_rimAnnotation->centerPoint();
auto centerPos = rimAnnotation->centerPoint();
double symbolSize = 20;
double xMin = centerPos.x() - symbolSize / 2.0;
double xMax = xMin + symbolSize;
@@ -141,13 +143,13 @@ void RivReachCircleAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::Mod
const caf::DisplayCoordTransform* displayXf,
const cvf::BoundingBox& boundingBox)
{
if (m_rimAnnotation.isNull()) return;
if (!m_rimAnnotation->isActive()) return;
if (m_rimAnnotationInView.isNull() || !m_rimAnnotationInView->sourceAnnotation()) return;
if (!m_rimAnnotationInView->isVisible()) return;
// Check bounding box
if (!isCircleInBoundingBox(boundingBox)) return;
if (!validateAnnotation(m_rimAnnotation)) return;
if (!validateAnnotation(m_rimAnnotationInView->sourceAnnotation())) return;
buildParts(displayXf, false, 0.0);
model->addPart(m_circlePart.p());
@@ -159,7 +161,8 @@ void RivReachCircleAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::Mod
//--------------------------------------------------------------------------------------------------
bool RivReachCircleAnnotationPartMgr::validateAnnotation(const RimReachCircleAnnotation* annotation) const
{
return m_rimAnnotation->centerPoint() != cvf::Vec3d::ZERO && m_rimAnnotation->radius() > 0.0;
auto a = m_rimAnnotationInView->sourceAnnotation();
return a->centerPoint() != cvf::Vec3d::ZERO && a->radius() > 0.0;
}
//--------------------------------------------------------------------------------------------------
@@ -185,8 +188,8 @@ bool RivReachCircleAnnotationPartMgr::isCircleInBoundingBox(const cvf::BoundingB
std::vector<cvf::Vec3d> RivReachCircleAnnotationPartMgr::computeCirclePointsInDomain(bool snapToPlaneZ, double planeZ)
{
int numPoints = 36;
auto centerPos = m_rimAnnotation->centerPoint();
auto radius = m_rimAnnotation->radius();
auto centerPos = m_rimAnnotationInView->sourceAnnotation()->centerPoint();
auto radius = m_rimAnnotationInView->sourceAnnotation()->radius();
if (snapToPlaneZ)
{

View File

@@ -42,6 +42,7 @@ namespace caf
class Rim3dView;
class RimReachCircleAnnotation;
class RimReachCircleAnnotationInView;
class RimAnnotationInViewCollection;
class RivReachCircleAnnotationPartMgr : public cvf::Object
@@ -49,7 +50,7 @@ class RivReachCircleAnnotationPartMgr : public cvf::Object
using Vec3d = cvf::Vec3d;
public:
RivReachCircleAnnotationPartMgr(Rim3dView* view, RimReachCircleAnnotation* annotation);
RivReachCircleAnnotationPartMgr(Rim3dView* view, RimReachCircleAnnotationInView* annotationInView);
~RivReachCircleAnnotationPartMgr() override;
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
@@ -70,7 +71,7 @@ private:
RimAnnotationInViewCollection* annotationCollection() const;
caf::PdmPointer<Rim3dView> m_rimView;
caf::PdmPointer<RimReachCircleAnnotation> m_rimAnnotation;
caf::PdmPointer<RimReachCircleAnnotationInView> m_rimAnnotationInView;
cvf::ref<cvf::Part> m_circlePart;
cvf::ref<cvf::Part> m_centerPointPart;
};

View File

@@ -30,6 +30,7 @@
#include "Rim3dView.h"
#include "RimAnnotationInViewCollection.h"
#include "RimTextAnnotation.h"
#include "RimTextAnnotationInView.h"
#include "RivPolylineGenerator.h"
#include "RivPartPriority.h"
@@ -48,8 +49,18 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotation* annotation)
: m_rimView(view), m_rimAnnotation(annotation)
RivTextAnnotationPartMgr::RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotation* annotationLocal)
: m_rimView(view), m_rimAnnotationLocal(annotationLocal), m_rimAnnotationInView(nullptr)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotationInView* annotationInView)
: m_rimView(view)
, m_rimAnnotationLocal(nullptr)
, m_rimAnnotationInView(annotationInView)
{
}
@@ -70,7 +81,7 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
{
clearAllGeometry();
cvf::ref<RivTextAnnotationSourceInfo> sourceInfo = new RivTextAnnotationSourceInfo(m_rimAnnotation);
cvf::ref<RivTextAnnotationSourceInfo> sourceInfo = new RivTextAnnotationSourceInfo(rimAnnotation());
auto collection = annotationCollection();
if (!collection) return;
@@ -80,7 +91,7 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
cvf::Vec3d anchorPosition = displayXf->transformToDisplayCoord(anchorPositionInDomain);
cvf::Vec3d labelPosition = displayXf->transformToDisplayCoord(labelPositionInDomain);
QString text = m_rimAnnotation->text();
QString text = rimAnnotation()->text();
// Line part
{
@@ -141,7 +152,7 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getAnchorPointInDomain(bool snapToPlaneZ, double planeZ)
{
auto pt = m_rimAnnotation->anchorPoint();
auto pt = rimAnnotation()->anchorPoint();
if (snapToPlaneZ)
{
@@ -155,7 +166,7 @@ RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getAnchorPointInDomain
//--------------------------------------------------------------------------------------------------
RivTextAnnotationPartMgr::Vec3d RivTextAnnotationPartMgr::getLabelPointInDomain(bool snapToPlaneZ, double planeZ)
{
auto pt = m_rimAnnotation->labelPoint();
auto pt = rimAnnotation()->labelPoint();
if (snapToPlaneZ)
{
@@ -194,13 +205,12 @@ void RivTextAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasic
const caf::DisplayCoordTransform * displayXf,
const cvf::BoundingBox& boundingBox)
{
if (m_rimAnnotation.isNull()) return;
if (!m_rimAnnotation->isActive()) return;
if (!rimAnnotation() || !isAnnotationVisible()) return;
// Check bounding box
if (!isTextInBoundingBox(boundingBox)) return;
if (!validateAnnotation(m_rimAnnotation)) return;
if (!validateAnnotation(rimAnnotation())) return;
buildParts(displayXf, false, 0.0);
model->addPart(m_linePart.p());
@@ -212,7 +222,7 @@ void RivTextAnnotationPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasic
//--------------------------------------------------------------------------------------------------
bool RivTextAnnotationPartMgr::validateAnnotation(const RimTextAnnotation* annotation) const
{
return m_rimAnnotation->anchorPoint() != cvf::Vec3d::ZERO && !m_rimAnnotation->text().isEmpty();
return rimAnnotation()->anchorPoint() != cvf::Vec3d::ZERO && !rimAnnotation()->text().isEmpty();
}
//--------------------------------------------------------------------------------------------------
@@ -224,3 +234,23 @@ RimAnnotationInViewCollection* RivTextAnnotationPartMgr::annotationCollection()
m_rimView->descendantsIncludingThisOfType(colls);
return !colls.empty() ? colls.front() : nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimTextAnnotation* RivTextAnnotationPartMgr::rimAnnotation() const
{
return m_rimAnnotationLocal ? m_rimAnnotationLocal : m_rimAnnotationInView->sourceAnnotation();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RivTextAnnotationPartMgr::isAnnotationVisible() const
{
if (m_rimAnnotationLocal)
return m_rimAnnotationLocal->isVisible();
if(m_rimAnnotationInView)
return m_rimAnnotationInView->isVisible();
return false;
}

View File

@@ -41,15 +41,15 @@ namespace caf
class Rim3dView;
class RimAnnotationInViewCollection;
class RimTextAnnotation;
class RimSimWellInView;
class RimSimWellInViewCollection;
class RimTextAnnotationInView;
class RivTextAnnotationPartMgr : public cvf::Object
{
using Vec3d = cvf::Vec3d;
public:
RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotation* annotation);
RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotation* annotationLocal);
RivTextAnnotationPartMgr(Rim3dView* view, RimTextAnnotationInView* annotationInView);
~RivTextAnnotationPartMgr() override;
void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model,
@@ -71,8 +71,12 @@ private:
RimAnnotationInViewCollection* annotationCollection() const;
RimTextAnnotation* rimAnnotation() const;
bool isAnnotationVisible() const;
caf::PdmPointer<Rim3dView> m_rimView;
caf::PdmPointer<RimTextAnnotation> m_rimAnnotation;
caf::PdmPointer<RimTextAnnotation> m_rimAnnotationLocal;
caf::PdmPointer<RimTextAnnotationInView> m_rimAnnotationInView;
cvf::ref<cvf::Part> m_linePart;
cvf::ref< cvf::Part > m_labelPart;
};