#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

@@ -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;
}