mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
caf::Viewer: Add method to get correct ray definition when it is inside comparison view
This commit is contained in:
@@ -60,6 +60,7 @@
|
|||||||
#include "cvfRenderSequence.h"
|
#include "cvfRenderSequence.h"
|
||||||
#include "cvfRenderbufferObject.h"
|
#include "cvfRenderbufferObject.h"
|
||||||
#include "cvfRendering.h"
|
#include "cvfRendering.h"
|
||||||
|
#include "cvfRenderingScissor.h"
|
||||||
#include "cvfScene.h"
|
#include "cvfScene.h"
|
||||||
#include "cvfShaderSourceProvider.h"
|
#include "cvfShaderSourceProvider.h"
|
||||||
#include "cvfSingleQuadRenderingGenerator.h"
|
#include "cvfSingleQuadRenderingGenerator.h"
|
||||||
@@ -72,11 +73,11 @@
|
|||||||
#include "cvfqtPerformanceInfoHud.h"
|
#include "cvfqtPerformanceInfoHud.h"
|
||||||
#include "cvfqtUtils.h"
|
#include "cvfqtUtils.h"
|
||||||
|
|
||||||
#include <cmath>
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QInputEvent>
|
#include <QInputEvent>
|
||||||
#include "cvfRenderingScissor.h"
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
namespace caf
|
namespace caf
|
||||||
{
|
{
|
||||||
@@ -641,6 +642,20 @@ const caf::NavigationPolicy* caf::Viewer::getNavigationPolicy() const
|
|||||||
return m_navigationPolicy.p();
|
return m_navigationPolicy.p();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::ref<cvf::RayIntersectSpec> caf::Viewer::rayIntersectSpecFromWindowCoordinates( int winPosX, int winPosY )
|
||||||
|
{
|
||||||
|
bool mousePosIsWithinComparisonView = isMousePosWithinComparisonView(winPosX, winPosY);
|
||||||
|
|
||||||
|
int translatedMousePosX = winPosX;
|
||||||
|
int translatedMousePosY = height() - winPosY;
|
||||||
|
|
||||||
|
cvf::Rendering* renderingToInvestigate = mousePosIsWithinComparisonView ? m_comparisonMainRendering.p(): m_mainRendering.p();
|
||||||
|
|
||||||
|
return renderingToInvestigate->rayIntersectSpecFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@@ -649,14 +664,12 @@ bool caf::Viewer::rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pick
|
|||||||
{
|
{
|
||||||
CVF_ASSERT(m_mainRendering.notNull());
|
CVF_ASSERT(m_mainRendering.notNull());
|
||||||
|
|
||||||
int translatedMousePosX = winPosX;
|
|
||||||
int translatedMousePosY = height() - winPosY;
|
|
||||||
|
|
||||||
bool mousePosIsWithinComparisonView = isMousePosWithinComparisonView(winPosX, winPosY);
|
bool mousePosIsWithinComparisonView = isMousePosWithinComparisonView(winPosX, winPosY);
|
||||||
|
|
||||||
cvf::Rendering* renderingToInvestigate = mousePosIsWithinComparisonView ? m_comparisonMainRendering.p(): m_mainRendering.p();
|
cvf::Rendering* renderingToInvestigate = mousePosIsWithinComparisonView ? m_comparisonMainRendering.p(): m_mainRendering.p();
|
||||||
|
|
||||||
cvf::ref<cvf::RayIntersectSpec> ris = renderingToInvestigate->rayIntersectSpecFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
cvf::ref<cvf::RayIntersectSpec> ris = rayIntersectSpecFromWindowCoordinates(winPosX, winPosY);
|
||||||
|
|
||||||
if (ris.notNull())
|
if (ris.notNull())
|
||||||
{
|
{
|
||||||
bool retVal = renderingToInvestigate->rayIntersect(*ris, pickedPoints);
|
bool retVal = renderingToInvestigate->rayIntersect(*ris, pickedPoints);
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ namespace cvf {
|
|||||||
class Scene;
|
class Scene;
|
||||||
class Texture;
|
class Texture;
|
||||||
class TextureImage;
|
class TextureImage;
|
||||||
|
class RayIntersectSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace caf {
|
namespace caf {
|
||||||
@@ -150,6 +151,7 @@ public:
|
|||||||
// Test whether it is any point in doing navigation etc.
|
// Test whether it is any point in doing navigation etc.
|
||||||
bool canRender() const;
|
bool canRender() const;
|
||||||
|
|
||||||
|
cvf::ref<cvf::RayIntersectSpec> rayIntersectSpecFromWindowCoordinates(int winPosX, int winPosY);
|
||||||
bool rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pickedPoints, cvf::Vec3d* rayGlobalOrigin = nullptr) ;
|
bool rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pickedPoints, cvf::Vec3d* rayGlobalOrigin = nullptr) ;
|
||||||
bool isMousePosWithinComparisonView(int winPosX, int winPosY);
|
bool isMousePosWithinComparisonView(int winPosX, int winPosY);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user