mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-16 10:08:36 +03:00
0032523: Draw Harness, ViewerTest - vrepaint -continuous has no effect
ViewerTest_ContinuousRedrawer now explicitly invalidates V3d_View content in addition to emitting window content redrawing request. "vrepaint -continuous" now tries to avoid creation of dedicated thread on Windows platform and relies on AIS_ViewController::SetContinuousRedraw().
This commit is contained in:
parent
1b5eb2be23
commit
f227f3dc96
@ -37,6 +37,7 @@
|
|||||||
AIS_ViewController::AIS_ViewController()
|
AIS_ViewController::AIS_ViewController()
|
||||||
: myLastEventsTime (0.0),
|
: myLastEventsTime (0.0),
|
||||||
myToAskNextFrame (false),
|
myToAskNextFrame (false),
|
||||||
|
myIsContinuousRedraw(false),
|
||||||
myMinCamDistance (1.0),
|
myMinCamDistance (1.0),
|
||||||
myRotationMode (AIS_RotationMode_BndBoxActive),
|
myRotationMode (AIS_RotationMode_BndBoxActive),
|
||||||
myNavigationMode (AIS_NavigationMode_Orbit),
|
myNavigationMode (AIS_NavigationMode_Orbit),
|
||||||
@ -2943,6 +2944,10 @@ void AIS_ViewController::handleViewRedraw (const Handle(AIS_InteractiveContext)&
|
|||||||
setAskNextFrame();
|
setAskNextFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (myIsContinuousRedraw)
|
||||||
|
{
|
||||||
|
myToAskNextFrame = true;
|
||||||
|
}
|
||||||
if (theView->View()->IsActiveXR())
|
if (theView->View()->IsActiveXR())
|
||||||
{
|
{
|
||||||
// VR requires continuous rendering
|
// VR requires continuous rendering
|
||||||
|
@ -77,6 +77,13 @@ public:
|
|||||||
//! Interrupt active view animation.
|
//! Interrupt active view animation.
|
||||||
Standard_EXPORT void AbortViewAnimation();
|
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
|
public: //! @name global parameters
|
||||||
|
|
||||||
//! Return camera rotation mode, AIS_RotationMode_BndBoxActive by default.
|
//! Return camera rotation mode, AIS_RotationMode_BndBoxActive by default.
|
||||||
@ -679,6 +686,7 @@ protected:
|
|||||||
|
|
||||||
Standard_Real myLastEventsTime; //!< last fetched events timer value for computing delta/progress
|
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 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
|
Standard_Real myMinCamDistance; //!< minimal camera distance for zoom operation
|
||||||
AIS_RotationMode myRotationMode; //!< rotation mode
|
AIS_RotationMode myRotationMode; //!< rotation mode
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <Aspect_Window.hxx>
|
#include <Aspect_Window.hxx>
|
||||||
#include <OSD.hxx>
|
#include <OSD.hxx>
|
||||||
#include <OSD_Timer.hxx>
|
#include <OSD_Timer.hxx>
|
||||||
|
#include <V3d_View.hxx>
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : Instance
|
// function : Instance
|
||||||
@ -55,14 +56,14 @@ ViewerTest_ContinuousRedrawer::~ViewerTest_ContinuousRedrawer()
|
|||||||
// function : Start
|
// function : Start
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void ViewerTest_ContinuousRedrawer::Start (const Handle(Aspect_Window)& theWindow,
|
void ViewerTest_ContinuousRedrawer::Start (const Handle(V3d_View)& theView,
|
||||||
Standard_Real theTargetFps)
|
Standard_Real theTargetFps)
|
||||||
{
|
{
|
||||||
if (myWindow != theWindow
|
if (myView != theView
|
||||||
|| myTargetFps != theTargetFps)
|
|| myTargetFps != theTargetFps)
|
||||||
{
|
{
|
||||||
Stop();
|
Stop();
|
||||||
myWindow = theWindow;
|
myView = theView;
|
||||||
myTargetFps = theTargetFps;
|
myTargetFps = theTargetFps;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,13 +85,13 @@ void ViewerTest_ContinuousRedrawer::Start (const Handle(Aspect_Window)& theWindo
|
|||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : Start
|
// function : Stop
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void ViewerTest_ContinuousRedrawer::Stop (const Handle(Aspect_Window)& theWindow)
|
void ViewerTest_ContinuousRedrawer::Stop (const Handle(V3d_View)& theView)
|
||||||
{
|
{
|
||||||
if (!theWindow.IsNull()
|
if (!theView.IsNull()
|
||||||
&& myWindow != theWindow)
|
&& myView != theView)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -103,11 +104,11 @@ void ViewerTest_ContinuousRedrawer::Stop (const Handle(Aspect_Window)& theWindow
|
|||||||
myWakeEvent.Set();
|
myWakeEvent.Set();
|
||||||
myThread.Wait();
|
myThread.Wait();
|
||||||
myToStop = false;
|
myToStop = false;
|
||||||
myWindow.Nullify();
|
myView.Nullify();
|
||||||
}
|
}
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// function : doThreadLoop
|
// function : Pause
|
||||||
// purpose :
|
// purpose :
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
void ViewerTest_ContinuousRedrawer::Pause()
|
void ViewerTest_ContinuousRedrawer::Pause()
|
||||||
@ -153,13 +154,15 @@ void ViewerTest_ContinuousRedrawer::doThreadLoop()
|
|||||||
const Standard_Real aDuration = aTimeNew - aTimeOld;
|
const Standard_Real aDuration = aTimeNew - aTimeOld;
|
||||||
if (aDuration >= aTargetDur)
|
if (aDuration >= aTargetDur)
|
||||||
{
|
{
|
||||||
myWindow->InvalidateContent (aDisp);
|
myView->Invalidate();
|
||||||
|
myView->Window()->InvalidateContent (aDisp);
|
||||||
aTimeOld = aTimeNew;
|
aTimeOld = aTimeNew;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
myWindow->InvalidateContent (aDisp);
|
myView->Invalidate();
|
||||||
|
myView->Window()->InvalidateContent (aDisp);
|
||||||
}
|
}
|
||||||
|
|
||||||
OSD::MilliSecSleep (1);
|
OSD::MilliSecSleep (1);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <Standard_Type.hxx>
|
#include <Standard_Type.hxx>
|
||||||
|
|
||||||
class Aspect_Window;
|
class Aspect_Window;
|
||||||
|
class V3d_View;
|
||||||
|
|
||||||
//! Auxiliary tool performing continuous redraws of specified window.
|
//! 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.
|
//! Tool creates an extra working thread pushing content invalidation messages to specific window using Aspect_Window::InvalidateContent() method.
|
||||||
@ -39,11 +40,11 @@ public:
|
|||||||
bool IsStarted() const { return myThread.GetId() != 0; }
|
bool IsStarted() const { return myThread.GetId() != 0; }
|
||||||
|
|
||||||
//! Start thread.
|
//! Start thread.
|
||||||
Standard_EXPORT void Start (const Handle(Aspect_Window)& theWindow,
|
Standard_EXPORT void Start (const Handle(V3d_View)& theView,
|
||||||
Standard_Real theTargetFps);
|
Standard_Real theTargetFps);
|
||||||
|
|
||||||
//! Stop thread.
|
//! 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.
|
//! Return TRUE if redrawer thread is in paused state.
|
||||||
bool IsPaused() const { return myToPause; }
|
bool IsPaused() const { return myToPause; }
|
||||||
@ -68,7 +69,7 @@ private:
|
|||||||
ViewerTest_ContinuousRedrawer();
|
ViewerTest_ContinuousRedrawer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Handle(Aspect_Window) myWindow; //!< window to invalidate
|
Handle(V3d_View) myView; //!< view to invalidate
|
||||||
OSD_Thread myThread; //!< working thread
|
OSD_Thread myThread; //!< working thread
|
||||||
Standard_Mutex myMutex; //!< mutex for accessing common variables
|
Standard_Mutex myMutex; //!< mutex for accessing common variables
|
||||||
Standard_Condition myWakeEvent; //!< event to wake up working thread
|
Standard_Condition myWakeEvent; //!< event to wake up working thread
|
||||||
|
@ -197,7 +197,7 @@ void ViewerTest_EventManager::handleViewRedraw (const Handle(AIS_InteractiveCont
|
|||||||
{
|
{
|
||||||
myIsTmpContRedraw = true;
|
myIsTmpContRedraw = true;
|
||||||
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
|
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
|
||||||
aRedrawer.Start (theView->Window(), 60.0);
|
aRedrawer.Start (theView, 60.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2668,7 +2668,7 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
|
|||||||
Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
|
Handle(V3d_View) aView = ViewerTest_myViews.Find1(theViewName);
|
||||||
Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView);
|
Handle(AIS_InteractiveContext) aCurrentContext = FindContextByView(aView);
|
||||||
ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
|
ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
|
||||||
aRedrawer.Stop (aView->Window());
|
aRedrawer.Stop (aView);
|
||||||
|
|
||||||
// Remove view resources
|
// Remove view resources
|
||||||
ViewerTest_myViews.UnBind1(theViewName);
|
ViewerTest_myViews.UnBind1(theViewName);
|
||||||
@ -2683,7 +2683,7 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
|
|||||||
// unused empty contexts
|
// unused empty contexts
|
||||||
if (!aCurrentContext.IsNull())
|
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)
|
if ((isContextRemoved || ViewerTest_myContexts.Size() != 1)
|
||||||
&& aCurrentContext->CurrentViewer()->DefinedViews().IsEmpty())
|
&& aCurrentContext->CurrentViewer()->DefinedViews().IsEmpty())
|
||||||
{
|
{
|
||||||
@ -3703,9 +3703,21 @@ static int VRepaint (Draw_Interpretor& , Standard_Integer theArgNb, const char**
|
|||||||
}
|
}
|
||||||
|
|
||||||
ViewerTest_ContinuousRedrawer& aRedrawer = ViewerTest_ContinuousRedrawer::Instance();
|
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
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user