mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
(#710) Clamp currentFrameIndex to available frame indices
This commit is contained in:
parent
0a15ccf577
commit
e8cf78c2af
@ -37,39 +37,36 @@
|
||||
|
||||
#include "cafViewer.h"
|
||||
|
||||
#include "cafCadNavigation.h"
|
||||
#include "cafFrameAnimationControl.h"
|
||||
#include "cafNavigationPolicy.h"
|
||||
|
||||
#include "cvfCamera.h"
|
||||
#include "cvfRendering.h"
|
||||
#include "cvfRenderSequence.h"
|
||||
#include "cvfOpenGLResourceManager.h"
|
||||
#include "cvfRenderQueueSorter.h"
|
||||
#include "cvfScene.h"
|
||||
#include "cvfModel.h"
|
||||
#include "cvfTextureImage.h"
|
||||
#include "cvfOverlayImage.h"
|
||||
|
||||
#include "cvfqtOpenGLContext.h"
|
||||
|
||||
#include "cvfRay.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfDebugTimer.h"
|
||||
#include "cvfDrawable.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfTransform.h"
|
||||
#include "cvfRayIntersectSpec.h"
|
||||
#include "cvfHitItemCollection.h"
|
||||
#include "cvfManipulatorTrackball.h"
|
||||
#include "cvfModel.h"
|
||||
#include "cvfOpenGLResourceManager.h"
|
||||
#include "cvfOverlayImage.h"
|
||||
#include "cvfPart.h"
|
||||
#include "cvfRay.h"
|
||||
#include "cvfRayIntersectSpec.h"
|
||||
#include "cvfRenderQueueSorter.h"
|
||||
#include "cvfRenderSequence.h"
|
||||
#include "cvfRendering.h"
|
||||
#include "cvfScene.h"
|
||||
#include "cvfTextureImage.h"
|
||||
#include "cvfTransform.h"
|
||||
|
||||
#include "cvfDebugTimer.h"
|
||||
#include "cvfqtOpenGLContext.h"
|
||||
#include "cvfqtPerformanceInfoHud.h"
|
||||
#include "cvfqtUtils.h"
|
||||
|
||||
#include "cafNavigationPolicy.h"
|
||||
#include "cafCadNavigation.h"
|
||||
#include "cafFrameAnimationControl.h"
|
||||
|
||||
#include <QInputEvent>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDebug>
|
||||
#include "cvfTrace.h"
|
||||
#include <QHBoxLayout>
|
||||
#include <QInputEvent>
|
||||
|
||||
std::list<caf::Viewer*> caf::Viewer::sm_viewers;
|
||||
cvf::ref<cvf::OpenGLContextGroup> caf::Viewer::sm_openGLContextGroup;
|
||||
@ -593,17 +590,7 @@ void caf::Viewer::slotSetCurrentFrame(int frameIndex)
|
||||
{
|
||||
if (m_frameScenes.size() == 0) return;
|
||||
|
||||
int clampedFrameIndex = frameIndex;
|
||||
|
||||
if (static_cast<size_t>(frameIndex) >= m_frameScenes.size())
|
||||
{
|
||||
clampedFrameIndex = static_cast<int>(m_frameScenes.size()) - 1;
|
||||
}
|
||||
|
||||
if (clampedFrameIndex < 0)
|
||||
{
|
||||
clampedFrameIndex = 0;
|
||||
}
|
||||
int clampedFrameIndex = clampFrameIndex(frameIndex);
|
||||
|
||||
if (m_frameScenes.at(clampedFrameIndex) == NULL) return;
|
||||
|
||||
@ -777,9 +764,13 @@ void caf::Viewer::enableForcedImmediateMode(bool enable)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int caf::Viewer::currentFrameIndex()
|
||||
int caf::Viewer::currentFrameIndex() const
|
||||
{
|
||||
if (m_animationControl) return m_animationControl->currentFrame();
|
||||
if (m_animationControl)
|
||||
{
|
||||
int clampedFrameIndex = clampFrameIndex(m_animationControl->currentFrame());
|
||||
return clampedFrameIndex;
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
|
||||
@ -1057,3 +1048,22 @@ void caf::Viewer::updateParallelProjectionCameraPosFromPointOfInterestMove(const
|
||||
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int caf::Viewer::clampFrameIndex(int frameIndex) const
|
||||
{
|
||||
size_t clampedFrameIndex = static_cast<size_t>(frameIndex);
|
||||
|
||||
if (clampedFrameIndex >= frameCount())
|
||||
{
|
||||
clampedFrameIndex = frameCount() - 1;
|
||||
}
|
||||
else if (clampedFrameIndex < 0)
|
||||
{
|
||||
clampedFrameIndex = 0;
|
||||
}
|
||||
|
||||
return static_cast<int>(clampedFrameIndex);
|
||||
}
|
||||
|
||||
|
@ -91,9 +91,10 @@ public:
|
||||
|
||||
// Frame scenes for animation control
|
||||
void addFrame(cvf::Scene* scene);
|
||||
size_t frameCount() { return m_frameScenes.size(); }
|
||||
size_t frameCount() const { return m_frameScenes.size(); }
|
||||
cvf::Scene* frame(size_t frameIndex);
|
||||
void removeAllFrames();
|
||||
int currentFrameIndex() const;
|
||||
|
||||
// Static models to be shown in all frames
|
||||
void addStaticModelOnce(cvf::Model* model);
|
||||
@ -152,7 +153,6 @@ public:
|
||||
public slots:
|
||||
virtual void slotSetCurrentFrame(int frameIndex);
|
||||
virtual void slotEndAnimation();
|
||||
int currentFrameIndex();
|
||||
|
||||
public:
|
||||
virtual QSize sizeHint() const;
|
||||
@ -196,6 +196,8 @@ private:
|
||||
void releaseOGlResourcesForCurrentFrame();
|
||||
void debugShowRenderingSequencePartNames();
|
||||
|
||||
int clampFrameIndex(int frameIndex) const;
|
||||
|
||||
bool m_showPerfInfoHud;
|
||||
size_t m_paintCounter;
|
||||
bool m_releaseOGLResourcesEachFrame;
|
||||
|
Loading…
Reference in New Issue
Block a user