#3763 Annotations. Define annotation plane Z for global annotations

This commit is contained in:
Bjørn Erik Jensen 2018-11-28 11:58:38 +01:00
parent 0083618dd2
commit c3dd6a14a7
15 changed files with 292 additions and 145 deletions

View File

@ -52,27 +52,15 @@ bool RicCreateTextAnnotationFeature::isCommandEnabled()
///
//--------------------------------------------------------------------------------------------------
void RicCreateTextAnnotationFeature::onActionTriggered(bool isChecked)
{
{
auto coll = annotationCollection();
if (coll)
{
auto newAnnotation = new RimTextAnnotation();
coll->addAnnotation(newAnnotation);
coll->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(newAnnotation);
}
}
{
auto coll = annotationCollectionBase();
if (coll)
{
auto coll = annotationInViewCollection();
if (coll)
{
auto newAnnotation = new RimTextAnnotation();
coll->addAnnotation(newAnnotation);
coll->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(newAnnotation);
}
auto newAnnotation = new RimTextAnnotation();
coll->addAnnotation(newAnnotation);
coll->updateConnectedEditors();
RiuMainWindow::instance()->selectAsCurrentItem(newAnnotation);
}
}
@ -88,17 +76,8 @@ void RicCreateTextAnnotationFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationCollection* RicCreateTextAnnotationFeature::annotationCollection() const
RimAnnotationCollectionBase* RicCreateTextAnnotationFeature::annotationCollectionBase() const
{
auto selObjs = caf::selectedObjectsByTypeStrict<RimAnnotationCollection*>();
return selObjs.size() == 1 ? selObjs.front() : nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationInViewCollection* RicCreateTextAnnotationFeature::annotationInViewCollection() const
{
auto selObjs = caf::selectedObjectsByTypeStrict<RimAnnotationInViewCollection*>();
auto selObjs = caf::selectedObjectsByTypeStrict<RimAnnotationCollectionBase*>();
return selObjs.size() == 1 ? selObjs.front() : nullptr;
}

View File

@ -26,6 +26,7 @@
class RimAnnotationCollection;
class RimAnnotationCollectionBase;
class RimAnnotationInViewCollection;
@ -42,6 +43,5 @@ protected:
void onActionTriggered(bool isChecked) override;
void setupActionLook(QAction* actionToSetup) override;
RimAnnotationCollection* annotationCollection() const;
RimAnnotationInViewCollection* annotationInViewCollection() const;
RimAnnotationCollectionBase* annotationCollectionBase() const;
};

View File

@ -18,6 +18,7 @@
#include "RivPolylineAnnotationPartMgr.h"
#include "RimAnnotationCollection.h"
#include "RimPolylinesAnnotation.h"
#include "RimAnnotationInViewCollection.h"
#include "RivPolylineGenerator.h"
@ -58,17 +59,22 @@ void RivPolylineAnnotationPartMgr::buildPolylineAnnotationParts(const caf::Displ
if (!m_rimAnnotation->isEmpty() && m_rimAnnotation->isActive())
{
const auto& points = m_rimAnnotation->polyLinesData();
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 = points->polyLines();
auto linesInDisplayCoords = pointsInDomain->polyLines();
auto* collection = dynamic_cast<RimAnnotationCollection*>(annotationCollection());
for (auto& line : linesInDisplayCoords)
{
for ( cvf::Vec3d& point : line)
{
if (collection && collection->snapAnnotations())
{
point.z() = collection->annotationPlaneZ();
}
point = displayXf->transformToDisplayCoord(point);
}
}
@ -101,6 +107,16 @@ void RivPolylineAnnotationPartMgr::clearAllGeometry()
m_part = nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationCollectionBase* RivPolylineAnnotationPartMgr::annotationCollection() const
{
RimAnnotationCollectionBase* coll;
m_rimAnnotation->firstAncestorOrThisOfType(coll);
return coll;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -37,9 +37,8 @@ namespace caf
class Rim3dView;
class RimPolylinesAnnotation;
class RimAnnotationInViewCollection;
class RimSimWellInView;
class RimSimWellInViewCollection;
class RimAnnotationCollectionBase;
class RivPolylineAnnotationPartMgr : public cvf::Object
{
@ -54,6 +53,7 @@ private:
void buildPolylineAnnotationParts(const caf::DisplayCoordTransform* displayXf);
void clearAllGeometry();
RimAnnotationCollectionBase* annotationCollection() const;
caf::PdmPointer<RimPolylinesAnnotation> m_rimAnnotation;
cvf::ref<cvf::Part> m_part;

View File

@ -22,6 +22,7 @@
#include "RivReachCircleAnnotationPartMgr.h"
#include "RimAnnotationCollection.h"
#include "RimReachCircleAnnotation.h"
#include "RivPolylineGenerator.h"
@ -62,7 +63,17 @@ void RivReachCircleAnnotationPartMgr::buildParts(const caf::DisplayCoordTransfor
cvf::ref<RivReachCircleAnnotationSourceInfo> sourceInfo = new RivReachCircleAnnotationSourceInfo(m_rimAnnotation);
Vec3d centerPosition = displayXf->transformToDisplayCoord(m_rimAnnotation->centerPoint());
Vec3d centerPositionInDomain = m_rimAnnotation->centerPoint();
{
auto* collection = dynamic_cast<RimAnnotationCollection*>(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();
@ -126,3 +137,13 @@ bool RivReachCircleAnnotationPartMgr::validateAnnotation(const RimReachCircleAnn
{
return m_rimAnnotation->centerPoint() != cvf::Vec3d::ZERO && m_rimAnnotation->radius() > 0.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationCollectionBase* RivReachCircleAnnotationPartMgr::annotationCollection() const
{
RimAnnotationCollectionBase* coll;
m_rimAnnotation->firstAncestorOrThisOfType(coll);
return coll;
}

View File

@ -39,9 +39,7 @@ namespace caf
class Rim3dView;
class RimReachCircleAnnotation;
class RimAnnotationInViewCollection;
class RimSimWellInView;
class RimSimWellInViewCollection;
class RimAnnotationCollectionBase;
class RivReachCircleAnnotationPartMgr : public cvf::Object
{
@ -59,6 +57,8 @@ private:
void clearAllGeometry();
bool validateAnnotation(const RimReachCircleAnnotation* annotation) const;
RimAnnotationCollectionBase* annotationCollection() const;
caf::PdmPointer<RimReachCircleAnnotation> m_rimAnnotation;
cvf::ref<cvf::Part> m_circlePart;
};

View File

@ -26,6 +26,7 @@
#include "RiaColorTools.h"
#include "RiaPreferences.h"
#include "RimAnnotationCollection.h"
#include "RimTextAnnotation.h"
#include "RivPolylineGenerator.h"
@ -69,8 +70,20 @@ void RivTextAnnotationPartMgr::buildParts(const caf::DisplayCoordTransform * dis
cvf::ref<RivTextAnnotationSourceInfo> sourceInfo = new RivTextAnnotationSourceInfo(m_rimAnnotation);
cvf::Vec3d anchorPosition = displayXf->transformToDisplayCoord(m_rimAnnotation->anchorPoint());
cvf::Vec3d labelPosition = displayXf->transformToDisplayCoord(m_rimAnnotation->labelPoint());
cvf::Vec3d anchorPositionInDomain = m_rimAnnotation->anchorPoint();
cvf::Vec3d labelPositionInDomain = m_rimAnnotation->labelPoint();
{
auto* collection = dynamic_cast<RimAnnotationCollection*>(annotationCollection());
if (collection && collection->snapAnnotations())
{
anchorPositionInDomain.z() = collection->annotationPlaneZ();
labelPositionInDomain.z() = collection->annotationPlaneZ();
}
}
cvf::Vec3d anchorPosition = displayXf->transformToDisplayCoord(anchorPositionInDomain);
cvf::Vec3d labelPosition = displayXf->transformToDisplayCoord(labelPositionInDomain);
QString text = m_rimAnnotation->text();
// Line part
@ -157,3 +170,12 @@ bool RivTextAnnotationPartMgr::validateAnnotation(const RimTextAnnotation* annot
return m_rimAnnotation->anchorPoint() != cvf::Vec3d::ZERO && !m_rimAnnotation->text().isEmpty();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationCollectionBase* RivTextAnnotationPartMgr::annotationCollection() const
{
RimAnnotationCollectionBase* coll;
m_rimAnnotation->firstAncestorOrThisOfType(coll);
return coll;
}

View File

@ -36,8 +36,8 @@ namespace caf
}
class Rim3dView;
class RimAnnotationCollectionBase;
class RimTextAnnotation;
class RimAnnotationInViewCollection;
class RimSimWellInView;
class RimSimWellInViewCollection;
@ -58,6 +58,8 @@ private:
void clearAllGeometry();
bool validateAnnotation(const RimTextAnnotation* annotation) const;
RimAnnotationCollectionBase* annotationCollection() const;
caf::PdmPointer<RimTextAnnotation> m_rimAnnotation;
cvf::ref<cvf::Part> m_linePart;
cvf::ref< cvf::Part > m_labelPart;

View File

@ -1,5 +1,6 @@
set (SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollectionBase.h
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotation.h
${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.h
@ -10,6 +11,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimLineBasedAnnotation.h
)
set (SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollectionBase.cpp
${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotation.cpp
${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.cpp

View File

@ -42,8 +42,6 @@ RimAnnotationCollection::RimAnnotationCollection()
{
CAF_PDM_InitObject("Annotations", ":/WellCollection.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_textAnnotations, "TextAnnotations", "Text Annotations", "", "", "");
m_textAnnotations.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_reachCircleAnnotations, "ReachCircleAnnotations", "Reach Circle Annotations", "", "", "");
m_reachCircleAnnotations.uiCapability()->setUiHidden(true);
CAF_PDM_InitFieldNoDefault(&m_polylineAnnotations, "PolylineAnnotations", "Polyline Annotations", "", "", "");
@ -51,6 +49,8 @@ RimAnnotationCollection::RimAnnotationCollection()
CAF_PDM_InitFieldNoDefault(&m_polylineFromFileAnnotations, "PolylineFromFileAnnotations", "Polylines From File", "", "", "");
m_polylineFromFileAnnotations.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_annotationPlaneZ, "AnnotationPlane", 0.0,"Annotation Plane Z", "", "", "");
CAF_PDM_InitField(&m_snapAnnotations, "SnapAnnotations", false, "Snap Annotations to Plane", "", "", "");
}
@ -59,15 +59,6 @@ RimAnnotationCollection::RimAnnotationCollection()
//--------------------------------------------------------------------------------------------------
RimAnnotationCollection::~RimAnnotationCollection()
{
// wellPaths.deleteAllChildObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationCollection::addAnnotation(RimTextAnnotation* annotation)
{
m_textAnnotations.push_back(annotation);
}
//--------------------------------------------------------------------------------------------------
@ -89,9 +80,17 @@ void RimAnnotationCollection::addAnnotation(RimPolylinesAnnotation* annotation)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimTextAnnotation*> RimAnnotationCollection::textAnnotations() const
double RimAnnotationCollection::annotationPlaneZ() const
{
return m_textAnnotations.childObjects();
return m_annotationPlaneZ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimAnnotationCollection::snapAnnotations() const
{
return m_snapAnnotations;
}
//--------------------------------------------------------------------------------------------------
@ -118,20 +117,6 @@ std::vector<RimPolylinesFromFileAnnotation*> RimAnnotationCollection::polylinesF
return m_polylineFromFileAnnotations.childObjects();
}
//--------------------------------------------------------------------------------------------------
/// At least one annotation have been deleted. Typically by the generic delete command
//--------------------------------------------------------------------------------------------------
void RimAnnotationCollection::onAnnotationDeleted()
{
auto project = RiaApplication::instance()->project();
std::vector<RimGridView*> views;
project->allVisibleGridViews(views);
for (auto& view : views)
{
if(view->annotationCollection()->isActive()) view->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -217,41 +202,22 @@ void RimAnnotationCollection::reloadPolylinesFromFile(const std::vector<RimPolyl
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationCollection::scheduleRedrawOfRelevantViews()
void RimAnnotationCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
{
// Todo: Do a Bounding Box check to see if this annotation actually is relevant for the view
auto views = gridViewsContainingAnnotations();
if ( !views.empty() )
{
for ( auto& view : views )
{
view->scheduleCreateDisplayModelAndRedraw();
}
}
uiOrdering.add(&m_annotationPlaneZ);
uiOrdering.add(&m_snapAnnotations);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimGridView*> RimAnnotationCollection::gridViewsContainingAnnotations() const
void RimAnnotationCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
const QVariant& oldValue,
const QVariant& newValue)
{
std::vector<RimGridView*> views;
RimProject* project = nullptr;
this->firstAncestorOrThisOfType(project);
if (!project) return views;
std::vector<RimGridView*> visibleGridViews;
project->allVisibleGridViews(visibleGridViews);
for (auto& gridView : visibleGridViews)
{
if (gridView->annotationCollection()->isActive()) views.push_back(gridView);
}
return views;
scheduleRedrawOfRelevantViews();
}
//--------------------------------------------------------------------------------------------------

View File

@ -20,6 +20,8 @@
#include "RiaEclipseUnitTools.h"
#include "RimAnnotationCollectionBase.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
@ -36,7 +38,7 @@ class RimGridView;
///
///
//==================================================================================================
class RimAnnotationCollection : public caf::PdmObject
class RimAnnotationCollection : public RimAnnotationCollectionBase
{
CAF_PDM_HEADER_INIT;
public:
@ -45,27 +47,29 @@ public:
void loadDataAndUpdate();
void addAnnotation(RimTextAnnotation* annotation);
double annotationPlaneZ() const;
bool snapAnnotations() const;
void addAnnotation(RimReachCircleAnnotation* annotation);
void addAnnotation(RimPolylinesAnnotation* annotation);
std::vector<RimTextAnnotation*> textAnnotations() const;
std::vector<RimReachCircleAnnotation*> reachCircleAnnotations() const;
std::vector<RimPolylinesAnnotation*> polylineAnnotations() const;
std::vector<RimPolylinesFromFileAnnotation*> polylinesFromFileAnnotations() const;
void onAnnotationDeleted();
RimPolylinesFromFileAnnotation* importOrUpdatePolylinesFromFile(const QStringList& fileNames );
void scheduleRedrawOfRelevantViews();
std::vector<RimGridView*> gridViewsContainingAnnotations() const;
protected:
void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override;
void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
private:
void reloadPolylinesFromFile(const std::vector<RimPolylinesFromFileAnnotation *>& polyLinesObjsToReload);
caf::PdmChildArrayField<RimTextAnnotation*> m_textAnnotations;
caf::PdmChildArrayField<RimReachCircleAnnotation*> m_reachCircleAnnotations;
caf::PdmChildArrayField<RimPolylinesAnnotation*> m_polylineAnnotations;
caf::PdmChildArrayField<RimPolylinesFromFileAnnotation*> m_polylineFromFileAnnotations;
caf::PdmField<double> m_annotationPlaneZ;
caf::PdmField<bool> m_snapAnnotations;
};

View File

@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiaEclipseUnitTools.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPointer.h"
class QString;
class RimTextAnnotation;
class RimGridView;
//==================================================================================================
///
///
//==================================================================================================
class RimAnnotationCollectionBase : public caf::PdmObject
{
CAF_PDM_HEADER_INIT;
public:
RimAnnotationCollectionBase();
~RimAnnotationCollectionBase() override;
void addAnnotation(RimTextAnnotation* annotation);
std::vector<RimTextAnnotation*> textAnnotations() const;
void onAnnotationDeleted();
void scheduleRedrawOfRelevantViews();
std::vector<RimGridView*> gridViewsContainingAnnotations() const;
private:
caf::PdmChildArrayField<RimTextAnnotation*> m_textAnnotations;
};

View File

@ -34,9 +34,6 @@ RimAnnotationInViewCollection::RimAnnotationInViewCollection()
{
CAF_PDM_InitObject("Annotations", ":/Plus.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_textAnnotations, "TextAnnotations", "Text Annotations", "", "", "");
m_textAnnotations.uiCapability()->setUiHidden(true);
CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", "");
m_isActive.uiCapability()->setUiHidden(true);
}
@ -48,36 +45,6 @@ RimAnnotationInViewCollection::~RimAnnotationInViewCollection()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationInViewCollection::addAnnotation(RimTextAnnotation* annotation)
{
m_textAnnotations.push_back(annotation);
}
//--------------------------------------------------------------------------------------------------
/// At least one annotation have been deleted. Typically by the generic delete command
//--------------------------------------------------------------------------------------------------
void RimAnnotationInViewCollection::onAnnotationDeleted()
{
auto project = RiaApplication::instance()->project();
std::vector<RimGridView*> views;
project->allVisibleGridViews(views);
for (auto& view : views)
{
if (view->annotationCollection()->isActive()) view->scheduleCreateDisplayModelAndRedraw();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimTextAnnotation*> RimAnnotationInViewCollection::textAnnotations() const
{
return m_textAnnotations.childObjects();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -18,6 +18,8 @@
#pragma once
#include "RimAnnotationCollectionBase.h"
#include "cafAppEnum.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
@ -31,7 +33,7 @@ class RimTextAnnotation;
///
///
//==================================================================================================
class RimAnnotationInViewCollection : public caf::PdmObject
class RimAnnotationInViewCollection : public RimAnnotationCollectionBase
{
CAF_PDM_HEADER_INIT;
public:
@ -39,10 +41,6 @@ public:
RimAnnotationInViewCollection();
~RimAnnotationInViewCollection() override;
void addAnnotation(RimTextAnnotation* annotation);
void onAnnotationDeleted();
std::vector<RimTextAnnotation*> textAnnotations() const;
bool isActive() const;
protected:
@ -50,6 +48,5 @@ protected:
caf::PdmFieldHandle* objectToggleField() override;
private:
caf::PdmChildArrayField<RimTextAnnotation*> m_textAnnotations;
caf::PdmField<bool> m_isActive;
};

View File

@ -0,0 +1,117 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimAnnotationCollectionBase.h"
#include "RiaApplication.h"
#include "RimTextAnnotation.h"
#include "RimReachCircleAnnotation.h"
#include "RimPolylinesAnnotation.h"
#include "RimProject.h"
#include "RimGridView.h"
#include "RimAnnotationInViewCollection.h"
#include "QMessageBox"
#include <QString>
#include "RiaColorTables.h"
CAF_PDM_SOURCE_INIT(RimAnnotationCollectionBase, "RimAnnotationCollectionBase");
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationCollectionBase::RimAnnotationCollectionBase()
{
CAF_PDM_InitObject("Annotations", ":/WellCollection.png", "", "");
CAF_PDM_InitFieldNoDefault(&m_textAnnotations, "TextAnnotations", "Text Annotations", "", "", "");
m_textAnnotations.uiCapability()->setUiHidden(true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimAnnotationCollectionBase::~RimAnnotationCollectionBase()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationCollectionBase::addAnnotation(RimTextAnnotation* annotation)
{
m_textAnnotations.push_back(annotation);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimTextAnnotation*> RimAnnotationCollectionBase::textAnnotations() const
{
return m_textAnnotations.childObjects();
}
//--------------------------------------------------------------------------------------------------
/// At least one annotation have been deleted. Typically by the generic delete command
//--------------------------------------------------------------------------------------------------
void RimAnnotationCollectionBase::onAnnotationDeleted()
{
scheduleRedrawOfRelevantViews();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimAnnotationCollectionBase::scheduleRedrawOfRelevantViews()
{
// Todo: Do a Bounding Box check to see if this annotation actually is relevant for the view
auto views = gridViewsContainingAnnotations();
if ( !views.empty() )
{
for ( auto& view : views )
{
view->scheduleCreateDisplayModelAndRedraw();
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RimGridView*> RimAnnotationCollectionBase::gridViewsContainingAnnotations() const
{
std::vector<RimGridView*> views;
RimProject* project = nullptr;
this->firstAncestorOrThisOfType(project);
if (!project) return views;
std::vector<RimGridView*> visibleGridViews;
project->allVisibleGridViews(visibleGridViews);
for (auto& gridView : visibleGridViews)
{
if (gridView->annotationCollection()->isActive()) views.push_back(gridView);
}
return views;
}