mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-04 13:13:25 +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:
@@ -17,6 +17,7 @@
|
||||
#include <Aspect_Window.hxx>
|
||||
#include <OSD.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
// =======================================================================
|
||||
// function : Instance
|
||||
@@ -55,14 +56,14 @@ ViewerTest_ContinuousRedrawer::~ViewerTest_ContinuousRedrawer()
|
||||
// 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;
|
||||
}
|
||||
|
||||
@@ -84,13 +85,13 @@ void ViewerTest_ContinuousRedrawer::Start (const Handle(Aspect_Window)& theWindo
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// 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;
|
||||
}
|
||||
@@ -103,11 +104,11 @@ void ViewerTest_ContinuousRedrawer::Stop (const Handle(Aspect_Window)& theWindow
|
||||
myWakeEvent.Set();
|
||||
myThread.Wait();
|
||||
myToStop = false;
|
||||
myWindow.Nullify();
|
||||
myView.Nullify();
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
// function : doThreadLoop
|
||||
// function : Pause
|
||||
// purpose :
|
||||
// =======================================================================
|
||||
void ViewerTest_ContinuousRedrawer::Pause()
|
||||
@@ -153,13 +154,15 @@ void ViewerTest_ContinuousRedrawer::doThreadLoop()
|
||||
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);
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#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.
|
||||
@@ -39,11 +40,11 @@ public:
|
||||
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; }
|
||||
@@ -68,7 +69,7 @@ private:
|
||||
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
|
||||
|
@@ -197,7 +197,7 @@ void ViewerTest_EventManager::handleViewRedraw (const Handle(AIS_InteractiveCont
|
||||
{
|
||||
myIsTmpContRedraw = true;
|
||||
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__)
|
||||
aRedrawer.Start (theView->Window(), 60.0);
|
||||
aRedrawer.Start (theView, 60.0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -2668,7 +2668,7 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
|
||||
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);
|
||||
@@ -2683,7 +2683,7 @@ void ViewerTest::RemoveView (const TCollection_AsciiString& theViewName, const S
|
||||
// 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())
|
||||
{
|
||||
@@ -3703,9 +3703,21 @@ static int VRepaint (Draw_Interpretor& , Standard_Integer theArgNb, const char**
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
|
Reference in New Issue
Block a user