0023525: Disappearing of highlight in screenshot
authorkgv <kgv@opencascade.com>
Fri, 25 Jan 2013 10:52:59 +0000 (14:52 +0400)
committerkgv <kgv@opencascade.com>
Fri, 25 Jan 2013 10:52:59 +0000 (14:52 +0400)
OpenGl immediate mode - get rid from GL display lists

Visual3d_TransientManager, Graphic3d_GraphicDriver:
removed outdated unused methods to draw primitives in immediate mode.
New Draw Harness command to swith rendering mode in immediate mode.

When set to false scene will be always redrawn in back buffer.
V3d_View::ToPixMap - temporarily switch immediate mode to draw into back buffer

Make happy immediate mode dump on OpenGL without FBO (like ms software implementation).
OpenGl_Workspace::RedrawImmediatMode - invalidate back buffer when immediate mode drawn into it
Added more detailed description for Graphic3d_GraphicDriver::SetImmediateModeDrawToFront method

Adding of test case

15 files changed:
src/Graphic3d/Graphic3d_GraphicDriver.cdl
src/OpenGl/FILES
src/OpenGl/OpenGl_GraphicDriver.cxx
src/OpenGl/OpenGl_GraphicDriver.hxx
src/OpenGl/OpenGl_GraphicDriver_8.cxx [deleted file]
src/OpenGl/OpenGl_Workspace.cxx
src/OpenGl/OpenGl_Workspace.hxx
src/OpenGl/OpenGl_Workspace_2.cxx
src/OpenGl/OpenGl_Workspace_3.cxx
src/OpenGl/OpenGl_Workspace_4.cxx
src/V3d/V3d_View.cxx
src/ViewerTest/ViewerTest_OpenGlCommands.cxx
src/Visual3d/Visual3d_TransientManager.cdl
src/Visual3d/Visual3d_TransientManager.cxx
tests/bugs/vis/bug23525 [new file with mode: 0755]

index f7db574..a672357 100755 (executable)
@@ -656,6 +656,23 @@ is
     -- Category: Immediat mode methods
     ----------------------------------
 
+    SetImmediateModeDrawToFront (me                   : mutable;
+                                 theCView             : CView from Graphic3d;
+                                 theDrawToFrontBuffer : Boolean from Standard)
+    returns Boolean from Standard
+    is deferred;
+    ---Purpose: @param theDrawToFrontBuffer Advanced option to modify rendering mode:
+    -- 1. TRUE.  Drawing immediate mode structures directly to the front buffer over the scene image.
+    --    Fast, so preferred for interactive work (used by default).
+    --    However these extra drawings will be missed in image dump since it is performed from back buffer.
+    --    Notice that since no pre-buffering used the V-Sync will be ignored and rendering could be seen
+    --    in run-time (in case of slow hardware) and/or tearing may appear.
+    --    So this is strongly recommended to draw only simple (fast) structures.
+    -- 2. FALSE. Drawing immediate mode structures to the back buffer.
+    --    The complete scene is redrawn first, so this mode is slower if scene contains complex data and/or V-Sync is turned on.
+    --    But it works in any case and is especially useful for view dump because the dump image is read from the back buffer.
+    -- @return previous mode.
+
     BeginImmediatMode ( me              : mutable;
                         ACView          : CView from Graphic3d;
                         ACUnderLayer    : CLayer2d from Aspect;
@@ -666,22 +683,11 @@ is
         is deferred;
     ---Purpose: call_togl_begin_immediat_mode
 
-    BeginPolyline ( me  : mutable )
-        is deferred;
-    ---Purpose: call_togl_begin_polyline
-
     ClearImmediatMode ( me  : mutable; ACView       : CView from Graphic3d;
                   aFlush        : Boolean from Standard = Standard_True)
         is deferred;
     ---Purpose: call_togl_clear_immediat_mode
 
-    Draw ( me   : mutable;
-           X    : ShortReal from Standard;
-           Y    : ShortReal from Standard;
-           Z    : ShortReal from Standard )
-        is deferred;
-    ---Purpose: call_togl_draw
-
     DrawStructure ( me          : mutable;
                     ACStructure : CStructure from Graphic3d )
         is deferred;
@@ -692,50 +698,6 @@ is
         is deferred;
     ---Purpose: call_togl_end_immediat_mode
 
-    EndPolyline ( me    : mutable )
-        is deferred;
-    ---Purpose: call_togl_end_polyline
-
-    Move ( me   : mutable;
-           X    : ShortReal from Standard;
-           Y    : ShortReal from Standard;
-           Z    : ShortReal from Standard )
-        is deferred;
-    ---Purpose: call_togl_move
-
-    SetLineColor ( me   : mutable;
-                   R    : ShortReal from Standard;
-                   G    : ShortReal from Standard;
-                   B    : ShortReal from Standard )
-        is deferred;
-    ---Purpose: call_togl_set_linecolor
-
-    SetLineType ( me    : mutable;
-                  Type  : Integer from Standard )
-        is deferred;
-    ---Purpose: call_togl_set_linetype
-
-    SetLineWidth ( me   : mutable;
-               Width    : ShortReal from Standard )
-        is deferred;
-    ---Purpose: call_togl_set_linewidth
-
-    SetMinMax ( me  : mutable;
-                X1  : ShortReal from Standard;
-                Y1  : ShortReal from Standard;
-                Z1  : ShortReal from Standard;
-                X2  : ShortReal from Standard;
-                Y2  : ShortReal from Standard;
-                Z2  : ShortReal from Standard )
-        is deferred;
-    ---Purpose: call_togl_set_minmax
-
-    Transform ( me      : mutable;
-                AMatrix : Array2OfReal from TColStd;
-                AType   : TypeOfComposition from Graphic3d )
-        is deferred;
-    ---Purpose: call_togl_transform
-
     -------------------------------
     -- Category: Layer mode methods
     -------------------------------
index cf3db3d..a5f77cb 100755 (executable)
@@ -8,7 +8,6 @@ OpenGl_GraphicDriver_2.cxx
 OpenGl_GraphicDriver_3.cxx
 OpenGl_GraphicDriver_4.cxx
 OpenGl_GraphicDriver_7.cxx
-OpenGl_GraphicDriver_8.cxx
 OpenGl_GraphicDriver_9.cxx
 OpenGl_GraphicDriver_703.cxx
 OpenGl_GraphicDriver_705.cxx
index c5d486f..1f9487b 100755 (executable)
@@ -1,6 +1,6 @@
 // Created on: 2011-10-20
 // Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
+// Copyright (c) 2011-2013 OPEN CASCADE SAS
 //
 // The content of this file is subject to the Open CASCADE Technology Public
 // License Version 6.5 (the "License"). You may not use the content of this file
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
-
 #include <OpenGl_GraphicDriver.hxx>
 
 #include <OpenGl_Context.hxx>
+#include <OpenGl_CView.hxx>
 #include <OpenGl_View.hxx>
 #include <OpenGl_Workspace.hxx>
 
@@ -150,3 +150,127 @@ Standard_Boolean OpenGl_GraphicDriver::MemoryInfo (Standard_Size&           theF
   theInfo      = aGlCtx.MemoryInfo();
   return !theInfo.IsEmpty();
 }
+
+// =======================================================================
+// function : SetImmediateModeDrawToFront
+// purpose  :
+// =======================================================================
+Standard_Boolean OpenGl_GraphicDriver::SetImmediateModeDrawToFront (const Graphic3d_CView& theCView,
+                                                                    const Standard_Boolean theDrawToFrontBuffer)
+{
+  if (theCView.ViewId == -1)
+  {
+    return Standard_False;
+  }
+
+  const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
+  if (aCView != NULL)
+  {
+    return aCView->WS->SetImmediateModeDrawToFront (theDrawToFrontBuffer);
+  }
+  return Standard_False;
+}
+
+// =======================================================================
+// function : BeginAddMode
+// purpose  :
+// =======================================================================
+Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& theCView)
+{
+  if (theCView.ViewId == -1)
+  {
+    return Standard_False;
+  }
+
+  const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
+  if (aCView != NULL && aCView->WS->BeginAddMode())
+  {
+    myImmediateWS = aCView->WS;
+    return Standard_True;
+  }
+
+  return Standard_False;
+}
+
+// =======================================================================
+// function : EndAddMode
+// purpose  :
+// =======================================================================
+void OpenGl_GraphicDriver::EndAddMode()
+{
+  if (!myImmediateWS.IsNull())
+  {
+    myImmediateWS->EndAddMode();
+    myImmediateWS.Nullify();
+  }
+}
+
+// =======================================================================
+// function : BeginImmediatMode
+// purpose  :
+// =======================================================================
+Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& theCView,
+                                                          const Aspect_CLayer2d& theCUnderLayer,
+                                                          const Aspect_CLayer2d& theCOverLayer,
+                                                          const Standard_Boolean theDoubleBuffer,
+                                                          const Standard_Boolean theRetainMode)
+{
+  if (theCView.ViewId == -1)
+  {
+    return Standard_False;
+  }
+
+  const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
+  if (aCView != NULL && aCView->WS->BeginImmediatMode (theCView, theDoubleBuffer, theRetainMode))
+  {
+    myImmediateWS = aCView->WS;
+    return Standard_True;
+  }
+
+  return Standard_False;
+}
+
+// =======================================================================
+// function : ClearImmediatMode
+// purpose  :
+// =======================================================================
+void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& theCView,
+                                              const Standard_Boolean theToFlush)
+{
+  const OpenGl_CView* aCView = (const OpenGl_CView* )theCView.ptrView;
+  if (aCView != NULL)
+  {
+    aCView->WS->ClearImmediatMode (theCView, theToFlush);
+  }
+}
+
+// =======================================================================
+// function : DrawStructure
+// purpose  :
+// =======================================================================
+void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& theCStructure)
+{
+  OpenGl_Structure* aStructure = (OpenGl_Structure* )theCStructure.ptrStructure;
+  if (aStructure == NULL)
+  {
+    return;
+  }
+
+  if (!myImmediateWS.IsNull())
+  {
+    myImmediateWS->DrawStructure (aStructure);
+  }
+}
+
+// =======================================================================
+// function : EndImmediatMode
+// purpose  :
+// =======================================================================
+void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer )
+{
+  if (!myImmediateWS.IsNull())
+  {
+    myImmediateWS->EndImmediatMode();
+    myImmediateWS.Nullify();
+  }
+}
index 2ca37dc..fbc2ca0 100644 (file)
@@ -32,6 +32,7 @@
 #include <Quantity_NameOfColor.hxx>
 #include <Handle_AlienImage_AlienImage.hxx>
 #include <Handle_OpenGl_View.hxx>
