0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[occt.git] / src / OpenGl / OpenGl_Trihedron.cxx
index 93c06ce..a0b6167 100644 (file)
@@ -20,6 +20,7 @@
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_ArrayOfPolylines.hxx>
 #include <Graphic3d_GraphicDriver.hxx>
+#include <Graphic3d_TransformUtils.hxx>
 #include <OpenGl_View.hxx>
 #include <OpenGl_Workspace.hxx>
 #include <Precision.hxx>
@@ -38,17 +39,17 @@ namespace
 // =======================================================================
 void OpenGl_Trihedron::resetTransformations (const Handle(OpenGl_Workspace)& theWorkspace) const
 {
-  const Handle(OpenGl_Context)& aContext = theWorkspace->GetGlContext();
-  const Handle(OpenGl_View)& aView    = theWorkspace->ActiveView();
-  GLdouble anU = 1.0;
-  GLdouble aV = 1.0;
-  if (aView->Height() < aView->Width())
+  const Handle(OpenGl_Context)&   aContext = theWorkspace->GetGlContext();
+  const Handle(Graphic3d_Camera)& aCamera  = theWorkspace->View()->Camera();
+  double anU = 1.0;
+  double aV  = 1.0;
+  if (aCamera->ViewDimensions().X() < aCamera->ViewDimensions().Y())
   {
-    aV = aView->Width() / aView->Height();
+    aV  = aCamera->ViewDimensions().Y() / aCamera->ViewDimensions().X();
   }
   else
   {
-    anU = aView->Height() / aView->Width();
+    anU = aCamera->ViewDimensions().X() / aCamera->ViewDimensions().Y();
   }
 
   // Reading the transformation matrices and projection of sight
@@ -87,25 +88,25 @@ void OpenGl_Trihedron::resetTransformations (const Handle(OpenGl_Workspace)& the
   {
     case Aspect_TOTP_LEFT_LOWER:
     {
-      OpenGl_Utils::Translate (aProjMatrix,
+      Graphic3d_TransformUtils::Translate (aProjMatrix,
         -0.5 * anU + myScale, -0.5 * aV + myScale, 0.0);
       break;
     }
     case Aspect_TOTP_LEFT_UPPER:
     {
-      OpenGl_Utils::Translate (aProjMatrix,
+      Graphic3d_TransformUtils::Translate (aProjMatrix,
         -0.5 * anU + myScale, 0.5 * aV - myScale - myScale / 3.0, 0.0);
       break;
     }
     case Aspect_TOTP_RIGHT_LOWER:
     {
-      OpenGl_Utils::Translate (aProjMatrix,
+      Graphic3d_TransformUtils::Translate (aProjMatrix,
         0.5 * anU - myScale - myScale / 3.0, -0.5 * aV + myScale, 0.0);
       break;
     }
     case Aspect_TOTP_RIGHT_UPPER:
     {
-      OpenGl_Utils::Translate (aProjMatrix,
+      Graphic3d_TransformUtils::Translate (aProjMatrix,
         0.5 * anU - myScale - myScale / 3.0, 0.5 * aV - myScale - myScale / 3.0, 0.0);
       break;
     }
@@ -185,9 +186,10 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con
   OpenGl_AspectFace anAspectY;
   OpenGl_AspectFace anAspectZ;
   OpenGl_AspectLine anAspectLine;
-  memcpy (anAspectX.ChangeIntFront().matcol.rgb, myXColor.GetData(), sizeof (TEL_COLOUR));
-  memcpy (anAspectY.ChangeIntFront().matcol.rgb, myYColor.GetData(), sizeof (TEL_COLOUR));
-  memcpy (anAspectZ.ChangeIntFront().matcol.rgb, myZColor.GetData(), sizeof (TEL_COLOUR));
+  anAspectX.Aspect()->SetInteriorColor (Quantity_Color (myXColor.rgb()));
+  anAspectY.Aspect()->SetInteriorColor (Quantity_Color (myYColor.rgb()));
+  anAspectZ.Aspect()->SetInteriorColor (Quantity_Color (myZColor.rgb()));
+
   OpenGl_Mat4d aModelMatrix;
   aModelMatrix.Convert (aContext->WorldViewState.Current());
   OpenGl_Mat4d aModelViewX (aModelMatrix);
@@ -195,12 +197,9 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con
   OpenGl_Mat4d aModelViewZ (aModelMatrix);
 
   // Set line aspect
-  const OpenGl_AspectLine* aCurrentAspectLine = theWorkspace->AspectLine (Standard_True);
-  CALL_DEF_CONTEXTLINE aLineAspect = {1, 1, { 1.F, 1.F, 1.F },  aCurrentAspectLine->Type(), aCurrentAspectLine->Width()};
-  aLineAspect.Color.r = myZColor.r();
-  aLineAspect.Color.g = myZColor.g();
-  aLineAspect.Color.b = myZColor.b();
-  anAspectLine.SetAspect (aLineAspect);
+  const OpenGl_AspectLine* aCurrentAspectLine = theWorkspace->ApplyAspectLine();
+  Handle(Graphic3d_AspectLine3d) anAspectLine3d = new Graphic3d_AspectLine3d (Quantity_Color(), aCurrentAspectLine->Aspect()->Type(), aCurrentAspectLine->Aspect()->Width());
+  anAspectLine.SetAspect (anAspectLine3d);
 
   // Disable depth test and face culling
   GLboolean wasDepthMaskEnabled = GL_FALSE;
@@ -230,9 +229,10 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con
 
   // Z axis
   const OpenGl_AspectFace* anOldAspectFace = theWorkspace->SetAspectFace(&anAspectZ);
+  anAspectLine3d->SetColor (Quantity_Color (myZColor.rgb()));
   theWorkspace->SetAspectLine (&anAspectLine);
   myLine.Render (theWorkspace);
-  OpenGl_Utils::Translate (aModelViewZ, 0.0, 0.0, aLineLength);
+  Graphic3d_TransformUtils::Translate (aModelViewZ, 0.0, 0.0, aLineLength);
   aContext->WorldViewState.SetCurrent<Standard_Real>(aModelViewZ);
   aContext->ApplyWorldViewMatrix();
   myDisk.Render (theWorkspace);
@@ -240,17 +240,14 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con
 
   // X axis
   theWorkspace->SetAspectFace (&anAspectX);
-  OpenGl_Utils::Rotate (aModelViewX, 90.0, 0.0, aScale, 0.0);
+  Graphic3d_TransformUtils::Rotate (aModelViewX, 90.0, 0.0, aScale, 0.0);
   aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
   aContext->ApplyWorldViewMatrix();
 
-  aLineAspect.Color.r = myXColor.r();
-  aLineAspect.Color.g = myXColor.g();
-  aLineAspect.Color.b = myXColor.b();
-  anAspectLine.SetAspect (aLineAspect);
+  anAspectLine3d->SetColor (Quantity_Color (myXColor.rgb()));
   theWorkspace->SetAspectLine (&anAspectLine);
   myLine.Render (theWorkspace);
-  OpenGl_Utils::Translate (aModelViewX, 0.0, 0.0, aLineLength);
+  Graphic3d_TransformUtils::Translate (aModelViewX, 0.0, 0.0, aLineLength);
   aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
   aContext->ApplyWorldViewMatrix();
   myDisk.Render (theWorkspace);
@@ -258,17 +255,14 @@ void OpenGl_Trihedron::redraw (const Handle(OpenGl_Workspace)& theWorkspace) con
 
   // Y axis
   theWorkspace->SetAspectFace (&anAspectY);
-  OpenGl_Utils::Rotate (aModelViewY, -90.0, aScale, 0.0, 0.0);
+  Graphic3d_TransformUtils::Rotate (aModelViewY, -90.0, aScale, 0.0, 0.0);
   aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
   aContext->ApplyWorldViewMatrix();
 
-  aLineAspect.Color.r = myYColor.r();
-  aLineAspect.Color.g = myYColor.g();
-  aLineAspect.Color.b = myYColor.b();
-  anAspectLine.SetAspect (aLineAspect);
+  anAspectLine3d->SetColor (Quantity_Color (myYColor.rgb()));
   theWorkspace->SetAspectLine (&anAspectLine);
   myLine.Render (theWorkspace);
-  OpenGl_Utils::Translate (aModelViewY, 0.0, 0.0, aLineLength);
+  Graphic3d_TransformUtils::Translate (aModelViewY, 0.0, 0.0, aLineLength);
   aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
   aContext->ApplyWorldViewMatrix();
   myDisk.Render (theWorkspace);
@@ -324,8 +318,8 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa
 
   const GLdouble aScale = myScale * myRatio;
 
-  const OpenGl_AspectLine* anAspectLine = theWorkspace->AspectLine (Standard_True);
-  const TEL_COLOUR&        aLineColor   = anAspectLine->Color();
+  const OpenGl_AspectLine* anAspectLine = theWorkspace->ApplyAspectLine();
+  const OpenGl_Vec4&       aLineColor   = anAspectLine->Aspect()->ColorRGBA();
 
   // Create the trihedron
   const Standard_Real THE_CYLINDER_LENGTH = 0.75;
@@ -388,10 +382,10 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa
   OpenGl_AspectFace anAspectX;
   OpenGl_AspectFace anAspectY;
   OpenGl_AspectFace anAspectZ;
-  memcpy (anAspectX.ChangeIntFront().matcol.rgb, myXColor.GetData(), sizeof (TEL_COLOUR));
-  memcpy (anAspectY.ChangeIntFront().matcol.rgb, myYColor.GetData(), sizeof (TEL_COLOUR));
-  memcpy (anAspectZ.ChangeIntFront().matcol.rgb, myZColor.GetData(), sizeof (TEL_COLOUR));
-  memcpy (anAspectC.ChangeIntFront().matcol.rgb, aLineColor.rgb,     sizeof (TEL_COLOUR));
+  anAspectX.Aspect()->SetInteriorColor (Quantity_Color (myXColor.rgb()));
+  anAspectY.Aspect()->SetInteriorColor (Quantity_Color (myYColor.rgb()));
+  anAspectZ.Aspect()->SetInteriorColor (Quantity_Color (myZColor.rgb()));
+  anAspectC.Aspect()->SetInteriorColor (Quantity_Color (aLineColor.rgb()));
 
   OpenGl_Mat4d aModelMatrix;
   aModelMatrix.Convert (aContext->WorldViewState.Current());
@@ -412,7 +406,7 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa
     // Z axis
     theWorkspace->SetAspectFace (&anAspectZ);
     myCylinder.Render (theWorkspace);
-    OpenGl_Utils::Translate (aModelViewZ, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
+    Graphic3d_TransformUtils::Translate (aModelViewZ, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
     aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewZ);
     aContext->ApplyWorldViewMatrix();
     myDisk.Render (theWorkspace);
@@ -420,11 +414,11 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa
 
     // X axis
     theWorkspace->SetAspectFace (&anAspectX);
-    OpenGl_Utils::Rotate (aModelViewX, 90.0, aTriedronAxeY[0], aTriedronAxeY[1], aTriedronAxeY[2]);
+    Graphic3d_TransformUtils::Rotate (aModelViewX, 90.0, aTriedronAxeY[0], aTriedronAxeY[1], aTriedronAxeY[2]);
     aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
     aContext->ApplyWorldViewMatrix();
     myCylinder.Render (theWorkspace);
-    OpenGl_Utils::Translate (aModelViewX, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
+    Graphic3d_TransformUtils::Translate (aModelViewX, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
     aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewX);
     aContext->ApplyWorldViewMatrix();
     myDisk.Render (theWorkspace);
@@ -432,11 +426,11 @@ void OpenGl_Trihedron::redrawZBuffer (const Handle(OpenGl_Workspace)& theWorkspa
 
     // Y axis
     theWorkspace->SetAspectFace (&anAspectY);
-    OpenGl_Utils::Rotate (aModelViewY, -90.0, aTriedronAxeX[0], aTriedronAxeX[1], aTriedronAxeX[2]);
+    Graphic3d_TransformUtils::Rotate (aModelViewY, -90.0, aTriedronAxeX[0], aTriedronAxeX[1], aTriedronAxeX[2]);
     aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
     aContext->ApplyWorldViewMatrix();
     myCylinder.Render (theWorkspace);
-    OpenGl_Utils::Translate (aModelViewY, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
+    Graphic3d_TransformUtils::Translate (aModelViewY, 0.0, 0.0, aScale * THE_CYLINDER_LENGTH);
     aContext->WorldViewState.SetCurrent<Standard_Real> (aModelViewY);
     aContext->ApplyWorldViewMatrix();
     myDisk.Render (theWorkspace);
@@ -500,10 +494,9 @@ OpenGl_Trihedron::OpenGl_Trihedron()
   myLine   (NULL), // do not register arrays UID - trihedron is not intended to be drawn by Ray Tracing engine
   myCircle (NULL)
 {
-  const TEL_COLOUR aWhiteColor = {{ 1.0f, 1.0f, 1.0f, 1.0f }};
-  myAspectLine.ChangeColor()    = aWhiteColor;
-  myAspectText.ChangeColor()    = aWhiteColor;
-  myAspectText.ChangeFontName() = "Courier";
+  myAspectLine.SetAspect (new Graphic3d_AspectLine3d (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
+  myAspectText.Aspect()->SetColor (Quantity_NOC_WHITE);
+  myAspectText.Aspect()->SetFont ("Courier");
 }
 
 // =======================================================================
@@ -606,9 +599,7 @@ void OpenGl_Trihedron::SetNbFacets (const Standard_Integer theNbFacets)
 // =======================================================================
 void OpenGl_Trihedron::SetLabelsColor (const Quantity_Color& theColor)
 {
-  myAspectText.ChangeColor().rgb[0] = float(theColor.Red());
-  myAspectText.ChangeColor().rgb[1] = float(theColor.Green());
-  myAspectText.ChangeColor().rgb[2] = float(theColor.Blue());
+  myAspectText.Aspect()->SetColor (theColor);
 }
 
 // =======================================================================
@@ -645,7 +636,7 @@ void OpenGl_Trihedron::Render (const Handle(OpenGl_Workspace)& theWorkspace) con
   }
 
   const Handle(OpenGl_Texture) aPrevTexture = theWorkspace->DisableTexture();
-  theWorkspace->ActiveView()->EndTransformPersistence (theWorkspace->GetGlContext());
+
   theWorkspace->GetGlContext()->ApplyModelViewMatrix();
 
   if (myIsWireframe)