mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
* Improve handling of MD at first target * When sea level well target is disabled, update MD of first target * Show well target spheres by default, allow toggling of spheres * Activate well target modifiers when clicking on well targets * Remove selection update causing an unstable 3D view * Improve display and handling of multiple locations * Add special 3D target for tie in well target * Add slider to tie in MD input field * Show MD in well path target table * Delete all well path laterals when deleting a well path * Python : Add lateral to parent well * Python : Add perforation interval
170 lines
5.9 KiB
C++
170 lines
5.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Copyright (C) 2013- Statoil ASA
|
|
// Copyright (C) 2013- Ceetron Solutions 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 <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RicPointTangentManipulator.h"
|
|
|
|
#include "RicPointTangentManipulatorPartMgr.h"
|
|
#include "RivPartPriority.h"
|
|
|
|
#include "cafPdmUiCommandSystemProxy.h"
|
|
#include "cafViewer.h"
|
|
|
|
#include "cvfCamera.h"
|
|
#include "cvfDrawableGeo.h"
|
|
#include "cvfHitItemCollection.h"
|
|
#include "cvfModelBasicList.h"
|
|
#include "cvfPart.h"
|
|
#include "cvfRay.h"
|
|
#include "cvfRayIntersectSpec.h"
|
|
|
|
#include <QDebug>
|
|
#include <QMouseEvent>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RicPointTangentManipulator::RicPointTangentManipulator( caf::Viewer* viewer )
|
|
: m_viewer( viewer )
|
|
{
|
|
m_partManager = new RicPointTangentManipulatorPartMgr;
|
|
|
|
m_viewer->installEventFilter( this );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RicPointTangentManipulator::~RicPointTangentManipulator()
|
|
{
|
|
if ( m_viewer ) m_viewer->removeEventFilter( this );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicPointTangentManipulator::setOrigin( const cvf::Vec3d& origin )
|
|
{
|
|
m_partManager->setOrigin( origin );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicPointTangentManipulator::setTangent( const cvf::Vec3d& tangent )
|
|
{
|
|
m_partManager->setTangent( tangent );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicPointTangentManipulator::setHandleSize( double handleSize )
|
|
{
|
|
m_partManager->setHandleSize( handleSize );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicPointTangentManipulator::setPolyline( const std::vector<cvf::Vec3d>& polyline )
|
|
{
|
|
m_partManager->setPolyline( polyline );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
void RicPointTangentManipulator::appendPartsToModel( cvf::ModelBasicList* model )
|
|
{
|
|
m_partManager->appendPartsToModel( model );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RicPointTangentManipulator::eventFilter( QObject* obj, QEvent* inputEvent )
|
|
{
|
|
if ( inputEvent->type() == QEvent::MouseButtonPress )
|
|
{
|
|
auto* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
|
|
|
|
if ( mouseEvent->button() == Qt::LeftButton )
|
|
{
|
|
cvf::HitItemCollection hitItems;
|
|
if ( m_viewer->rayPick( mouseEvent->x(), mouseEvent->y(), &hitItems ) )
|
|
{
|
|
m_partManager->tryToActivateManipulator( hitItems.firstItem() );
|
|
|
|
if ( m_partManager->isManipulatorActive() )
|
|
{
|
|
m_isDraggingInComparisonView =
|
|
m_viewer->isMousePosWithinComparisonView( mouseEvent->x(), mouseEvent->y() );
|
|
|
|
emit notifySelected();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if ( inputEvent->type() == QEvent::MouseMove )
|
|
{
|
|
if ( m_partManager->isManipulatorActive() )
|
|
{
|
|
auto* mouseEvent = static_cast<QMouseEvent*>( inputEvent );
|
|
|
|
cvf::ref<cvf::RayIntersectSpec> rayIs =
|
|
m_viewer->rayIntersectSpecFromWindowCoordinates( mouseEvent->pos().x(),
|
|
mouseEvent->pos().y(),
|
|
m_isDraggingInComparisonView );
|
|
|
|
if ( !rayIs.isNull() && rayIs->ray() )
|
|
{
|
|
m_partManager->updateManipulatorFromRay( rayIs->ray() );
|
|
|
|
cvf::Vec3d origin;
|
|
cvf::Vec3d tangent;
|
|
m_partManager->originAndTangent( &origin, &tangent );
|
|
|
|
emit notifyUpdate( origin, tangent );
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else if ( inputEvent->type() == QEvent::MouseButtonRelease )
|
|
{
|
|
if ( m_partManager->isManipulatorActive() )
|
|
{
|
|
m_partManager->endManipulator();
|
|
|
|
cvf::Vec3d origin;
|
|
cvf::Vec3d tangent;
|
|
m_partManager->originAndTangent( &origin, &tangent );
|
|
|
|
emit notifyUpdate( origin, tangent );
|
|
emit notifyDragFinished();
|
|
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|