+#include <Handle_OpenGl_Workspace.hxx>
 
 #include <Aspect_Display.hxx>
 #include <Aspect_GradientFillMethod.hxx>
@@ -178,21 +179,14 @@ public:
   Standard_EXPORT void GraduatedTrihedronMinMaxValues (const Standard_ShortReal xmin, const Standard_ShortReal ymin, const Standard_ShortReal zmin, const Standard_ShortReal xmax, const Standard_ShortReal ymax, const Standard_ShortReal zmax);
   Standard_EXPORT void BeginAnimation (const Graphic3d_CView& ACView);
   Standard_EXPORT void EndAnimation (const Graphic3d_CView& ACView);
+  Standard_EXPORT Standard_Boolean SetImmediateModeDrawToFront (const Graphic3d_CView& theCView,
+                                                                const Standard_Boolean theDrawToFrontBuffer);
   Standard_EXPORT Standard_Boolean BeginAddMode (const Graphic3d_CView& ACView);
   Standard_EXPORT void EndAddMode ();
   Standard_EXPORT Standard_Boolean BeginImmediatMode(const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode);
-  Standard_EXPORT void BeginPolyline ();
   Standard_EXPORT void ClearImmediatMode (const Graphic3d_CView& ACView,const Standard_Boolean aFlush = Standard_True);
-  Standard_EXPORT void Draw (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z);
   Standard_EXPORT void DrawStructure (const Graphic3d_CStructure& ACStructure);
   Standard_EXPORT void EndImmediatMode (const Standard_Integer Synchronize);
-  Standard_EXPORT void EndPolyline ();
-  Standard_EXPORT void Move (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z);
-  Standard_EXPORT void SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B);
-  Standard_EXPORT void SetLineType (const Standard_Integer Type);
-  Standard_EXPORT void SetLineWidth (const Standard_ShortReal Width);
-  Standard_EXPORT void SetMinMax (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal Z1, const Standard_ShortReal X2, const Standard_ShortReal Y2, const Standard_ShortReal Z2);
-  Standard_EXPORT void Transform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType);
   Standard_EXPORT void Layer (Aspect_CLayer2d& ACLayer);
   Standard_EXPORT void RemoveLayer (const Aspect_CLayer2d& ACLayer);
   Standard_EXPORT void BeginLayer (const Aspect_CLayer2d& ACLayer);
@@ -342,6 +336,7 @@ private:
   NCollection_DataMap<Standard_Integer, Handle(OpenGl_View)>      myMapOfView;
   NCollection_DataMap<Standard_Integer, Handle(OpenGl_Workspace)> myMapOfWS;
   NCollection_DataMap<Standard_Integer, OpenGl_Structure*>        myMapOfStructure;
+  Handle(OpenGl_Workspace)                                        myImmediateWS;
   OpenGl_UserDrawCallback_t                                       myUserDrawCallback;
 
 };
diff --git a/src/OpenGl/OpenGl_GraphicDriver_8.cxx b/src/OpenGl/OpenGl_GraphicDriver_8.cxx
deleted file mode 100755 (executable)
index 49faf8f..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-// Created on: 2011-10-20
-// Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
-//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
-//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
-//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
-#include <OpenGl_GraphicDriver.hxx>
-
-#include <OpenGl_CView.hxx>
-#include <OpenGl_Structure.hxx>
-
-static Handle(OpenGl_Workspace) myImmediateWS;
-
-/*----------------------------------------------------------------------*/
-
-Standard_Boolean OpenGl_GraphicDriver::BeginAddMode (const Graphic3d_CView& ACView)
-{
-  if (ACView.ViewId == -1)
-    return Standard_False;
-
-  const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
-  if (aCView && aCView->WS->BeginAddMode())
-  {
-    myImmediateWS = aCView->WS;
-    return Standard_True;
-  }
-
-  return Standard_False;
-}
-
-void OpenGl_GraphicDriver::EndAddMode (void)
-{
-  if (!myImmediateWS.IsNull())
-  {
-    myImmediateWS->EndAddMode();
-    myImmediateWS.Nullify();
-  }
-}
-
-Standard_Boolean OpenGl_GraphicDriver::BeginImmediatMode (const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACUnderLayer, const Aspect_CLayer2d& ACOverLayer, const Standard_Boolean DoubleBuffer, const Standard_Boolean RetainMode)
-{
-  if (ACView.ViewId == -1)
-    return Standard_False;
-
-  const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
-  if (aCView && aCView->WS->BeginImmediatMode(ACView, DoubleBuffer, RetainMode))
-  {
-    myImmediateWS = aCView->WS;
-    return Standard_True;
-  }
-
-  return Standard_False;
-}
-
-void OpenGl_GraphicDriver::BeginPolyline ()
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->BeginPolyline();
-}
-
-void OpenGl_GraphicDriver::ClearImmediatMode (const Graphic3d_CView& ACView, const Standard_Boolean aFlush)
-{
-  const OpenGl_CView *aCView = (const OpenGl_CView *)ACView.ptrView;
-  if (aCView)
-    aCView->WS->ClearImmediatMode(ACView,aFlush);
-}
-
-void OpenGl_GraphicDriver::Draw (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->Draw(X,Y,Z);
-}
-
-void OpenGl_GraphicDriver::DrawStructure (const Graphic3d_CStructure& ACStructure)
-{
-  OpenGl_Structure *astructure = (OpenGl_Structure *)ACStructure.ptrStructure;
-  if (!astructure)
-    return;
-
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->DrawStructure(astructure);
-}
-
-void OpenGl_GraphicDriver::EndImmediatMode (const Standard_Integer Synchronize)
-{
-  if (!myImmediateWS.IsNull())
-  {
-    myImmediateWS->EndImmediatMode();
-    myImmediateWS.Nullify();
-  }
-}
-
-void OpenGl_GraphicDriver::EndPolyline ()
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->EndPolyline();
-}
-
-void OpenGl_GraphicDriver::Move (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->Move(X,Y,Z);
-}
-
-void OpenGl_GraphicDriver::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->SetLineColor(R,G,B);
-}
-
-void OpenGl_GraphicDriver::SetLineType (const Standard_Integer Type)
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->SetLineType(Type);
-}
-
-void OpenGl_GraphicDriver::SetLineWidth (const Standard_ShortReal Width)
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->SetLineWidth(Width);
-}
-
-void OpenGl_GraphicDriver::SetMinMax (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal Z1, const Standard_ShortReal X2, const Standard_ShortReal Y2, const Standard_ShortReal Z2)
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->SetMinMax(X1,Y1,Z1,X2,Y2,Z2);
-}
-
-void OpenGl_GraphicDriver::Transform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType)
-{
-  if (!myImmediateWS.IsNull())
-    myImmediateWS->Transform(AMatrix,AType);
-}
index 3f1bd81..29a65c3 100644 (file)
@@ -71,6 +71,7 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay,
 : OpenGl_Window (theDisplay, theCWindow, theGContext, theShareCtx),
   myTransientList (0),
   myIsTransientOpen (Standard_False),
+  myTransientDrawToFront (Standard_True),
   myRetainMode (Standard_False),
   myUseTransparency (Standard_False),
   myUseZBuffer (Standard_False),
@@ -114,6 +115,17 @@ OpenGl_Workspace::OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay,
   EnablePolygonOffset();
 }
 
+// =======================================================================
+// function : SetImmediateModeDrawToFront
+// purpose  :
+// =======================================================================
+Standard_Boolean OpenGl_Workspace::SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer)
+{
+  const Standard_Boolean aPrevMode = myTransientDrawToFront;
+  myTransientDrawToFront = theDrawToFrontBuffer;
+  return aPrevMode;
+}
+
 // =======================================================================
 // function : ~OpenGl_Workspace
 // purpose  :
index b49634b..d556ceb 100644 (file)
@@ -1,6 +1,6 @@
 // Created on: 2011-09-20
 // Created by: Sergey ZERCHANINOV
-// Copyright (c) 2011-2012 OPEN CASCADE SAS
+// Copyright (c) 2011-2013 OPEN CASCADE SAS
 //
 // The content of this file is subject to the Open CASCADE Technology Public
 // License Version 6.5 (the "License"). You may not use the content of this file
@@ -39,6 +39,8 @@
 #include <InterfaceGraphic_Graphic3d.hxx>
 #include <InterfaceGraphic_Visual3d.hxx>
 
+#include <NCollection_Sequence.hxx>
+
 #include <OpenGl_tsm.hxx>
 
 #include <OpenGl_AspectFace.hxx>
@@ -107,6 +109,7 @@ public:
   void EndAnimation();
   void EraseAnimation();
 
+  Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer);
   Standard_Boolean BeginAddMode();
   void EndAddMode();
   void ClearImmediatMode (const Graphic3d_CView& theCView,
@@ -116,17 +119,7 @@ public:
                                       const Standard_Boolean theUseDepthTest,
                                       const Standard_Boolean theRetainMode);
   void EndImmediatMode();
-  void Transform (const TColStd_Array2OfReal& theMatrix, const Graphic3d_TypeOfComposition theType);
   void DrawStructure (const OpenGl_Structure* theStructure);
