From cdaa5e2af6c9663fb3eb32ffa82478c9173c2a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Mon, 26 Nov 2018 14:48:06 +0100 Subject: [PATCH] #3756 Annotation. Refactore features. Add view local text annotations --- .../Commands/CMakeLists_files.cmake | 8 +- ...RicCreateReachCircleAnnotationFeature.cpp} | 76 +++++++------ .../RicCreateReachCircleAnnotationFeature.h | 46 ++++++++ .../RicCreateTextAnnotationFeature.cpp | 104 ++++++++++++++++++ .../Commands/RicCreateTextAnnotationFeature.h | 47 ++++++++ ...eUserDefinedPolylinesAnnotationFeature.cpp | 82 ++++++++++++++ ...ateUserDefinedPolylinesAnnotationFeature.h | 46 ++++++++ .../Commands/RicNewAnnotationFeature.h | 84 -------------- .../RivPolylineAnnotationPartMgr.cpp | 2 - .../ProjectDataModel/CMakeLists_files.cmake | 2 - .../RimAnnotationCollection.cpp | 1 - .../RimAnnotationCollectionInterface.cpp | 28 +++++ ...w.h => RimAnnotationCollectionInterface.h} | 30 ++--- .../RimAnnotationInViewCollection.cpp | 29 +++-- .../RimAnnotationInViewCollection.h | 10 +- .../RimContextCommandBuilder.cpp | 11 +- .../ProjectDataModel/RimProject.cpp | 26 ++++- ApplicationCode/ProjectDataModel/RimProject.h | 4 +- .../ProjectDataModel/RimTextAnnotation.cpp | 2 +- 19 files changed, 472 insertions(+), 166 deletions(-) rename ApplicationCode/{ProjectDataModel/RimAnnotationInView.cpp => Commands/RicCreateReachCircleAnnotationFeature.cpp} (51%) create mode 100644 ApplicationCode/Commands/RicCreateReachCircleAnnotationFeature.h create mode 100644 ApplicationCode/Commands/RicCreateTextAnnotationFeature.cpp create mode 100644 ApplicationCode/Commands/RicCreateTextAnnotationFeature.h create mode 100644 ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp create mode 100644 ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.h delete mode 100644 ApplicationCode/Commands/RicNewAnnotationFeature.h create mode 100644 ApplicationCode/ProjectDataModel/RimAnnotationCollectionInterface.cpp rename ApplicationCode/ProjectDataModel/{RimAnnotationInView.h => RimAnnotationCollectionInterface.h} (57%) diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 5d58b3e5e6..27ba0eabd1 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -76,7 +76,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.h ${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.h -${CMAKE_CURRENT_LIST_DIR}/RicNewAnnotationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateReachCircleAnnotationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateUserDefinedPolylinesAnnotationFeature.h ) @@ -151,7 +153,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicResampleDialog.cpp ${CMAKE_CURRENT_LIST_DIR}/RicCreateTemporaryLgrFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicDeleteTemporaryLgrsFeature.cpp -${CMAKE_CURRENT_LIST_DIR}/RicNewAnnotationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateReachCircleAnnotationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateUserDefinedPolylinesAnnotationFeature.cpp ) diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationInView.cpp b/ApplicationCode/Commands/RicCreateReachCircleAnnotationFeature.cpp similarity index 51% rename from ApplicationCode/ProjectDataModel/RimAnnotationInView.cpp rename to ApplicationCode/Commands/RicCreateReachCircleAnnotationFeature.cpp index 26a9841ec6..188609880d 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationInView.cpp +++ b/ApplicationCode/Commands/RicCreateReachCircleAnnotationFeature.cpp @@ -1,8 +1,6 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS +// Copyright (C) 2016- Statoil 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 @@ -18,57 +16,67 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimAnnotationInView.h" +#include "RicCreateReachCircleAnnotationFeature.h" -#include "cafPdmUiTreeOrdering.h" +#include "RiaApplication.h" + +#include "RimTextAnnotation.h" +#include "RimReachCircleAnnotation.h" +#include "RimPolylinesAnnotation.h" +#include "RimAnnotationCollection.h" +#include "RimAnnotationInViewCollection.h" +#include "RimProject.h" +#include "RimOilField.h" + +#include "RiuMainWindow.h" + +#include + +#include -CAF_PDM_SOURCE_INIT(RimAnnotationInView, "Annotation"); +CAF_CMD_SOURCE_INIT(RicCreateReachCircleAnnotationFeature, "RicCreateReachCircleAnnotationFeature"); + //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RimAnnotationInView::RimAnnotationInView() +bool RicCreateReachCircleAnnotationFeature::isCommandEnabled() { - CAF_PDM_InitObject("Well", ":/Well.png", "", ""); - - CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", ""); - m_isActive.uiCapability()->setUiHidden(true); + auto selObjs = caf::selectedObjectsByTypeStrict(); + return selObjs.size() == 1; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RimAnnotationInView::~RimAnnotationInView() +void RicCreateReachCircleAnnotationFeature::onActionTriggered(bool isChecked) { + auto coll = annotationCollection(); + if (coll) + { + auto newAnnotation = new RimReachCircleAnnotation(); + coll->addAnnotation(newAnnotation); + coll->updateConnectedEditors(); + RiuMainWindow::instance()->selectAsCurrentItem(newAnnotation); + } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimAnnotationInView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RicCreateReachCircleAnnotationFeature::setupActionLook(QAction* actionToSetup) { + actionToSetup->setIcon(QIcon(":/Plus.png")); + actionToSetup->setText("Create Reach Circle Annotation"); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimAnnotationInView::objectToggleField() -{ - return &m_isActive; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimAnnotationInView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ - uiOrdering.skipRemainingFields(true); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimAnnotationInView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +RimAnnotationCollection* RicCreateReachCircleAnnotationFeature::annotationCollection() const { + auto project = RiaApplication::instance()->project(); + auto oilField = project->activeOilField(); + return oilField ? oilField->annotationCollection() : nullptr; } diff --git a/ApplicationCode/Commands/RicCreateReachCircleAnnotationFeature.h b/ApplicationCode/Commands/RicCreateReachCircleAnnotationFeature.h new file mode 100644 index 0000000000..c17064cdb6 --- /dev/null +++ b/ApplicationCode/Commands/RicCreateReachCircleAnnotationFeature.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimAnnotationCollection; + + +//================================================================================================== +/// +//================================================================================================== +class RicCreateReachCircleAnnotationFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; + +private: + RimAnnotationCollection* annotationCollection() const; +}; diff --git a/ApplicationCode/Commands/RicCreateTextAnnotationFeature.cpp b/ApplicationCode/Commands/RicCreateTextAnnotationFeature.cpp new file mode 100644 index 0000000000..716aa82cf3 --- /dev/null +++ b/ApplicationCode/Commands/RicCreateTextAnnotationFeature.cpp @@ -0,0 +1,104 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicCreateTextAnnotationFeature.h" + +#include "RiaApplication.h" + +#include "RimTextAnnotation.h" +#include "RimReachCircleAnnotation.h" +#include "RimPolylinesAnnotation.h" +#include "RimAnnotationCollection.h" +#include "RimAnnotationInViewCollection.h" +#include "RimProject.h" +#include "RimOilField.h" + +#include "RiuMainWindow.h" + +#include + +#include + + +CAF_CMD_SOURCE_INIT(RicCreateTextAnnotationFeature, "RicCreateTextAnnotationFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCreateTextAnnotationFeature::isCommandEnabled() +{ + auto selObjsGlobal = caf::selectedObjectsByTypeStrict(); + auto selObjs2InView = caf::selectedObjectsByTypeStrict(); + + return selObjsGlobal.size() == 1 || selObjs2InView.size() == 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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 = annotationInViewCollection(); + if (coll) + { + auto newAnnotation = new RimTextAnnotation(); + coll->addAnnotation(newAnnotation); + coll->updateConnectedEditors(); + RiuMainWindow::instance()->selectAsCurrentItem(newAnnotation); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateTextAnnotationFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/Plus.png")); + actionToSetup->setText("Create Text Annotation"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- + RimAnnotationCollection* RicCreateTextAnnotationFeature::annotationCollection() const +{ + auto selObjs = caf::selectedObjectsByTypeStrict(); + return selObjs.size() == 1 ? selObjs.front() : nullptr; + } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimAnnotationInViewCollection* RicCreateTextAnnotationFeature::annotationInViewCollection() const +{ + auto selObjs = caf::selectedObjectsByTypeStrict(); + return selObjs.size() == 1 ? selObjs.front() : nullptr; +} diff --git a/ApplicationCode/Commands/RicCreateTextAnnotationFeature.h b/ApplicationCode/Commands/RicCreateTextAnnotationFeature.h new file mode 100644 index 0000000000..afac3f00fe --- /dev/null +++ b/ApplicationCode/Commands/RicCreateTextAnnotationFeature.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimAnnotationCollection; +class RimAnnotationInViewCollection; + + +//================================================================================================== +/// +//================================================================================================== +class RicCreateTextAnnotationFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; + + RimAnnotationCollection* annotationCollection() const; + RimAnnotationInViewCollection* annotationInViewCollection() const; +}; diff --git a/ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp b/ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp new file mode 100644 index 0000000000..ce5a0403bc --- /dev/null +++ b/ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicCreateUserDefinedPolylinesAnnotationFeature.h" + +#include "RiaApplication.h" + +#include "RimTextAnnotation.h" +#include "RimReachCircleAnnotation.h" +#include "RimPolylinesAnnotation.h" +#include "RimAnnotationCollection.h" +#include "RimAnnotationInViewCollection.h" +#include "RimProject.h" +#include "RimOilField.h" + +#include "RiuMainWindow.h" + +#include + +#include + + +CAF_CMD_SOURCE_INIT(RicCreateUserDefinedPolylinesAnnotationFeature, "RicCreateUserDefinedPolylinesAnnotationFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCreateUserDefinedPolylinesAnnotationFeature::isCommandEnabled() +{ + auto selObjs = caf::selectedObjectsByTypeStrict(); + return selObjs.size() == 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateUserDefinedPolylinesAnnotationFeature::onActionTriggered(bool isChecked) +{ + auto coll = annotationCollection(); + if (coll) + { + auto newAnnotation = new RimUserDefinedPolyLinesAnnotation(); + coll->addAnnotation(newAnnotation); + coll->updateConnectedEditors(); + RiuMainWindow::instance()->selectAsCurrentItem(newAnnotation); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateUserDefinedPolylinesAnnotationFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/Plus.png")); + actionToSetup->setText("Create User Defined Polyline Annotation"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- + RimAnnotationCollection* RicCreateUserDefinedPolylinesAnnotationFeature::annotationCollection() const +{ + auto project = RiaApplication::instance()->project(); + auto oilField = project->activeOilField(); + return oilField ? oilField->annotationCollection() : nullptr; +} diff --git a/ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.h b/ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.h new file mode 100644 index 0000000000..577e3a0df9 --- /dev/null +++ b/ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimAnnotationCollection; + + +//================================================================================================== +/// +//================================================================================================== +class RicCreateUserDefinedPolylinesAnnotationFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; + +private: + RimAnnotationCollection* annotationCollection() const; +}; diff --git a/ApplicationCode/Commands/RicNewAnnotationFeature.h b/ApplicationCode/Commands/RicNewAnnotationFeature.h deleted file mode 100644 index 725cbf1271..0000000000 --- a/ApplicationCode/Commands/RicNewAnnotationFeature.h +++ /dev/null @@ -1,84 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2016- Statoil 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "RiaPreferences.h" - -#include "cafCmdFeature.h" - -#include - - -class RimAnnotationCollection; - - -//================================================================================================== -/// -//================================================================================================== -class RicNewAnnotationFeature : public caf::CmdFeature -{ - CAF_CMD_HEADER_INIT; - -protected: - // Overrides - bool isCommandEnabled() override; - void onActionTriggered( bool isChecked ) override; - void setupActionLook( QAction* actionToSetup ) override; - - RimAnnotationCollection* annotationCollection() const; -}; - -//================================================================================================== -/// -//================================================================================================== -class RicNewTextAnnotationFeature : public RicNewAnnotationFeature -{ - CAF_CMD_HEADER_INIT; - -protected: - // Overrides - void onActionTriggered(bool isChecked) override; - void setupActionLook(QAction* actionToSetup) override; -}; - -//================================================================================================== -/// -//================================================================================================== -class RicNewReachCircleAnnotationFeature : public RicNewAnnotationFeature -{ - CAF_CMD_HEADER_INIT; - -protected: - // Overrides - void onActionTriggered(bool isChecked) override; - void setupActionLook(QAction* actionToSetup) override; -}; - -//================================================================================================== -/// -//================================================================================================== -class RicNewPolylineAnnotationFeature : public RicNewAnnotationFeature -{ - CAF_CMD_HEADER_INIT; - -protected: - // Overrides - void onActionTriggered(bool isChecked) override; - void setupActionLook(QAction* actionToSetup) override; -}; diff --git a/ApplicationCode/ModelVisualization/RivPolylineAnnotationPartMgr.cpp b/ApplicationCode/ModelVisualization/RivPolylineAnnotationPartMgr.cpp index 32ecb72f3b..06d09a9538 100644 --- a/ApplicationCode/ModelVisualization/RivPolylineAnnotationPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivPolylineAnnotationPartMgr.cpp @@ -33,8 +33,6 @@ #include "cvfTransform.h" #include "cafDisplayCoordTransform.h" -static RimSimWellInViewCollection* simWellInViewCollection() { return nullptr; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 9638683bbe..5a80f5bdf5 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -126,7 +126,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotation.h ${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.h ${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.h -${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInView.h ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.h ) @@ -258,7 +257,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPolylinesAnnotation.cpp ${CMAKE_CURRENT_LIST_DIR}/RimReachCircleAnnotation.cpp ${CMAKE_CURRENT_LIST_DIR}/RimTextAnnotation.cpp -${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInView.cpp ${CMAKE_CURRENT_LIST_DIR}/RimAnnotationInViewCollection.cpp ) diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationCollection.cpp b/ApplicationCode/ProjectDataModel/RimAnnotationCollection.cpp index 47cc5aeaef..e2984ea4bf 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimAnnotationCollection.cpp @@ -30,7 +30,6 @@ #include - CAF_PDM_SOURCE_INIT(RimAnnotationCollection, "RimAnnotationCollection"); //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationCollectionInterface.cpp b/ApplicationCode/ProjectDataModel/RimAnnotationCollectionInterface.cpp new file mode 100644 index 0000000000..85327b9d77 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimAnnotationCollectionInterface.cpp @@ -0,0 +1,28 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimAnnotationCollection.h" + +#include "RimTextAnnotation.h" +#include "RimReachCircleAnnotation.h" +#include "RimPolylineAnnotation.h" + +#include + diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationInView.h b/ApplicationCode/ProjectDataModel/RimAnnotationCollectionInterface.h similarity index 57% rename from ApplicationCode/ProjectDataModel/RimAnnotationInView.h rename to ApplicationCode/ProjectDataModel/RimAnnotationCollectionInterface.h index 56e903a56d..04932b8269 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationInView.h +++ b/ApplicationCode/ProjectDataModel/RimAnnotationCollectionInterface.h @@ -20,35 +20,23 @@ #pragma once -#include "cafPdmField.h" +#include "RiaEclipseUnitTools.h" + #include "cafPdmObject.h" -#include "cafPdmPointer.h" -#include "cafAppEnum.h" -#include "cafPdmChildField.h" -#include "cvfObject.h" -#include "cvfVector3.h" +class RimTextAnnotation; +class RimReachCircleAnnotation; +class RimPolylineAnnotation; //================================================================================================== /// /// //================================================================================================== -class RimAnnotationInView : public caf::PdmObject +class RimAnnotationCollectionInterface : public caf::PdmObject { - CAF_PDM_HEADER_INIT; public: - - RimAnnotationInView(); - ~RimAnnotationInView() override; - - caf::PdmFieldHandle* objectToggleField() override; - -protected: - void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; - void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; - -private: - caf::PdmField m_isActive; + virtual std::vector textAnnotations() const = 0; + virtual std::vector reachCircleAnnotations() const = 0; + virtual std::vector polylineAnnotations() const = 0; }; diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.cpp index 85e0d5ddcf..37f1ba3921 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.cpp @@ -21,6 +21,7 @@ #include "RimAnnotationInViewCollection.h" #include "RimGridView.h" +#include "RimTextAnnotation.h" CAF_PDM_SOURCE_INIT(RimAnnotationInViewCollection, "Annotations"); @@ -32,7 +33,10 @@ RimAnnotationInViewCollection::RimAnnotationInViewCollection() { CAF_PDM_InitObject("Annotations", ":/Plus.png", "", ""); - CAF_PDM_InitField(&m_isActive, "Active", true, "Active", "", "", ""); + 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); } @@ -43,6 +47,22 @@ RimAnnotationInViewCollection::~RimAnnotationInViewCollection() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimAnnotationInViewCollection::addAnnotation(RimTextAnnotation* annotation) +{ + m_textAnnotations.push_back(annotation); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimAnnotationInViewCollection::textAnnotations() const +{ + return m_textAnnotations.childObjects(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -70,13 +90,6 @@ void RimAnnotationInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimAnnotationInViewCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.h b/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.h index 3a51ef2125..c3ee7398ea 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.h @@ -27,6 +27,7 @@ #include "cafPdmPointer.h" #include "cafTristate.h" +class RimTextAnnotation; //================================================================================================== /// @@ -40,13 +41,16 @@ public: RimAnnotationInViewCollection(); ~RimAnnotationInViewCollection() override; - bool isActive() const; + void addAnnotation(RimTextAnnotation* annotation); + + std::vector textAnnotations() const; + bool isActive() const; protected: void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; caf::PdmFieldHandle* objectToggleField() override; private: - caf::PdmField m_isActive; + caf::PdmChildArrayField m_textAnnotations; + caf::PdmField m_isActive; }; diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 2153a1e686..264166340e 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -27,6 +27,7 @@ #include "Rim3dWellLogFileCurve.h" #include "Rim3dWellLogRftCurve.h" #include "RimAnnotationCollection.h" +#include "RimAnnotationInViewCollection.h" #include "RimCalcScript.h" #include "RimCaseCollection.h" #include "RimCellRangeFilter.h" @@ -682,10 +683,14 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicCreateTextAnnotationFeature"; + menuBuilder << "RicCreateReachCircleAnnotationFeature"; + menuBuilder << "RicCreateUserDefinedPolylinesAnnotationFeature"; menuBuilder << "RicImportPolylinesAnnotationFeature"; - menuBuilder << "RicNewTextAnnotationFeature"; - menuBuilder << "RicNewReachCircleAnnotationFeature"; - menuBuilder << "RicNewPolygonAnnotationFeature"; + } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicCreateTextAnnotationFeature"; } if (dynamic_cast(uiItem)) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 9c65aca32b..6fd89fa339 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -31,8 +31,8 @@ #include "RigGridBase.h" #include "RimAnnotationCollection.h" +#include "RimAnnotationInViewCollection.h" #include "RimPolylinesAnnotation.h" - #include "RimCalcScript.h" #include "RimCase.h" #include "RimCaseCollection.h" @@ -683,7 +683,7 @@ void RimProject::allNotLinkedViews(std::vector& views) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allVisibleViews(std::vector& views) +void RimProject::allVisibleViews(std::vector& views) const { std::vector cases; allCases(cases); @@ -707,7 +707,7 @@ void RimProject::allVisibleViews(std::vector& views) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allVisibleGridViews(std::vector& views) +void RimProject::allVisibleGridViews(std::vector& views) const { std::vector visibleViews; this->allVisibleViews(visibleViews); @@ -966,6 +966,8 @@ std::vector RimProject::allWellPaths() const std::vector RimProject::textAnnotations() const { std::vector annotations; + + // 'Global' text annotations for (const auto& oilField : oilFields()) { auto annotationColl = oilField->annotationCollection(); @@ -974,6 +976,24 @@ std::vector RimProject::textAnnotations() const annotations.push_back(annotation); } } + + // 'Local' text annotations + std::vector visibleViews; + allVisibleGridViews(visibleViews); + for (const auto& view : visibleViews) + { + std::vector annotationColls; + view->descendantsIncludingThisOfType(annotationColls); + + if (annotationColls.size() == 1) + { + for (const auto& annotation : annotationColls.front()->textAnnotations()) + { + annotations.push_back(annotation); + } + } + } + return annotations; } diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 4a9c87ea3c..7b0d756183 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -115,8 +115,8 @@ public: std::vector summaryGroups() const; RimSummaryCaseMainCollection* firstSummaryCaseMainCollection() const; - void allVisibleViews(std::vector& views); - void allVisibleGridViews(std::vector& views); + void allVisibleViews(std::vector& views) const; + void allVisibleGridViews(std::vector& views) const; void allNotLinkedViews(std::vector& views); void scheduleCreateDisplayModelAndRedrawAllViews(); diff --git a/ApplicationCode/ProjectDataModel/RimTextAnnotation.cpp b/ApplicationCode/ProjectDataModel/RimTextAnnotation.cpp index 9eeb3d2160..d189280693 100644 --- a/ApplicationCode/ProjectDataModel/RimTextAnnotation.cpp +++ b/ApplicationCode/ProjectDataModel/RimTextAnnotation.cpp @@ -71,7 +71,7 @@ RimTextAnnotation::RimTextAnnotation() CAF_PDM_InitField(&m_anchorPoint, "AnchorPoint", Vec3d::ZERO, "Anchor Point", "", "", ""); CAF_PDM_InitField(&m_labelPoint, "LabelPoint", Vec3d::ZERO, "Label Point", "", "", ""); - CAF_PDM_InitField(&m_text, "Text", QString(), "Text", "", "", ""); + CAF_PDM_InitField(&m_text, "Text", QString("(New text)"), "Text", "", "", ""); } //--------------------------------------------------------------------------------------------------