#3924 Measurements : Rename, fix issues with points in multiple views

This commit is contained in:
Magne Sjaastad 2019-01-03 07:18:22 +01:00
parent 31a30f8a94
commit 8f85e49849
5 changed files with 59 additions and 50 deletions

View File

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

View File

@ -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<RivMeasurementPartMgr::Vec3d>
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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// 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<cvf::Vec3d> RimMeasurement::pointsInDomain() const
std::vector<cvf::Vec3d> RimMeasurement::pointsInDomainCoords() const
{
return m_pointsInDomain;
return m_pointsInDomainCoords;
}
//--------------------------------------------------------------------------------------------------
@ -93,7 +97,7 @@ std::vector<cvf::Vec3d> 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();
}
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// 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<Vec3d> pointsInDomain() const;
void addPointInDomainCoords(const Vec3d& pointInDomainCoord);
std::vector<Vec3d> 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<Vec3d> m_pointsInDomain;
private:
bool m_isInMeasurementMode;
std::vector<Vec3d> m_pointsInDomainCoords;
caf::PdmPointer<Rim3dView> m_sourceView;
};

View File

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