diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 45d155ad02..b87664ea27 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -37,6 +37,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/CommandFileInterface/Core ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel + ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Annotations ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Completions ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Flow ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Summary @@ -90,6 +91,7 @@ list( APPEND REFERENCED_CMAKE_FILES ProjectDataModel/CMakeLists_files.cmake ProjectDataModel/Summary/CMakeLists_files.cmake ProjectDataModel/Flow/CMakeLists_files.cmake + ProjectDataModel/Annotations/CMakeLists_files.cmake ProjectDataModel/Completions/CMakeLists_files.cmake GeoMech/GeoMechVisualization/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/AnnotationCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/AnnotationCommands/CMakeLists_files.cmake index 30f0e11302..3b83838d9c 100644 --- a/ApplicationCode/Commands/AnnotationCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/AnnotationCommands/CMakeLists_files.cmake @@ -1,12 +1,16 @@ set (SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportPolylinesAnnotationFeature.h - +${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateReachCircleAnnotationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateUserDefinedPolylinesAnnotationFeature.h ) set (SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicImportPolylinesAnnotationFeature.cpp - +${CMAKE_CURRENT_LIST_DIR}/RicCreateTextAnnotationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateReachCircleAnnotationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateUserDefinedPolylinesAnnotationFeature.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationInView.cpp b/ApplicationCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.cpp similarity index 51% rename from ApplicationCode/ProjectDataModel/RimAnnotationInView.cpp rename to ApplicationCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.cpp index 26a9841ec6..188609880d 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationInView.cpp +++ b/ApplicationCode/Commands/AnnotationCommands/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/ProjectDataModel/RimAnnotationInView.h b/ApplicationCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.h similarity index 50% rename from ApplicationCode/ProjectDataModel/RimAnnotationInView.h rename to ApplicationCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.h index 56e903a56d..c17064cdb6 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationInView.h +++ b/ApplicationCode/Commands/AnnotationCommands/RicCreateReachCircleAnnotationFeature.h @@ -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 @@ -20,35 +18,29 @@ #pragma once -#include "cafPdmField.h" -#include "cafPdmObject.h" -#include "cafPdmPointer.h" -#include "cafAppEnum.h" -#include "cafPdmChildField.h" +#include "RiaPreferences.h" -#include "cvfObject.h" -#include "cvfVector3.h" +#include "cafCmdFeature.h" + +#include + + +class RimAnnotationCollection; //================================================================================================== -/// -/// +/// //================================================================================================== -class RimAnnotationInView : public caf::PdmObject +class RicCreateReachCircleAnnotationFeature : public caf::CmdFeature { - CAF_PDM_HEADER_INIT; -public: - - RimAnnotationInView(); - ~RimAnnotationInView() override; - - caf::PdmFieldHandle* objectToggleField() override; + CAF_CMD_HEADER_INIT; 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; + // Overrides + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; private: - caf::PdmField m_isActive; + RimAnnotationCollection* annotationCollection() const; }; diff --git a/ApplicationCode/Commands/AnnotationCommands/RicCreateTextAnnotationFeature.cpp b/ApplicationCode/Commands/AnnotationCommands/RicCreateTextAnnotationFeature.cpp new file mode 100644 index 0000000000..716aa82cf3 --- /dev/null +++ b/ApplicationCode/Commands/AnnotationCommands/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/AnnotationCommands/RicCreateTextAnnotationFeature.h b/ApplicationCode/Commands/AnnotationCommands/RicCreateTextAnnotationFeature.h new file mode 100644 index 0000000000..afac3f00fe --- /dev/null +++ b/ApplicationCode/Commands/AnnotationCommands/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/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp b/ApplicationCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp new file mode 100644 index 0000000000..5fd6c0e6b3 --- /dev/null +++ b/ApplicationCode/Commands/AnnotationCommands/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/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h b/ApplicationCode/Commands/AnnotationCommands/RicCreateUserDefinedPolylinesAnnotationFeature.h new file mode 100644 index 0000000000..577e3a0df9 --- /dev/null +++ b/ApplicationCode/Commands/AnnotationCommands/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/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp b/ApplicationCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp index 40432f9c66..29d719d311 100644 --- a/ApplicationCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp +++ b/ApplicationCode/Commands/AnnotationCommands/RicImportPolylinesAnnotationFeature.cpp @@ -71,7 +71,7 @@ void RicImportPolylinesAnnotationFeature::onActionTriggered(bool isChecked) // For each file, - RimPolyLinesFromFileAnnotation* lastCreatedOrUpdated = annotColl->importOrUpdatePolylinesFromFile(fileNames); + RimPolylinesFromFileAnnotation* lastCreatedOrUpdated = annotColl->importOrUpdatePolylinesFromFile(fileNames); proj->updateConnectedEditors(); diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 5d58b3e5e6..51078ac36c 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -76,7 +76,6 @@ ${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 ) @@ -151,7 +150,6 @@ ${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 ) diff --git a/ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp b/ApplicationCode/Commands/RicCreateUserDefinedPolylinesAnnotationFeature.cpp new file mode 100644 index 0000000000..5fd6c0e6b3 --- /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/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/Annotations/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Annotations/CMakeLists_files.cmake new file mode 100644 index 0000000000..684422948c --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Annotations/CMakeLists_files.cmake @@ -0,0 +1,31 @@ + +set (SOURCE_GROUP_HEADER_FILES +${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}/RimAnnotationInViewCollection.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${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}/RimAnnotationInViewCollection.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +set (QT_MOC_HEADERS +${QT_MOC_HEADERS} +) + + +source_group( "ProjectDataModel\\Annotations" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationCollection.cpp b/ApplicationCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp similarity index 95% rename from ApplicationCode/ProjectDataModel/RimAnnotationCollection.cpp rename to ApplicationCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp index 47cc5aeaef..d60173ea0b 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Annotations/RimAnnotationCollection.cpp @@ -30,7 +30,6 @@ #include - CAF_PDM_SOURCE_INIT(RimAnnotationCollection, "RimAnnotationCollection"); //-------------------------------------------------------------------------------------------------- @@ -111,7 +110,7 @@ std::vector RimAnnotationCollection::polylineAnnotation //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimAnnotationCollection::polylinesFromFileAnnotations() const +std::vector RimAnnotationCollection::polylinesFromFileAnnotations() const { return m_polylineFromFileAnnotations.childObjects(); } @@ -119,16 +118,16 @@ std::vector RimAnnotationCollection::polylinesF //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolyLinesFromFileAnnotation* RimAnnotationCollection::importOrUpdatePolylinesFromFile(const QStringList& fileNames) +RimPolylinesFromFileAnnotation* RimAnnotationCollection::importOrUpdatePolylinesFromFile(const QStringList& fileNames) { QStringList newFileNames; - std::vector polyLinesObjsToReload; + std::vector polyLinesObjsToReload; size_t formationListBeforeImportCount = m_polylineFromFileAnnotations.size(); for(const QString& newFileName : fileNames) { bool isFound = false; - for(RimPolyLinesFromFileAnnotation* polyLinesAnnot: m_polylineFromFileAnnotations) + for(RimPolylinesFromFileAnnotation* polyLinesAnnot: m_polylineFromFileAnnotations) { if(polyLinesAnnot->fileName() == newFileName) { @@ -146,7 +145,7 @@ RimPolyLinesFromFileAnnotation* RimAnnotationCollection::importOrUpdatePolylines for(const QString& newFileName : newFileNames) { - RimPolyLinesFromFileAnnotation* newPolyLinesAnnot = new RimPolyLinesFromFileAnnotation; + RimPolylinesFromFileAnnotation* newPolyLinesAnnot = new RimPolylinesFromFileAnnotation; newPolyLinesAnnot->setFileName(newFileName); m_polylineFromFileAnnotations.push_back(newPolyLinesAnnot); polyLinesObjsToReload.push_back(newPolyLinesAnnot); @@ -155,7 +154,7 @@ RimPolyLinesFromFileAnnotation* RimAnnotationCollection::importOrUpdatePolylines QString totalErrorMessage; - for (RimPolyLinesFromFileAnnotation* polyLinesAnnot: polyLinesObjsToReload) + for (RimPolylinesFromFileAnnotation* polyLinesAnnot: polyLinesObjsToReload) { QString errormessage; diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationCollection.h b/ApplicationCode/ProjectDataModel/Annotations/RimAnnotationCollection.h similarity index 91% rename from ApplicationCode/ProjectDataModel/RimAnnotationCollection.h rename to ApplicationCode/ProjectDataModel/Annotations/RimAnnotationCollection.h index d81912911d..e7dfb33fc2 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationCollection.h +++ b/ApplicationCode/ProjectDataModel/Annotations/RimAnnotationCollection.h @@ -29,7 +29,7 @@ class QString; class RimTextAnnotation; class RimReachCircleAnnotation; class RimPolylinesAnnotation; -class RimPolyLinesFromFileAnnotation; +class RimPolylinesFromFileAnnotation; class RimGridView; //================================================================================================== @@ -50,9 +50,9 @@ public: std::vector textAnnotations() const; std::vector reachCircleAnnotations() const; std::vector polylineAnnotations() const; - std::vector polylinesFromFileAnnotations() const; + std::vector polylinesFromFileAnnotations() const; - RimPolyLinesFromFileAnnotation* importOrUpdatePolylinesFromFile(const QStringList& fileNames ); + RimPolylinesFromFileAnnotation* importOrUpdatePolylinesFromFile(const QStringList& fileNames ); void scheduleRedrawOfRelevantViews(); std::vector gridViewsContainingAnnotations() const; @@ -60,5 +60,5 @@ private: caf::PdmChildArrayField m_textAnnotations; caf::PdmChildArrayField m_reachCircleAnnotations; caf::PdmChildArrayField m_polylineAnnotations; - caf::PdmChildArrayField m_polylineFromFileAnnotations; + caf::PdmChildArrayField m_polylineFromFileAnnotations; }; diff --git a/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.cpp b/ApplicationCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp similarity index 80% rename from ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.cpp rename to ApplicationCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.cpp index 85e0d5ddcf..37f1ba3921 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Annotations/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/Annotations/RimAnnotationInViewCollection.h similarity index 83% rename from ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.h rename to ApplicationCode/ProjectDataModel/Annotations/RimAnnotationInViewCollection.h index 3a51ef2125..c3ee7398ea 100644 --- a/ApplicationCode/ProjectDataModel/RimAnnotationInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/Annotations/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/RimPolylinesAnnotation.cpp b/ApplicationCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.cpp similarity index 89% rename from ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.cpp rename to ApplicationCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.cpp index e4de0642d1..c87dbc6762 100644 --- a/ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.cpp +++ b/ApplicationCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.cpp @@ -57,12 +57,12 @@ caf::PdmFieldHandle* RimPolylinesAnnotation::objectToggleField() return &m_isActive; } -CAF_PDM_SOURCE_INIT(RimUserDefinedPolyLinesAnnotation, "UserDefinedPolyLinesAnnotation"); +CAF_PDM_SOURCE_INIT(RimUserDefinedPolylinesAnnotation, "UserDefinedPolylinesAnnotation"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimUserDefinedPolyLinesAnnotation::RimUserDefinedPolyLinesAnnotation() +RimUserDefinedPolylinesAnnotation::RimUserDefinedPolylinesAnnotation() { CAF_PDM_InitObject("PolyLines Annotation", ":/WellCollection.png", "", ""); @@ -72,7 +72,7 @@ RimUserDefinedPolyLinesAnnotation::RimUserDefinedPolyLinesAnnotation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimUserDefinedPolyLinesAnnotation::~RimUserDefinedPolyLinesAnnotation() +RimUserDefinedPolylinesAnnotation::~RimUserDefinedPolylinesAnnotation() { } @@ -80,7 +80,7 @@ RimUserDefinedPolyLinesAnnotation::~RimUserDefinedPolyLinesAnnotation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimUserDefinedPolyLinesAnnotation::polyLinesData() +cvf::ref RimUserDefinedPolylinesAnnotation::polyLinesData() { cvf::ref pld = new RigPolyLinesData; std::vector > lines; @@ -93,7 +93,7 @@ cvf::ref RimUserDefinedPolyLinesAnnotation::polyLinesData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimUserDefinedPolyLinesAnnotation::isEmpty() +bool RimUserDefinedPolylinesAnnotation::isEmpty() { return m_points().empty(); } @@ -101,7 +101,7 @@ bool RimUserDefinedPolyLinesAnnotation::isEmpty() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUserDefinedPolyLinesAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimUserDefinedPolylinesAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { uiOrdering.add(&m_points); @@ -111,7 +111,7 @@ void RimUserDefinedPolyLinesAnnotation::defineUiOrdering(QString uiConfigName, c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUserDefinedPolyLinesAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField, +void RimUserDefinedPolylinesAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { @@ -126,12 +126,12 @@ void RimUserDefinedPolyLinesAnnotation::fieldChangedByUi(const caf::PdmFieldHand #include "cafPdmUiFilePathEditor.h" -CAF_PDM_SOURCE_INIT(RimPolyLinesFromFileAnnotation, "PolyLinesFromFileAnnotation"); +CAF_PDM_SOURCE_INIT(RimPolylinesFromFileAnnotation, "PolylinesFromFileAnnotation"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolyLinesFromFileAnnotation::RimPolyLinesFromFileAnnotation() +RimPolylinesFromFileAnnotation::RimPolylinesFromFileAnnotation() { CAF_PDM_InitObject("PolyLines Annotation", ":/WellCollection.png", "", ""); @@ -144,7 +144,7 @@ RimPolyLinesFromFileAnnotation::RimPolyLinesFromFileAnnotation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimPolyLinesFromFileAnnotation::~RimPolyLinesFromFileAnnotation() +RimPolylinesFromFileAnnotation::~RimPolylinesFromFileAnnotation() { } @@ -152,7 +152,7 @@ RimPolyLinesFromFileAnnotation::~RimPolyLinesFromFileAnnotation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolyLinesFromFileAnnotation::setFileName(const QString& fileName) +void RimPolylinesFromFileAnnotation::setFileName(const QString& fileName) { m_polyLinesFileName = fileName; } @@ -160,7 +160,7 @@ void RimPolyLinesFromFileAnnotation::setFileName(const QString& fileName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const QString& RimPolyLinesFromFileAnnotation::fileName() +const QString& RimPolylinesFromFileAnnotation::fileName() { return m_polyLinesFileName(); } @@ -168,7 +168,7 @@ const QString& RimPolyLinesFromFileAnnotation::fileName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolyLinesFromFileAnnotation::readPolyLinesFile(QString * errorMessage) +void RimPolylinesFromFileAnnotation::readPolyLinesFile(QString * errorMessage) { QFile dataFile(m_polyLinesFileName()); @@ -239,7 +239,7 @@ void RimPolyLinesFromFileAnnotation::readPolyLinesFile(QString * errorMessage) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimPolyLinesFromFileAnnotation::isEmpty() +bool RimPolylinesFromFileAnnotation::isEmpty() { bool isThisEmpty = true; for (const std::vector & line :m_polyLinesData->polyLines()) @@ -253,7 +253,7 @@ bool RimPolyLinesFromFileAnnotation::isEmpty() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolyLinesFromFileAnnotation::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) +void RimPolylinesFromFileAnnotation::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { m_polyLinesFileName = RimTools::relocateFile(m_polyLinesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr); @@ -262,7 +262,7 @@ void RimPolyLinesFromFileAnnotation::updateFilePathsFromProjectPath(const QStrin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimPolyLinesFromFileAnnotation::setDescriptionFromFileName() +void RimPolylinesFromFileAnnotation::setDescriptionFromFileName() { QFileInfo fileInfo(m_polyLinesFileName()); m_userDescription = fileInfo.fileName(); @@ -272,7 +272,7 @@ void RimPolyLinesFromFileAnnotation::setDescriptionFromFileName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmFieldHandle* RimPolyLinesFromFileAnnotation::userDescriptionField() +caf::PdmFieldHandle* RimPolylinesFromFileAnnotation::userDescriptionField() { return &m_userDescription; } diff --git a/ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.h b/ApplicationCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.h similarity index 93% rename from ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.h rename to ApplicationCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.h index b67054fbc7..359314d17c 100644 --- a/ApplicationCode/ProjectDataModel/RimPolylinesAnnotation.h +++ b/ApplicationCode/ProjectDataModel/Annotations/RimPolylinesAnnotation.h @@ -69,14 +69,14 @@ private: /// //================================================================================================== -class RimUserDefinedPolyLinesAnnotation : public RimPolylinesAnnotation +class RimUserDefinedPolylinesAnnotation : public RimPolylinesAnnotation { using Vec3d = cvf::Vec3d; CAF_PDM_HEADER_INIT; public: - RimUserDefinedPolyLinesAnnotation(); - ~RimUserDefinedPolyLinesAnnotation(); + RimUserDefinedPolylinesAnnotation(); + ~RimUserDefinedPolylinesAnnotation(); cvf::ref polyLinesData() override; virtual bool isEmpty() override; @@ -95,12 +95,12 @@ private: //================================================================================================== -class RimPolyLinesFromFileAnnotation : public RimPolylinesAnnotation +class RimPolylinesFromFileAnnotation : public RimPolylinesAnnotation { CAF_PDM_HEADER_INIT; public: - RimPolyLinesFromFileAnnotation(); - ~RimPolyLinesFromFileAnnotation(); + RimPolylinesFromFileAnnotation(); + ~RimPolylinesFromFileAnnotation(); void setFileName(const QString& fileName); const QString& fileName(); diff --git a/ApplicationCode/ProjectDataModel/RimReachCircleAnnotation.cpp b/ApplicationCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp similarity index 100% rename from ApplicationCode/ProjectDataModel/RimReachCircleAnnotation.cpp rename to ApplicationCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.cpp diff --git a/ApplicationCode/ProjectDataModel/RimReachCircleAnnotation.h b/ApplicationCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.h similarity index 100% rename from ApplicationCode/ProjectDataModel/RimReachCircleAnnotation.h rename to ApplicationCode/ProjectDataModel/Annotations/RimReachCircleAnnotation.h diff --git a/ApplicationCode/ProjectDataModel/RimTextAnnotation.cpp b/ApplicationCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp similarity index 98% rename from ApplicationCode/ProjectDataModel/RimTextAnnotation.cpp rename to ApplicationCode/ProjectDataModel/Annotations/RimTextAnnotation.cpp index 9eeb3d2160..d189280693 100644 --- a/ApplicationCode/ProjectDataModel/RimTextAnnotation.cpp +++ b/ApplicationCode/ProjectDataModel/Annotations/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", "", "", ""); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimTextAnnotation.h b/ApplicationCode/ProjectDataModel/Annotations/RimTextAnnotation.h similarity index 100% rename from ApplicationCode/ProjectDataModel/RimTextAnnotation.h rename to ApplicationCode/ProjectDataModel/Annotations/RimTextAnnotation.h diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index 9638683bbe..036c54b2c2 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -122,12 +122,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RimContourMapView.h ${CMAKE_CURRENT_LIST_DIR}/RimContourMapViewCollection.h ${CMAKE_CURRENT_LIST_DIR}/RimContourMapNameConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimScaleLegendConfig.h -${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 ) @@ -254,12 +248,6 @@ ${CMAKE_CURRENT_LIST_DIR}/RimContourMapView.cpp ${CMAKE_CURRENT_LIST_DIR}/RimContourMapViewCollection.cpp ${CMAKE_CURRENT_LIST_DIR}/RimContourMapNameConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/RimScaleLegendConfig.cpp -${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 ) list(APPEND CODE_HEADER_FILES 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/RimPolylineAnnotation.cpp b/ApplicationCode/ProjectDataModel/RimPolylineAnnotation.cpp deleted file mode 100644 index 022757ec59..0000000000 --- a/ApplicationCode/ProjectDataModel/RimPolylineAnnotation.cpp +++ /dev/null @@ -1,144 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// 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 "RimPolylineAnnotation.h" - -#include "RiaApplication.h" -#include "RiaColorTables.h" -#include "RiaLogging.h" -#include "RiaPreferences.h" -#include "RiaWellNameComparer.h" - -#include "RigEclipseCaseData.h" -#include "RigMainGrid.h" -#include "RigWellPath.h" - -#include "RimAnnotationInViewCollection.h" -#include "RimEclipseCase.h" -#include "RimEclipseCaseCollection.h" -#include "RimGridView.h" -#include "RimOilField.h" -#include "RimProject.h" -#include "RimWellLogFile.h" -#include "RimWellPath.h" -#include "RimPerforationCollection.h" - -#include "Riu3DMainWindowTools.h" - -#include "RifWellPathFormationsImporter.h" -#include "RifWellPathImporter.h" - -#include "cafPdmUiEditorHandle.h" -#include "cafProgressInfo.h" - -#include -#include -#include -#include - -#include -#include -#include "RimFileWellPath.h" -#include "RimModeledWellPath.h" - - -CAF_PDM_SOURCE_INIT(RimPolylineAnnotation, "RimPolylineAnnotation"); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimPolylineAnnotation::RimPolylineAnnotation() -{ - CAF_PDM_InitObject("PolylineAnnotation", ":/WellCollection.png", "", ""); - - CAF_PDM_InitField(&m_points, "Points", {}, "Points", "", "", ""); -} - -RimPolylineAnnotation::~RimPolylineAnnotation() -{ - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolylineAnnotation::setPoints(const std::vector& points) -{ - m_points = points; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const std::vector& RimPolylineAnnotation::points() const -{ - return m_points(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolylineAnnotation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ - uiOrdering.add(&m_points); - - uiOrdering.skipRemainingFields(true); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimPolylineAnnotation::fieldChangedByUi(const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue) -{ - auto views = gridViewsContainingAnnotations(); - if (!views.empty()) - { - if (changedField == &m_points) - { - for (auto& view : views) - { - view->scheduleCreateDisplayModelAndRedraw(); - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimPolylineAnnotation::gridViewsContainingAnnotations() const -{ - std::vector views; - RimProject* project = nullptr; - this->firstAncestorOrThisOfType(project); - - if (!project) return views; - - std::vector visibleGridViews; - project->allVisibleGridViews(visibleGridViews); - - for (auto& gridView : visibleGridViews) - { - if (gridView->annotationCollection()->isActive()) views.push_back(gridView); - } - return views; -} 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();