-  void BeginPolyline();
-  void EndPolyline();
-  void Draw (const Standard_ShortReal theX, const Standard_ShortReal theY, const Standard_ShortReal theZ);
-  void Move (const Standard_ShortReal theX, const Standard_ShortReal theY, const Standard_ShortReal theZ);
-  void SetLineColor (const Standard_ShortReal theR, const Standard_ShortReal theG, const Standard_ShortReal theB);
-  void SetLineType (const Standard_Integer theType);
-  void SetLineWidth (const Standard_ShortReal theWidth);
-  void SetMinMax (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal Z1,
-                  const Standard_ShortReal X2, const Standard_ShortReal Y2, const Standard_ShortReal Z2);
 
   Graphic3d_PtrFrameBuffer FBOCreate (const Standard_Integer theWidth, const Standard_Integer theHeight);
   void FBORelease (Graphic3d_PtrFrameBuffer theFBOPtr);
@@ -196,10 +189,7 @@ public:
 
 protected:
 
-  void CopyBuffers (Tint vid, int FrontToBack,
-                    Tfloat xm, Tfloat ym, Tfloat zm,
-                    Tfloat XM, Tfloat YM, Tfloat ZM,
-                    Tint flag);
+  void CopyBuffers (const Standard_Boolean theFrontToBack);
 
   virtual Standard_Boolean Activate();
 
@@ -217,9 +207,11 @@ protected:
 protected: //! @name protected fields
 
   Handle(OpenGl_View)    myView;            // WSViews - now just one view is supported
-  Tint                   myTransientList;   // WSTransient
   Standard_Boolean       myIsTransientOpen; // transientOpen
-  Tint                   myRetainMode;      // WSRetainMode
+  Standard_Boolean       myRetainMode;
+  Standard_Boolean       myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer)
+
+  NCollection_Sequence<const OpenGl_Structure*> myTransientList;
 
   Standard_Boolean       myUseTransparency;
   Standard_Boolean       myUseZBuffer;
index 03c3a33..7cfa880 100644 (file)
@@ -591,7 +591,11 @@ Standard_Boolean OpenGl_Workspace::Print
                               (GLfloat)aFrameHeight/viewHeight);
     aFrameBuffer->SetupViewport ();
     Redraw1(ACView, ACUnderLayer, ACOverLayer, 0);
-    RedrawImmediatMode();
+    if (!myTransientDrawToFront)
+    {
+      // render to FBO only if allowed to render to back buffer
+      RedrawImmediatMode();
+    }
     glReadPixels (0, 0, aFrameWidth, aFrameHeight,
                   GL_BGR_EXT, GL_UNSIGNED_BYTE, (GLvoid* )aViewBuffer);
 
@@ -698,7 +702,11 @@ Standard_Boolean OpenGl_Workspace::Print
         // draw to the offscreen buffer and capture the result
         aFrameBuffer->SetupViewport ();
         Redraw1(ACView, ACUnderLayer, ACOverLayer, 0);
-        RedrawImmediatMode();
+        if (!myTransientDrawToFront)
+        {
+          // render to FBO only if forces to render to back buffer
+          RedrawImmediatMode();
+        }
         glReadPixels (0, 0, aFrameWidth, aFrameHeight,
                       GL_BGR_EXT, GL_UNSIGNED_BYTE, (GLvoid* )aViewBuffer);
 #ifdef HAVE_FREEIMAGE
