]> OCCT Git - occt.git/commitdiff
#add new params CR30979_2
authormzernova <mzernova@opencascade.com>
Mon, 16 Sep 2024 02:53:10 +0000 (03:53 +0100)
committermzernova <mzernova@opencascade.com>
Mon, 16 Sep 2024 02:53:10 +0000 (03:53 +0100)
21 files changed:
src/AIS/AIS_ViewController.cxx
src/Aspect/Aspect_Grid.hxx
src/Aspect/Aspect_GridParams.hxx [new file with mode: 0644]
src/Aspect/Aspect_RectangularGrid.cxx
src/Aspect/FILES
src/Graphic3d/Graphic3d_CView.cxx
src/Graphic3d/Graphic3d_CView.hxx
src/Graphic3d/Graphic3d_Camera.cxx
src/Graphic3d/Graphic3d_ShaderManager.cxx
src/Graphic3d/Graphic3d_StructureManager.cxx
src/OpenGl/OpenGl_ShaderManager.hxx
src/OpenGl/OpenGl_View.cxx
src/OpenGl/OpenGl_View.hxx
src/V3d/V3d_CircularGrid.cxx
src/V3d/V3d_RectangularGrid.cxx
src/V3d/V3d_RectangularGrid.hxx
src/V3d/V3d_View.cxx
src/V3d/V3d_View.hxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/v3d/grid/ortho [new file with mode: 0644]
tests/v3d/grid/persp [new file with mode: 0644]

index 4a9300f71215780784b4356ac98272736ef4c8d9..0f7b06317384574b38715b2086ac7417e602df31 100644 (file)
@@ -27,8 +27,6 @@
 #include <V3d_Viewer.hxx>
 #include <WNT_HIDSpaceMouse.hxx>
 
-#include <iostream>
-
 // =======================================================================
 // function : AIS_ViewController
 // purpose  :
index ba66a7ea87c26358387cd417006ed209e93e99a9..ab8e76eab1bc53ce0abf3b00e94e991631805ce0 100644 (file)
@@ -87,7 +87,7 @@ public:
   //! Display the grid at screen.
   Standard_EXPORT virtual void Display() = 0;
 
-  //! 
+  //! Update grid presentation
   Standard_EXPORT virtual void Update() = 0;
   
   //! Erase the grid from screen.
