0027750: Visualization, V3d_View - remove unused functionality ZClipping and ZCueing
[occt.git] / src / OpenGl / OpenGl_View.cxx
index 6ec36bb..42dec5a 100644 (file)
@@ -40,15 +40,6 @@ IMPLEMENT_STANDARD_RTTIEXT(OpenGl_View,Graphic3d_CView)
 #include <gl2ps.h>
 #endif
 
-/*----------------------------------------------------------------------*/
-
-namespace
-{
-  static const OPENGL_ZCLIP myDefaultZClip = { { Standard_False, 0.F }, { Standard_False, 1.F } };
-  static const OPENGL_FOG   myDefaultFog   = { Standard_False, 0.F, 1.F, { { 0.F, 0.F, 0.F, 1.F } } };
-  static const TEL_COLOUR   myDefaultBg    = { { 0.F, 0.F, 0.F, 1.F } };
-}
-
 // =======================================================================
 // function : Constructor
 // purpose  :
@@ -63,13 +54,10 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
   myCaps           (theCaps),
   myDeviceLostFlag (theDeviceLostFlag),
   myWasRedrawnGL   (Standard_False),
-  myAntiAliasing   (Standard_False),
   myCulling        (Standard_True),
   myShadingModel   (Graphic3d_TOSM_FACET),
   myBackfacing     (Graphic3d_TOBM_AUTOMATIC),
-  myBgColor        (myDefaultBg),
-  myFog            (myDefaultFog),
-  myZClip          (myDefaultZClip),
+  myBgColor        (Quantity_NOC_BLACK),
   myCamera         (new Graphic3d_Camera()),
   myUseGLLight     (Standard_True),
   myToShowTrihedron      (false),
@@ -81,6 +69,7 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
   myToFlipOutput         (Standard_False),
   myFrameCounter         (0),
   myHasFboBlit           (Standard_True),
+  myToDisableMSAA        (Standard_False),
   myTransientDrawToFront (Standard_True),
   myBackBufferRestored   (Standard_False),
   myIsImmediateDrawn     (Standard_False),
