2019-02-05 09:03:17 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2019- 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>
|
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RicVec3dPickEventHandler.h"
|
|
|
|
|
|
|
|
#include "Rim3dView.h"
|
2019-04-16 05:55:53 -05:00
|
|
|
#include "RimCase.h"
|
2019-03-22 09:55:51 -05:00
|
|
|
#include "RiuViewer.h"
|
2019-02-05 09:03:17 -06:00
|
|
|
|
|
|
|
#include "cafDisplayCoordTransform.h"
|
2019-02-06 06:20:33 -06:00
|
|
|
#include "cafSelectionManager.h"
|
2019-02-05 09:03:17 -06:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-04-16 05:55:53 -05:00
|
|
|
/// zOffsetFactor will be multiplied by characteristic length to yield a z-offset
|
2019-02-05 09:03:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RicVec3dPickEventHandler::RicVec3dPickEventHandler( caf::PdmField<cvf::Vec3d>* vectorField, double zOffsetFactor )
|
|
|
|
: m_vectorField( vectorField )
|
|
|
|
, m_zOffsetFactor( zOffsetFactor )
|
2019-02-05 09:03:17 -06:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
bool RicVec3dPickEventHandler::handle3dPickEvent( const Ric3dPickEvent& eventObject )
|
2019-02-05 09:03:17 -06:00
|
|
|
{
|
2019-02-11 06:46:48 -06:00
|
|
|
const Rim3dView* rimView = eventObject.m_view;
|
2019-02-05 09:03:17 -06:00
|
|
|
|
2019-04-16 05:55:53 -05:00
|
|
|
cvf::Vec3d pickedPosition = eventObject.m_pickItemInfos.front().globalPickedPoint();
|
|
|
|
|
2024-03-15 03:32:45 -05:00
|
|
|
if ( rimView->ownerCase() )
|
2019-04-16 05:55:53 -05:00
|
|
|
{
|
2024-03-15 03:32:45 -05:00
|
|
|
double zPickOffset = rimView->ownerCase()->characteristicCellSize() * m_zOffsetFactor;
|
2019-04-16 05:55:53 -05:00
|
|
|
pickedPosition.z() += zPickOffset;
|
|
|
|
}
|
2019-04-10 09:13:40 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
cvf::ref<caf::DisplayCoordTransform> transForm = rimView->displayCoordTransform();
|
|
|
|
cvf::Vec3d pickedPositionInUTM = transForm->transformToDomainCoord( pickedPosition );
|
2019-02-06 06:20:33 -06:00
|
|
|
|
2019-02-11 06:46:48 -06:00
|
|
|
pickedPositionInUTM.z() *= -1.0;
|
2019-04-10 09:13:40 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_vectorField->setValueWithFieldChanged( pickedPositionInUTM );
|
2019-02-11 06:46:48 -06:00
|
|
|
return true;
|
2019-02-05 09:03:17 -06:00
|
|
|
}
|
|
|
|
|
2019-02-07 09:34:23 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicVec3dPickEventHandler::registerAsPickEventHandler()
|
|
|
|
{
|
|
|
|
Ric3dViewPickEventHandler::registerAsPickEventHandler();
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuViewer::setHoverCursor( Qt::CrossCursor );
|
2019-02-07 09:34:23 -06:00
|
|
|
}
|
|
|
|
|
2019-02-05 09:03:17 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RicVec3dPickEventHandler::notifyUnregistered()
|
|
|
|
{
|
2019-03-22 09:55:51 -05:00
|
|
|
RiuViewer::clearHoverCursor();
|
2019-02-05 09:03:17 -06:00
|
|
|
}
|