diff --git a/src/Aspect/Aspect_GridParams.hxx b/src/Aspect/Aspect_GridParams.hxx
new file mode 100644 (file)
index 0000000..41c01e3
--- /dev/null
@@ -0,0 +1,67 @@
+// Created on: 1995-03-02
+// Created by: Jean-Louis Frenkel
+// Copyright (c) 1995-1999 Matra Datavision
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
+//
+// This file is part of Open CASCADE Technology software library.
+//
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
+//
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+
+#ifndef _Aspect_GridParams_HeaderFile
+#define _Aspect_GridParams_HeaderFile
+
+#include <Quantity_Color.hxx>
+#include <gp_Pnt.hxx>
+
+class Aspect_GridParams
+{
+public:
+
+  //! Constructor.
+  Aspect_GridParams()
+  : myIsHorizontal (true),
+    myIsDrawAxis(true),
+    myColor(0.8, 0.8, 0.8, Quantity_TOC_RGB),
+    myScale (0.01),
+    myIsInfinity (false),
+    myPosition (0.0, 0.0, 0.0),
+    myLineThickness (0.01)
+  {}
+
+  //! Getters
+  Standard_Boolean IsHorizontal() const { return myIsHorizontal; }
+  Standard_Boolean IsDrawAxis() const { return myIsDrawAxis; }
+  const Quantity_Color& Color() const { return myColor; }
+  Standard_Real Scale() const { return myScale; }
+  Standard_Boolean IsInfinity() const { return myIsInfinity; }
+  const gp_Pnt& Position() const { return myPosition; }
+  Standard_Real LineThickness() const { return myLineThickness; }
+
+  //! Setters
+  void SetIsHorizontal (Standard_Boolean theValue) { myIsHorizontal = theValue; }
+  void SetIsDrawAxis (Standard_Boolean theValue) { myIsDrawAxis = theValue; }
+  void SetColor (const Quantity_Color& theColor) { myColor = theColor; }
+  void SetScale (Standard_Real theScale) { myScale = theScale; }
+  void SetIsInfinity (Standard_Boolean theValue) { myIsInfinity = theValue; }
+  void SetPosition (const gp_Pnt& thePosition) { myPosition = thePosition; }
+  void SetLineThickness (Standard_Real theThickness) { myLineThickness = theThickness; }
+
+private:
+
+  Quantity_Color   myColor;
+  gp_Pnt           myPosition;
+  Standard_Real    myScale;
+  Standard_Real    myLineThickness;
+  Standard_Boolean myIsHorizontal;
+  Standard_Boolean myIsDrawAxis;
+  Standard_Boolean myIsInfinity;
+};
+
+#endif // _Aspect_GridParams_HeaderFile
index 325617ff363c73fcb633774ccea57025550ea8a1..a6263ec5b00fa5d306e13dc690f48a1baf19f87c 100644 (file)
@@ -33,29 +33,28 @@ Aspect_RectangularGrid::Aspect_RectangularGrid(
   myFirstAngle (aFirstAngle),
   mySecondAngle (aSecondAngle)
 {
-  Standard_NumericError_Raise_if (!CheckAngle (aFirstAngle, mySecondAngle),
-                                  "networks are parallel");
-  Standard_NegativeValue_Raise_if (aXStep < 0.0, "invalid x step");
-  Standard_NegativeValue_Raise_if (aYStep < 0.0, "invalid y step");
-  Standard_NullValue_Raise_if (aXStep == 0.0, "invalid x step");
-  Standard_NullValue_Raise_if (aYStep == 0.0, "invalid y step");
+  Standard_NumericError_Raise_if(!CheckAngle (aFirstAngle,mySecondAngle),
+                                 "networks are parallel");
+
+  Standard_NegativeValue_Raise_if(aXStep < 0. , "invalid x step");
+  Standard_NegativeValue_Raise_if(aYStep < 0. , "invalid y step");
+  Standard_NullValue_Raise_if(aXStep == 0. , "invalid x step");
+  Standard_NullValue_Raise_if(aYStep == 0. , "invalid y step");
 }
 
 
 
-void Aspect_RectangularGrid::SetXStep (const Standard_Real aStep)
-{
-  Standard_NegativeValue_Raise_if (aStep < 0.0, "invalid x step");
-  Standard_NullValue_Raise_if (aStep == 0.0, "invalid y step");
+void Aspect_RectangularGrid::SetXStep(const Standard_Real aStep) {
+  Standard_NegativeValue_Raise_if(aStep < 0. , "invalid x step");
+  Standard_NullValue_Raise_if(aStep == 0. , "invalid y step");
   myXStep = aStep;
   Init();
   UpdateDisplay();
 }
 
-void Aspect_RectangularGrid::SetYStep (const Standard_Real aStep)
-{
-  Standard_NegativeValue_Raise_if (aStep < 0.0, "invalid x step");
-  Standard_NullValue_Raise_if (aStep == 0.0, "invalid y step");
+void Aspect_RectangularGrid::SetYStep(const Standard_Real aStep) {
+  Standard_NegativeValue_Raise_if(aStep < 0. , "invalid x step");
+  Standard_NullValue_Raise_if(aStep == 0. , "invalid y step");
   myYStep = aStep;
   Init();
   UpdateDisplay();
@@ -64,72 +63,67 @@ void Aspect_RectangularGrid::SetYStep (const Standard_Real aStep)
 void Aspect_RectangularGrid::SetAngle (const Standard_Real anAngle1,
                                        const Standard_Real anAngle2)
 {
-  Standard_NumericError_Raise_if (!CheckAngle (anAngle1,anAngle2),
-                                  "axis are parallel");
+  Standard_NumericError_Raise_if(!CheckAngle (anAngle1,anAngle2 ),
+                                 "axis are parallel");
   myFirstAngle = anAngle1;
   mySecondAngle = anAngle2;
   Init();
   UpdateDisplay();
 }
 
-void Aspect_RectangularGrid::SetGridValues (
-  const Standard_Real theXOrigin,
-  const Standard_Real theYOrigin,
-  const Standard_Real theXStep,
-  const Standard_Real theYStep,
-  const Standard_Real theRotationAngle)
-{
+void Aspect_RectangularGrid::SetGridValues(
+       const Standard_Real theXOrigin,
+       const Standard_Real theYOrigin,
+       const Standard_Real theXStep,
+       const Standard_Real theYStep,
+       const Standard_Real theRotationAngle) {
+
   myXOrigin = theXOrigin;
   myYOrigin = theYOrigin;
-  Standard_NegativeValue_Raise_if (theXStep < 0.0, "invalid x step");
-  Standard_NullValue_Raise_if (theXStep == 0.0, "invalid x step");
+  Standard_NegativeValue_Raise_if(theXStep < 0. , "invalid x step");
+  Standard_NullValue_Raise_if(theXStep == 0. , "invalid x step");
   myXStep = theXStep;
-  Standard_NegativeValue_Raise_if (theYStep < 0.0, "invalid y step");
-  Standard_NullValue_Raise_if (theYStep == 0.0, "invalid y step");
+  Standard_NegativeValue_Raise_if(theYStep < 0. , "invalid y step");
+  Standard_NullValue_Raise_if(theYStep == 0. , "invalid y step");
   myYStep = theYStep;
   myRotationAngle = theRotationAngle;
   Init();
   UpdateDisplay();
 }
 
-void Aspect_RectangularGrid::Compute (const Standard_Real X,
-                                      const Standard_Real Y,
-                                      Standard_Real& gridX,
-                                      Standard_Real& gridY) const
-{
+void Aspect_RectangularGrid::Compute(const Standard_Real X,
+                         const Standard_Real Y,
+                         Standard_Real& gridX,
+                         Standard_Real& gridY) const {
     Standard_Real D1 = b1 * X - a1 * Y - c1;
     Standard_Real D2 = b2 * X - a2 * Y - c2;
-    Standard_Integer n1 = Standard_Integer (Abs (D1) / myXStep + 0.5);
-    Standard_Integer n2 = Standard_Integer (Abs (D2) / myYStep + 0.5);
-    Standard_Real offset1 = c1 + Standard_Real(n1) * Sign (myXStep, D1);
-    Standard_Real offset2 = c2 + Standard_Real(n2) * Sign (myYStep, D2);
-    Standard_Real Delta = a1 * b2 - b1 * a2;
-    gridX = (offset2 * a1 - offset1 * a2) / Delta;
-    gridY = (offset2 * b1 - offset1 * b2) / Delta;
+    Standard_Integer n1 = Standard_Integer ( Abs(D1)/myXStep + 0.5);
+    Standard_Integer n2 = Standard_Integer ( Abs(D2)/myYStep + 0.5);
+    Standard_Real offset1 = c1 + Standard_Real(n1) * Sign (myXStep , D1);
+    Standard_Real offset2 = c2 + Standard_Real(n2) * Sign (myYStep , D2);
+    Standard_Real Delta = a1*b2 - b1*a2;
+    gridX = ( offset2*a1 - offset1*a2) /Delta;
+    gridY = ( offset2*b1 - offset1*b2) /Delta;
 }
 
-Standard_Real Aspect_RectangularGrid::XStep() const
-{
+Standard_Real Aspect_RectangularGrid::XStep() const {
   return myXStep;
 }
 
-Standard_Real Aspect_RectangularGrid::YStep() const
-{
+Standard_Real Aspect_RectangularGrid::YStep() const {
   return myYStep;
 }
 
-Standard_Real Aspect_RectangularGrid::FirstAngle() const
-{
+Standard_Real Aspect_RectangularGrid::FirstAngle() const {
   return myFirstAngle;
 }
 
-Standard_Real Aspect_RectangularGrid::SecondAngle() const
-{
+Standard_Real Aspect_RectangularGrid::SecondAngle() const {
   return mySecondAngle;
 }
 
-void Aspect_RectangularGrid::Init()
-{
+void Aspect_RectangularGrid::Init () {
+
 //+zov Fixing CTS17856
 //  a1 = Cos (myFirstAngle + RotationAngle() ); 
 //  b1 = Sin (myFirstAngle + RotationAngle() );
@@ -141,39 +135,28 @@ void Aspect_RectangularGrid::Init()
 
   Standard_Real angle1 = myFirstAngle + RotationAngle();
   Standard_Real angle2 = mySecondAngle + RotationAngle();
-  if (angle1 != 0.0)
-  {
-    a1 = -Sin (angle1);
+  if ( angle1 != 0. ) {
+    a1 = -Sin (angle1); 
     b1 = Cos (angle1);
     c1 = XOrigin() * b1 - YOrigin() * a1;
-  }
-  else
-  {
-    a1 = 0.0;
-    b1 = 1.0;
-    c1 = XOrigin();
+  } else {
+    a1 = 0.; b1 = 1.; c1 = XOrigin();
   }
 
-  if (angle2 != 0.0)
-  {
-    angle2 += M_PI / 2.0;
-    a2 = -Sin (angle2);
+  if ( angle2 != 0. ) {
+    angle2 += M_PI / 2.;
+    a2 = -Sin (angle2); 
     b2 = Cos (angle2);
     c2 = XOrigin() * b2 - YOrigin() * a2;
-  }
-  else
-  {
-    a2 = -1.0;
-    b2 = 0.0;
-    c2 = YOrigin();
+  } else {
+    a2 = -1.; b2 = 0.; c2 = YOrigin();
   }
 //-zov
 }
 
-Standard_Boolean Aspect_RectangularGrid::CheckAngle (const Standard_Real alpha,
-                                                     const Standard_Real beta) const
-{
-  return (Abs (Sin (alpha) * Cos (beta + M_PI / 2.0) - Cos (alpha) * Sin (beta + M_PI / 2.0)) != 0);
+Standard_Boolean Aspect_RectangularGrid::CheckAngle(const Standard_Real alpha,
+                                            const Standard_Real beta) const {
+  return (Abs( Sin(alpha) * Cos(beta + M_PI / 2.) - Cos(alpha) * Sin(beta + M_PI / 2.)) != 0) ;
 }
 
 //=======================================================================
index b1c7fa3f980ad0fc43ea2169d3f1976f7b9647f7..7152c787905d115c02bc47b99fe458290c296305 100755 (executable)
@@ -25,6 +25,7 @@ Aspect_GraphicsLibrary.hxx
 Aspect_Grid.cxx
 Aspect_Grid.hxx
 Aspect_GridDrawMode.hxx
+Aspect_GridParams.hxx
 Aspect_GridType.hxx
 Aspect_NeutralWindow.cxx
 Aspect_NeutralWindow.hxx
index 43a340935f76f84557969e4c24b23d02cc2dc8c8..2a0be6b193304cf6175720d90df1f2c2c64f5eab 100644 (file)
@@ -573,38 +573,6 @@ Bnd_Box Graphic3d_CView::MinMaxValues (const Standard_Boolean theToIncludeAuxili
                                         aCamera,
                                         aWinSize.x(), aWinSize.y(),
                                         theToIncludeAuxiliary);
-    /*std::cout << "Identification: " << Identification() << std::endl;
-    std::cout << "aWinSize: " << aWinSize.x() << " " << aWinSize.y() << std::endl;
-    std::cout << "theToIncludeAuxiliary: " << (theToIncludeAuxiliary ? "true" : "false") << std::endl;
-    std::cout << "ProjectionMatrix: " << std::endl;
-    for (int i = 0; i < 4; i++)
-    {
-      for (int j = 0; j < 4; j++)
-      {
-        std::cout << aCamera->ProjectionMatrix().GetValue(i, j) << " ";
-      }
-      std::cout << std::endl;
-    }
-    std::cout << std::endl;
-    std::cout << "OrientationMatrix: " << std::endl;
-    for (int i = 0; i < 4; i++)
-    {
-      for (int j = 0; j < 4; j++)
-      {
-        std::cout << aCamera->OrientationMatrix().GetValue(i, j) << " ";
-      }
-      std::cout << std::endl;
-    }
-    std::cout << std::endl;*/
-
-    if (aBox.IsVoid())
-    {
-      //std::cout << "add void box" << std::endl;
-    }
-    else
-    {
-      //std::cout << "add NOT void box" << std::endl;
-    }
     aResult.Add (aBox);
   }
   return aResult;
index abebcebc61c1704205ad460cbd2f6dbe8f0eac30..e8f6e95502d6fe4d98d6615cb92524349de30336 100644 (file)
@@ -14,6 +14,7 @@
 #ifndef _Graphic3d_CView_HeaderFile
 #define _Graphic3d_CView_HeaderFile
 
+#include <Aspect_GridParams.hxx>
 #include <Aspect_RenderingContext.hxx>
 #include <Aspect_SkydomeBackground.hxx>
 #include <Aspect_Window.hxx>
@@ -547,6 +548,12 @@ public: //! @name obsolete Graduated Trihedron functionality
   //! Erases Graduated Trihedron.
   virtual void GraduatedTrihedronErase() {}
 
+  //! Displays Grid.
+  virtual void GridDisplay (const Aspect_GridParams& theGridParams) { (void)theGridParams; }
+
+  //! Erases Grid.
+  virtual void GridErase() {}
+
   //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object.
   //! @param theMin [in] the minimum point of scene.
   //! @param theMax [in] the maximum point of scene.
index 9da668fa776c7f5277c6f2886326db90d0785821..4ea36f7226c5eeefe9a603cf55098fcbbf9fb558 100644 (file)
@@ -505,12 +505,6 @@ void Graphic3d_Camera::SetZRange (const Standard_Real theZNear,
     return;
   }
 
-  if (theZFar != 3000)
-  {
-    //std::cout << "SetZRange: " << theZNear << " " << theZFar << std::endl;
-  }
-  //std::cout << "SetZRange: " << theZNear << " " << theZFar << std::endl;
-
   myZNear = theZNear;
   myZFar  = theZFar;
 
index f7640fed46362b66204cde979ac8c07cbe1c2bba..f635dd398d3cb7bfa78cb77ef141d406ccae7dc4 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (c) 2013-2021 OPEN CASCADE SAS
+// Copyright (c) 2013-2021 OPEN CASCADE SAS
 //
 // This file is part of Open CASCADE Technology software library.
 //
@@ -2195,7 +2195,9 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getGridProgram() const
   aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("float uZNear", Graphic3d_TOS_FRAGMENT));
   aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("float uZFar", Graphic3d_TOS_FRAGMENT));
   aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("float uScale", Graphic3d_TOS_FRAGMENT));
+  aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("float uThickness", Graphic3d_TOS_FRAGMENT));
   aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("bool uIsDrawAxis", Graphic3d_TOS_FRAGMENT));
+  aUniforms.Append (Graphic3d_ShaderObject::ShaderVariable ("vec3 uColor", Graphic3d_TOS_FRAGMENT));
 
   TCollection_AsciiString aSrcVert = TCollection_AsciiString()
   + EOL"vec3 gridPlane[6] = vec3[] (vec3( 1.0,  1.0, 0.0), vec3(-1.0, -1.0, 0.0), vec3(-1.0,  1.0, 0.0),"
@@ -2203,7 +2205,7 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getGridProgram() const
 
     EOL"vec3 UnprojectPoint (float aX, float anY, float aZ)"
     EOL"{"
-    EOL"  vec4 anUnprojPnt = occWorldViewMatrixInverse * occProjectionMatrixInverse * vec4 (aX, anY, aZ, 1.0);"
+    EOL"  vec4 anUnprojPnt = occModelWorldMatrixInverse * occWorldViewMatrixInverse * occProjectionMatrixInverse * vec4 (aX, anY, aZ, 1.0);"
     EOL"  return anUnprojPnt.xyz / anUnprojPnt.w;"
     EOL"}"
 
@@ -2220,17 +2222,18 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getGridProgram() const
   + EOL"vec4 grid (vec3 theFragPos3D, vec3 theColor, float theScale, bool theIsDrawAxis, float theThickness)"
     EOL"{"
     EOL"  vec2 aCoord = theFragPos3D.xy * theScale;"
-    EOL"  vec2 aDerivative = fwidth (aCoord);"
+
+    EOL"  vec2 aDerivative = max (fwidth (aCoord), vec2 (theThickness));"
     EOL"  vec2 aGrid = abs (fract (aCoord - 0.5) - 0.5) / aDerivative;"
     EOL"  float aLine = min (aGrid.x, aGrid.y);"
-    EOL"  float aMinY = min (aDerivative.y, 1);"
-    EOL"  float aMinX = min (aDerivative.x, 1);"
+    EOL"  float aMinY = min (aDerivative.y, 1.0);"
+    EOL"  float aMinX = min (aDerivative.x, 1.0);"
 
     EOL"  vec4 aColor = vec4 (theColor, round (1.0 - min (aLine, 1.0)));"
     EOL"  if (uIsDrawAxis && theIsDrawAxis)"
     EOL"  {"
-    EOL"    bool isYAxis = -aMinX < aCoord.x && aCoord.x < aMinX;"
-    EOL"    bool isXAxis = -aMinY < aCoord.y && aCoord.y < aMinY;"
+    EOL"    bool isYAxis = abs(aCoord.x) < aMinX;"
+    EOL"    bool isXAxis = abs(aCoord.y) < aMinY;"
     EOL"    if (isXAxis && isYAxis) { aColor.xyz = vec3 (0.0, 0.0, 1.0); }"
     EOL"    else if (isXAxis) { aColor.xyz = vec3 (1.0, 0.0, 0.0); }"
     EOL"    else if (isYAxis) { aColor.xyz = vec3 (0.0, 1.0, 0.0); }"
@@ -2257,59 +2260,9 @@ Handle(Graphic3d_ShaderProgram) Graphic3d_ShaderManager::getGridProgram() const
     EOL"  vec3 aFragPos3D = NearPoint + aParam * (FarPoint - NearPoint);"
     EOL"  float aLinearDepth = computeLinearDepth (aFragPos3D);"
 
-    //EOL"  float aScale = /*0.001*/ 1.0 / uScale;"
-
-/*
-pload ALL
-vinit
-vcamera -persp
-box b 100 100 100
-vdisplay b -dispmode 1
-vfit
-*/
-
-    /*EOL"  float aScale;"
-    EOL"  if (uScale < 10.0) {"
-    EOL"    aScale = 1.0;"
-    EOL"  }"
-    EOL"  else if (uScale < 100.0) {"
-    EOL"    aScale = 0.1;"
-    EOL"  }"
-    EOL"  else if (uScale < 1000.0) {"
-    EOL"    aScale = 0.01;"
-    EOL"  }"
-    EOL"  else if (uScale < 10000.0) {"
-    EOL"    aScale = 0.001;"
-    EOL"  }"
-    EOL"  else if (uScale < 100000.0) {"
-    EOL"    aScale = 0.0001;"
-    EOL"  }"
-    EOL"  else if (uScale < 1000000.0) {"
-    EOL"    aScale = 0.00001;"
-    EOL"  }"
-    EOL"  else if (uScale < 10000000.0) {"
-    EOL"    aScale = 0.000001;"
-    EOL"  }"
-    EOL"  else if (uScale < 100000000.0) {"
-    EOL"    aScale = 0.0000001;"
-    EOL"  }"
-    EOL"  else if (uScale < 1000000000.0) {"
-    EOL"    aScale = 0.00000001;"
-    EOL"  }"
-    EOL"  else if (uScale < 10000000000.0) {"
-    EOL"    aScale = 0.000000001;"
-    EOL"  }"
-    EOL"  else if (uScale < 100000000000.0) {"
-    EOL"    aScale = 0.0000000001;"
-    EOL"  }"
-    EOL"  else {"
-    EOL"    aScale = 0.00000000001;"
-    EOL"  }"*/
-
-
-    EOL"  vec4 aBigGridColor = grid (aFragPos3D, vec3 (0.8), uScale, true, 500.0);"
+    EOL"  vec4 aBigGridColor = grid (aFragPos3D, uColor, uScale, true, uThickness);"
     EOL"  vec4 aColor = aBigGridColor.a == 0.0"
-    EOL"              ? grid (aFragPos3D, vec3 (0.2), uScale * 10.0, false, 0.1)"
+    EOL"              ? grid (aFragPos3D, 0.25 * uColor, uScale * 10.0, false, uThickness)"
     EOL"              : aBigGridColor;"
     EOL"  float aDepth = computeDepth (aFragPos3D);"
     EOL"  float aFar  = gl_DepthRange.far;"
@@ -2319,30 +2272,13 @@ vfit
     EOL"  {"
     EOL"    discard;"
     EOL"  };"
-    // TODO : Get actual background color
-    EOL"  vec4 aBackgroundColor = vec4 (0.0, 0.0, 0.0, aColor.a);"
-    EOL"  if (abs (aLinearDepth) > 1.0)"
+
+    EOL"  if (aLinearDepth < 0.0)"
     EOL"  {"
-    EOL"    float aFading;"
-    //EOL"    if (aLinearDepth > 0.0) { aFading = 1.0 - (3.0 - aLinearDepth + 2.0) * 0.25; }"
-    //EOL"    else                    { aFading = 1.0 + (3.0 + aLinearDepth - 2.0) * 0.25; }"
-    EOL"    if (aLinearDepth > 0.0) { aFading = (aLinearDepth - 1.0) / ( 1.0 - 2.0) * (0.5 - 0.0) + 0.0; }"
-    EOL"    else                    { aFading = (aLinearDepth + 2.0) / (-1.0 + 2.0) * (1.0 - 0.5) + 0.5; }"
-    EOL"    aColor = mix (aColor, aBackgroundColor, aFading);"
-
-    //EOL"    float anInterpVal = float (aLinearDepth > 0.0) - sign (aLinearDepth) * clamp (1.0 / (abs (aLinearDepth) - 1.0), 0.5, 1.0);"
-    //EOL"    aColor = mix (aColor, aBackgroundColor, anInterpVal);"
-    //EOL"    aColor = mix (aColor, aBackgroundColor, 0.99);"
+    EOL"    float aFading = max (0.0, 0.5 * log (abs (aLinearDepth)));"
+    EOL"    aColor.a *= aFading;"
     EOL"  }"
 
-    EOL"  if (aLinearDepth < -1.5)      { aColor = vec4 (0.0, 1.0, 1.0, 1.0); }"
-    EOL"  else if (aLinearDepth < -1.0) { aColor = vec4 (1.0, 0.0, 0.0, 1.0); }"
-    EOL"  else if (aLinearDepth < 0.0)  { aColor = vec4 (0.0, 1.0, 0.0, 1.0); }"
-    EOL"  else if (aLinearDepth < 1.0)  { aColor = vec4 (0.0, 0.0, 1.0, 1.0); }"
-    EOL"  else if (aLinearDepth < 1.5)  { aColor = vec4 (1.0, 0.0, 1.0, 1.0); }"
-    EOL"  else if (aLinearDepth < 2.0)  { aColor = vec4 (1.0, 0.0, 0.0, 1.0); }"
-    EOL"  else                          { aColor = vec4 (1.0, 1.0, 0.0, 1.0); }"
-
     EOL"  gl_FragDepth = aDepth;"
     EOL"  occFragColor = aColor;"
     EOL"}";
index 3fbd7478fa890d8d60f90bb0746c91f97583c816..5abb44781f2c95d2267cab34af37a1e5c577ab7a 100644 (file)
@@ -98,16 +98,16 @@ void Graphic3d_StructureManager::DisplayedStructures (Graphic3d_MapOfStructure&
 
   SG.Assign(myDisplayedStructure);
 
-  //JMBStandard_Integer Length  = myDisplayedStructure.Length();
+  //JMBStandard_Integer Length  = myDisplayedStructure.Length ();
 
   //JMBfor (Standard_Integer i=1; i<=Length; i++)
   //JMB SG.Add (myDisplayedStructure.Value (i));
 
 }
 
-Standard_Integer Graphic3d_StructureManager::NumberOfDisplayedStructures() const {
+Standard_Integer Graphic3d_StructureManager::NumberOfDisplayedStructures () const {
 
-Standard_Integer Length = myDisplayedStructure.Extent();
+Standard_Integer Length = myDisplayedStructure.Extent ();
 
         return (Length);
 
@@ -138,7 +138,7 @@ Handle(Graphic3d_Structure) Graphic3d_StructureManager::Identification (const St
 
   for (; it.More() && notfound; it.Next()) {
     const Handle(Graphic3d_Structure)& SG = it.Key();
-    if ( SG->Identification() == AId) {
+    if ( SG->Identification () == AId) {
       notfound  = Standard_False;
       SGfound = SG;
     }
@@ -152,7 +152,7 @@ Handle(Graphic3d_Structure) Graphic3d_StructureManager::Identification (const St
 
 }
 
-const Handle(Graphic3d_GraphicDriver)& Graphic3d_StructureManager::GraphicDriver() const 
+const Handle(Graphic3d_GraphicDriver)& Graphic3d_StructureManager::GraphicDriver () const 
 {
   return (myGraphicDriver);
 }
index 7b9dc5a3e219b75565bca002bd3fe62c122af4f1..f3f0210d960bfd491b7debf31b4e86e9a7eacda2 100644 (file)
@@ -225,7 +225,7 @@ public:
     return myContext->BindProgram (myPBREnvBakingProgram[theIndex]);
   }
 
-  //! Bind program for IBL maps generation in PBR pipeline.
+  //! Bind program for grid visualisation.
   Standard_Boolean BindGridProgram()
   {
     if (myGridProgram.IsNull())
@@ -719,6 +719,7 @@ protected:
   Standard_Boolean IsPbrAllowed() const { return myShadingModel == Graphic3d_TypeOfShadingModel_Pbr
                                               || myShadingModel == Graphic3d_TypeOfShadingModel_PbrFacet; }
 
+  //! Generate standard GLSL program for grid.
   Standard_EXPORT Standard_Boolean prepareGridProgram();
 
 protected:
index 76042f81d102b9c2816a63362bae803d47a8d0c5..43125ce45132887142326ef3a7840b1c7004f7f6 100644 (file)
@@ -108,6 +108,7 @@ OpenGl_View::OpenGl_View (const Handle(Graphic3d_StructureManager)& theMgr,
   myCaps           (theCaps),
   myWasRedrawnGL   (Standard_False),
   myToShowGradTrihedron  (false),
+  myToShowGrid           (false),
   myStateCounter         (theCounter),
   myCurrLightSourceState (theCounter->Increment()),
   myLightsRevision       (0),
@@ -502,6 +503,25 @@ void OpenGl_View::GraduatedTrihedronErase()
   myToShowGradTrihedron = false;
 }
 
+// =======================================================================
+// function : GridDisplay
+// purpose  :
+// =======================================================================
+void OpenGl_View::GridDisplay (const Aspect_GridParams& theGridParams)
+{
+  myGridParams = theGridParams;
+  myToShowGrid = true;
+}
+
+// =======================================================================
+// function : GridErase
+// purpose  :
+// =======================================================================
+void OpenGl_View::GridErase()
+{
+  myToShowGrid = false;
+}
+
 // =======================================================================
 // function : GraduatedTrihedronMinMaxValues
 // purpose  :
@@ -2602,16 +2622,17 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
 // =======================================================================
 void OpenGl_View::renderGrid()
 {
-  const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
+  if (!myToShowGrid)
+  {
+    return;
+  }
 
-  /*aContext->ShaderManager()->UpdateModelWorldStateTo (aContext->ModelWorldState.Current());
-  aContext->ShaderManager()->UpdateProjectionStateTo (aContext->ProjectionState.Current());
-  aContext->ShaderManager()->UpdateWorldViewStateTo (aContext->WorldViewState.Current());*/
+  const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
 
   if (MinMaxValues (Standard_True).IsVoid())
   {
     Bnd_Box aDummy;
-    aDummy.Set (gp::Origin());
+    aDummy.Set (myGridParams.Position());
     aContext->Camera()->ZFitAll (1.0, aDummy, aDummy);
   }
 
@@ -2623,60 +2644,33 @@ void OpenGl_View::renderGrid()
   aContext->ProjectionState.SetCurrent (aContext->Camera()->ProjectionMatrixF());
 
   aContext->ApplyProjectionMatrix();
-  aContext->ApplyWorldViewMatrix();
-
-  aContext->core11fwd->glEnable (GL_BLEND);
-  aContext->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-
-  aContext->core11fwd->glEnable(GL_MULTISAMPLE);
 
-  Graphic3d_Vec3 gridPlane[4] = { Graphic3d_Vec3 (1.0,  1.0, 0.0), Graphic3d_Vec3(-1.0,  1.0, 0.0),
-                                  Graphic3d_Vec3(-1.0, -1.0, 0.0), Graphic3d_Vec3 (1.0, -1.0, 0.0) };
+  OpenGl_Mat4 aCurrent = aContext->WorldViewState.Current();
+  aContext->WorldViewState.Push();
 
-  for (int i = 0; i < 4; i++)
+  OpenGl_Mat4 aMat;
+  if (!myGridParams.IsHorizontal())
   {
-    if (!aContext->WorldViewState.Current().Inverted().IsEqual (aContext->ShaderManager()->WorldViewState().WorldViewMatrixInverse()))
-    {
-      std::cout << "WorldViewState not equal" << std::endl;
-    }
-    if (!aContext->ProjectionState.Current().Inverted().IsEqual (aContext->ShaderManager()->ProjectionState().ProjectionMatrixInverse()))
-    {
-      std::cout << "ProjectionState not equal" << std::endl;
-    }
-    Graphic3d_Vec4 aNearPntVar = aContext->ShaderManager()->WorldViewState().WorldViewMatrixInverse() * aContext->ShaderManager()->ProjectionState().ProjectionMatrixInverse()
-      * Graphic3d_Vec4 (gridPlane[i].x(), gridPlane[i].y(), 0.0, 1.0);
-    Graphic3d_Vec3 aNearPnt = aNearPntVar.xyz() / aNearPntVar.w();
-    Graphic3d_Vec4 aFarPntVar = aContext->WorldViewState.Current().Inverted() * aContext->ProjectionState.Current().Inverted()
-      * Graphic3d_Vec4 (gridPlane[i].x(), gridPlane[i].y(), 1.0, 1.0);
-    Graphic3d_Vec3 aFarPnt = aFarPntVar.xyz() / aFarPntVar.w();
-    float aParam = -aNearPnt.z() / (aFarPnt.z() - aNearPnt.z());
-    Graphic3d_Vec3 aFragPos3D = aNearPnt + (aFarPnt - aNearPnt).Multiplied (aParam);
-
-    //std::cout << aFragPos3D.x() << " " << aFragPos3D.y() << " " << aFragPos3D.z() << std::endl;
+    aMat.SetRow (0, Graphic3d_Vec4 (1, 0,  0, 0));
+    aMat.SetRow (1, Graphic3d_Vec4 (0, 0, -1, 0));
+    aMat.SetRow (2, Graphic3d_Vec4 (0, 1,  0, 0));
+    aMat.SetRow (3, Graphic3d_Vec4 (0, 0,  0, 1));
   }
+  const gp_Pnt& aPosition = myGridParams.Position();
+  aMat.SetColumn (3, Graphic3d_Vec4 ((float)aPosition.X(), (float)aPosition.Y(), (float)aPosition.Z(), 1.0));
 
-  //std::cout << "ZNear: " << aContext->Camera()->ZNear() << std::endl;
-  //std::cout << "ZFar : " << aContext->Camera()->ZFar() << std::endl;
-
-  //Standard_Integer aScale = TCollection_AsciiString(RealToInt(aContext->Camera()->Scale())).Length();
+  aContext->WorldViewState.SetCurrent (aCurrent * aMat);
+  aContext->ApplyWorldViewMatrix();
 
-  unsigned x = (unsigned) aContext->Camera()->Scale();
-  x = x - 1;
-  x = x | (x >> 1);
-  x = x | (x >> 2);
-  x = x | (x >> 4);
-  x = x | (x >> 8);
-  x = x | (x >> 16);
-  x = x + 1;
+  aContext->core11fwd->glEnable (GL_BLEND);
+  aContext->core11fwd->glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-  int k = (int)(log10 (aContext->Camera()->Scale()) / log10(2));
+  aContext->core11fwd->glEnable (GL_MULTISAMPLE);
 
-  //Standard_Integer aScale = k;
   const Standard_Real aCameraScale = aContext->Camera()->Scale();
-  Standard_Real aScale = 10.0 / pow (10.0, floor (log10 (Max (aCameraScale, 1.0))) + 1.0);
-  //std::cout << "Scale: " << aScale << std::endl;
-
-  //aContext->Camera()->SetZRange (aContext->Camera()->ZNear(), aContext->Camera()->ZFar() + 1.0);
+  Standard_Real aScale = myGridParams.IsInfinity()
+                       ? 10.0 / pow (10.0, floor (log10 (Max (aCameraScale, 1.0))) + 1.0)
+                       : myGridParams.Scale();
 
   if (aContext->ShaderManager()->BindGridProgram())
   {
@@ -2684,16 +2678,18 @@ void OpenGl_View::renderGrid()
     aProg->SetUniform (aContext, "uZNear", GLfloat (aContext->Camera()->ZNear()));
     aProg->SetUniform (aContext, "uZFar",  GLfloat (aContext->Camera()->ZFar()));
     aProg->SetUniform (aContext, "uScale", GLfloat (aScale));
-    std::cout << aContext->Camera()->Scale() << std::endl;
-    std::cout << aScale << std::endl;
-    // TODO : add param to draw command
-    aProg->SetUniform (aContext, "uIsDrawAxis", GLboolean (true));
+    aProg->SetUniform (aContext, "uThickness", GLfloat (myGridParams.LineThickness()));
+    aProg->SetUniform (aContext, "uColor", OpenGl_Vec3 (myGridParams.Color().Rgb()));
+    aProg->SetUniform(aContext, "uIsDrawAxis", GLboolean(myGridParams.IsDrawAxis()));
 
     aContext->core20fwd->glDrawArrays (GL_TRIANGLES, 0, 6);
     aContext->BindProgram (NULL);
   }
 
   aContext->Camera()->SetZRange (aZNear, aZFar);
+
+  aContext->WorldViewState.Pop();
+  aContext->ApplyWorldViewMatrix();
 }
 
 // =======================================================================
index 3ed729664271bed6809814e7f9212ee696a1698a..9af36bee248d70aea612b4a647255121397ae892 100644 (file)
@@ -306,6 +306,12 @@ public: //! @name obsolete Graduated Trihedron functionality
   //! Erases Graduated Trihedron.
   Standard_EXPORT virtual void GraduatedTrihedronErase() Standard_OVERRIDE;
 
+  //! Displays Grid.
+  Standard_EXPORT virtual void GridDisplay (const Aspect_GridParams& theGridParams) Standard_OVERRIDE;
+
+  //! Erases Grid.
+  Standard_EXPORT virtual void GridErase() Standard_OVERRIDE;
+
   //! Sets minimum and maximum points of scene bounding box for Graduated Trihedron stored in graphic view object.
   //! @param theMin [in] the minimum point of scene.
   //! @param theMax [in] the maximum point of scene.
@@ -452,7 +458,9 @@ protected:
   gp_XYZ                          myLocalOrigin;
   Handle(OpenGl_FrameBuffer)      myFBO;
   Standard_Boolean                myToShowGradTrihedron;
+  Standard_Boolean                myToShowGrid;
   Graphic3d_GraduatedTrihedron    myGTrihedronData;
+  Aspect_GridParams               myGridParams;
 
   Handle(Graphic3d_LightSet)      myNoShadingLight;
   Handle(Graphic3d_LightSet)      myLights;
index 474a6f30c38e0e58aef12a4a514b4629202e52fb..a812fd9896179da829dba484636ea0e8fb077062 100644 (file)
@@ -91,8 +91,7 @@ V3d_CircularGrid::~V3d_CircularGrid()
 
 void V3d_CircularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
 {
-  if( myColor != aColor || myTenthColor != aTenthColor )
-  {
+  if( myColor != aColor || myTenthColor != aTenthColor ) {
     myColor = aColor;
     myTenthColor = aTenthColor;
     myCurAreDefined = Standard_False;
@@ -100,7 +99,7 @@ void V3d_CircularGrid::SetColors (const Quantity_Color& aColor, const Quantity_C
   }
 }
 
-void V3d_CircularGrid::Display()
+void V3d_CircularGrid::Display ()
 {
   myStructure->SetDisplayPriority (Graphic3d_DisplayPriority_AlmostBottom);
   myStructure->Display();
@@ -112,28 +111,28 @@ void V3d_CircularGrid::Update()
   //
 }
 
-void V3d_CircularGrid::Erase() const
+void V3d_CircularGrid::Erase () const
 {
-  myStructure->Erase();
+  myStructure->Erase ();
 }
 
-Standard_Boolean V3d_CircularGrid::IsDisplayed() const
+Standard_Boolean V3d_CircularGrid::IsDisplayed () const
 {
-  return myStructure->IsDisplayed();
+  return myStructure->IsDisplayed ();
 }
 
-void V3d_CircularGrid::UpdateDisplay()
+void V3d_CircularGrid::UpdateDisplay ()
 {
   gp_Ax3 ThePlane = myViewer->PrivilegedPlane();
 
-  Standard_Real xl,  yl,  zl;
+  Standard_Real xl, yl, zl;
   Standard_Real xdx, xdy, xdz;
   Standard_Real ydx, ydy, ydz;
-  Standard_Real dx,  dy,  dz;
-  ThePlane.Location  ().Coord (xl,  yl,  zl);
-  ThePlane.XDirection().Coord (xdx, xdy, xdz);
-  ThePlane.YDirection().Coord (ydx, ydy, ydz);
-  ThePlane.Direction ().Coord (dx,  dy,  dz);
+  Standard_Real dx, dy, dz;
+  ThePlane.Location ().Coord (xl, yl, zl);
+  ThePlane.XDirection ().Coord (xdx, xdy, xdz);
+  ThePlane.YDirection ().Coord (ydx, ydy, ydz);
+  ThePlane.Direction ().Coord (dx, dy, dz);
 
   Standard_Boolean MakeTransform = !myCurAreDefined;
   if (!MakeTransform)
@@ -141,28 +140,26 @@ void V3d_CircularGrid::UpdateDisplay()
     MakeTransform = (RotationAngle() != myCurAngle || XOrigin() != myCurXo || YOrigin() != myCurYo);
     if (!MakeTransform)
     {
-      Standard_Real curxl,  curyl,  curzl;
+      Standard_Real curxl, curyl, curzl;
       Standard_Real curxdx, curxdy, curxdz;
       Standard_Real curydx, curydy, curydz;
-      Standard_Real curdx,  curdy,  curdz;
-      myCurViewPlane.Location   ().Coord (curxl,  curyl,  curzl);
+      Standard_Real curdx, curdy, curdz;
+      myCurViewPlane.Location ().Coord (curxl, curyl, curzl);
       myCurViewPlane.XDirection ().Coord (curxdx, curxdy, curxdz);
       myCurViewPlane.YDirection ().Coord (curydx, curydy, curydz);
-      myCurViewPlane.Direction  ().Coord (curdx,  curdy,  curdz);
-      if (xl  != curxl  || yl  != curyl  || zl  != curzl  ||
+      myCurViewPlane.Direction ().Coord (curdx, curdy, curdz);
+      if (xl != curxl || yl != curyl || zl != curzl ||
           xdx != curxdx || xdy != curxdy || xdz != curxdz ||
           ydx != curydx || ydy != curydy || ydz != curydz ||
-          dx  != curdx  || dy  != curdy  || dz  != curdz)
-      {
+          dx != curdx || dy != curdy || dz != curdz)
         MakeTransform = Standard_True;
-      }
     }
   }
 
   if (MakeTransform)
   {
-    const Standard_Real CosAlpha = Cos (RotationAngle());
-    const Standard_Real SinAlpha = Sin (RotationAngle());
+    const Standard_Real CosAlpha = Cos (RotationAngle ());
+    const Standard_Real SinAlpha = Sin (RotationAngle ());
 
     gp_Trsf aTrsf;
     // Translation
@@ -176,24 +173,23 @@ void V3d_CircularGrid::UpdateDisplay()
     gp_Trsf aTrsf2;
     aTrsf2.SetValues ( CosAlpha, SinAlpha, 0.0, -XOrigin(),
                       -SinAlpha, CosAlpha, 0.0, -YOrigin(),
-                       0.0,      0.0,      1.0,  0.0 );
+                            0.0,      0.0, 1.0, 0.0);
     aTrsf.Multiply (aTrsf2);
     myStructure->SetTransformation (new TopLoc_Datum3D (aTrsf));
 
-    myCurAngle = RotationAngle();
-    myCurXo = XOrigin();
-    myCurYo = YOrigin();
+    myCurAngle = RotationAngle ();
+    myCurXo = XOrigin (), myCurYo = YOrigin ();
     myCurViewPlane = ThePlane;
   }
 
   switch (myDrawMode)
   {
     case Aspect_GDM_Points:
-      DefinePoints();
+      DefinePoints ();
       myCurDrawMode = Aspect_GDM_Points;
       break;
     case Aspect_GDM_Lines:
-      DefineLines();
+      DefineLines ();
       myCurDrawMode = Aspect_GDM_Lines;
       break;
     case Aspect_GDM_None:
@@ -203,15 +199,16 @@ void V3d_CircularGrid::UpdateDisplay()
   myCurAreDefined = Standard_True;
 }
 
-void V3d_CircularGrid::DefineLines()
+void V3d_CircularGrid::DefineLines ()
 {
-  const Standard_Real    aStep     = RadiusStep();
-  const Standard_Real    aDivision = DivisionNumber();
+  const Standard_Real    aStep     = RadiusStep ();
+  const Standard_Real    aDivision = DivisionNumber ();
   const Standard_Boolean toUpdate  = !myCurAreDefined
                                   || myCurDrawMode != Aspect_GDM_Lines
                                   || aDivision != myCurDivi
                                   || aStep     != myCurStep;
-  if (!toUpdate && !myToComputePrs)
+  if (!toUpdate
+   && !myToComputePrs)
   {
     return;
   }
@@ -222,36 +219,33 @@ void V3d_CircularGrid::DefineLines()
   }
 
   myToComputePrs = Standard_False;
-  myGroup->Clear();
+  myGroup->Clear ();
 
-  const Standard_Integer Division = (Standard_Integer )((aDivision >= DIVISION ? aDivision : DIVISION));
+  const Standard_Integer Division = (Standard_Integer )( (aDivision >= DIVISION ? aDivision : DIVISION));
 
   Standard_Integer nbpnts = 2 * Division;
   // diametres
   Standard_Real alpha = M_PI / aDivision;
 
   myGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (myTenthColor, Aspect_TOL_SOLID, 1.0));
-  Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments (2 * nbpnts);
-  const gp_Pnt p0 (0.0, 0.0, -myOffSet);
-  for (Standard_Integer i = 1; i <= nbpnts; i++)
-  {
-    aPrims1->AddVertex (p0);
-    aPrims1->AddVertex (Cos (alpha * i) * myRadius, Sin (alpha * i) * myRadius, -myOffSet);
+  Handle(Graphic3d_ArrayOfSegments) aPrims1 = new Graphic3d_ArrayOfSegments(2*nbpnts);
+  const gp_Pnt p0(0., 0., -myOffSet);
+  for (Standard_Integer i=1; i<=nbpnts; i++) {
+    aPrims1->AddVertex(p0);
+    aPrims1->AddVertex(Cos(alpha*i)*myRadius, Sin(alpha*i)*myRadius, -myOffSet);
   }
-  myGroup->AddPrimitiveArray (aPrims1, Standard_False);
+  myGroup->AddPrimitiveArray(aPrims1, Standard_False);
 
   // circles
   nbpnts = 2 * Division + 1;
   alpha = M_PI / Division;
   Standard_Integer nblines = 0;
   TColgp_SequenceOfPnt aSeqLines, aSeqTenth;
-  for (Standard_Real r = aStep; r <= myRadius; r += aStep, nblines++)
-  {
-    const Standard_Boolean isTenth = (Modulus (nblines, 10) == 0);
-    for (Standard_Integer i = 0; i < nbpnts; i++)
-    {
-      const gp_Pnt pt (Cos (alpha * i) * r, Sin (alpha * i) * r, -myOffSet);
-      (isTenth ? aSeqTenth : aSeqLines).Append (pt);
+  for (Standard_Real r=aStep; r<=myRadius; r+=aStep, nblines++) {
+    const Standard_Boolean isTenth = (Modulus(nblines, 10) == 0);
+    for (Standard_Integer i=0; i<nbpnts; i++) {
+      const gp_Pnt pt(Cos(alpha*i)*r,Sin(alpha*i)*r,-myOffSet);
+      (isTenth? aSeqTenth : aSeqLines).Append(pt);
     }
   }
   if (aSeqTenth.Length())
@@ -259,44 +253,37 @@ void V3d_CircularGrid::DefineLines()
     myGroup->SetGroupPrimitivesAspect (new Graphic3d_AspectLine3d (myTenthColor, Aspect_TOL_SOLID, 1.0));
     Standard_Integer n, np;
     const Standard_Integer nbl = aSeqTenth.Length() / nbpnts;
-    Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines (aSeqTenth.Length(), nbl);
-    for (np = 1, n = 0; n < nbl; n++)
-    {
-      aPrims2->AddBound (nbpnts);
-      for (Standard_Integer i = 0; i < nbpnts; i++, np++)
-      {
-        aPrims2->AddVertex (aSeqTenth (np));
-      }
-    }
-    myGroup->AddPrimitiveArray (aPrims2, Standard_False);
+    Handle(Graphic3d_ArrayOfPolylines) aPrims2 = new Graphic3d_ArrayOfPolylines(aSeqTenth.Length(),nbl);
+    for (np = 1, n=0; n<nbl; n++) {
+      aPrims2->AddBound(nbpnts);
+      for (Standard_Integer i=0; i<nbpnts; i++, np++)
+        aPrims2->AddVertex(aSeqTenth(np));
+  }
+    myGroup->AddPrimitiveArray(aPrims2, Standard_False);
   }
   if (aSeqLines.Length())
   {
     myGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (myColor, Aspect_TOL_SOLID, 1.0));
     Standard_Integer n, np;
     const Standard_Integer nbl = aSeqLines.Length() / nbpnts;
-    Handle(Graphic3d_ArrayOfPolylines) aPrims3 = new Graphic3d_ArrayOfPolylines (aSeqLines.Length(), nbl);
-    for (np = 1, n = 0; n < nbl; n++)
-    {
+    Handle(Graphic3d_ArrayOfPolylines) aPrims3 = new Graphic3d_ArrayOfPolylines(aSeqLines.Length(),nbl);
+    for (np = 1, n=0; n<nbl; n++) {
       aPrims3->AddBound(nbpnts);
-      for (Standard_Integer i = 0; i < nbpnts; i++, np++)
-      {
-        aPrims3->AddVertex (aSeqLines (np));
-      }
-    }
-    myGroup->AddPrimitiveArray (aPrims3, Standard_False);
+      for (Standard_Integer i=0; i<nbpnts; i++, np++)
+        aPrims3->AddVertex(aSeqLines(np));
+  }
+    myGroup->AddPrimitiveArray(aPrims3, Standard_False);
   }
 
   myGroup->SetMinMaxValues (-myRadius, -myRadius, -myOffSet, myRadius, myRadius, -myOffSet);
-  myCurStep = aStep;
-  myCurDivi = (Standard_Integer) aDivision;
+  myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
 
   // update bounding box
   myStructure->CalculateBoundBox();
   myViewer->StructureManager()->Update (myStructure->GetZLayer());
 }
 
-void V3d_CircularGrid::DefinePoints()
+void V3d_CircularGrid::DefinePoints ()
 {
   const Standard_Real    aStep     = RadiusStep();
   const Standard_Real    aDivision = DivisionNumber();
@@ -304,7 +291,8 @@ void V3d_CircularGrid::DefinePoints()
                                   || myCurDrawMode != Aspect_GDM_Points
                                   || aDivision != myCurDivi
                                   || aStep     != myCurStep;
-  if (!toUpdate && !myToComputePrs)
+  if (!toUpdate
+   && !myToComputePrs)
   {
     return;
   }
@@ -315,43 +303,39 @@ void V3d_CircularGrid::DefinePoints()
   }
 
   myToComputePrs = Standard_False;
-  myGroup->Clear();
+  myGroup->Clear ();
 
-  Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d();
+  Handle(Graphic3d_AspectMarker3d) MarkerAttrib = new Graphic3d_AspectMarker3d ();
   MarkerAttrib->SetColor (myColor);
   MarkerAttrib->SetType (Aspect_TOM_POINT);
-  MarkerAttrib->SetScale (3.0);
+  MarkerAttrib->SetScale (3.);
 
-  const Standard_Integer nbpnts = Standard_Integer (2 * aDivision);
-  Standard_Real alpha = M_PI / aDivision;
+  const Standard_Integer nbpnts = Standard_Integer (2*aDivision);
+  Standard_Real r, alpha = M_PI / aDivision;
 
   // diameters
   TColgp_SequenceOfPnt aSeqPnts;
-  aSeqPnts.Append (gp_Pnt (0.0, 0.0, -myOffSet));
-  for (Standard_Real r = aStep; r <= myRadius; r += aStep)
-  {
-    for (Standard_Integer i = 0; i < nbpnts; i++)
-    {
-      aSeqPnts.Append (gp_Pnt (Cos (alpha * i) * r, Sin (alpha * i) * r, -myOffSet));
-    }
+  aSeqPnts.Append(gp_Pnt(0.0, 0.0, -myOffSet));
+  for (r=aStep; r<=myRadius; r+=aStep) {
+    for (Standard_Integer i=0; i<nbpnts; i++)
+      aSeqPnts.Append(gp_Pnt(Cos(alpha*i)*r, Sin(alpha*i)*r, -myOffSet));
   }
   myGroup->SetGroupPrimitivesAspect (MarkerAttrib);
   if (aSeqPnts.Length())
   {
     Standard_Real X,Y,Z;
     const Standard_Integer nbv = aSeqPnts.Length();
-    Handle(Graphic3d_ArrayOfPoints) aCircle = new Graphic3d_ArrayOfPoints (nbv);
-    for (Standard_Integer i = 1; i <= nbv; i++)
+    Handle(Graphic3d_ArrayOfPoints) Cercle = new Graphic3d_ArrayOfPoints (nbv);
+    for (Standard_Integer i=1; i<=nbv; i++)
     {
-      aSeqPnts (i).Coord (X,Y,Z);
-      aCircle->AddVertex (X,Y,Z);
+      aSeqPnts(i).Coord(X,Y,Z);
+      Cercle->AddVertex (X,Y,Z);
     }
-    myGroup->AddPrimitiveArray (aCircle, Standard_False);
+    myGroup->AddPrimitiveArray (Cercle, Standard_False);
   }
   myGroup->SetMinMaxValues (-myRadius, -myRadius, -myOffSet, myRadius, myRadius, -myOffSet);
 
-  myCurStep = aStep;
-  myCurDivi = (Standard_Integer) aDivision;
+  myCurStep = aStep, myCurDivi = (Standard_Integer ) aDivision;
 
   // update bounding box
   myStructure->CalculateBoundBox();
@@ -366,22 +350,19 @@ void V3d_CircularGrid::GraphicValues (Standard_Real& theRadius, Standard_Real& t
 
 void V3d_CircularGrid::SetGraphicValues (const Standard_Real theRadius, const Standard_Real theOffSet)
 {
-  if (!myCurAreDefined)
-  {
+  if (! myCurAreDefined) {
     myRadius = theRadius;
     myOffSet = theOffSet;
   }
-  if (myRadius != theRadius)
-  {
+  if (myRadius != theRadius) {
     myRadius = theRadius;
     myCurAreDefined = Standard_False;
   }
-  if (myOffSet != theOffSet)
-  {
+  if (myOffSet != theOffSet) {
     myOffSet = theOffSet;
     myCurAreDefined = Standard_False;
   }
-  if (!myCurAreDefined) { UpdateDisplay(); }
+  if( !myCurAreDefined ) UpdateDisplay();
 }
 
 //=======================================================================
index b971b3d9594371921eccc58085980b8322a952a2..fb13f15d88c3f07cb455145e5a7681ed78fe456c 100644 (file)
@@ -91,8 +91,7 @@ V3d_RectangularGrid::~V3d_RectangularGrid()
 
 void V3d_RectangularGrid::SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor)
 {
-  if( myColor != aColor || myTenthColor != aTenthColor )
-  {
+  if( myColor != aColor || myTenthColor != aTenthColor ) {
     myColor = aColor;
     myTenthColor = aTenthColor;
     myCurAreDefined = Standard_False;
@@ -100,7 +99,7 @@ void V3d_RectangularGrid::SetColors (const Quantity_Color& aColor, const Quantit
   }
 }
 
-void V3d_RectangularGrid::Display()
+void V3d_RectangularGrid::Display ()
 {
   myStructure->SetDisplayPriority (Graphic3d_DisplayPriority_AlmostBottom);
   myStructure->Display();
@@ -113,56 +112,48 @@ void V3d_RectangularGrid::Update()
   UpdateDisplay();
 }
 
-void V3d_RectangularGrid::Erase() const
+void V3d_RectangularGrid::Erase () const
 {
-  myStructure->Erase();
+  myStructure->Erase ();
 }
 
-Standard_Boolean V3d_RectangularGrid::IsDisplayed() const
+Standard_Boolean V3d_RectangularGrid::IsDisplayed () const
 {
-  return myStructure->IsDisplayed();
+  return myStructure->IsDisplayed ();
 }
 
-void V3d_RectangularGrid::UpdateDisplay()
+void V3d_RectangularGrid::UpdateDisplay ()
 {
-  gp_Ax3 ThePlane = myViewer->PrivilegedPlane();
+  gp_Ax3 ThePlane = myViewer->PrivilegedPlane ();
 
   Standard_Boolean MakeTransform = Standard_False;
-  Standard_Real xl,  yl,  zl;
+  Standard_Real xl, yl, zl;
   Standard_Real xdx, xdy, xdz;
   Standard_Real ydx, ydy, ydz;
-  Standard_Real dx,  dy,  dz;
-  ThePlane.Location  ().Coord (xl,  yl,  zl);
-  ThePlane.XDirection().Coord (xdx, xdy, xdz);
-  ThePlane.YDirection().Coord (ydx, ydy, ydz);
-  ThePlane.Direction ().Coord (dx,  dy,  dz);
-  if (!myCurAreDefined)
-  {
+  Standard_Real dx, dy, dz;
+  ThePlane.Location ().Coord (xl, yl, zl);
+  ThePlane.XDirection ().Coord (xdx, xdy, xdz);
+  ThePlane.YDirection ().Coord (ydx, ydy, ydz);
+  ThePlane.Direction ().Coord (dx, dy, dz);
+  if (! myCurAreDefined)
     MakeTransform = Standard_True;
-  }
-  else
-  {
+  else {
     if (RotationAngle() != myCurAngle || XOrigin() != myCurXo || YOrigin() != myCurYo)
-    {
       MakeTransform = Standard_True;
-    }
-    if (!MakeTransform)
-    {
-      Standard_Real curxl,  curyl,  curzl;
+    if (! MakeTransform) {
+      Standard_Real curxl, curyl, curzl;
       Standard_Real curxdx, curxdy, curxdz;
       Standard_Real curydx, curydy, curydz;
-      Standard_Real curdx,  curdy,  curdz;
-      myCurViewPlane.Location  ().Coord (curxl,  curyl,  curzl);
-      myCurViewPlane.XDirection().Coord (curxdx, curxdy, curxdz);
-      myCurViewPlane.YDirection().Coord (curydx, curydy, curydz);
-      myCurViewPlane.Direction ().Coord (curdx,  curdy,  curdz);
-      if (xl  != curxl  || yl  != curyl  || zl  != curzl  ||
+      Standard_Real curdx, curdy, curdz;
+      myCurViewPlane.Location ().Coord (curxl, curyl, curzl);
+      myCurViewPlane.XDirection ().Coord (curxdx, curxdy, curxdz);
+      myCurViewPlane.YDirection ().Coord (curydx, curydy, curydz);
+      myCurViewPlane.Direction ().Coord (curdx, curdy, curdz);
+      if (xl != curxl || yl != curyl || zl != curzl ||
           xdx != curxdx || xdy != curxdy || xdz != curxdz ||
           ydx != curydx || ydy != curydy || ydz != curydz ||
-          dx  != curdx  || dy  != curdy  || dz  != curdz)
-      {
+          dx != curdx || dy != curdy || dz != curdz)
         MakeTransform = Standard_True;
-      }
     }
   }
 
@@ -182,34 +173,33 @@ void V3d_RectangularGrid::UpdateDisplay()
     gp_Trsf aTrsf2;
     aTrsf2.SetValues ( CosAlpha, SinAlpha, 0.0, -XOrigin(),
                       -SinAlpha, CosAlpha, 0.0, -YOrigin(),
-                       0.0,      0.0,      1.0,  0.0 );
+                            0.0,      0.0, 1.0, 0.0);
     aTrsf.Multiply (aTrsf2);
     myStructure->SetTransformation (new TopLoc_Datum3D (aTrsf));
 
-    myCurAngle = RotationAngle();
-    myCurXo = XOrigin();
-    myCurYo = YOrigin();
+    myCurAngle = RotationAngle ();
+    myCurXo = XOrigin (), myCurYo = YOrigin ();
     myCurViewPlane = ThePlane;
   }
 
   switch (myDrawMode)
   {
     case Aspect_GDM_Points:
-      DefinePoints();
+      DefinePoints ();
       myCurDrawMode = Aspect_GDM_Points;
       break;
     case Aspect_GDM_Lines:
-      DefineLines();
+      DefineLines ();
       myCurDrawMode = Aspect_GDM_Lines;
       break;
     case Aspect_GDM_None:
       myCurDrawMode = Aspect_GDM_None;
       break;
-  }
-  myCurAreDefined = Standard_True;
+       }
+       myCurAreDefined = Standard_True;
 }
 
-void V3d_RectangularGrid::DefineLines()
+void V3d_RectangularGrid::DefineLines ()
 {
   const Standard_Real aXStep = XStep();
   const Standard_Real aYStep = YStep();
@@ -217,7 +207,8 @@ void V3d_RectangularGrid::DefineLines()
                                  || myCurDrawMode != Aspect_GDM_Lines
                                  || aXStep != myCurXStep
                                  || aYStep != myCurYStep;
-  if (!toUpdate && !myToComputePrs)
+  if (!toUpdate
+   && !myToComputePrs)
   {
     return;
   }
@@ -236,27 +227,27 @@ void V3d_RectangularGrid::DefineLines()
   TColgp_SequenceOfPnt aSeqLines, aSeqTenth;
 
   // verticals
-  aSeqTenth.Append (gp_Pnt (0.0, -myYSize, -zl));
-  aSeqTenth.Append (gp_Pnt (0.0,  myYSize, -zl));
+  aSeqTenth.Append(gp_Pnt(0., -myYSize, -zl));
+  aSeqTenth.Append(gp_Pnt(0.,  myYSize, -zl));
   for (nblines = 1, xl = aXStep; xl < myXSize; xl += aXStep, nblines++)
   {
-    TColgp_SequenceOfPnt &aSeq = (Modulus (nblines, 10) != 0) ? aSeqLines : aSeqTenth;
-    aSeq.Append (gp_Pnt ( xl, -myYSize, -zl));
-    aSeq.Append (gp_Pnt ( xl,  myYSize, -zl));
-    aSeq.Append (gp_Pnt (-xl, -myYSize, -zl));
-    aSeq.Append (gp_Pnt (-xl,  myYSize, -zl));
+    TColgp_SequenceOfPnt &aSeq = (Modulus(nblines, 10) != 0)? aSeqLines : aSeqTenth;
+    aSeq.Append(gp_Pnt( xl, -myYSize, -zl));
+    aSeq.Append(gp_Pnt( xl,  myYSize, -zl));
+    aSeq.Append(gp_Pnt(-xl, -myYSize, -zl));
+    aSeq.Append(gp_Pnt(-xl,  myYSize, -zl));
   }
 
   // horizontals
-  aSeqTenth.Append (gp_Pnt (-myXSize, 0.0, -zl));
-  aSeqTenth.Append (gp_Pnt ( myXSize, 0.0, -zl));
+  aSeqTenth.Append(gp_Pnt(-myXSize, 0., -zl));
+  aSeqTenth.Append(gp_Pnt( myXSize, 0., -zl));
   for (nblines = 1, yl = aYStep; yl < myYSize; yl += aYStep, nblines++)
   {
-    TColgp_SequenceOfPnt &aSeq = (Modulus (nblines, 10) != 0) ? aSeqLines : aSeqTenth;
-    aSeq.Append (gp_Pnt (-myXSize,  yl, -zl));
-    aSeq.Append (gp_Pnt ( myXSize,  yl, -zl));
-    aSeq.Append (gp_Pnt (-myXSize, -yl, -zl));
-    aSeq.Append (gp_Pnt ( myXSize, -yl, -zl));
+    TColgp_SequenceOfPnt &aSeq = (Modulus(nblines, 10) != 0)? aSeqLines : aSeqTenth;
+    aSeq.Append(gp_Pnt(-myXSize,  yl, -zl));
+    aSeq.Append(gp_Pnt( myXSize,  yl, -zl));
+    aSeq.Append(gp_Pnt(-myXSize, -yl, -zl));
+    aSeq.Append(gp_Pnt( myXSize, -yl, -zl));
   }
 
   if (aSeqLines.Length())
@@ -264,36 +255,33 @@ void V3d_RectangularGrid::DefineLines()
     Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d (myColor, Aspect_TOL_SOLID, 1.0);
     myGroup->SetPrimitivesAspect (aLineAspect);
     const Standard_Integer nbv = aSeqLines.Length();
-    Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (nbv);
-    for (Standard_Integer n = 1; n <= nbv; n++)
-    {
-      aPrims->AddVertex (aSeqLines (n));
-    }
-    myGroup->AddPrimitiveArray (aPrims, Standard_False);
+    Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(nbv);
+    Standard_Integer n = 1;
+    while (n<=nbv)
+      aPrims->AddVertex(aSeqLines(n++));
+    myGroup->AddPrimitiveArray(aPrims, Standard_False);
   }
   if (aSeqTenth.Length())
   {
     Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d (myTenthColor, Aspect_TOL_SOLID, 1.0);
     myGroup->SetPrimitivesAspect (aLineAspect);
     const Standard_Integer nbv = aSeqTenth.Length();
-    Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (nbv);
-    for (Standard_Integer n = 1; n <= nbv; n++)
-    {
-      aPrims->AddVertex (aSeqTenth (n));
-    }
-    myGroup->AddPrimitiveArray (aPrims, Standard_False);
+    Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments(nbv);
+    Standard_Integer n = 1;
+    while (n<=nbv)
+      aPrims->AddVertex(aSeqTenth(n++));
+    myGroup->AddPrimitiveArray(aPrims, Standard_False);
   }
 
-  myGroup->SetMinMaxValues (-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
-  myCurXStep = aXStep;
-  myCurYStep = aYStep;
+  myGroup->SetMinMaxValues(-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
+  myCurXStep = aXStep, myCurYStep = aYStep;
 
   // update bounding box
   myStructure->CalculateBoundBox();
   myViewer->StructureManager()->Update (myStructure->GetZLayer());
 }
 
-void V3d_RectangularGrid::DefinePoints()
+void V3d_RectangularGrid::DefinePoints ()
 {
   const Standard_Real aXStep = XStep();
   const Standard_Real aYStep = YStep();
@@ -318,16 +306,14 @@ void V3d_RectangularGrid::DefinePoints()
   // horizontals
   Standard_Real xl, yl;
   TColgp_SequenceOfPnt aSeqPnts;
-  for (xl = 0.0; xl <= myXSize; xl += aXStep)
-  {
-    aSeqPnts.Append (gp_Pnt ( xl, 0.0, -myOffSet));
-    aSeqPnts.Append (gp_Pnt (-xl, 0.0, -myOffSet));
-    for (yl = aYStep; yl <= myYSize; yl += aYStep)
-    {
-      aSeqPnts.Append (gp_Pnt ( xl,  yl, -myOffSet));
-      aSeqPnts.Append (gp_Pnt ( xl, -yl, -myOffSet));
-      aSeqPnts.Append (gp_Pnt (-xl,  yl, -myOffSet));
-      aSeqPnts.Append (gp_Pnt (-xl, -yl, -myOffSet));
+  for (xl = 0.0; xl <= myXSize; xl += aXStep) {
+    aSeqPnts.Append(gp_Pnt( xl, 0.0, -myOffSet));
+    aSeqPnts.Append(gp_Pnt(-xl, 0.0, -myOffSet));
+    for (yl = aYStep; yl <= myYSize; yl += aYStep) {
+      aSeqPnts.Append(gp_Pnt( xl,  yl, -myOffSet));
+      aSeqPnts.Append(gp_Pnt( xl, -yl, -myOffSet));
+      aSeqPnts.Append(gp_Pnt(-xl,  yl, -myOffSet));
+      aSeqPnts.Append(gp_Pnt(-xl, -yl, -myOffSet));
     }
   }
   if (aSeqPnts.Length())
@@ -336,9 +322,9 @@ void V3d_RectangularGrid::DefinePoints()
     Standard_Real X,Y,Z;
     const Standard_Integer nbv = aSeqPnts.Length();
     Handle(Graphic3d_ArrayOfPoints) Vertical = new Graphic3d_ArrayOfPoints (nbv);
-    for (i = 1; i <= nbv; i++)
+    for (i=1; i<=nbv; i++)
     {
-      aSeqPnts (i).Coord (X,Y,Z);
+      aSeqPnts(i).Coord(X,Y,Z);
       Vertical->AddVertex (X,Y,Z);
     }
 
@@ -347,9 +333,8 @@ void V3d_RectangularGrid::DefinePoints()
     myGroup->AddPrimitiveArray (Vertical, Standard_False);
   }
 
-  myGroup->SetMinMaxValues (-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
-  myCurXStep = aXStep;
-  myCurYStep = aYStep;
+  myGroup->SetMinMaxValues(-myXSize, -myYSize, -myOffSet, myXSize, myYSize, -myOffSet);
+  myCurXStep = aXStep, myCurYStep = aYStep;
 
   // update bounding box
   myStructure->CalculateBoundBox();
@@ -365,28 +350,24 @@ void V3d_RectangularGrid::GraphicValues (Standard_Real& theXSize, Standard_Real&
 
 void V3d_RectangularGrid::SetGraphicValues (const Standard_Real theXSize, const Standard_Real theYSize, const Standard_Real theOffSet)
 {
-  if (! myCurAreDefined)
-  {
+  if (! myCurAreDefined) {
     myXSize = theXSize;
     myYSize = theYSize;
     myOffSet = theOffSet;
   }
-  if (myXSize != theXSize)
-  {
+  if (myXSize != theXSize) {
     myXSize = theXSize;
     myCurAreDefined = Standard_False;
   }
-  if (myYSize != theYSize)
-  {
+  if (myYSize != theYSize) {
     myYSize = theYSize;
     myCurAreDefined = Standard_False;
   }
-  if (myOffSet != theOffSet)
-  {
+  if (myOffSet != theOffSet) {
     myOffSet = theOffSet;
     myCurAreDefined = Standard_False;
   }
-  if (!myCurAreDefined) { UpdateDisplay(); }
+  if( !myCurAreDefined ) UpdateDisplay();
 }
 
 //=======================================================================
index a66b3e79d99fd9b065b57161f360af2a7dea806d..35e5922c39356af1f8031211dfdb59d530348995 100644 (file)
@@ -35,26 +35,26 @@ public:
   Standard_EXPORT V3d_RectangularGrid(const V3d_ViewerPointer& aViewer, const Quantity_Color& aColor, const Quantity_Color& aTenthColor);
 
   Standard_EXPORT virtual ~V3d_RectangularGrid();
-
+  
   Standard_EXPORT virtual void SetColors (const Quantity_Color& aColor, const Quantity_Color& aTenthColor) Standard_OVERRIDE;
-
+  
   Standard_EXPORT virtual void Display() Standard_OVERRIDE;
-
+  
   Standard_EXPORT virtual void Update() Standard_OVERRIDE;
 
   Standard_EXPORT virtual void Erase() const Standard_OVERRIDE;
-
+  
   Standard_EXPORT virtual Standard_Boolean IsDisplayed() const Standard_OVERRIDE;
-
+  
   Standard_EXPORT void GraphicValues (Standard_Real& XSize, Standard_Real& YSize, Standard_Real& OffSet) const;
-
+  
   Standard_EXPORT void SetGraphicValues (const Standard_Real XSize, const Standard_Real YSize, const Standard_Real OffSet);
   
   //! Dumps the content of me into the stream
   Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
 
 protected:
-
+  
   Standard_EXPORT virtual void UpdateDisplay() Standard_OVERRIDE;
 
 private:
index adafb827f41562a500d8e41392faae615a0fdb0e..b44fe23ae71d8d1c73a877345fc28a1be6612fc2 100644 (file)
@@ -3797,6 +3797,24 @@ void V3d_View::GraduatedTrihedronErase()
   myView->GraduatedTrihedronErase();
 }
 
+//=============================================================================
+//function : GridDisplay
+//purpose  :
+//=============================================================================
+void V3d_View::GridDisplay (const Aspect_GridParams& theGridParams)
+{
+  myView->GridDisplay (theGridParams);
+}
+
+//=============================================================================
+//function : GridErase
+//purpose  :
+//=============================================================================
+void V3d_View::GridErase()
+{
+  myView->GridErase();
+}
+
 // =======================================================================
 // function : DumpJson
 // purpose  :
index 93804995a4b8632ba59c575d50acd268ea751a9b..c7dc8c870e2ba7ee778c2e9959242b013a7dd6f3 100644 (file)
@@ -318,6 +318,12 @@ public:
   //! Erases a graduated trihedron from the view.
   Standard_EXPORT void GraduatedTrihedronErase();
 
+  //! Displays a grid.
+  Standard_EXPORT void GridDisplay (const Aspect_GridParams& theGridParams);
+
+  //! Erases a grid from the view.
+  Standard_EXPORT void GridErase();
+
   //! modify the Projection of the view perpendicularly to
   //! the privileged plane of the viewer.
   Standard_EXPORT void SetFront();
index 630ac437f4c09d3c56c5cd05c0b14e3d8ace9d15..a9a1d538afabaf578f9ee520a13d462e9e20711c 100644 (file)
@@ -5392,6 +5392,116 @@ static int VGrid (Draw_Interpretor& /*theDI*/,
   return 0;
 }
 
+//==============================================================================
+//function : VInfGrid
+//purpose  :
+//==============================================================================
+static int VInfGrid (Draw_Interpretor& /*theDI*/,
+                     Standard_Integer  theArgNb,
+                     const char**      theArgVec)
+{
+  Handle(V3d_View)   aView = ViewerTest::CurrentView();
+  Handle(V3d_Viewer) aViewer = ViewerTest::GetViewerFromContext();
+  if (aView.IsNull() || aViewer.IsNull())
+  {
+    Message::SendFail("Error: no active viewer");
+    return 1;
+  }
+
+  Aspect_GridParams aGridParams;
+  Standard_Boolean toDisplay = true;
+  ViewerTest_AutoUpdater anUpdateTool (ViewerTest::GetAISContext(), aView);
+  for (Standard_Integer anArgIter = 1; anArgIter < theArgNb; ++anArgIter)
+  {
+    TCollection_AsciiString anArg (theArgVec[anArgIter]);
+    anArg.LowerCase();
+    if (anUpdateTool.parseRedrawMode(theArgVec[anArgIter]))
+    {
+      continue;
+    }
+    else if (anArgIter < theArgNb && anArg == "-vertical")
+    {
+      aGridParams.SetIsHorizontal (Standard_False);
+    }
+    else if (anArgIter + 1 < theArgNb && anArg == "-drawaxis")
+    {
+      Standard_Integer aVal = Draw::Atoi (theArgVec[++anArgIter]);
+      if (aVal == 0)
+      {
+        aGridParams.SetIsDrawAxis (Standard_False);
+      }
+      else if (aVal == 1)
+      {
+        aGridParams.SetIsDrawAxis (Standard_True);
+      }
+      else
+      {
+        Message::SendFail() << "Syntax error at '" << anArg << " " << aVal <<"'";
+        return 1;
+      }
+    }
+    else if (anArgIter + 3 < theArgNb && (anArg == "-color"))
+    {
+      Quantity_Color aColor;
+      aColor.SetValues (Draw::Atof (theArgVec[anArgIter + 1]), Draw::Atof (theArgVec[anArgIter + 2]), Draw::Atof (theArgVec[anArgIter + 3]), Quantity_TOC_RGB);
+      aGridParams.SetColor (aColor);
+      anArgIter += 3;
+    }
+    else if (anArgIter + 3 < theArgNb && anArg == "-origin")
+    {
+      gp_Pnt aPoint;
+      aPoint.SetXYZ (gp_XYZ (Draw::Atof (theArgVec[anArgIter + 1]), Draw::Atof (theArgVec[anArgIter + 2]), Draw::Atof (theArgVec[anArgIter + 3])));
+      aGridParams.SetPosition (aPoint);
+      anArgIter += 3;
+    }
+    else if (anArgIter + 1 < theArgNb && (anArg == "-inf"))
+    {
+      Standard_Integer aVal = Draw::Atoi(theArgVec[++anArgIter]);
+      if (aVal == 0)
+      {
+        aGridParams.SetIsInfinity (Standard_False);
+      }
+      else if (aVal == 1)
+      {
+        aGridParams.SetIsInfinity (Standard_True);
+      }
+      else
+      {
+        Message::SendFail() << "Syntax error at '" << anArg << " " << aVal << "'";
+        return 1;
+      }
+    }
+    else if (anArgIter + 1 < theArgNb && (anArg == "-scale"))
+    {
+      aGridParams.SetScale (Draw::Atof(theArgVec[++anArgIter]));
+    }
+    else if (anArgIter + 1 < theArgNb && anArg == "-linethickness")
+    {
+      aGridParams.SetLineThickness (Draw::Atof (theArgVec[++anArgIter]));
+    }
+    else if (anArgIter >= theArgNb && anArg == "off")
+    {
+      toDisplay = Standard_False;
+    }
+    else
+    {
+      Message::SendFail() << "Syntax error at '" << anArg << "'";
+      return 1;
+    }
+  }
+
+  if (toDisplay)
+  {
+    ViewerTest::CurrentView()->GridDisplay (aGridParams);
+  }
+  else
+  {
+    ViewerTest::CurrentView()->GridErase();
+  }
+
+  return 0;
+}
+
 //==============================================================================
 //function : VPriviledgedPlane
 //purpose  :
@@ -14425,6 +14535,11 @@ vgrid [off] [-type {rect|circ}] [-mode {line|point}] [-origin X Y] [-rotAngle An
       [-step StepRadius NbDivisions] [-radius Radius]
 )" /* [vgrid] */);
 
+  addCmd("vinfgrid", VInfGrid, /* [vinfgrid] */ R"(
+vinfgrid [off] [-vertical] [-drawAxis {0|1}] [-color R G B] [-origin X Y Z] 
+      [-inf {0|1}] [-scale value] [-lineThickness value]
+)" /* [vinfgrid] */);
+
   addCmd ("vpriviledgedplane", VPriviledgedPlane, /* [vpriviledgedplane] */ R"(
 vpriviledgedplane [Ox Oy Oz Nx Ny Nz [Xx Xy Xz]]
 Sets or prints viewer's priviledged plane geometry:
diff --git a/tests/v3d/grid/ortho b/tests/v3d/grid/ortho
new file mode 100644 (file)
index 0000000..d45ad34
--- /dev/null
@@ -0,0 +1,23 @@
+puts "=================================="
+puts "Grid in ortographic projection"
+puts "=================================="
+
+pload MODELING VISUALIZATION
+
+vclear
+vinit View1
+vaxo
+
+box b 1 2 3
+vdisplay b -dispMode 1
+
+vcamera -ortho
+
+vfit
+vzoom 0.1
+
+vinfgrid
+vdump $imagedir/${casename}_0.png
+
+vinfgrid -vertical -drawAxis 0 -color 0 0 1 -origin 1 1 1 -inf 1 -lineThickness 0.05
+vdump $imagedir/${casename}_1.png
diff --git a/tests/v3d/grid/persp b/tests/v3d/grid/persp
new file mode 100644 (file)
index 0000000..8f1adf0
--- /dev/null
@@ -0,0 +1,23 @@
+puts "=================================="
+puts "Grid in perspective projection"
+puts "=================================="
+
+pload MODELING VISUALIZATION
+
+vclear
+vinit View1
+vaxo
+
+box b 1 2 3
+vdisplay b -dispMode 1
+
+vcamera -persp
+
+vfit
+vzoom 0.1
+
+vinfgrid
+vdump $imagedir/${casename}_0.png
+
+vinfgrid -vertical -drawAxis 0 -color 0 0 1 -origin 1 1 1 -inf 1 -lineThickness 0.05
+vdump $imagedir/${casename}_1.png