mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
caf::Viewer: Maintain a flag telling if we have an active comparison view.
Set a custom widget property to communicate it to PdmUiSelection3dEditorVisualizer Add method to specifically get the Ray intersect speck from each rendering
This commit is contained in:
parent
6850a37c11
commit
904808394b
@ -133,7 +133,8 @@ caf::Viewer::Viewer(const QGLFormat& format, QWidget* parent)
|
||||
m_parallelProjectionLightDirection(0, 0, -1), // Light directly from behind
|
||||
m_comparisonViewOffset(0, 0, 0),
|
||||
m_comparisonWindowNormalizedRect(0.5f, 0.0f, 0.5f, 1.0f),
|
||||
m_isComparisonFollowingAnimation(true)
|
||||
m_isComparisonFollowingAnimation(true),
|
||||
m_isComparisonViewActiveFlag(false)
|
||||
{
|
||||
#if QT_VERSION >= 0x050000
|
||||
m_layoutWidget = new QWidget(parent);
|
||||
@ -353,6 +354,14 @@ cvf::Rectf caf::Viewer::comparisonViewVisibleNormalizedRect() const
|
||||
return m_comparisonWindowNormalizedRect;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::Viewer::isComparisonViewActive() const
|
||||
{
|
||||
return m_isComparisonViewActiveFlag;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Set the scene to be rendered when the animation is inactive (Stopped)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -368,6 +377,7 @@ void caf::Viewer::setMainScene(cvf::Scene* scene, bool isForComparisonView )
|
||||
{
|
||||
m_comparisonMainScene = scene;
|
||||
m_comparisonMainRendering->setScene(scene);
|
||||
updateComparisonViewActiveFlag();
|
||||
}
|
||||
}
|
||||
|
||||
@ -648,11 +658,19 @@ cvf::ref<cvf::RayIntersectSpec> caf::Viewer::rayIntersectSpecFromWindowCoordinat
|
||||
{
|
||||
bool mousePosIsWithinComparisonView = isMousePosWithinComparisonView(winPosX, winPosY);
|
||||
|
||||
return this->rayIntersectSpecFromWindowCoordinates(winPosX, winPosY, mousePosIsWithinComparisonView);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::RayIntersectSpec> caf::Viewer::rayIntersectSpecFromWindowCoordinates(int winPosX, int winPosY, bool isForComparisonView)
|
||||
{
|
||||
int translatedMousePosX = winPosX;
|
||||
int translatedMousePosY = height() - winPosY;
|
||||
|
||||
cvf::Rendering* renderingToInvestigate = mousePosIsWithinComparisonView ? m_comparisonMainRendering.p(): m_mainRendering.p();
|
||||
|
||||
cvf::Rendering* renderingToInvestigate = isForComparisonView ? m_comparisonMainRendering.p(): m_mainRendering.p();
|
||||
|
||||
return renderingToInvestigate->rayIntersectSpecFromWindowCoordinates(translatedMousePosX, translatedMousePosY);
|
||||
}
|
||||
|
||||
@ -952,6 +970,7 @@ void caf::Viewer::removeAllFrames(bool isForComparisonView)
|
||||
{
|
||||
m_comparisonFrameScenes.clear();
|
||||
m_comparisonMainRendering->setScene(m_comparisonMainScene.p());
|
||||
updateComparisonViewActiveFlag();
|
||||
}
|
||||
|
||||
m_animationControl->setNumFrames(static_cast<int>(frameCount()));
|
||||
@ -978,6 +997,15 @@ bool caf::Viewer::isAnimationActive()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::Viewer::updateComparisonViewActiveFlag()
|
||||
{
|
||||
m_isComparisonViewActiveFlag = m_comparisonMainRendering->scene() != nullptr;
|
||||
this->setProperty("cafViewer_IsComparisonViewActive", QVariant(m_isComparisonViewActiveFlag));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -995,10 +1023,12 @@ void caf::Viewer::setCurrentComparisonFrame(int frameIndex)
|
||||
if ( m_comparisonFrameScenes.size() > clampedFrameIndex && m_comparisonFrameScenes.at(clampedFrameIndex) != nullptr )
|
||||
{
|
||||
m_comparisonMainRendering->setScene(m_comparisonFrameScenes.at(clampedFrameIndex));
|
||||
updateComparisonViewActiveFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_comparisonMainRendering->setScene(nullptr);
|
||||
updateComparisonViewActiveFlag();
|
||||
}
|
||||
|
||||
update();
|
||||
@ -1040,16 +1070,21 @@ void caf::Viewer::slotSetCurrentFrame(int frameIndex)
|
||||
if ( m_comparisonFrameScenes.size() > clampedFrameIndex && m_comparisonFrameScenes.at(clampedFrameIndex) != nullptr )
|
||||
{
|
||||
m_comparisonMainRendering->setScene(m_comparisonFrameScenes.at(clampedFrameIndex));
|
||||
updateComparisonViewActiveFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_comparisonMainRendering->setScene(nullptr);
|
||||
updateComparisonViewActiveFlag();
|
||||
}
|
||||
}
|
||||
|
||||
update();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void caf::Viewer::releaseOGlResourcesForCurrentFrame()
|
||||
{
|
||||
if (isAnimationActive())
|
||||
|
@ -97,6 +97,7 @@ public:
|
||||
|
||||
void setComparisonViewVisibleNormalizedRect( const cvf::Rectf& visibleRect );
|
||||
cvf::Rectf comparisonViewVisibleNormalizedRect() const;
|
||||
bool isComparisonViewActive() const;
|
||||
|
||||
// Set the main scene : the scene active when the animation is not active. (Stopped)
|
||||
void setMainScene(cvf::Scene* scene, bool isForComparisonView = false);
|
||||
@ -151,8 +152,10 @@ public:
|
||||
// Test whether it is any point in doing navigation etc.
|
||||
bool canRender() const;
|
||||
|
||||
cvf::ref<cvf::RayIntersectSpec> rayIntersectSpecFromWindowCoordinates(int winPosX, int winPosY, bool isForComparisonView);
|
||||
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);
|
||||
|
||||
cvf::OverlayItem* overlayItem(int winPosX, int winPosY);
|
||||
@ -263,6 +266,8 @@ private:
|
||||
cvf::Collection<cvf::Scene> m_comparisonFrameScenes;
|
||||
cvf::Collection<cvf::Model> m_comparisonStaticModels;
|
||||
bool m_isComparisonFollowingAnimation;
|
||||
bool m_isComparisonViewActiveFlag;
|
||||
void updateComparisonViewActiveFlag();
|
||||
|
||||
cvf::Vec3d m_comparisonViewOffset;
|
||||
cvf::ref<cvf::RenderingScissor> m_comparisonRenderingScissor;
|
||||
|
Loading…
Reference in New Issue
Block a user