@@ -96,13 +85,13 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
 {
   myWorkspace = new OpenGl_Workspace (this, NULL);
 
-  // AA mode
-  const char* anAaEnv = ::getenv ("CALL_OPENGL_ANTIALIASING_MODE");
-  if (anAaEnv != NULL)
-  {
-    int v;
-    if (sscanf (anAaEnv, "%d", &v) > 0) myAntiAliasing = v;
-  }
+  OpenGl_Light       aLight;
+  aLight.Type        = Graphic3d_TOLS_AMBIENT;
+  aLight.IsHeadlight = Standard_False;
+  aLight.Color.r()   = 1.;
+  aLight.Color.g()   = 1.;
+  aLight.Color.b()   = 1.;
+  myNoShadingLight.Append (aLight);
 
   myCurrLightSourceState  = myStateCounter->Increment();
   myMainSceneFbos[0]      = new OpenGl_FrameBuffer();
@@ -392,7 +381,7 @@ Standard_Boolean OpenGl_View::BufferDump (Image_PixMap& theImage, const Graphic3
 // =======================================================================
 Aspect_Background OpenGl_View::Background() const
 {
-  return Aspect_Background (Quantity_Color (myBgColor.rgb[0], myBgColor.rgb[1], myBgColor.rgb[2], Quantity_TOC_RGB));
+  return Aspect_Background (myBgColor.GetRGB());
 }
 
 // =======================================================================
@@ -401,11 +390,7 @@ Aspect_Background OpenGl_View::Background() const
 // =======================================================================
 void OpenGl_View::SetBackground (const Aspect_Background& theBackground)
 {
-  Quantity_Color aBgColor = theBackground.Color();
-  myBgColor.rgb[0] = static_cast<float> (aBgColor.Red());
-  myBgColor.rgb[1] = static_cast<float> (aBgColor.Green());
-  myBgColor.rgb[2] = static_cast<float> (aBgColor.Blue());
-  myFog.Color      = myBgColor;
+  myBgColor.SetRGB (theBackground.Color());
 }
 
 // =======================================================================
@@ -452,6 +437,7 @@ void OpenGl_View::SetBackgroundImage (const TCollection_AsciiString& theFilePath
                                         Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
   anAspect->SetTextureMap (aTextureMap);
   anAspect->SetInteriorStyle (Aspect_IS_SOLID);
+  anAspect->SetSuppressBackFaces (false);
   // Enable texture mapping
   if (aTextureMap->IsDone())
   {
@@ -513,6 +499,91 @@ void OpenGl_View::SetZLayerSettings (const Graphic3d_ZLayerId        theLayerId,
   myZLayers.SetLayerSettings (theLayerId, theSettings);
 }
 
+//=======================================================================
+//function : ZLayerMax
+//purpose  :
+//=======================================================================
+Standard_Integer OpenGl_View::ZLayerMax() const
+{
+  Standard_Integer aLayerMax = Graphic3d_ZLayerId_Default;
+  for (OpenGl_LayerSeqIds::Iterator aMapIt(myZLayers.LayerIDs()); aMapIt.More(); aMapIt.Next())
+  {
+    aLayerMax = Max (aLayerMax, aMapIt.Value());
+  }
+
+  return aLayerMax;
+}
+
+//=======================================================================
+//function : InvalidateZLayerBoundingBox
+//purpose  :
+//=======================================================================
+void OpenGl_View::InvalidateZLayerBoundingBox (const Graphic3d_ZLayerId theLayerId) const
+{
+  if (myZLayers.LayerIDs().IsBound (theLayerId))
+  {
+    myZLayers.Layer (theLayerId).InvalidateBoundingBox();
+  }
+  else
+  {
+    for (Standard_Integer aLayerId = Graphic3d_ZLayerId_Default; aLayerId < ZLayerMax(); ++aLayerId)
+    {
+      if (myZLayers.LayerIDs().IsBound (aLayerId))
+      {
+        const OpenGl_Layer& aLayer = myZLayers.Layer (aLayerId);
+        if (aLayer.NbOfTransformPersistenceObjects() > 0)
+        {
+          aLayer.InvalidateBoundingBox();
+        }
+      }
+    }
+  }
+}
+
+//=======================================================================
+//function : ZLayerBoundingBox
+//purpose  :
+//=======================================================================
+Graphic3d_BndBox4f OpenGl_View::ZLayerBoundingBox (const Graphic3d_ZLayerId        theLayerId,
+                                                   const Handle(Graphic3d_Camera)& theCamera,
+                                                   const Standard_Integer          theWindowWidth,
+                                                   const Standard_Integer          theWindowHeight,
+                                                   const Standard_Boolean          theToIgnoreInfiniteFlag) const
+{
+  if (myZLayers.LayerIDs().IsBound (theLayerId))
+  {
+    return myZLayers.Layer (theLayerId).BoundingBox (Identification(),
+                                                     theCamera,
+                                                     theWindowWidth,
+                                                     theWindowHeight,
+                                                     theToIgnoreInfiniteFlag);
+  }
+
+  return Graphic3d_BndBox4f();
+}
+
+//=======================================================================
+//function : considerZoomPersistenceObjects
+//purpose  :
+//=======================================================================
+Standard_Real OpenGl_View::considerZoomPersistenceObjects (const Graphic3d_ZLayerId        theLayerId,
+                                                           const Handle(Graphic3d_Camera)& theCamera,
+                                                           const Standard_Integer          theWindowWidth,
+                                                           const Standard_Integer          theWindowHeight,
+                                                           const Standard_Boolean          theToIgnoreInfiniteFlag) const
+{
+  if (myZLayers.LayerIDs().IsBound (theLayerId))
+  {
+    return myZLayers.Layer (theLayerId).considerZoomPersistenceObjects (Identification(),
+                                                                        theCamera,
+                                                                        theWindowWidth,
+                                                                        theWindowHeight,
+                                                                        theToIgnoreInfiniteFlag);
+  }
+
+  return 1.0;
+}
+
 //=======================================================================
 //function : FBO
 //purpose  :
@@ -734,6 +805,8 @@ void OpenGl_View::changeZLayer (const Handle(Graphic3d_CStructure)& theStructure
   const Graphic3d_ZLayerId anOldLayer = theStructure->ZLayer();
   const OpenGl_Structure* aStruct = reinterpret_cast<const OpenGl_Structure*> (theStructure.operator->());
   myZLayers.ChangeLayer (aStruct, anOldLayer, theNewLayerId);
+  Update (Aspect_TOU_WAIT, anOldLayer);
+  Update (Aspect_TOU_WAIT, theNewLayerId);
 }
 
 //=======================================================================