mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
This commit is contained in:
@@ -20,30 +20,27 @@
|
||||
#include "RiuRmsNavigation.h"
|
||||
#include "cafViewer.h"
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfScene.h"
|
||||
#include "cvfModel.h"
|
||||
#include "cvfViewport.h"
|
||||
#include "cvfHitItemCollection.h"
|
||||
#include "cvfRay.h"
|
||||
#include "cvfManipulatorTrackball.h"
|
||||
|
||||
#include <QInputEvent>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
using cvf::ManipulatorTrackball;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRmsNavigation::init()
|
||||
RiuRmsNavigation::RiuRmsNavigation()
|
||||
{
|
||||
m_trackball = new cvf::ManipulatorTrackball;
|
||||
m_trackball->setCamera(m_viewer->mainCamera());
|
||||
m_isRotCenterInitialized = false;
|
||||
m_hasMovedMouseDuringNavigation = false;
|
||||
m_isNavigating = false;
|
||||
m_isZooming = false;
|
||||
m_lastPosX = 0;
|
||||
m_lastPosY = 0;
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuRmsNavigation::~RiuRmsNavigation()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -196,87 +193,3 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent)
|
||||
return false;//isEventHandled;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRmsNavigation::initializeRotationCenter()
|
||||
{
|
||||
if (m_isRotCenterInitialized
|
||||
|| m_trackball.isNull()
|
||||
|| !m_viewer->currentScene()->boundingBox().isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cvf::Vec3d pointOfInterest = m_viewer->currentScene()->boundingBox().center();
|
||||
|
||||
this->setPointOfInterest(pointOfInterest);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Repositions and orients the camera to view the rotation point along the
|
||||
/// direction "alongDirection". The distance to the rotation point is maintained.
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRmsNavigation::setView( const cvf::Vec3d& alongDirection, const cvf::Vec3d& upDirection )
|
||||
{
|
||||
m_trackball->setView(alongDirection, upDirection);
|
||||
/*
|
||||
if (m_camera.isNull()) return;
|
||||
|
||||
Vec3d dir = alongDirection;
|
||||
if (!dir.normalize()) return;
|
||||
Vec3d up = upDirection;
|
||||
if(!up.normalize()) up = Vec3d::Z_AXIS;
|
||||
|
||||
if((up * dir) < 1e-2) up = dir.perpendicularVector();
|
||||
|
||||
Vec3d cToE = m_camera->position() - m_rotationPoint;
|
||||
Vec3d newEye = m_rotationPoint - cToE.length() * dir;
|
||||
|
||||
m_camera->setFromLookAt(newEye, m_rotationPoint, upDirection);
|
||||
*/
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::Vec3d RiuRmsNavigation::pointOfInterest()
|
||||
{
|
||||
initializeRotationCenter();
|
||||
return m_pointOfInterest;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRmsNavigation::setPointOfInterest(cvf::Vec3d poi)
|
||||
{
|
||||
m_pointOfInterest = poi;
|
||||
m_trackball->setRotationPoint(poi);
|
||||
m_isRotCenterInitialized = true;
|
||||
m_viewer->updateParallelProjectionCameraPosFromPointOfInterestMove(m_pointOfInterest);
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuRmsNavigation::zoomAlongRay(cvf::Ray* ray, int delta)
|
||||
{
|
||||
if (ray && abs(delta) > 0)
|
||||
{
|
||||
cvf::Vec3d pos, vrp, up;
|
||||
m_viewer->mainCamera()->toLookAt(&pos, &vrp, &up);
|
||||
|
||||
double scale = delta/8.0 * 1.0/150 * (pos - m_pointOfInterest).length();
|
||||
cvf::Vec3d trans = scale * ray->direction();
|
||||
cvf::Vec3d newPos = pos + trans;
|
||||
cvf::Vec3d newVrp = vrp + trans;
|
||||
|
||||
m_viewer->mainCamera()->setFromLookAt(newPos, newVrp, up );
|
||||
m_viewer->updateParallelProjectionHeightFromMoveZoom(m_pointOfInterest);
|
||||
|
||||
m_viewer->navigationPolicyUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user