0021981: Additional callback before redraw procedure
authorAPL <>
Thu, 22 Sep 2011 15:08:38 +0000 (15:08 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:30:24 +0000 (19:30 +0400)
src/Aspect/Aspect_GraphicCallbackProc.hxx
src/NIS/NIS_View.cxx
src/OpenGl/OpenGl_togl_print.cxx
src/OpenGl/OpenGl_togl_redraw.cxx

index 3a6e79e..0b2fd79 100755 (executable)
 #define OCC_REDRAW_WINDOWAREA 2
 #define OCC_REDRAW_BITMAP 3
 
-/* 
-   This flag, when bitwise OR`ed with the "reason" value, 
-   informs the callback that it is called before redrawing the overlayer .
-   Otherwise, the callback is invoked after the overlayer is redrawn.        
-*/
+// The flags below provide additional information to define the moment when
+// callback was invoked in redraw procedure. These flags are bitwise OR'ed
+// with the "reason" value of callback:
+// 1) OCC_PRE_REDRAW  - callback was invoked before redrawing underlayer
+//                      ( at the beginning of redraw procedure );
+// 2) OCC_PRE_OVERLAY - callback was invoked before redrawing overlayer;
+// Otherwise, if no flags added to the "reason" value, the callback was
+// invoked at the end of redraw ( after the overlayer is redrawn )
+#define OCC_PRE_REDRAW  0x4000
 #define OCC_PRE_OVERLAY 0x8000
 
+// mask for all additional callbacks that invoked in process of redrawing
+#define OCC_REDRAW_ADDITIONAL_CALLBACKS ( OCC_PRE_REDRAW | OCC_PRE_OVERLAY )
+
  typedef struct {
    int reason;
    int wsID;
index d5d1db9..12aaf3d 100755 (executable)
@@ -262,8 +262,16 @@ void NIS_View::GetBndBox( Standard_Integer& theXMin, Standard_Integer& theXMax,
 
 int NIS_View::MyCallback (Aspect_Drawable                /* Window ID */,
                           void*                          ptrData, 
-                          Aspect_GraphicCallbackStruct*  /* call data */)
+                          Aspect_GraphicCallbackStruct*  callData /* call data */)
 {
+  // Avoid multiple rendering of the scene ( accordingly with update of
+  // callback mechanism, that invokes additional callbacks before
+  // underlay and overlay redrawing with OCC_PRE_REDRAW and OCC_PRE_OVERLAY
+  // bits added to the "reason" value of the callback data structure;
+  // see comments to OCC_REDRAW_ADDITIONAL_CALLBACKS definition )
+  if (callData->reason & OCC_REDRAW_ADDITIONAL_CALLBACKS)
+    return 0;
+  
   const Handle(NIS_View) thisView (static_cast<NIS_View *> (ptrData));
   NCollection_List<NIS_InteractiveContext *>::Iterator anIter;
 #ifdef CLIP
index d5b580b..7429b7f 100755 (executable)
@@ -163,6 +163,7 @@ static void redrawView (CALL_DEF_VIEW *aview,
 {
   // prepare for redraw
   call_func_redraw_all_structs_begin (aview->WsId);
+  call_subr_displayCB (aview, OCC_REDRAW_BITMAP | OCC_PRE_REDRAW);
   call_togl_setplane (aview);
 
   // clear background
index dfbbce6..377d3c2 100755 (executable)
@@ -89,6 +89,7 @@ call_togl_redraw
     }
     OpenGl_ResourceCleaner::GetInstance()->Cleanup();
     call_func_redraw_all_structs_begin (aview->WsId);
+    call_subr_displayCB (aview, OCC_REDRAW_WINDOW | OCC_PRE_REDRAW);
     call_togl_setplane( aview );
     if (anunderlayer->ptrLayer)
     {
@@ -167,6 +168,7 @@ call_togl_redraw_area
                  (GLsizei )width, (GLsizei )height);
       OpenGl_ResourceCleaner::GetInstance()->Cleanup();
       call_func_redraw_all_structs_begin (aview->WsId);
+      call_subr_displayCB (aview, OCC_REDRAW_WINDOWAREA | OCC_PRE_REDRAW);
       call_togl_setplane( aview );
       if (anunderlayer->ptrLayer)
       {