From 849a623379c128d77ce3127127c15c172de530c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Wed, 19 Dec 2018 14:41:17 +0100 Subject: [PATCH] #3804 #3805 Measurement. Add toolbar button and interactive picking --- ApplicationCode/CMakeLists.txt | 4 + .../CMakeLists_files.cmake | 23 ++ .../RicMeasurementPickEventHandler.cpp | 91 ++++++++ .../RicMeasurementPickEventHandler.h | 35 +++ .../RicToggleMeasurementModeFeature.cpp | 89 ++++++++ .../RicToggleMeasurementModeFeature.h | 45 ++++ .../ModelVisualization/CMakeLists_files.cmake | 2 + .../RivMeasurementPartMgr.cpp | 210 ++++++++++++++++++ .../RivMeasurementPartMgr.h | 72 ++++++ .../Measurement/CMakeLists_files.cmake | 23 ++ .../Measurement/RimMeasurement.cpp | 100 +++++++++ .../Measurement/RimMeasurement.h | 52 +++++ .../ProjectDataModel/Rim3dView.cpp | 49 ++++ ApplicationCode/ProjectDataModel/Rim3dView.h | 4 + .../ProjectDataModel/RimOilField.cpp | 6 +- .../ProjectDataModel/RimOilField.h | 3 +- .../ProjectDataModel/RimProject.cpp | 10 + ApplicationCode/ProjectDataModel/RimProject.h | 3 + ApplicationCode/Resources/NoRuler16x16.png | Bin 0 -> 299 bytes ApplicationCode/Resources/ResInsight.qrc | 3 +- ApplicationCode/Resources/Ruler16x16.png | Bin 0 -> 265 bytes .../UserInterface/RiuMainWindow.cpp | 15 ++ .../UserInterface/RiuViewerCommands.cpp | 1 + 23 files changed, 837 insertions(+), 3 deletions(-) create mode 100644 ApplicationCode/Commands/MeasurementCommands/CMakeLists_files.cmake create mode 100644 ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp create mode 100644 ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.h create mode 100644 ApplicationCode/Commands/MeasurementCommands/RicToggleMeasurementModeFeature.cpp create mode 100644 ApplicationCode/Commands/MeasurementCommands/RicToggleMeasurementModeFeature.h create mode 100644 ApplicationCode/ModelVisualization/RivMeasurementPartMgr.cpp create mode 100644 ApplicationCode/ModelVisualization/RivMeasurementPartMgr.h create mode 100644 ApplicationCode/ProjectDataModel/Measurement/CMakeLists_files.cmake create mode 100644 ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.cpp create mode 100644 ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.h create mode 100644 ApplicationCode/Resources/NoRuler16x16.png create mode 100644 ApplicationCode/Resources/Ruler16x16.png diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index e71d2246e5..6a9918acb7 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -45,6 +45,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/Commands/EclipseCommands ${CMAKE_CURRENT_SOURCE_DIR}/FileInterface ${CMAKE_CURRENT_SOURCE_DIR}/SocketInterface + ${CMAKE_CURRENT_SOURCE_DIR}/Measurement ${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization ${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization/GridBox ${CMAKE_CURRENT_SOURCE_DIR}/ModelVisualization/Intersections @@ -56,6 +57,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Annotations ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Completions ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Flow + ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Measurement ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Summary ${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache @@ -109,6 +111,7 @@ list( APPEND REFERENCED_CMAKE_FILES ProjectDataModel/Flow/CMakeLists_files.cmake ProjectDataModel/Annotations/CMakeLists_files.cmake ProjectDataModel/Completions/CMakeLists_files.cmake + ProjectDataModel/Measurement/CMakeLists_files.cmake GeoMech/GeoMechVisualization/CMakeLists_files.cmake @@ -132,6 +135,7 @@ list( APPEND REFERENCED_CMAKE_FILES Commands/HoloLensCommands/CMakeLists_files.cmake Commands/IntersectionBoxCommands/CMakeLists_files.cmake Commands/IntersectionViewCommands/CMakeLists_files.cmake + Commands/MeasurementCommands/CMakeLists_files.cmake Commands/OctaveScriptCommands/CMakeLists_files.cmake Commands/OperationsUsingObjReferences/CMakeLists_files.cmake Commands/SummaryPlotCommands/CMakeLists_files.cmake diff --git a/ApplicationCode/Commands/MeasurementCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/MeasurementCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..ce64437e6c --- /dev/null +++ b/ApplicationCode/Commands/MeasurementCommands/CMakeLists_files.cmake @@ -0,0 +1,23 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RicToggleMeasurementModeFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicMeasurementPickEventHandler.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RicToggleMeasurementModeFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicMeasurementPickEventHandler.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +list(APPEND QT_MOC_HEADERS +) + +source_group( "CommandFeature\\Measurement" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp b/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp new file mode 100644 index 0000000000..35b914e342 --- /dev/null +++ b/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- 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 "RicMeasurementPickEventHandler.h" + +#include "RiaApplication.h" + +#include "RimProject.h" +#include "RimIntersection.h" +#include "RimMeasurement.h" +#include "Rim3dView.h" + +#include "cafDisplayCoordTransform.h" +#include "cafSelectionManager.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicMeasurementPickEventHandler* RicMeasurementPickEventHandler::instance() +{ + static RicMeasurementPickEventHandler* singleton = new RicMeasurementPickEventHandler; + return singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicMeasurementPickEventHandler::handlePickEvent(const Ric3DPickEvent& eventObject) +{ + auto measurement = RiaApplication::instance()->project()->measurement(); + + if (measurement && measurement->isInMeasurementMode()) + { + { + Rim3dView* rimView = RiaApplication::instance()->activeReservoirView(); + + cvf::ref transForm = rimView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_pickItemInfos.front().globalPickedPoint()); + + //if (intersection->inputPolyLineFromViewerEnabled()) + { + measurement->addPointInDomain(domainCoord); + + // Further Ui processing is stopped when true is returned + return true; + } + //else if (intersection->inputExtrusionPointsFromViewerEnabled()) + //{ + // intersection->appendPointToExtrusionDirection(domainCoord); + + // // Further Ui processing is stopped when true is returned + // return true; + //} + //else if (intersection->inputTwoAzimuthPointsFromViewerEnabled()) + //{ + // intersection->appendPointToAzimuthLine(domainCoord); + + // // Further Ui processing is stopped when true is returned + // return true; + //} + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicMeasurementPickEventHandler::notifyUnregistered() +{ + +} + diff --git a/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.h b/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.h new file mode 100644 index 0000000000..61d1737b49 --- /dev/null +++ b/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.h @@ -0,0 +1,35 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- 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 "RicPickEventHandler.h" + +//================================================================================================== +/// +//================================================================================================== +class RicMeasurementPickEventHandler : public RicPickEventHandler +{ +public: + static RicMeasurementPickEventHandler* instance(); + +protected: + bool handlePickEvent(const Ric3DPickEvent& eventObject) override; + void notifyUnregistered(); +}; + diff --git a/ApplicationCode/Commands/MeasurementCommands/RicToggleMeasurementModeFeature.cpp b/ApplicationCode/Commands/MeasurementCommands/RicToggleMeasurementModeFeature.cpp new file mode 100644 index 0000000000..56e00b9f72 --- /dev/null +++ b/ApplicationCode/Commands/MeasurementCommands/RicToggleMeasurementModeFeature.cpp @@ -0,0 +1,89 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RicToggleMeasurementModeFeature.h" + +#include "RiaApplication.h" + +#include "RimProject.h" +#include "RimMeasurement.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicToggleMeasurementModeFeature, "RicToggleMeasurementModeFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicToggleMeasurementModeFeature::refreshActionLook() +{ + setupActionLook(action()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicToggleMeasurementModeFeature::isCommandEnabled() +{ + return activeView() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicToggleMeasurementModeFeature::onActionTriggered(bool isChecked) +{ + auto meas = measurement(); + meas->setMeasurementMode(!meas->isInMeasurementMode()); + refreshActionLook(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicToggleMeasurementModeFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Measurement Mode"); + + if(measurement()->isInMeasurementMode()) + actionToSetup->setIcon(QIcon(":/NoRuler16x16.png")); + else + actionToSetup->setIcon(QIcon(":/Ruler16x16.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimMeasurement* RicToggleMeasurementModeFeature::measurement() const +{ + return RiaApplication::instance()->project()->measurement(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dView* RicToggleMeasurementModeFeature::activeView() const +{ + auto view = RiaApplication::instance()->activeReservoirView(); + return view; +} diff --git a/ApplicationCode/Commands/MeasurementCommands/RicToggleMeasurementModeFeature.h b/ApplicationCode/Commands/MeasurementCommands/RicToggleMeasurementModeFeature.h new file mode 100644 index 0000000000..c66cec7761 --- /dev/null +++ b/ApplicationCode/Commands/MeasurementCommands/RicToggleMeasurementModeFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "cafCmdFeature.h" + +class RimMeasurement; +class Rim3dView; + +//================================================================================================== +/// +//================================================================================================== +class RicToggleMeasurementModeFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + void refreshActionLook(); + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook(QAction* actionToSetup) override; + +private: + RimMeasurement* measurement() const; + Rim3dView* activeView() const; +}; diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index f248013042..3a444be0a5 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -54,6 +54,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTextAnnotationSourceInfo.h ${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationSourceInfo.h ${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.h ${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivMeasurementPartMgr.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -106,6 +107,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RivTextAnnotationSourceInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RivReachCircleAnnotationSourceInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RivPolylinesAnnotationSourceInfo.cpp ${CMAKE_CURRENT_LIST_DIR}/RivPolylineGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivMeasurementPartMgr.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.cpp b/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.cpp new file mode 100644 index 0000000000..d1e6127fcd --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.cpp @@ -0,0 +1,210 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 "RivMeasurementPartMgr.h" + +#include "RiaApplication.h" +#include "RiaBoundingBoxTools.h" + +#include "Rim3dView.h" +#include "RimAnnotationInViewCollection.h" +#include "RimProject.h" +#include "RimMeasurement.h" +#include "RimUserDefinedPolylinesAnnotationInView.h" +#include "RimPolylinesFromFileAnnotationInView.h" + +#include "RivTextAnnotationPartMgr.h" +#include "RivReachCircleAnnotationPartMgr.h" +#include "RivPolylineAnnotationPartMgr.h" +#include "RivPolylineGenerator.h" +#include "RivPartPriority.h" + +#include +#include +#include +#include "cvfRenderStateDepth.h" +#include "cvfRenderStatePoint.h" +#include "cvfBoundingBox.h" + +#include "cafEffectGenerator.h" +#include "cafDisplayCoordTransform.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivMeasurementPartMgr::RivMeasurementPartMgr(Rim3dView* view) +: m_rimView(view), m_measurement(nullptr) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivMeasurementPartMgr::~RivMeasurementPartMgr() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivMeasurementPartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& boundingBox) +{ + if (m_measurement.isNull()) + { + m_measurement = RiaApplication::instance()->project()->measurement(); + } + + if (m_measurement.isNull()) return; + if (m_measurement->pointsInDomain().empty()) return; + + // Check bounding box + if (!isPolylinesInBoundingBox(boundingBox)) return; + + buildPolyLineParts(displayCoordTransform); + + if (m_linePart.notNull()) + { + model->addPart(m_linePart.p()); + } + + if (m_pointPart.notNull()) + { + model->addPart(m_pointPart.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivMeasurementPartMgr::clearGeometryCache() +{ + m_linePart = nullptr; + m_pointPart = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivMeasurementPartMgr::buildPolyLineParts(const caf::DisplayCoordTransform* displayCoordTransform) +{ + auto pointsInDisplay = transformPolylinesPointsToDisplay(m_measurement->pointsInDomain(), displayCoordTransform); + + // Highlight line + { + cvf::ref polylineGeo = RivPolylineGenerator::createLineAlongPolylineDrawable(pointsInDisplay); + if (polylineGeo.notNull()) + { + //if (useBufferObjects) + //{ + // polylineGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT); + //} + + cvf::ref part = new cvf::Part; + part->setName("Cross Section Polyline"); + part->setDrawable(polylineGeo.p()); + + part->updateBoundingBox(); + part->setPriority(RivPartPriority::PartType::Highlight); + + // Always show this part, also when mesh is turned off + // part->setEnableMask(meshFaultBit); + + cvf::ref eff; + caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA); + eff = lineEffGen.generateUnCachedEffect(); + + cvf::ref depth = new cvf::RenderStateDepth; + depth->enableDepthTest(false); + eff->setRenderState(depth.p()); + + part->setEffect(eff.p()); + + m_linePart = part; + } + } + + cvf::ref polylinePointsGeo = RivPolylineGenerator::createPointsFromPolylineDrawable(pointsInDisplay); + if (polylinePointsGeo.notNull()) + { + //if (useBufferObjects) + //{ + // polylinePointsGeo->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT); + //} + + cvf::ref part = new cvf::Part; + part->setName("Cross Section Polyline"); + part->setDrawable(polylinePointsGeo.p()); + + part->updateBoundingBox(); + part->setPriority(RivPartPriority::PartType::Highlight); + + // Always show this part, also when mesh is turned off + // part->setEnableMask(meshFaultBit); + + cvf::ref eff; + caf::MeshEffectGenerator lineEffGen(cvf::Color3::MAGENTA); + eff = lineEffGen.generateUnCachedEffect(); + + cvf::ref depth = new cvf::RenderStateDepth; + depth->enableDepthTest(false); + eff->setRenderState(depth.p()); + + cvf::ref pointRendState = new cvf::RenderStatePoint(cvf::RenderStatePoint::FIXED_SIZE); + pointRendState->setSize(5.0f); + eff->setRenderState(pointRendState.p()); + + part->setEffect(eff.p()); + + m_pointPart = part; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RivMeasurementPartMgr::transformPolylinesPointsToDisplay(const std::vector& pointsInDomain, + const caf::DisplayCoordTransform* displayXf) +{ + std::vector pointsInDisplay; + for (const auto& pt : pointsInDomain) + { + pointsInDisplay.push_back(displayXf->transformToDisplayCoord(pt)); + } + return pointsInDisplay; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivMeasurementPartMgr::isPolylinesInBoundingBox(const cvf::BoundingBox& boundingBox) +{ + auto effectiveBoundingBox = RiaBoundingBoxTools::inflate(boundingBox, 3); + for (const auto& pt : m_measurement->pointsInDomain()) + { + if (effectiveBoundingBox.contains(pt)) return true; + } + return false; +} diff --git a/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.h b/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.h new file mode 100644 index 0000000000..1c8e246b08 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, 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. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfAssert.h" +#include "cvfCollection.h" +#include "cvfObject.h" +#include "cafPdmPointer.h" +#include "cvfVector3.h" + +namespace cvf +{ + class BoundingBox; + class Part; + class ModelBasicList; + class Transform; + class Font; +} +namespace caf +{ + class DisplayCoordTransform; +} + +class Rim3dView; +class RimMeasurement; + + +class RivMeasurementPartMgr : public cvf::Object +{ + using Vec3d = cvf::Vec3d; + +public: + RivMeasurementPartMgr(Rim3dView* view); + ~RivMeasurementPartMgr() override; + + void appendGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& boundingBox); + + void clearGeometryCache(); + + +private: + void buildPolyLineParts(const caf::DisplayCoordTransform* displayCoordTransform); + + std::vector transformPolylinesPointsToDisplay(const std::vector& pointsInDomain, + const caf::DisplayCoordTransform* displayXf); + bool isPolylinesInBoundingBox(const cvf::BoundingBox& boundingBox); + +private: + caf::PdmPointer m_rimView; + caf::PdmPointer m_measurement; + cvf::ref m_linePart; + cvf::ref m_pointPart; +}; diff --git a/ApplicationCode/ProjectDataModel/Measurement/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Measurement/CMakeLists_files.cmake new file mode 100644 index 0000000000..604b4ed9e4 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Measurement/CMakeLists_files.cmake @@ -0,0 +1,23 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RimMeasurement.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RimMeasurement.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\\Measurement" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.cpp b/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.cpp new file mode 100644 index 0000000000..10d9d3e39f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.cpp @@ -0,0 +1,100 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimMeasurement.h" + +#include "RiaApplication.h" + +#include "Rim3dView.h" + +#include "MeasurementCommands/RicMeasurementPickEventHandler.h" + +#include "RiuViewerCommands.h" + + +CAF_PDM_SOURCE_INIT(RimMeasurement, "RimMeasurement"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimMeasurement::RimMeasurement() + : m_isInMeasurementMode(false) +{ + CAF_PDM_InitObject("Measurement", ":/TextAnnotation16x16.png", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimMeasurement::~RimMeasurement() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMeasurement::setMeasurementMode(bool measurementMode) +{ + m_isInMeasurementMode = measurementMode; + + if (m_isInMeasurementMode) + RiuViewerCommands::setPickEventHandler(RicMeasurementPickEventHandler::instance()); + else + { + RiuViewerCommands::removePickEventHandlerIfActive(RicMeasurementPickEventHandler::instance()); + + m_pointsInDomain.clear(); + updateView(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimMeasurement::isInMeasurementMode() const +{ + return m_isInMeasurementMode; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMeasurement::addPointInDomain(const Vec3d& pointInDomain) +{ + m_pointsInDomain.push_back(pointInDomain); + updateView(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimMeasurement::pointsInDomain() const +{ + return m_pointsInDomain; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimMeasurement::updateView() const +{ + auto view = RiaApplication::instance()->activeReservoirView(); + if (view) view->scheduleCreateDisplayModelAndRedraw(); +} diff --git a/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.h b/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.h new file mode 100644 index 0000000000..97e1706dea --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.h @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfVector3.h" +#include "cafPdmObject.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimMeasurement : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + + using Vec3d = cvf::Vec3d; + +public: + RimMeasurement(); + ~RimMeasurement() override; + + void setMeasurementMode(bool measurementMode); + bool isInMeasurementMode() const; + + void addPointInDomain(const Vec3d& pointInDomain); + std::vector pointsInDomain() const; + +private: + void updateView() const; + + bool m_isInMeasurementMode; + + std::vector m_pointsInDomain; +}; + diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index b7c0641dbf..b779ea54be 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -35,9 +35,11 @@ #include "RimViewLinker.h" #include "RimWellPathCollection.h" #include "RimViewNameConfig.h" +#include "RimMeasurement.h" #include "RivAnnotationsPartMgr.h" #include "RivWellPathsPartMgr.h" +#include "RivMeasurementPartMgr.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -141,6 +143,7 @@ Rim3dView::Rim3dView(void) m_wellPathsPartManager = new RivWellPathsPartMgr(this); m_annotationsPartManager = new RivAnnotationsPartMgr(this); + m_measurementPartManager = new RivMeasurementPartMgr(this); this->setAs3DViewMdiWindow(); } @@ -350,6 +353,7 @@ void Rim3dView::setCurrentTimeStepAndUpdate(int frameIndex) project->mainPlotCollection()->updateCurrentTimeStepInPlots(); appendAnnotationsToModel(); + appendMeasurementToModel(); } //-------------------------------------------------------------------------------------------------- @@ -738,6 +742,29 @@ void Rim3dView::addAnnotationsToModel(cvf::ModelBasicList* wellPathModelBasicLis wellPathModelBasicList->updateBoundingBoxesRecursive(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::addMeasurementToModel(cvf::ModelBasicList* wellPathModelBasicList) +{ + if (!this->ownerCase()) return; + + RimMeasurement* measurement = RiaApplication::instance()->project()->measurement(); + + if (!measurement || measurement->pointsInDomain().empty()) + { + m_measurementPartManager->clearGeometryCache(); + } + else + { + cvf::ref transForm = displayCoordTransform(); + m_measurementPartManager->appendGeometryPartsToModel( + wellPathModelBasicList, transForm.p(), ownerCase()->allCellsBoundingBox()); + } + + wellPathModelBasicList->updateBoundingBoxesRecursive(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1072,3 +1099,25 @@ void Rim3dView::appendAnnotationsToModel() frameScene->addModel(model.p()); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::appendMeasurementToModel() +{ + if (!m_viewer) return; + + cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); + if (frameScene) + { + cvf::String name = "Measurement"; + this->removeModelByName(frameScene, name); + + cvf::ref model = new cvf::ModelBasicList; + model->setName(name); + + addMeasurementToModel(model.p()); + + frameScene->addModel(model.p()); + } +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h index ff93edbcc5..4c685361af 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -43,6 +43,7 @@ class RimLegendConfig; class RimWellPathCollection; class RiuViewer; class RivAnnotationsPartMgr; +class RivMeasurementPartMgr; class RivWellPathsPartMgr; class RimViewNameConfig; @@ -171,6 +172,7 @@ protected: const cvf::BoundingBox& wellPathClipBoundingBox); void addAnnotationsToModel(cvf::ModelBasicList* wellPathModelBasicList); + void addMeasurementToModel(cvf::ModelBasicList* wellPathModelBasicList); void createHighlightAndGridBoxDisplayModel(); @@ -208,6 +210,7 @@ protected: cvf::ref m_wellPathsPartManager; cvf::ref m_annotationsPartManager; + cvf::ref m_measurementPartManager; private: // Overridden PdmObject methods: @@ -239,6 +242,7 @@ private: void handleMdiWindowClosed() override; void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) override; void appendAnnotationsToModel(); + void appendMeasurementToModel(); private: caf::PdmField m_name_OBSOLETE; diff --git a/ApplicationCode/ProjectDataModel/RimOilField.cpp b/ApplicationCode/ProjectDataModel/RimOilField.cpp index 54bf784c72..b835ac1882 100644 --- a/ApplicationCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationCode/ProjectDataModel/RimOilField.cpp @@ -32,7 +32,7 @@ #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" #include "RimWellPathCollection.h" - +#include "RimMeasurement.h" CAF_PDM_SOURCE_INIT(RimOilField, "ResInsightOilField"); //-------------------------------------------------------------------------------------------------- @@ -58,6 +58,10 @@ RimOilField::RimOilField(void) &m_fractureTemplateCollection_OBSOLETE, "FractureDefinitionCollection", "Defenition of Fractures", "", "", ""); completionTemplateCollection = new RimCompletionTemplateCollection; + + CAF_PDM_InitFieldNoDefault(&measurement, "Measurement", "Measurement", "", "", ""); + measurement = new RimMeasurement(); + analysisModels = new RimEclipseCaseCollection(); wellPathCollection = new RimWellPathCollection(); summaryCaseMainCollection = new RimSummaryCaseMainCollection(); diff --git a/ApplicationCode/ProjectDataModel/RimOilField.h b/ApplicationCode/ProjectDataModel/RimOilField.h index 5558889bc4..e2e1790755 100644 --- a/ApplicationCode/ProjectDataModel/RimOilField.h +++ b/ApplicationCode/ProjectDataModel/RimOilField.h @@ -36,6 +36,7 @@ class RimSummaryCase; class RimSummaryCaseMainCollection; class RimWellPathCollection; class RimAnnotationCollection; +class RimMeasurement; //================================================================================================== /// @@ -65,11 +66,11 @@ public: caf::PdmChildField observedDataCollection; caf::PdmChildField formationNamesCollection; caf::PdmChildField annotationCollection; + caf::PdmChildField measurement; protected: virtual void initAfterRead() override; private: caf::PdmChildField m_fractureTemplateCollection_OBSOLETE; - }; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 8233e0abb3..bf4be065f6 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -55,6 +55,7 @@ #include "RimGridView.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" +#include "RimMeasurement.h" #include "RimMultiSnapshotDefinition.h" #include "RimObservedDataCollection.h" #include "RimOilField.h" @@ -1160,6 +1161,14 @@ RiaEclipseUnitTools::UnitSystemType RimProject::commonUnitSystemForAllCases() co return commonUnitSystem; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimMeasurement* RimProject::measurement() const +{ + return activeOilField()->measurement; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1245,6 +1254,7 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS if (oilField->formationNamesCollection()) uiTreeOrdering.add(oilField->formationNamesCollection()); if (oilField->completionTemplateCollection()) uiTreeOrdering.add(oilField->completionTemplateCollection()); if (oilField->annotationCollection()) uiTreeOrdering.add(oilField->annotationCollection()); + if (oilField->measurement()) uiTreeOrdering.add(oilField->measurement()); } uiTreeOrdering.add(scriptCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 547dc87a8a..7815a7395e 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -41,11 +41,13 @@ class RimPolylinesAnnotation; class RimSummaryCalculationCollection; class RimCase; class RimCommandObject; +class RimCommandObject; class RimDialogData; class RimEclipseCase; class RimGeoMechCase; class RimIdenticalGridCaseGroup; class RimMainPlotCollection; +class RimMeasurement; class RimMultiSnapshotDefinition; class RimObservedData; class RimOilField; @@ -161,6 +163,7 @@ public: std::vector allValveTemplates() const; RiaEclipseUnitTools::UnitSystemType commonUnitSystemForAllCases() const; + RimMeasurement* measurement() const; protected: // Overridden methods diff --git a/ApplicationCode/Resources/NoRuler16x16.png b/ApplicationCode/Resources/NoRuler16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..21bf8311d54d1a9cdb863fed81f6857f32f3b2a8 GIT binary patch literal 299 zcmV+`0o4A9P)j{bx)~P5nQ6_G}bM0^Wfe;Ns$fVF27>V!{MuIl2o_ zoKDD)yu7^sj4?4W{{;mF8SdY|kD^&XK!D-zzkdu<4xPdXlRSHKaDWO42|)sb5WwdW xq6|P!?#StcXaler0!s2E8GvpGSq7ko7XX%OY@v$zI;a2u002ovPDHLkV1m&9eG&iw literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 6b42fc8490..6c45973d1a 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -145,7 +145,8 @@ PolylinesFromFile16x16.png ReachCircle16x16.png 2DMapProjection16x16.png - + Ruler16x16.png + NoRuler16x16.png fs_CellFace.glsl diff --git a/ApplicationCode/Resources/Ruler16x16.png b/ApplicationCode/Resources/Ruler16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..cea54428d07fb8d8cb12236bc73c7533b6f59c56 GIT binary patch literal 265 zcmV+k0rvihP)Yqo6C2Or2|Syq<+ie*7IA_b5=cx6v2&_F?989x?JnVD z(8+#W!JsG#UX}&ZG(k!U$8oUbzVBlkM_85x!!V$f0uh0k5r&~g*S0OFsw%GQTC=ci zo0U>p2SLD6O0DBK=3y9Kycl@0%d(6q&vR~?W_JkSUHDHYNwPCIbgSF&?+p$alx4}3 zrYU=#hpy{BnqAk$eO+-A0)5{jiXsi#G)>I&tbqz4F7c2KQTtJR`ZGNMC?-^)78&_u P00000NkvXXu0mjfa>{H` literal 0 HcmV?d00001 diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 69d7f3f5be..390ed41e03 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -75,6 +75,7 @@ #include "cafUtils.h" #include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" +#include "MeasurementCommands/RicToggleMeasurementModeFeature.h" #include "SummaryPlotCommands/RicEditSummaryPlotFeature.h" #include "SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.h" @@ -597,6 +598,11 @@ void RiuMainWindow::createToolBars() m_holoLensToolBar->addAction(cmdFeatureMgr->action("RicHoloLensExportToSharingServerFeature")); } + { + QToolBar* measToolBar = addToolBar(tr("Measurement")); + measToolBar->addAction(cmdFeatureMgr->action("RicToggleMeasurementModeFeature")); + } + RiaApplication* app = RiaApplication::instance(); if (app->preferences()->showTestToolbar()) { @@ -869,6 +875,15 @@ void RiuMainWindow::slotRefreshViewActions() << "RicViewZoomAllFeature"; caf::CmdFeatureManager::instance()->refreshEnabledState(commandIds); + + + caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance(); + auto feature = dynamic_cast( + cmdFeatureMgr->getCommandFeature("RicToggleMeasurementModeFeature")); + if (feature) + { + feature->refreshActionLook(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 2d145e7804..aeccff9223 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -27,6 +27,7 @@ #include "RicGeoMechPropertyFilterNewExec.h" #include "RicPickEventHandler.h" #include "RicContourMapPickEventHandler.h" +#include "MeasurementCommands/RicMeasurementPickEventHandler.h" #include "WellLogCommands/Ric3dWellLogCurvePickEventHandler.h" #include "WellPathCommands/RicIntersectionPickEventHandler.h" #include "WellPathCommands/RicWellPathPickEventHandler.h"