From 8f85e49849b3e85d8dc8007455001a30754052d8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 3 Jan 2019 07:18:22 +0100 Subject: [PATCH] #3924 Measurements : Rename, fix issues with points in multiple views --- .../RicMeasurementPickEventHandler.cpp | 4 +- .../RivMeasurementPartMgr.cpp | 6 +-- .../Measurement/RimMeasurement.cpp | 48 ++++++++++-------- .../Measurement/RimMeasurement.h | 49 ++++++++++--------- .../ProjectDataModel/Rim3dView.cpp | 2 +- 5 files changed, 59 insertions(+), 50 deletions(-) diff --git a/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp b/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp index 8cb5f940da..c82096610b 100644 --- a/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp +++ b/ApplicationCode/Commands/MeasurementCommands/RicMeasurementPickEventHandler.cpp @@ -57,13 +57,13 @@ bool RicMeasurementPickEventHandler::handlePickEvent(const Ric3DPickEvent& event if (!isControlButtonDown) { - if (measurement->pointsInDomain().size() > 1) + if (measurement->pointsInDomainCoords().size() > 1) { measurement->removeAllPoints(); } } - measurement->addPointInDomain(domainCoord); + measurement->addPointInDomainCoords(domainCoord); // Further Ui processing is stopped when true is returned return true; diff --git a/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.cpp b/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.cpp index a19d1d5939..721afe4631 100644 --- a/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivMeasurementPartMgr.cpp @@ -82,7 +82,7 @@ void RivMeasurementPartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* } if (m_measurement.isNull()) return; - if (m_measurement->pointsInDomain().empty()) return; + if (m_measurement->pointsInDomainCoords().empty()) return; // Check bounding box if (!isPolylinesInBoundingBox(boundingBox)) return; @@ -120,7 +120,7 @@ void RivMeasurementPartMgr::clearGeometryCache() //-------------------------------------------------------------------------------------------------- void RivMeasurementPartMgr::buildPolyLineParts(const caf::DisplayCoordTransform* displayCoordTransform) { - auto pointsInDisplay = transformPolylinesPointsToDisplay(m_measurement->pointsInDomain(), displayCoordTransform); + auto pointsInDisplay = transformPolylinesPointsToDisplay(m_measurement->pointsInDomainCoords(), displayCoordTransform); // Measurement lines { @@ -234,7 +234,7 @@ std::vector bool RivMeasurementPartMgr::isPolylinesInBoundingBox(const cvf::BoundingBox& boundingBox) { auto effectiveBoundingBox = RiaBoundingBoxTools::inflate(boundingBox, 3); - for (const auto& pt : m_measurement->pointsInDomain()) + for (const auto& pt : m_measurement->pointsInDomainCoords()) { if (effectiveBoundingBox.contains(pt)) return true; } diff --git a/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.cpp b/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.cpp index 4ff90a468a..114b913bd8 100644 --- a/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.cpp +++ b/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -26,10 +26,8 @@ #include "RiuViewerCommands.h" - CAF_PDM_SOURCE_INIT(RimMeasurement, "RimMeasurement"); - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -40,12 +38,9 @@ RimMeasurement::RimMeasurement() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RimMeasurement::~RimMeasurement() -{ - -} +RimMeasurement::~RimMeasurement() {} //-------------------------------------------------------------------------------------------------- /// @@ -74,18 +69,27 @@ bool RimMeasurement::isInMeasurementMode() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimMeasurement::addPointInDomain(const Vec3d& pointInDomain) +void RimMeasurement::addPointInDomainCoords(const Vec3d& domainCoord) { - m_pointsInDomain.push_back(pointInDomain); + auto activeView = RiaApplication::instance()->activeReservoirView(); + + if (m_sourceView.p() != activeView) + { + removeAllPoints(); + } + + m_pointsInDomainCoords.push_back(domainCoord); + m_sourceView = activeView; + updateView(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimMeasurement::pointsInDomain() const +std::vector RimMeasurement::pointsInDomainCoords() const { - return m_pointsInDomain; + return m_pointsInDomainCoords; } //-------------------------------------------------------------------------------------------------- @@ -93,7 +97,7 @@ std::vector RimMeasurement::pointsInDomain() const //-------------------------------------------------------------------------------------------------- void RimMeasurement::removeAllPoints() { - m_pointsInDomain.clear(); + m_pointsInDomainCoords.clear(); updateView(); } @@ -117,10 +121,10 @@ RimMeasurement::Lengths RimMeasurement::calculateLenghts() const { Lengths lengths; - for (size_t p = 1; p < m_pointsInDomain.size(); p++) + for (size_t p = 1; p < m_pointsInDomainCoords.size(); p++) { - const auto& p0 = m_pointsInDomain[p - 1]; - const auto& p1 = m_pointsInDomain[p]; + const auto& p0 = m_pointsInDomainCoords[p - 1]; + const auto& p1 = m_pointsInDomainCoords[p]; lengths.lastSegmentLength = (p1 - p0).length(); @@ -140,6 +144,8 @@ RimMeasurement::Lengths RimMeasurement::calculateLenghts() const //-------------------------------------------------------------------------------------------------- void RimMeasurement::updateView() const { - auto view = RiaApplication::instance()->activeReservoirView(); - if (view) view->createDisplayModelAndRedraw(); + if (m_sourceView) + { + m_sourceView->createDisplayModelAndRedraw(); + } } diff --git a/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.h b/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.h index f2d5ce9eea..31edc0ea21 100644 --- a/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.h +++ b/ApplicationCode/ProjectDataModel/Measurement/RimMeasurement.h @@ -1,26 +1,28 @@ ///////////////////////////////////////////////////////////////////////////////// // // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once +#include "cafPdmObject.h" #include "cvfBase.h" #include "cvfVector3.h" -#include "cafPdmObject.h" + +class Rim3dView; //================================================================================================== /// @@ -37,11 +39,13 @@ public: { public: Lengths() - : totalLength(0), - lastSegmentLength(0), - totalHorizontalLength(0), - lastSegmentHorisontalLength(0), - area(0) {} + : totalLength(0) + , lastSegmentLength(0) + , totalHorizontalLength(0) + , lastSegmentHorisontalLength(0) + , area(0) + { + } double totalLength; double lastSegmentLength; @@ -53,24 +57,23 @@ public: RimMeasurement(); ~RimMeasurement() override; - void setMeasurementMode(bool measurementMode); - bool isInMeasurementMode() const; + void setMeasurementMode(bool measurementMode); + bool isInMeasurementMode() const; - void addPointInDomain(const Vec3d& pointInDomain); - std::vector pointsInDomain() const; + void addPointInDomainCoords(const Vec3d& pointInDomainCoord); + std::vector pointsInDomainCoords() const; - void removeAllPoints(); + void removeAllPoints(); - QString label() const; + QString label() const; private: - Lengths calculateLenghts() const; + Lengths calculateLenghts() const; + void updateView() const; - void updateView() const; - - bool m_isInMeasurementMode; - - std::vector m_pointsInDomain; +private: + bool m_isInMeasurementMode; + std::vector m_pointsInDomainCoords; + caf::PdmPointer m_sourceView; }; - diff --git a/ApplicationCode/ProjectDataModel/Rim3dView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp index 44391fac8b..fc99a8b59d 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -751,7 +751,7 @@ void Rim3dView::addMeasurementToModel(cvf::ModelBasicList* wellPathModelBasicLis RimMeasurement* measurement = RiaApplication::instance()->project()->measurement(); - if (!measurement || measurement->pointsInDomain().empty()) + if (!measurement || measurement->pointsInDomainCoords().empty()) { m_measurementPartManager->clearGeometryCache(); }