@@ -849,9 +857,12 @@ void OpenGl_Workspace::Redraw1 (const Graphic3d_CView& ACView,
 /*----------------------------------------------------------------------*/
 
 //TelCopyBuffers
-void OpenGl_Workspace::CopyBuffers (Tint vid, int FrontToBack, Tfloat xm, Tfloat ym, Tfloat zm, Tfloat XM, Tfloat YM, Tfloat ZM, Tint flag)
+void OpenGl_Workspace::CopyBuffers (const Standard_Boolean theFrontToBack)
 {
-  if (FrontToBack) myBackBufferRestored = Standard_False;
+  if (theFrontToBack)
+  {
+    myBackBufferRestored = Standard_False;
+  }
 
   glMatrixMode (GL_PROJECTION);
   glPushMatrix ();
@@ -863,84 +874,11 @@ void OpenGl_Workspace::CopyBuffers (Tint vid, int FrontToBack, Tfloat xm, Tfloat
 
   DisableFeatures();
 
-  GLsizei width = myWidth+1, height = myHeight+1;
-  Tfloat xmr = 0, ymr = 0;
-
-  if (flag)
-  {
-    if (!myView.IsNull()) //szvgl: use vid here!
-       {
-    // Calculate bounding box and store the projected rectangle
-    Tfloat xr[8], yr[8];
-    // Project bounding box
-    if (myView->ProjectObjectToRaster (myWidth, myHeight, xm, ym, zm, xr[0], yr[0]) &&
-        myView->ProjectObjectToRaster (myWidth, myHeight, xm, YM, zm, xr[1], yr[1]) &&
-        myView->ProjectObjectToRaster (myWidth, myHeight, XM, YM, zm, xr[2], yr[2]) &&
-        myView->ProjectObjectToRaster (myWidth, myHeight, XM, ym, zm, xr[3], yr[3]) &&
-        myView->ProjectObjectToRaster (myWidth, myHeight, xm, ym, ZM, xr[4], yr[4]) &&
-        myView->ProjectObjectToRaster (myWidth, myHeight, xm, YM, ZM, xr[5], yr[5]) &&
-        myView->ProjectObjectToRaster (myWidth, myHeight, XM, YM, ZM, xr[6], yr[6]) &&
-        myView->ProjectObjectToRaster (myWidth, myHeight, XM, ym, ZM, xr[7], yr[7]))
-    {
-      Tfloat XMR, YMR;
-      xmr = ymr = (float ) shortreallast ();
-      XMR = YMR = (float ) shortrealfirst ();
-      /*
-      * Recherche du rectangle projete
-      */
-      Tint i;
-      for (i=0; i<8; i++) {
-        if (xmr > xr[i]) xmr = xr[i];
-        if (ymr > yr[i]) ymr = yr[i];
-        if (XMR < xr[i]) XMR = xr[i];
-        if (YMR < yr[i]) YMR = yr[i];
-      }
-      /* pour eviter les bavures de pixels ! */
-      xmr--;ymr--;
-      XMR++;YMR++;
-
-      /*
-      * Ajout CAL : 10/05/96
-      * Si les MinMax viennent d'un ensemble de markers
-      * on ne tient pas compte du scale factor de ceux-ci
-      * dans les valeurs de MinMax. En effet, ce facteur
-      * est dans l'espace pixel et les MinMax dans l'espace
-      * du modele. Donc ajout d'un delta de pixels
-      * en esperant que les applis n'utilisent pas des
-      * markers tres gros !
-      */
-      xmr -= CALL_DEF_DELTA; ymr -= CALL_DEF_DELTA;
-      XMR += CALL_DEF_DELTA; YMR += CALL_DEF_DELTA;
-
-      /*
-      * Le rectangle projete peut-etre clippe
-      */
-      width = (GLsizei) (XMR-xmr+1);
-      height = (GLsizei) (YMR-ymr+1);
-      /*
-      * (xmr,ymr) coin inferieur gauche
-      * (XMR,YMR) coin superieur droit
-      */
-      /* cas ou 1 coin est en dehors de la fenetre */
-      if (xmr < 0) { width  = (GLsizei) (XMR+1); xmr = 0; }
-      if (ymr < 0) { height = (GLsizei) (YMR+1); ymr = 0; }
-      if (XMR > myWidth)  { width  = (GLsizei) (myWidth-xmr+1); }
-      if (YMR > myHeight) { height = (GLsizei) (myHeight-ymr+1); }
-
-      /* cas ou les 2 coins sont en dehors de la fenetre */
-      if (XMR < 0) { xmr = 0; width = height = 1; }
-      if (YMR < 0) { ymr = 0; width = height = 1; }
-      if (xmr > myWidth)  { xmr = 0; width = height = 1; }
-      if (ymr > myHeight) { ymr = 0; width = height = 1; }
-    }
-       }
-  }
+  glDrawBuffer (theFrontToBack ? GL_BACK  : GL_FRONT);
+  glReadBuffer (theFrontToBack ? GL_FRONT : GL_BACK);
 
-  glDrawBuffer (FrontToBack? GL_BACK : GL_FRONT);
-  glReadBuffer (FrontToBack? GL_FRONT : GL_BACK);
-  /* copie complete */
-  glRasterPos2i ((GLint) xmr, (GLint) ymr);
-  glCopyPixels ((GLint) xmr, (GLint) ymr, width, height, GL_COLOR);
+  glRasterPos2i (0, 0);
+  glCopyPixels  (0, 0, myWidth  + 1, myHeight + 1, GL_COLOR);
 
   EnableFeatures();
 
index 6ee748a..273ad4a 100644 (file)
 // purpose or non-infringement. Please see the License for the specific terms
 // and conditions governing the rights and limitations under the License.
 
-#include <math.h>
 #include <stdio.h>
 
 #include <OpenGl_GlCore11.hxx>
 #include <OpenGl_Context.hxx>
-#include <OpenGl_telem_util.hxx>
-#include <OpenGl_AspectLine.hxx>
 #include <OpenGl_Structure.hxx>
 #include <OpenGl_Workspace.hxx>
 
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef HAVE_GL2PS
-  #include <gl2ps.h>
-#endif
-
-/*----------------------------------------------------------------------*/
-/*
-* Prototypes Private functions
-*/
-
-static void call_util_transform_pt (float *x, float *y, float *z);
-static void call_util_transpose_mat (float tmat[16], float mat[4][4]);
-
-/*----------------------------------------------------------------------*/
-/*
-* Variables statiques
-*/
-
-static int openglNumberOfPoints = 0;
-
-static int myImmediateMatIsIdentity = 1;
-
-static int partial = -1;  /* -1 init, 0 complete, 1 partielle */
-
-static float xm, ym, zm, XM, YM, ZM;
-
-static float myImmediateMat[4][4] = {
-  {1., 0., 0., 0.},
-  {0., 1., 0., 0.},
-  {0., 0., 1., 0.},
-  {0., 0., 0., 1.},
-};
-
 /*----------------------------------------------------------------------*/
 /*  Mode Ajout              */
 /*----------------------------------------------------------------------*/
 
 //call_togl_begin_ajout_mode
-Standard_Boolean OpenGl_Workspace::BeginAddMode ()
+Standard_Boolean OpenGl_Workspace::BeginAddMode()
 {
   if (!Activate())
+  {
     return Standard_False;
+  }
 
   NamedStatus |= OPENGL_NS_ADD;
 
@@ -95,9 +58,7 @@ void OpenGl_Workspace::EndAddMode ()
     NamedStatus &= ~OPENGL_NS_ADD;
   }
 
-  myImmediateMatIsIdentity = 1;
-
-  /* FMN necessaire pour l'affichage sur WNT */
+  // FMN necessaire pour l'affichage sur WNT
   glFlush();
 
   //TsmPopAttri();
@@ -108,379 +69,169 @@ void OpenGl_Workspace::EndAddMode ()
 /*----------------------------------------------------------------------*/
 
 //call_togl_clear_immediat_mode
-void OpenGl_Workspace::ClearImmediatMode (const Graphic3d_CView& ACView, const Standard_Boolean AFlush)
+void OpenGl_Workspace::ClearImmediatMode (const Graphic3d_CView& theCView,
+                                          const Standard_Boolean theToFlush)
 {
-  if ( myIsTransientOpen )
+  if (myIsTransientOpen)
+  {
     EndImmediatMode();
+  }
 
-  if (!Activate()) return;
+  if (!Activate())
+  {
+    myTransientList.Clear(); // Clear current list contents
+    return;
+  }
 
-  if ( !myBackBufferRestored )
+  GLboolean isDoubleBuffer = GL_FALSE;
+  glGetBooleanv (GL_DOUBLEBUFFER, &isDoubleBuffer);
+  if (!myBackBufferRestored || !myTransientDrawToFront || !isDoubleBuffer)
   {
     EraseAnimation();
-
-    Redraw1(ACView,*((CALL_DEF_LAYER *)ACView.ptrUnderLayer),*((CALL_DEF_LAYER *)ACView.ptrOverLayer),AFlush);
+    Redraw1 (theCView, *((CALL_DEF_LAYER* )theCView.ptrUnderLayer), *((CALL_DEF_LAYER* )theCView.ptrOverLayer), theToFlush);
 
     // After a redraw,
     // Made the back identical to the front buffer.
     // Always perform full copy (partial update optimization is useless on mordern hardware)!
-    if (myRetainMode)
-      CopyBuffers (ACView.ViewId, 1 /* GL_FRONT -> GL_BACK */, xm, ym, zm, XM, YM, ZM, 0);
+    if (myRetainMode && myTransientDrawToFront && isDoubleBuffer)
+    {
+      const Standard_Boolean toCopyFrontToBack = Standard_True;
+      CopyBuffers (toCopyFrontToBack);
+    }
 
     myBackBufferRestored = Standard_True;
   }
-  else if ( partial >= 0 )
+  else if (!myTransientList.IsEmpty() && isDoubleBuffer)
   {
-    // Restore pixels from the back buffer.
-    // Always perform full copy (partial update optimization is useless on mordern hardware)!
-    CopyBuffers (ACView.ViewId, 0 /* GL_BACK -> GL_FRONT */, xm, ym, zm, XM, YM, ZM, 0);
+    // restore pixels from the back buffer
+    const Standard_Boolean toCopyFrontToBack = Standard_False;
+    CopyBuffers (toCopyFrontToBack);
   }
 
-  if (myTransientList)
-  {
-    /* Clear current list contents */
-    glNewList( (GLuint) myTransientList, GL_COMPILE_AND_EXECUTE);
-    glEndList();
-  }
-  partial = -1;
-  XM = YM = ZM = (float ) shortrealfirst ();
-  xm = ym = zm = (float ) shortreallast ();
+  myTransientList.Clear(); // clear current list contents
 }
 
 /*----------------------------------------------------------------------*/
 
 //call_togl_redraw_immediat_mode
-void OpenGl_Workspace::RedrawImmediatMode ()
+void OpenGl_Workspace::RedrawImmediatMode()
 {
-  if (myRetainMode)
+  if (!myRetainMode || myTransientList.IsEmpty())
   {
-    if (myTransientList)
-    {
-      MakeFrontBufCurrent();
-      glDisable(GL_LIGHTING);
-      glCallList((GLuint) myTransientList);
-      /* FMN necessaire pour l'affichage sur WNT */
-      glFlush();
-      MakeBackBufCurrent();
-    }
+    return;
   }
-}
-
-/*----------------------------------------------------------------------*/
-
-//call_togl_begin_immediat_mode
-Standard_Boolean OpenGl_Workspace::BeginImmediatMode (const Graphic3d_CView& ACView, const Standard_Boolean UseDepthTest, const Standard_Boolean RetainMode)
-{
-  if (!Activate())
-    return Standard_False;
-
-  OpenGl_Workspace::ClearImmediatMode(ACView,1);
-
-  NamedStatus |= OPENGL_NS_IMMEDIATE;
-  myRetainMode = RetainMode;
 
-  MakeFrontBufCurrent();
-
-  //TsmPushAttri();
-
-  if ( myRetainMode )
+  GLboolean isDoubleBuffer = GL_FALSE;
+  glGetBooleanv (GL_DOUBLEBUFFER, &isDoubleBuffer);
+  if (isDoubleBuffer && myTransientDrawToFront)
   {
-    GLuint listid = (GLuint) myTransientList;
-    if (!listid)
-      listid = glGenLists(1);
-    if (!listid) return Standard_False;
-
-    glNewList(listid, GL_COMPILE_AND_EXECUTE);
-    myTransientList = listid;
-    myIsTransientOpen = Standard_True;
+    MakeFrontBufCurrent();
   }
-
-  if ( UseDepthTest )
-    glEnable(GL_DEPTH_TEST);
   else
-    glDisable(GL_DEPTH_TEST);
-
-  return Standard_True;
-}
-
-/*----------------------------------------------------------------------*/
-
-//call_togl_end_immediat_mode
-void OpenGl_Workspace::EndImmediatMode ()
-{
-  if (NamedStatus & OPENGL_NS_IMMEDIATE)
   {
-    if (myIsTransientOpen)
-    {
-      glEndList();
-      myIsTransientOpen = Standard_False;
-    }
-    MakeBackBufCurrent();
-
-    // Clear immediate mode flag
-    NamedStatus &= ~OPENGL_NS_IMMEDIATE;
+    myBackBufferRestored = Standard_False;
   }
+  glDisable (GL_LIGHTING);
 
-  // Ajout CAL : pour voir quelque chose avant le prochain begin_immediat_mode
-  glFinish ();
-
-  myImmediateMatIsIdentity = 1;
-
-  //TsmPopAttri();
-}
-
-/*----------------------------------------------------------------------*/
-
-//call_togl_transform
-void OpenGl_Workspace::Transform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType)
-{
-  //call_togl_transform in OpenGl_togl_begin_immediat_mode.cxx
-  const Standard_Integer lr = AMatrix.LowerRow ();
-  const Standard_Integer lc = AMatrix.LowerCol ();
-
-  Standard_Integer i, j;
-  if ((AType == Graphic3d_TOC_REPLACE) || myImmediateMatIsIdentity)
+  Handle(OpenGl_Workspace) aWS (this);
+  for (Standard_Integer anIter = 1; anIter <= myTransientList.Size(); ++anIter)
   {
-    for (i=0; i<4; i++)
-      for (j=0; j<4; j++)
-        myImmediateMat[i][j] = float (AMatrix (i+lr, j+lc));
+    const OpenGl_Structure* aStructure = myTransientList.Value (anIter);
+    aStructure->Render (aWS);
   }
-  else
-  {
-    float theMatrix[4][4];
-    for (i=0; i<4; i++)
-      for (j=0; j<4; j++)
-        theMatrix[i][j] = float (AMatrix (i+lr, j+lc));
 
-    TelMultiplymat3 (myImmediateMat, myImmediateMat, theMatrix);
+  if (isDoubleBuffer && myTransientDrawToFront)
+  {
+    glFlush(); // FMN necessaire pour l'affichage sur WNT
+    MakeBackBufCurrent();
   }
-
-  myImmediateMatIsIdentity = 1;
-  for (i = 0; i < 4; i++)
-    for (j = 0; j < 4; j++)
-      if (myImmediateMat[i][j] != (i == j? 1. : 0.))
-      {
-        myImmediateMatIsIdentity = 0;
-        return;
-      }
 }
 
 /*----------------------------------------------------------------------*/
 
-//call_togl_begin_polyline
-void OpenGl_Workspace::BeginPolyline ()
+//call_togl_begin_immediat_mode
+Standard_Boolean OpenGl_Workspace::BeginImmediatMode (const Graphic3d_CView& theCView,
+                                                      const Standard_Boolean theToUseDepthTest,
+                                                      const Standard_Boolean theRetainMode)
 {
-  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
+  if (!Activate())
   {
-    openglNumberOfPoints = 0;
-    glDisable(GL_LIGHTING);
-    glBegin(GL_LINE_STRIP);
+    return Standard_False;
   }
-}
 
-/*----------------------------------------------------------------------*/
-
-//call_togl_end_polyline
-void OpenGl_Workspace::EndPolyline ()
-{
-  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
-    glEnd();
-}
+  OpenGl_Workspace::ClearImmediatMode (theCView, Standard_True);
 
-/*----------------------------------------------------------------------*/
+  NamedStatus |= OPENGL_NS_IMMEDIATE;
+  myRetainMode = theRetainMode;
 
-//call_togl_draw
-void OpenGl_Workspace::Draw (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
-{
-  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
+  if (myTransientDrawToFront)
   {
-    openglNumberOfPoints++;
-    float x = X, y = Y, z = Z;
-    if (!myImmediateMatIsIdentity)
-      call_util_transform_pt (&x, &y, &z);
-    if (x > XM) XM = x;
-    if (y > YM) YM = y;
-    if (z > ZM) ZM = z;
-    if (x < xm) xm = x;
-    if (y < ym) ym = y;
-    if (z < zm) zm = z;
-    glVertex3f (x, y, z);
-    partial = 1;
+    MakeFrontBufCurrent();
   }
-}
 
-/*----------------------------------------------------------------------*/
+  //TsmPushAttri();
 
-//call_togl_move
-void OpenGl_Workspace::Move (const Standard_ShortReal X, const Standard_ShortReal Y, const Standard_ShortReal Z)
-{
-  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
+  if (myRetainMode)
   {
-    if (openglNumberOfPoints != 0)
-    {
-      OpenGl_Workspace::EndPolyline();
-      OpenGl_Workspace::BeginPolyline();
-    }
-    OpenGl_Workspace::Draw(X,Y,Z);
+    myIsTransientOpen = Standard_True;
   }
-}
-
-/*----------------------------------------------------------------------*/
 
-//call_togl_set_linecolor
-void OpenGl_Workspace::SetLineColor (const Standard_ShortReal R, const Standard_ShortReal G, const Standard_ShortReal B)
-{
-  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
+  if (theToUseDepthTest)
   {
-    GLfloat color[3];
-    color[0] = R;
-    color[1] = G;
-    color[2] = B;
-    glColor3fv(color);
+    glEnable (GL_DEPTH_TEST);
   }
-}
-
-/*----------------------------------------------------------------------*/
-
-//call_togl_set_linetype
-void OpenGl_Workspace::SetLineType (const Standard_Integer Type)
-{
-  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
+  else
   {
-    myDisplay->SetTypeOfLine((Aspect_TypeOfLine)Type);
+    glDisable (GL_DEPTH_TEST);
   }
-}
-
-/*----------------------------------------------------------------------*/
 
-//call_togl_set_linewidth
-void OpenGl_Workspace::SetLineWidth (const Standard_ShortReal Width)
-{
-  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
-  {
-    glLineWidth( (GLfloat)Width );
-#ifdef HAVE_GL2PS
-    gl2psLineWidth( (GLfloat)Width );
-#endif
-  }
+  return Standard_True;
 }
 
 /*----------------------------------------------------------------------*/
 
-//call_togl_draw_structure
-void OpenGl_Workspace::DrawStructure (const OpenGl_Structure *AStructure)
+//call_togl_end_immediat_mode
+void OpenGl_Workspace::EndImmediatMode()
 {
-  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
+  if (NamedStatus & OPENGL_NS_IMMEDIATE)
   {
-    float mat16[16];
-    GLint mode1;
-
-    //TsmPushAttri();
-
-    /* mise en place de la matrice de transformation du trace transient */
-    if (!myImmediateMatIsIdentity)
+    if (myIsTransientOpen)
     {
-      call_util_transpose_mat (mat16, myImmediateMat);
-      glGetIntegerv (GL_MATRIX_MODE, &mode1);
-      glMatrixMode (GL_MODELVIEW);
-      glPushMatrix ();
-      glScalef (1.F, 1.F, 1.F);
-      glMultMatrixf (mat16);
+      myIsTransientOpen = Standard_False;
     }
-
-    // Render structure
-    Handle(OpenGl_Workspace) aWS(this);
-    AStructure->Render(aWS);
-
-    //TsmPopAttri();
-
-    if (!myImmediateMatIsIdentity)
+    if (myTransientDrawToFront)
     {
-      glPopMatrix ();
-      glMatrixMode (mode1);
+      MakeBackBufCurrent();
     }
-  }
-}
 
-/*----------------------------------------------------------------------*/
+    // Clear immediate mode flag
+    NamedStatus &= ~OPENGL_NS_IMMEDIATE;
+  }
 
-//call_togl_set_minmax
-void OpenGl_Workspace::SetMinMax (const Standard_ShortReal X1, const Standard_ShortReal Y1, const Standard_ShortReal Z1, const Standard_ShortReal X2, const Standard_ShortReal Y2, const Standard_ShortReal Z2)
-{
-  if ((X1 > shortreallast ()) || (Y1 > shortreallast ()) || (Z1 > shortreallast ()) ||
-      (X2 > shortreallast ()) || (Y2 > shortreallast ()) || (Z2 > shortreallast ()) ||
-      (X1 < shortrealfirst ()) || (Y1 < shortrealfirst ()) || (Z1 < shortrealfirst ()) ||
-      (X2 < shortrealfirst ()) || (Y2 < shortrealfirst ()) || (Z2 < shortrealfirst ()))
+  if (myTransientDrawToFront)
   {
-    XM = YM = ZM = (float ) shortreallast ();
-    xm = ym = zm = (float ) shortrealfirst ();
-    partial = 0;
+    // Ajout CAL : pour voir quelque chose avant le prochain begin_immediat_mode
+    glFinish();
   }
   else
   {
-    float x1=X1,y1=Y1,z1=Z1,x2=X2,y2=Y2,z2=Z2;
-    if (!myImmediateMatIsIdentity)
-    {
-      call_util_transform_pt (&x1, &y1, &z1);
-      call_util_transform_pt (&x2, &y2, &z2);
-    }
-    if (x1 > XM) XM = x1;
-    if (x1 < xm) xm = x1;
-    if (y1 > YM) YM = y1;
-    if (y1 < ym) ym = y1;
-    if (z1 > ZM) ZM = z1;
-    if (z1 < zm) zm = z1;
-
-    if (x2 > XM) XM = x2;
-    if (x2 < xm) xm = x2;
-    if (y2 > YM) YM = y2;
-    if (y2 < ym) ym = y2;
-    if (z2 > ZM) ZM = z2;
-    if (z2 < zm) zm = z2;
-    if (partial != 0) partial = 1;
-  }
-}
-
-/*----------------------------------------------------------------------*/
-/*
-* Private functions
-*/
-
-/*----------------------------------------------------------------------*/
-/*
-Transform the point pt
-*/
-static void call_util_transform_pt ( float *x, float *y, float *z )
-{
-  float tpt[4], pt[4];
-  pt[0] = *x, pt[1] = *y, pt[2] = *z, pt[3] = 1.0;
-
-  int i, j;
-  for (i = 0; i < 4; i++)
-  {
-    float sum = 0.;
-    for (j = 0; j < 4; j++)
-      sum += myImmediateMat[i][j] * pt[j];
-    tpt[i] = sum;
+    GetGlContext()->SwapBuffers();
   }
 
-  *x = tpt[0], *y = tpt[1], *z = tpt[2];
+  //TsmPopAttri();
 }
 
-/*----------------------------------------------------------------------*/
-/*
-void call_util_transpose_mat (tmat, mat)
-float tmat[16];
-float mat[4][4];
-
-Transpose mat and returns tmat.
-*/
-
-static void call_util_transpose_mat (float tmat[16], float mat[4][4])
+//call_togl_draw_structure
+void OpenGl_Workspace::DrawStructure (const OpenGl_Structure* theStructure)
 {
-  int i, j;
+  if (NamedStatus & (OPENGL_NS_ADD | OPENGL_NS_IMMEDIATE))
+  {
+    Handle(OpenGl_Workspace) aWS (this);
+    theStructure->Render (aWS);
 
-  for (i=0; i<4; i++)
-    for (j=0; j<4; j++)
-      tmat[j*4+i] = mat[i][j];
+    if (myIsTransientOpen && myRetainMode)
+    {
+      myTransientList.Append (theStructure);
+    }
+  }
 }
index 15534d3..0dbec40 100644 (file)
@@ -43,7 +43,7 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
 
   // cache render mode state
   GLint aRendMode = GL_RENDER;
-  glGetIntegerv (GL_RENDER_MODE, &aRendMode);
+  glGetIntegerv (GL_RENDER_MODE,  &aRendMode);
   aGlCtx->SetFeedback (aRendMode == GL_FEEDBACK);
 
   Tint toSwap = (aRendMode == GL_RENDER); // swap buffers
@@ -58,7 +58,10 @@ void OpenGl_Workspace::Redraw (const Graphic3d_CView& theCView,
   }
 
   Redraw1 (theCView, theCUnderLayer, theCOverLayer, toSwap);
-  RedrawImmediatMode();
+  if (aFrameBuffer == NULL || !myTransientDrawToFront)
+  {
+    RedrawImmediatMode();
+  }
 
   if (aFrameBuffer != NULL)
   {
index 0f5dd25..1d417c3 100755 (executable)
@@ -169,6 +169,7 @@ To solve the problem (for lack of a better solution) I make 2 passes.
 
 // S3892
 #include <Graphic3d_AspectMarker3d.hxx>
+#include <Graphic3d_GraphicDriver.hxx>
 
 // S3603
 #include <Aspect_GenericColorMap.hxx>
@@ -3440,8 +3441,9 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap&               theImage,
                                      const Graphic3d_BufferType& theBufferType,
                                      const Standard_Boolean      theIsForceCentred)
 {
-  // always prefer hardware accelerated offscreen buffer
   Graphic3d_CView* cView = (Graphic3d_CView* )MyView->CView();
+
+  // always prefer hardware accelerated offscreen buffer
   Graphic3d_PtrFrameBuffer aFBOPtr = NULL;
   Graphic3d_PtrFrameBuffer aPrevFBOPtr = (Graphic3d_PtrFrameBuffer )cView->ptrFBO;
   Standard_Integer aFBOVPSizeX (theWidth), aFBOVPSizeY (theHeight), aFBOSizeXMax (0), aFBOSizeYMax (0);
@@ -3531,8 +3533,18 @@ Standard_Boolean V3d_View::ToPixMap (Image_PixMap&               theImage,
   {
     MyLayerMgr->Compute();
   }
+
+  // render immediate structures into back buffer rather than front
+  Handle(Graphic3d_GraphicDriver) aDriver = Handle(Graphic3d_GraphicDriver)::DownCast (MyView->GraphicDriver());
+  const Standard_Boolean aPrevImmediateMode = aDriver.IsNull() ? Standard_True : aDriver->SetImmediateModeDrawToFront (*cView, Standard_False);
+
   Redraw();
 
+  if (!aDriver.IsNull())
+  {
+    aDriver->SetImmediateModeDrawToFront (*cView, aPrevImmediateMode);
+  }
+
   //szv: restore mapping
   MyViewMapping = prevMapping;
   MyView->SetViewMapping (prevMapping);
index c9a3625..9a152b7 100644 (file)
@@ -48,6 +48,7 @@
 #include <V3d_Viewer.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <V3d_View.hxx>
+#include <Visual3d_View.hxx>
 
 extern Standard_Boolean VDisplayAISObject (const TCollection_AsciiString& theName,
                                            const Handle(AIS_InteractiveObject)& theAISObj,
@@ -194,8 +195,6 @@ void VUserDrawObj::Render(const Handle(OpenGl_Workspace)& theWorkspace) const
   glPopAttrib();
 }
 
-
-
 OpenGl_Element* VUserDrawCallback(const CALL_DEF_USERDRAW * theUserDraw)
 {
   Handle(VUserDrawObj) anIObj = (VUserDrawObj*)theUserDraw->Data;
@@ -395,6 +394,44 @@ static int VFeedback (Draw_Interpretor& theDI,
   }
 }
 
+//==============================================================================
+//function : VImmediateFront
+//purpose  :
+//==============================================================================
+
+static int VImmediateFront (Draw_Interpretor& theDI,
+                            Standard_Integer  theArgNb,
+                            const char**      theArgVec)
+{
+  // get the context
+  Handle(AIS_InteractiveContext) aContextAIS = ViewerTest::GetAISContext();
+  if (aContextAIS.IsNull())
+  {
+    std::cerr << "No active view. Please call vinit.\n";
+    return 1;
+  }
+
+  Handle(Graphic3d_GraphicDriver) aDriver =
+         Handle(Graphic3d_GraphicDriver)::DownCast (aContextAIS->CurrentViewer()->Device()->GraphicDriver());
+  if (aDriver.IsNull())
+  {
+    std::cerr << "Graphic driver not available.\n";
+    return 1;
+  }
+
+  if (theArgNb < 2)
+  {
+    //theDI << "VBO: " << aDriver->ToUseVBO() << "\n";
+    //return 0;
+    std::cerr << "Wrong number of arguments.\n";
+    return 1;
+  }
+
+  Graphic3d_CView* aCView = (Graphic3d_CView* )(ViewerTest::CurrentView()->View()->CView());
+  aDriver->SetImmediateModeDrawToFront (*aCView, atoi(theArgVec[1]) != 0);
+  return 0;
+}
+
 //=======================================================================
 //function : OpenGlCommands
 //purpose  :
@@ -410,4 +447,8 @@ void ViewerTest::OpenGlCommands(Draw_Interpretor& theCommands)
   theCommands.Add("vfeedback",
     "vfeedback       : perform test GL feedback rendering",
     __FILE__, VFeedback, aGroup);
+  theCommands.Add("vimmediatefront",
+    "vimmediatefront : render immediate mode to front buffer or to back buffer",
+    __FILE__, VImmediateFront, aGroup);
+
 }
index 57a86a5..1e5c988 100755 (executable)
@@ -18,8 +18,6 @@
 -- purpose or non-infringement. Please see the License for the specific terms
 -- and conditions governing the rights and limitations under the License.
 
---      05-97: CAL; Ajout du Clear sur les TOS_COMPUTED.
-
 class TransientManager from Visual3d inherits TShared
 
     ---Version:
@@ -28,10 +26,6 @@ class TransientManager from Visual3d inherits TShared
     --      above one View.
     --      A simple way to drawn something very quicly above
     --      a complex scene (Hilighting,Sketching,...)
-    --      All transient graphics will be drawn with
-    --      the projection defined by the view with the current
-    --      attributes depending of the primitive type :
-    --      Lines,Markers,Polygons,Texts
     --      All transient graphics will be erased at the next
     --      View::BeginDraw().
     --      If RetainMode is active,
@@ -137,7 +131,7 @@ is
     -- if   Drawing is already opened.
     -- or   the associated view is not mapped on a window.
     raises TransientDefinitionError from Visual3d;
-    
+
     EndDraw (myclass;
          Synchronize: Boolean = Standard_False)
     ---Level: Public
@@ -147,7 +141,7 @@ is
         --  Raises TransientDefinitionError from Visual3d;
     -- if   Drawing is not opened.
     raises TransientDefinitionError from Visual3d;
-    
+
     ClearDraw (myclass; aView : View from Visual3d; 
                             aFlush : Boolean from Standard = Standard_True)
     ---Level: Public
@@ -157,7 +151,7 @@ is
     -- if   Drawing is already opened.
     -- or   the associated view is not mapped on a window.
     raises TransientDefinitionError from Visual3d;
-    
+
     ---------------------------------------------------
     -- Category: Methods to modify the class definition
     ---------------------------------------------------
@@ -183,251 +177,22 @@ is
     -- if   Drawing is already opened.
     -- or   the associated view is not mapped on a window.
     raises TransientDefinitionError from Visual3d;
-    
+
     EndAddDraw (myclass)
     ---Purpose: Flush all add graphics to the front buffer.
     -- Raises TransientDefinitionError from Visual3d;
     -- if   Drawing is not opened.
-raises TransientDefinitionError from Visual3d;
+    raises TransientDefinitionError from Visual3d;
 
     ---------------------------------------
     -- Category: Graphic definition methods
     ---------------------------------------
 
-    BeginPolyline (myclass)
-    ---Level: Public
-    ---Purpose: After this call, <me> is ready to receive
-    --      a definition of a polyline with AddVertex().
-        --  Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is already opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    BeginPolygon (myclass)
-    ---Level: Public
-    ---Purpose: After this call, <me> is ready to receive
-    --      a definition of a polygon with AddVertex().
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is already opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    BeginTriangleMesh (myclass)
-    ---Level: Public
-    ---Purpose: After this call, <me> is ready to receive
-    --      a definition of a triangle mesh with AddVertex().
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is already opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    BeginMarker (myclass)
-    ---Level: Public
-    ---Purpose: After this call, <me> is ready to receive
-    --      a definition of a marker with AddVertex().
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is already opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    BeginBezier (myclass)
-    ---Level: Public
-    ---Purpose: After this call, <me> is ready to receive
-    --      a definition of a curve with AddVertex().
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is already opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    AddVertex (myclass;
-               X, Y, Z : Real from Standard;
-               AFlag   : Boolean from Standard = Standard_True)
-    ---Level: Public
-    ---Purpose: Puts <X, Y, Z> as a new point in the current primitive.
-    --      If <AFlag> then it is a draw between last point and
-    --      this point else it is a move between last point and
-    --      this point.
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is not opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    AddVertex (myclass;
-               X, Y, Z, W  : Real from Standard;
-               AFlag        : Boolean from Standard = Standard_True)
-    ---Level: Public
-    ---Purpose: Puts <X, Y, Z, W> as a new point coordinates and
-    --      weight in the current primitive.
-    --      If <AFlag> then it is a draw between last point and
-    --      this point else it is a move between last point and
-    --      this point.
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is not opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    AddVertex (myclass;
-               X, Y, Z     : Real from Standard;
-               NX, NY, NZ  : Real from Standard;
-               AFlag       : Boolean from Standard = Standard_True)
-    ---Level: Public
-    ---Purpose: Puts <X, Y, Z> as a new point in the current primitive.
-    --          Puts <NX, NY, NZ> as a new normal in the current 
-    --      primitive.
-    --      If <AFlag> then it is a draw between last point and
-    --      this point else it is a move between last point and
-    --      this point.
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is not opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    ClosePrimitive (myclass)
-    ---Level: Public
-    ---Purpose: After this call, <me> stops the reception of
-    --      a definition of a Begin... primitive.
-        --  Raises TransientDefinitionError from Visual3d;
-    -- if a Begin... primitive is not opened,
-    -- or   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    DrawText (myclass;
-              AText   : ExtendedString from TCollection;
-              X, Y, Z : Real from Standard;
-              AHeight : Real from Standard;
-              AAngle  : PlaneAngle from Quantity = 0.0;
-              ATp     : TextPath from Graphic3d = Graphic3d_TP_RIGHT;
-              AHta    : HorizontalTextAlignment from Graphic3d = Graphic3d_HTA_LEFT;
-              AVta    : VerticalTextAlignment from Graphic3d = Graphic3d_VTA_BOTTOM)
-        ---Purpose: Drawn the string <AText> at position <X,Y,Z>.
-        --     The 3D point of attachment is projected. The text is
-        --          written in the plane of projection.
-        --  The attributes are given with respect to the plane of
-        --          projection.
-        --          AHeight     : Height of text.
-        --             (Relative to the Normalized Projection
-        --                          Coordinates (NPC) Space).
-        --          AAngle      : Orientation of the text
-        --                  (with respect to the horizontal).
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
     DrawStructure (myclass;
                 AStructure   : Structure from Graphic3d)
         ---Purpose: Drawn the structure <AStructure>.
     -- Raises TransientDefinitionError from Visual3d;
     -- if   Drawing is not opened.
     raises TransientDefinitionError from Visual3d;
-    
-
-    ------------------------------------------------
-    -- Summary of attributes                      --
-    ------------------------------------------------
 
-    SetPrimitivesAspect (myclass;
-        CTX : AspectLine3d from Graphic3d)
-    ---Level: Public
-    ---Purpose: Modifies the current lines attributes.
-    --  Warning: No default attributes
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-    SetPrimitivesAspect (myclass;
-        CTX : AspectFillArea3d from Graphic3d)
-    ---Level: Public
-    ---Purpose: Modifies the current faces attributes
-    --  Warning: No default attributes
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-
-    SetPrimitivesAspect (myclass;
-        CTX : AspectText3d from Graphic3d)
-    ---Level: Public
-    ---Purpose: Modifies the current texts attributes
-    --  Warning: No default attributes
-    --    Raises TransientDefinitionError from Visual3d;
-    -- if   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-    SetPrimitivesAspect (myclass;
-        CTX : AspectMarker3d from Graphic3d)
-    ---Level: Public
-    ---Purpose: Modifies the current markers attributes
-    --  Warning: No default attributes
-    -- Raises TransientDefinitionError from Visual3d;
-    -- if   Drawing is not opened.
-    raises TransientDefinitionError from Visual3d;
-    
-    ----------------------------
-    -- Category: Inquire methods
-    ----------------------------
-
-    MinMaxValues (myclass;
-                  XMin, YMin, ZMin    : out Real from Standard;
-                  XMax, YMax, ZMax    : out Real from Standard);
-    ---Level: Public
-    ---Purpose: Returns the coordinates of the boundary box
-    --      of the Transient graphics actually drawn
-    --      since BeginDraw() has been call.
-    --  Warning: If nothing has been drawn then :
-    --      XMin = YMin = ZMin = RealFirst ().
-    --      XMax = YMax = ZMax = RealLast ().
-    ---Category: Inquire methods
-
-    MinMaxValues (myclass;
-                  UMin, VMin  : out Real from Standard;
-                  UMax, VMax  : out Real from Standard);
-    ---Level: Public
-    ---Purpose: Returns the coordinates of the boundary box projection
-    --      of the Transient graphics actually drawn
-    --      since BeginDraw() has been call.
-    --  Warning: If nothing has been drawn then :
-    --      XMin = YMin = ZMin = RealFirst ().
-    --      XMax = YMax = ZMax = RealLast ().
-    ---Category: Inquire methods
-
-    -----------------------------------------------------------
-    -- Category: Methods to manage the graphics transformation
-    -----------------------------------------------------------
-
-    SetTransform (myclass;
-        AMatrix : Array2OfReal from TColStd;
-        AType   : TypeOfComposition from Graphic3d =
-                    Graphic3d_TOC_REPLACE)
-    ---Level: Public
-    ---Purpose: Modifies the current local modelling transformation
-    --      of the transient graphics.
-    --
-    --      It is defined as a 4*4 real matrix.
-    --
-    --      -------------------
-    --      | a11 a12 a13  t1 |
-    --      | a21 a22 a23  t2 |
-    --      | a31 a32 a33  t3 |
-    --      |  0   0   0   1  |
-    --      -------------------
-    --
-    --      TypeOfComposition : TOC_REPLACE
-    --              TOC_POSTCONCATENATE
-    --
-    ---Category: Methods to manage the graphic transformation
-    -- Raises TransformError from Graphic3d
-    -- if   Drawing is not opened.
-    -- or the matrix is not a 4x4 matrix.
-    raises TransformError from Graphic3d;
-    
 end TransientManager from Visual3d;
index ce64ced..1deb8ca 100755 (executable)
 #include <Graphic3d_TypeOfPrimitive.hxx>
 #include <Visual3d_Layer.hxx>
 
-//-Aliases
-#define Graphic3d_TOP_BEZIER Graphic3d_TOP_UNDEFINED
-
-#define DEBUG_PRO4022
-#define DEBUG_TEMPO_FOR_ROB
-
 enum TypeOfImmediat {
  Immediat_None,
  Immediat_Transient,
@@ -71,9 +65,7 @@ enum TypeOfImmediat {
 
 //-Global data definitions
 static Standard_Integer theDrawingState = 0;
-static Standard_Real theMinX,theMinY,theMinZ,theMaxX,theMaxY,theMaxZ;
 static TypeOfImmediat theImmediatState = Immediat_None;
-static Graphic3d_TypeOfPrimitive theTypeOfPrimitive = Graphic3d_TOP_UNDEFINED;
 
 static Handle(Graphic3d_GraphicDriver)& _theGraphicDriver() {
     static Handle(Graphic3d_GraphicDriver) theGraphicDriver;
@@ -139,17 +131,10 @@ Handle(Visual3d_Layer) UnderLayer = AView->UnderLayer ();
        theGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
 
        if (theGraphicDriver->BeginImmediatMode
-               (theCView, UnderCLayer, OverCLayer, DoubleBuffer, RetainMode)) {
+               (theCView, UnderCLayer, OverCLayer, DoubleBuffer, RetainMode))
+  {
                theDrawingState++;
-               theTypeOfPrimitive = Graphic3d_TOP_UNDEFINED;
                theImmediatState = Immediat_Transient;
-               // Reset MinMax
-               theMinX = RealLast ();
-               theMinY = RealLast ();
-               theMinZ = RealLast ();
-               theMaxX = RealFirst ();
-               theMaxY = RealFirst ();
-               theMaxZ = RealFirst ();
        }
 
        return theDrawingState;
@@ -196,8 +181,10 @@ void Visual3d_TransientManager::ClearDraw (const Handle(Visual3d_View)& AView,
 //-Mode Ajout
 //
 
-Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_View)& AView) {
-       if (theDrawingState > 0) {
+Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_View)& AView)
+{
+       if (theDrawingState > 0)
+  {
          Graphic3d_CView* pview = (Graphic3d_CView* )AView->CView();
          if( theImmediatState == Immediat_Ajout &&
              pview->ViewId == theCView.ViewId ) {
@@ -222,17 +209,10 @@ Standard_Boolean Visual3d_TransientManager::BeginAddDraw (const Handle(Visual3d_
 
        theGraphicDriver = *(Handle(Graphic3d_GraphicDriver) *) &agd;
 
-       if (theGraphicDriver->BeginAddMode (theCView)) {
+       if (theGraphicDriver->BeginAddMode (theCView))
+  {
                theDrawingState++;
-               theTypeOfPrimitive = Graphic3d_TOP_UNDEFINED;
                theImmediatState = Immediat_Ajout;
-               // Reset MinMax
-               theMinX = RealLast ();
-               theMinY = RealLast ();
-               theMinZ = RealLast ();
-               theMaxX = RealFirst ();
-               theMaxY = RealFirst ();
-               theMaxZ = RealFirst ();
        }
 
        return theDrawingState;
@@ -255,344 +235,14 @@ void Visual3d_TransientManager::EndAddDraw () {
 //-Graphic definition methods
 //
 
-void Visual3d_TransientManager::BeginPolyline () {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-       if( theTypeOfPrimitive != Graphic3d_TOP_UNDEFINED )
-               Visual3d_TransientDefinitionError::Raise
-                       ("One primitive is already opened !");
-
-       theTypeOfPrimitive = Graphic3d_TOP_POLYLINE;
-
-       theGraphicDriver->BeginPolyline();
-
-}
-
-void Visual3d_TransientManager::BeginPolygon () {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-       if( theTypeOfPrimitive != Graphic3d_TOP_UNDEFINED )
-               Visual3d_TransientDefinitionError::Raise
-                       ("One primitive is already opened !");
-
-       theTypeOfPrimitive = Graphic3d_TOP_POLYGON;
-
-}
-
-void Visual3d_TransientManager::BeginTriangleMesh () {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-       if( theTypeOfPrimitive != Graphic3d_TOP_UNDEFINED )
-               Visual3d_TransientDefinitionError::Raise
-                       ("One primitive is already opened !");
-
-       theTypeOfPrimitive = Graphic3d_TOP_TRIANGLEMESH;
-
-}
-
-void Visual3d_TransientManager::BeginMarker () {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-       if( theTypeOfPrimitive != Graphic3d_TOP_UNDEFINED )
-               Visual3d_TransientDefinitionError::Raise
-                       ("One primitive is already opened !");
-
-       theTypeOfPrimitive = Graphic3d_TOP_MARKER;
-
-}
-
-void Visual3d_TransientManager::BeginBezier () {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-       if( theTypeOfPrimitive != Graphic3d_TOP_UNDEFINED )
-               Visual3d_TransientDefinitionError::Raise
-                       ("One primitive is already opened !");
-
-       theTypeOfPrimitive = Graphic3d_TOP_BEZIER;
-
-}
-
-void Visual3d_TransientManager::AddVertex (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean AFlag) {
-Standard_ShortReal x = Standard_ShortReal(X);
-Standard_ShortReal y = Standard_ShortReal(Y);
-Standard_ShortReal z = Standard_ShortReal(Z);
-
-       switch (theTypeOfPrimitive) {
-         case Graphic3d_TOP_POLYLINE :
-           if( AFlag ) theGraphicDriver->Draw (x, y, z);
-           else        theGraphicDriver->Move (x, y, z);
-           break;
-         case Graphic3d_TOP_POLYGON :
-           break;
-         case Graphic3d_TOP_TRIANGLEMESH :
-           break;
-         case Graphic3d_TOP_QUADRANGLEMESH :
-           break;
-         case Graphic3d_TOP_TEXT :
-           break;
-         case Graphic3d_TOP_MARKER :
-           break;
-         case Graphic3d_TOP_BEZIER :
-           break;
-         default:
-           Visual3d_TransientDefinitionError::Raise
-                       ("Bad Primitive type!");
-       }
-       theMinX  = Min(theMinX,X);
-       theMinY  = Min(theMinY,Y);
-       theMinZ  = Min(theMinZ,Z);
-       theMaxX  = Max(theMaxX,X);
-       theMaxY  = Max(theMaxY,Y);
-       theMaxZ  = Max(theMaxZ,Z);
-}
-
-void Visual3d_TransientManager::AddVertex (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real W, const Standard_Boolean AFlag) {
-
-       switch (theTypeOfPrimitive) {
-         case Graphic3d_TOP_POLYLINE :
-           break;
-         case Graphic3d_TOP_POLYGON :
-           break;
-         case Graphic3d_TOP_TRIANGLEMESH :
-           break;
-         case Graphic3d_TOP_QUADRANGLEMESH :
-           break;
-         case Graphic3d_TOP_TEXT :
-           break;
-         case Graphic3d_TOP_MARKER :
-           break;
-         case Graphic3d_TOP_BEZIER :
-           break;
-         default:
-           Visual3d_TransientDefinitionError::Raise
-                       ("Bad Primitive type!");
-       }
-       theMinX  = Min(theMinX,X);
-       theMinY  = Min(theMinY,Y);
-       theMinZ  = Min(theMinZ,Z);
-       theMaxX  = Max(theMaxX,X);
-       theMaxY  = Max(theMaxY,Y);
-       theMaxZ  = Max(theMaxZ,Z);
-}
-
-void Visual3d_TransientManager::AddVertex (const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real NX, const Standard_Real NY, const Standard_Real NZ, const Standard_Boolean AFlag) {
-
-       switch (theTypeOfPrimitive) {
-         case Graphic3d_TOP_POLYLINE :
-           break;
-         case Graphic3d_TOP_POLYGON :
-           break;
-         case Graphic3d_TOP_TRIANGLEMESH :
-           break;
-         case Graphic3d_TOP_QUADRANGLEMESH :
-           break;
-         case Graphic3d_TOP_TEXT :
-           break;
-         case Graphic3d_TOP_MARKER :
-           break;
-         case Graphic3d_TOP_BEZIER :
-           break;
-         default:
-           Visual3d_TransientDefinitionError::Raise
-                       ("Bad Primitive type!");
-       }
-       theMinX  = Min(theMinX,X);
-       theMinY  = Min(theMinY,Y);
-       theMinZ  = Min(theMinZ,Z);
-       theMaxX  = Max(theMaxX,X);
-       theMaxY  = Max(theMaxY,Y);
-       theMaxZ  = Max(theMaxZ,Z);
-}
-
-void Visual3d_TransientManager::ClosePrimitive () {
-
-       switch (theTypeOfPrimitive) {
-         case Graphic3d_TOP_POLYLINE :
-           theGraphicDriver->EndPolyline();
-           break;
-         case Graphic3d_TOP_POLYGON :
-           break;
-         case Graphic3d_TOP_TRIANGLEMESH :
-           break;
-         case Graphic3d_TOP_QUADRANGLEMESH :
-           break;
-         case Graphic3d_TOP_TEXT :
-           break;
-         case Graphic3d_TOP_MARKER :
-           break;
-         case Graphic3d_TOP_BEZIER :
-           break;
-         default:
-           Visual3d_TransientDefinitionError::Raise
-                       ("Bad Primitive type!");
-       }
-
-       theTypeOfPrimitive = Graphic3d_TOP_UNDEFINED;
-}
-
-#ifdef WNT
-#undef DrawText
-#endif
-void Visual3d_TransientManager::DrawText (const TCollection_ExtendedString &AText, const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Real AHeight, const Quantity_PlaneAngle AAngle, const Graphic3d_TextPath ATp, const Graphic3d_HorizontalTextAlignment AHta, const Graphic3d_VerticalTextAlignment AVta) {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-       if( theTypeOfPrimitive != Graphic3d_TOP_UNDEFINED )
-               Visual3d_TransientDefinitionError::Raise
-                       ("One primitive is already opened !");
-}
-
-void Visual3d_TransientManager::DrawStructure (const Handle(Graphic3d_Structure) &AStructure) {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-       if( theTypeOfPrimitive != Graphic3d_TOP_UNDEFINED )
-               Visual3d_TransientDefinitionError::Raise
-                       ("One primitive is already opened !");
-
-#ifdef DEBUG_PRO4022
-       if (! AStructure->IsEmpty ()) {
-Standard_Real RL       = RealLast ();
-Standard_Real RF       = RealFirst ();
-Standard_Real XMin, YMin, ZMin, XMax, YMax, ZMax;
-Standard_ShortReal x1, y1, z1, x2, y2, z2;
-               AStructure->MinMaxValues (XMin, YMin, ZMin, XMax, YMax, ZMax);
-               if ((XMin == RF) && (YMin == RF) &&
-                   (ZMin == RF) && (XMax == RL) &&
-                   (YMax == RL) && (ZMax == RL)) {
-Standard_ShortReal SRL = ShortRealLast ();
-Standard_ShortReal SRF = ShortRealFirst ();
-                       x1 = y1 = z1 = SRF;
-                       x2 = y2 = z2 = SRL;
-               }
-               else {
-                       x1 = Standard_ShortReal (XMin);
-                       y1 = Standard_ShortReal (YMin);
-                       z1 = Standard_ShortReal (ZMin);
-                       x2 = Standard_ShortReal (XMax);
-                       y2 = Standard_ShortReal (YMax);
-                       z2 = Standard_ShortReal (ZMax);
-               }
-               theGraphicDriver->SetMinMax (x1, y1, z1, x2, y2, z2);
-#endif /* DEBUG_PRO4022 */
-
-               theGraphicDriver->DrawStructure (*AStructure->CStructure());
+void Visual3d_TransientManager::DrawStructure (const Handle(Graphic3d_Structure)& theStructure)
+{
+       if (!theDrawingState)
+  {
+               Visual3d_TransientDefinitionError::Raise ("Drawing is not open !");
+  }
+  else if (!theStructure->IsEmpty())
+  {
+               theGraphicDriver->DrawStructure (*theStructure->CStructure());
        }
-
-}
-
-void Visual3d_TransientManager::SetPrimitivesAspect (const Handle(Graphic3d_AspectLine3d)& CTX) {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-
-Standard_Real AWidth;
-Quantity_Color AColor;
-Aspect_TypeOfLine AType;
-
-       CTX->Values (AColor, AType, AWidth);
-
-       Standard_ShortReal r = Standard_ShortReal(AColor.Red());
-       Standard_ShortReal g = Standard_ShortReal(AColor.Green());
-       Standard_ShortReal b = Standard_ShortReal(AColor.Blue());
-       theGraphicDriver->SetLineColor(r, g, b);
-
-       Standard_Integer t = AType;
-       theGraphicDriver->SetLineType(t);
-
-       Standard_ShortReal w = Standard_ShortReal (AWidth);
-       theGraphicDriver->SetLineWidth(w);
-}
-
-void Visual3d_TransientManager::SetPrimitivesAspect (const Handle(Graphic3d_AspectFillArea3d)& CTX) {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-
-Standard_Real AWidth;
-Quantity_Color AIntColor,AEdgeColor;
-Aspect_TypeOfLine AType;
-Aspect_InteriorStyle AStyle;
-
-       CTX->Values (AStyle,AIntColor,AEdgeColor,AType,AWidth);
-
-}
-
-void Visual3d_TransientManager::SetPrimitivesAspect (const Handle(Graphic3d_AspectText3d)& CTX) {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-
-}
-
-void Visual3d_TransientManager::SetPrimitivesAspect (const Handle(Graphic3d_AspectMarker3d)& CTX) {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-                       ("Drawing is not open !");
-
-Standard_Real AScale;
-Quantity_Color AColor;
-Aspect_TypeOfMarker AType;
-
-       CTX->Values (AColor,AType,AScale);
-
-}
-
-void Visual3d_TransientManager::SetTransform (const TColStd_Array2OfReal& AMatrix, const Graphic3d_TypeOfComposition AType) {
-
-       if( !theDrawingState )
-               Visual3d_TransientDefinitionError::Raise
-       ("Visual3d_TransientManager::SetTransform, Drawing is not open !");
-
-Standard_Integer lr, ur, lc, uc;
-
-       lr = AMatrix.LowerRow ();
-       ur = AMatrix.UpperRow ();
-       lc = AMatrix.LowerCol ();
-       uc = AMatrix.UpperCol ();
-
-       if ( (ur - lr + 1 != 4) || (uc - lc + 1 != 4) )
-               Visual3d_TransientDefinitionError::Raise
-       ("Visual3d_TransientManager::SetTransform, Bad Transformation matrix !");
-
-       theGraphicDriver->Transform (AMatrix, AType);
-
-}
-
-void Visual3d_TransientManager::MinMaxValues (Standard_Real& XMin, Standard_Real& YMin, Standard_Real& ZMin, Standard_Real& XMax, Standard_Real& YMax, Standard_Real& ZMax) {
-
-       XMin    = theMinX;
-       YMin    = theMinY;
-       ZMin    = theMinZ;
-
-       XMax    = theMaxX;
-       YMax    = theMaxY;
-       ZMax    = theMaxZ;
-
-}
-
-void Visual3d_TransientManager::MinMaxValues (Standard_Real& UMin, Standard_Real& VMin, Standard_Real& UMax, Standard_Real& VMax) {
-
-       UMin    = theMinX;
-       VMin    = theMinY;
-
-       UMax    = theMaxX;
-       VMax    = theMaxY;
-
 }
diff --git a/tests/bugs/vis/bug23525 b/tests/bugs/vis/bug23525
new file mode 100755 (executable)
index 0000000..b52e27d
--- /dev/null
@@ -0,0 +1,28 @@
+puts "======="
+puts "CR23525"
+puts "======="
+puts ""
+
+########################################
+## Disappearing of highlight in screenshot
+########################################
+
+vinit
+vclear
+box t_box 100 100 100
+vdisplay t_box
+vfit
+
+set x_coord 110
+set y_coord 352
+
+vmoveto 0 0
+
+# EDGE ON
+vselmode 2 1
+
+vmoveto $x_coord $y_coord
+
+checkcolor $x_coord $y_coord 0 1 1
+
+set only_screen 1