diff --git a/libsrc/include/nginterface.h b/libsrc/include/nginterface.h index 71adea2f..7e71cea7 100644 --- a/libsrc/include/nginterface.h +++ b/libsrc/include/nginterface.h @@ -324,7 +324,7 @@ extern "C" { /// delete gridfunctions DLL_HEADER void Ng_ClearSolutionData(); // redraw - DLL_HEADER void Ng_Redraw(); + DLL_HEADER void Ng_Redraw(bool blocking = false); /// DLL_HEADER void Ng_SetMouseEventHandler (netgen::MouseEventHandler * handler); /// diff --git a/libsrc/meshing/meshtype.hpp b/libsrc/meshing/meshtype.hpp index f3c340c2..2aca460c 100644 --- a/libsrc/meshing/meshtype.hpp +++ b/libsrc/meshing/meshtype.hpp @@ -1110,11 +1110,11 @@ namespace netgen // void CopyFrom(const MeshingParameters & other); - void (*render_function)() = NULL; - void Render() + void (*render_function)(bool) = NULL; + void Render(bool blocking = false) { if (render_function) - (*render_function)(); + (*render_function)(blocking); } }; diff --git a/libsrc/visualization/mvdraw.cpp b/libsrc/visualization/mvdraw.cpp index 3975585b..5a8d934f 100644 --- a/libsrc/visualization/mvdraw.cpp +++ b/libsrc/visualization/mvdraw.cpp @@ -112,10 +112,16 @@ namespace netgen } - extern DLL_HEADER void Render(); - DLL_HEADER void Render () + extern DLL_HEADER void Render(bool blocking); + DLL_HEADER void Render (bool blocking) { - multithread.redraw = 1; + if (blocking) + { + multithread.redraw = 2; + while (multithread.redraw == 2) ; + } + else + multithread.redraw = 1; } diff --git a/libsrc/visualization/vssolution.cpp b/libsrc/visualization/vssolution.cpp index 496155a6..c39341f7 100644 --- a/libsrc/visualization/vssolution.cpp +++ b/libsrc/visualization/vssolution.cpp @@ -4609,14 +4609,14 @@ void Ng_SetSolutionData (Ng_SolutionData * soldata) namespace netgen { - extern void Render (); + extern void Render (bool blocking); } -void Ng_Redraw () +void Ng_Redraw (bool blocking) { #ifdef OPENGL netgen::vssolution.UpdateSolutionTimeStamp(); - netgen::Render(); + netgen::Render(blocking); #endif } diff --git a/ng/menustat.tcl b/ng/menustat.tcl index e71efd06..54155f69 100644 --- a/ng/menustat.tcl +++ b/ng/menustat.tcl @@ -971,6 +971,7 @@ proc timer2 { } { Ng_ReadStatus if { $multithread_redraw == 1 } { + # non-blocking redraw set multithread_redraw 0; redraw; @@ -980,6 +981,20 @@ proc timer2 { } { .ndraw Ng_VideoClip addframe } } + if { $multithread_redraw == 2 } { + # blocking redraw + redraw; + set multithread_redraw 0; + + global videoactive + if { $videoactive == 1 } { + puts "addframe" + .ndraw Ng_VideoClip addframe + } + after 1 { timer2 } + return + } + # global mem_moveable # set mem_moveable [Ng_MemInfo moveable] diff --git a/ng/ngpkg.cpp b/ng/ngpkg.cpp index 08e2ac5a..2f5afa54 100644 --- a/ng/ngpkg.cpp +++ b/ng/ngpkg.cpp @@ -1364,7 +1364,7 @@ namespace netgen multithread.running = 1; multithread.terminate = 0; - extern void Render(); + extern void Render(bool blocking); mparam.render_function = &Render; for (int i = 0; i < geometryregister.Size(); i++)