AIS_ViewController::AIS_ViewController()
: myLastEventsTime (0.0),
myToAskNextFrame (false),
+ myIsContinuousRedraw(false),
myMinCamDistance (1.0),
myRotationMode (AIS_RotationMode_BndBoxActive),
myNavigationMode (AIS_NavigationMode_Orbit),
setAskNextFrame();
}
+ if (myIsContinuousRedraw)
+ {
+ myToAskNextFrame = true;
+ }
if (theView->View()->IsActiveXR())
{
// VR requires continuous rendering
//! Interrupt active view animation.
Standard_EXPORT void AbortViewAnimation();
+ //! Return TRUE if continuous redrawing is enabled; FALSE by default.
+ //! This option would request a next viewer frame to be completely redrawn right after current frame is finished.
+ bool IsContinuousRedraw() const { return myIsContinuousRedraw; }
+
+ //! Enable or disable continuous updates.
+ void SetContinuousRedraw (bool theToEnable) { myIsContinuousRedraw = theToEnable; }
+
public: //! @name global parameters
//! Return camera rotation mode, AIS_RotationMode_BndBoxActive by default.
Standard_Real myLastEventsTime; //!< last fetched events timer value for computing delta/progress
Standard_Boolean myToAskNextFrame; //!< flag indicating that another frame should be drawn right after this one
+ Standard_Boolean myIsContinuousRedraw; //!< continuous redrawing (without immediate rendering optimization)
Standard_Real myMinCamDistance; //!< minimal camera distance for zoom operation
AIS_RotationMode myRotationMode; //!< rotation mode
#include <Aspect_Window.hxx>
#include <OSD.hxx>
#include <OSD_Timer.hxx>
+#include <V3d_View.hxx>
// =======================================================================
// function : Instance
// function : Start
// purpose :
// =======================================================================
-void ViewerTest_ContinuousRedrawer::Start (const Handle(Aspect_Window)& theWindow,
+void ViewerTest_ContinuousRedrawer::Start (const Handle(V3d_View)& theView,
Standard_Real theTargetFps)
{
- if (myWindow != theWindow
+ if (myView != theView
|| myTargetFps != theTargetFps)
{
Stop();
- myWindow = theWindow;
+ myView = theView;
myTargetFps = theTargetFps;
}
}
// =======================================================================
-// function : Start
+// function : Stop
// purpose :
// =======================================================================
-void ViewerTest_ContinuousRedrawer::Stop (const Handle(Aspect_Window)& theWindow)
+void ViewerTest_ContinuousRedrawer::Stop (const Handle(V3d_View)& theView)
{
- if (!theWindow.IsNull()
- && myWindow != theWindow)
+ if (!theView.IsNull()
+ && myView != theView)
{
return;
}
myWakeEvent.Set();
myThread.Wait();
myToStop = false;
- myWindow.Nullify();
+ myView.Nullify();
}
// =======================================================================
-// function : doThreadLoop
+// function : Pause
// purpose :
// =======================================================================
void ViewerTest_ContinuousRedrawer::Pause()
const Standard_Real aDuration = aTimeNew - aTimeOld;
if (aDuration >= aTargetDur)
{
- myWindow->InvalidateContent (aDisp);
+ myView->Invalidate();
+ myView->Window()->InvalidateContent (aDisp);
aTimeOld = aTimeNew;
}
}
else
{
- myWindow->InvalidateContent (aDisp);
+ myView->Invalidate();
+ myView->Window()->InvalidateContent (aDisp);
}
OSD::MilliSecSleep (1);
#include <Standard_Type.hxx>
class Aspect_Window;
+class V3d_View;
//! Auxiliary tool performing continuous redraws of specified window.
//! Tool creates an extra working thread pushing content invalidation messages to specific window using Aspect_Window::InvalidateContent() method.
bool IsStarted() const { return myThread.GetId() != 0; }
//! Start thread.
- Standard_EXPORT void Start (const Handle(Aspect_Window)& theWindow,
+ Standard_EXPORT void Start (const Handle(V3d_View)& theView,
Standard_Real theTargetFps);
//! Stop thread.
- Standard_EXPORT void Stop (const Handle(Aspect_Window)& theWindow = NULL);
+ Standard_EXPORT void Stop (const Handle(V3d_View)& theView = NULL);
//! Return TRUE if redrawer thread is in paused state.
bool IsPaused() const { return myToPause; }
ViewerTest_ContinuousRedrawer();
private:
- Handle(Aspect_Window) myWindow; //!< window to invalidate
+ Handle(V3d_View) myView; //!< view to invalidate
OSD_Thread myThread; //!< working thread
Standard_Mutex myMutex; //!< mutex for accessing common variables
Standard_Condition myWakeEvent; //!< event to wake up working thread
{
myIsTmpContRedraw = true;
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
- aRedrawer.Start (theView->Window(), 60.0);
+ aRedrawer.Start (theView, 60.0);
#endif
}
Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView);
ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
- aRedrawer.Stop (aView->Window());
+ aRedrawer.Stop (aView);
// Remove view resources
ViewerTest_myViews.UnBind1(theViewName);
// unused empty contexts
if (!aCurrentContext.IsNull())
{
- // Check if there are more difined views in the viewer
+ // Check if there are more defined views in the viewer
if ((isContextRemoved || ViewerTest_myContexts.Size() != 1)
&& aCurrentContext->CurrentViewer()->DefinedViews().IsEmpty())
{
}
ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
- if (Abs (aFps) >= 1.0)
+ ViewerTest::CurrentEventManager()->SetContinuousRedraw (false);
+ if (aFps >= 1.0)
{
- aRedrawer.Start (aView->Window(), aFps);
+ aRedrawer.Start (aView, aFps);
+ }
+ else if (aFps < 0.0)
+ {
+ if (ViewerTest::GetViewerFromContext()->ActiveViews().Extent() == 1)
+ {
+ aRedrawer.Stop();
+ ViewerTest::CurrentEventManager()->SetContinuousRedraw (true);
+ ViewerTest::CurrentEventManager()->FlushViewEvents (ViewerTest::GetAISContext(), ViewerTest::CurrentView(), true);
+ continue;
+ }
+ aRedrawer.Start (aView, aFps);
}
else
{