2018-12-19 07:41:17 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
2019-01-09 08:21:38 -06:00
|
|
|
// Copyright (C) 2018- Equinor ASA
|
2019-01-02 08:04:05 -06:00
|
|
|
//
|
2018-12-19 07:41:17 -06:00
|
|
|
// 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.
|
2019-01-02 08:04:05 -06:00
|
|
|
//
|
2018-12-19 07:41:17 -06:00
|
|
|
// 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.
|
2019-01-02 08:04:05 -06:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-12-19 07:41:17 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicMeasurementPickEventHandler.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
2019-01-02 08:04:05 -06:00
|
|
|
#include "Rim3dView.h"
|
2018-12-19 07:41:17 -06:00
|
|
|
#include "RimIntersection.h"
|
|
|
|
#include "RimMeasurement.h"
|
2019-01-02 08:04:05 -06:00
|
|
|
#include "RimProject.h"
|
2018-12-19 07:41:17 -06:00
|
|
|
|
|
|
|
#include "cafDisplayCoordTransform.h"
|
|
|
|
#include "cafSelectionManager.h"
|
|
|
|
|
2019-01-03 04:34:50 -06:00
|
|
|
#include "RivPartPriority.h"
|
|
|
|
|
|
|
|
#include "cvfPart.h"
|
|
|
|
|
2018-12-19 07:41:17 -06:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 08:04:05 -06:00
|
|
|
///
|
2018-12-19 07:41:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicMeasurementPickEventHandler* RicMeasurementPickEventHandler::instance()
|
|
|
|
{
|
|
|
|
static RicMeasurementPickEventHandler* singleton = new RicMeasurementPickEventHandler;
|
|
|
|
return singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 08:04:05 -06:00
|
|
|
///
|
2018-12-19 07:41:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
bool RicMeasurementPickEventHandler::handlePickEvent(const Ric3DPickEvent& eventObject)
|
|
|
|
{
|
2019-01-02 08:04:05 -06:00
|
|
|
auto measurement = RiaApplication::instance()->project()->measurement();
|
2018-12-19 07:41:17 -06:00
|
|
|
|
|
|
|
if (measurement && measurement->isInMeasurementMode())
|
|
|
|
{
|
2019-01-03 04:34:50 -06:00
|
|
|
const RiuPickItemInfo* firstGeometryPickInfo = nullptr;
|
|
|
|
for (const auto& info : eventObject.m_pickItemInfos)
|
|
|
|
{
|
|
|
|
auto partCandidate = info.pickedPart();
|
|
|
|
if (!firstGeometryPickInfo && partCandidate->priority() != RivPartPriority::PartType::Text)
|
|
|
|
{
|
|
|
|
firstGeometryPickInfo = &info;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-20 05:34:17 -06:00
|
|
|
Rim3dView* rimView = RiaApplication::instance()->activeReservoirView();
|
2018-12-19 07:41:17 -06:00
|
|
|
|
2019-01-03 04:34:50 -06:00
|
|
|
if (firstGeometryPickInfo && rimView)
|
|
|
|
{
|
|
|
|
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
2018-12-19 07:41:17 -06:00
|
|
|
|
2019-01-03 04:34:50 -06:00
|
|
|
cvf::Vec3d domainCoord = transForm->transformToDomainCoord(firstGeometryPickInfo->globalPickedPoint());
|
2019-01-02 08:04:05 -06:00
|
|
|
|
2019-01-03 04:34:50 -06:00
|
|
|
bool isControlButtonDown = QApplication::keyboardModifiers() & Qt::ControlModifier;
|
|
|
|
|
|
|
|
if (!isControlButtonDown)
|
2019-01-02 08:04:05 -06:00
|
|
|
{
|
2019-01-03 04:34:50 -06:00
|
|
|
if (measurement->pointsInDomainCoords().size() > 1)
|
|
|
|
{
|
|
|
|
measurement->removeAllPoints();
|
|
|
|
}
|
2019-01-02 08:04:05 -06:00
|
|
|
}
|
|
|
|
|
2019-01-03 04:34:50 -06:00
|
|
|
measurement->addPointInDomainCoords(domainCoord);
|
|
|
|
}
|
2018-12-19 07:41:17 -06:00
|
|
|
|
2018-12-20 05:34:17 -06:00
|
|
|
// Further Ui processing is stopped when true is returned
|
|
|
|
return true;
|
2018-12-19 07:41:17 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-01-02 08:04:05 -06:00
|
|
|
void RicMeasurementPickEventHandler::notifyUnregistered() {}
|