0026915: Visualization - return Handle from Graphic3d_CView::FBOCreate() instead...
[occt.git] / src / ViewerTest / ViewerTest_ViewerCommands.cxx
index a16b936..8a3cdc1 100644 (file)
@@ -3448,6 +3448,11 @@ static int VColorScale (Draw_Interpretor& theDI,
     std::cout << "Error: no active view!\n";
     return 1;
   }
+  if (theArgNb <= 1)
+  {
+    std::cout << "Error: wrong syntax at command '" << theArgVec[0] << "'!\n";
+    return 1;
+  }
 
   Handle(AIS_ColorScale) aCS;
   // find object
@@ -3478,18 +3483,16 @@ static int VColorScale (Draw_Interpretor& theDI,
 
   Standard_Real                   aMinRange    = aCS->GetMin();
   Standard_Real                   aMaxRange    = aCS->GetMax();
+  Standard_Integer                aWidth       = aCS->GetWidth();
+  Standard_Integer                aHeight      = aCS->GetHeight();
   Standard_Integer                aNbIntervals = aCS->GetNumberOfIntervals();
   Standard_Integer                aTextHeight  = aCS->GetTextHeight();
   Aspect_TypeOfColorScalePosition aLabPosition = aCS->GetLabelPosition();
-  gp_XY                           aPos (aCS->GetXPosition(), aCS->GetYPosition());
+  Standard_Integer                aPosX = aCS->GetXPosition();
+  Standard_Integer                aPosY = aCS->GetYPosition();
 
   ViewerTest_AutoUpdater anUpdateTool (aContext, aView);
 
-  if (theArgNb <= 1)
-  {
-    std::cout << "Error: wrong syntax at command '" << theArgVec[0] << "'!\n";
-    return 1;
-  }
   if (theArgNb <= 2)
   {
     theDI << "Color scale parameters for '"<< theArgVec[1] << "':\n"
@@ -3497,7 +3500,7 @@ static int VColorScale (Draw_Interpretor& theDI,
           << "Max range: " << aMaxRange << "\n"
           << "Number of intervals: " << aNbIntervals << "\n"
           << "Text height: " << aTextHeight << "\n"
-          << "Color scale position: " << aPos.X() <<" "<< aPos.Y()<< "\n"
+          << "Color scale position: " << aPosX <<" "<< aPosY<< "\n"
           << "Color scale title: " << aCS->GetTitle() << "\n"
           << "Label position: ";
     switch (aLabPosition)
@@ -3606,6 +3609,22 @@ static int VColorScale (Draw_Interpretor& theDI,
         return 1;
       }
     }
+    else if (aFlag == "-logarithmic"
+          || aFlag == "-log")
+    {
+      if (anArgIter + 1 >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+      Standard_Boolean IsLog;
+      if (!ViewerTest::ParseOnOff(theArgVec[++anArgIter], IsLog))
+      {
+        std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+      aCS->SetLogarithmic (IsLog);
+    }
     else if (aFlag == "-xy")
     {
       if (anArgIter + 2 >= theArgNb)
@@ -3616,14 +3635,51 @@ static int VColorScale (Draw_Interpretor& theDI,
 
       TCollection_AsciiString aX (theArgVec[++anArgIter]);
       TCollection_AsciiString aY (theArgVec[++anArgIter]);
-      if (!aX.IsRealValue()
-       || !aY.IsRealValue())
+      if (!aX.IsIntegerValue()
+       || !aY.IsIntegerValue())
       {
-        std::cout << "Error: coordinates should be real values!\n";
+        std::cout << "Error: coordinates should be integer values!\n";
         return 1;
       }
 
-      aPos.SetCoord (aX.RealValue(), aY.RealValue());
+      aPosX = aX.IntegerValue();
+      aPosY = aY.IntegerValue();
+    }
+    else if (aFlag == "-width"
+          || aFlag == "-w")
+    {
+      if (anArgIter + 1 >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aW (theArgVec[++anArgIter]);
+      if (!aW.IsIntegerValue())
+      {
+        std::cout << "Error: a width should be an integer value!\n";
+        return 1;
+      }
+
+      aWidth = aW.IntegerValue();
+    }
+    else if (aFlag == "-height"
+          || aFlag == "-h")
+    {
+      if (anArgIter + 1 >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at argument '" << anArg << "'!\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aH (theArgVec[++anArgIter]);
+      if (!aH.IsIntegerValue())
+      {
+        std::cout << "Error: a width should be an integer value!\n";
+        return 1;
+      }
+
+      aHeight = aH.IntegerValue();
     }
     else if (aFlag == "-color")
     {
@@ -3828,11 +3884,14 @@ static int VColorScale (Draw_Interpretor& theDI,
     else if (aFlag == "-demoversion"
           || aFlag == "-demo")
     {
-      aPos.SetCoord (0.0, 0.0);
+      aPosX        = 0;
+      aPosY        = 0;
       aTextHeight  = 16;
       aMinRange    = 0.0;
       aMaxRange    = 100;
       aNbIntervals = 10;
+      aWidth       = 0;
+      aHeight      = 0;
       aLabPosition = Aspect_TOCSP_RIGHT;
       aCS->SetColorType (Aspect_TOCSD_AUTO);
       aCS->SetLabelType (Aspect_TOCSD_AUTO);
@@ -3843,13 +3902,26 @@ static int VColorScale (Draw_Interpretor& theDI,
       return 1;
     }
   }
-
-  aCS->SetPosition          (aPos.X(), aPos.Y());
-  aCS->SetHeight            (0.95);
+  if (!aWidth || !aHeight)
+  {
+    Standard_Integer aWinWidth, aWinHeight;
+    aView->Window()->Size (aWinWidth, aWinHeight);
+    if (!aWidth)
+    {
+      aWidth = aWinWidth;
+    }
+    if (!aHeight)
+    {
+      aHeight = aWinHeight;
+    }
+  }
+  aCS->SetSize              (aWidth, aHeight);
+  aCS->SetPosition          (aPosX, aPosY);
   aCS->SetTextHeight        (aTextHeight);
   aCS->SetRange             (aMinRange, aMaxRange);
   aCS->SetNumberOfIntervals (aNbIntervals);
   aCS->SetLabelPosition     (aLabPosition);
+  aCS->SetBGColor           (aView->BackgroundColor());
   aCS->SetToUpdate();
   aContext->Display (aCS);
 
@@ -4203,6 +4275,8 @@ static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
                        const char** argv)
 {
 #ifndef _WIN32
+  (void )argc;
+  (void )argv;
   di << "Printing implemented only for WNT!\n";
   return 0;
 #else
@@ -4296,9 +4370,9 @@ static int VPrintView (Draw_Interpretor& di, Standard_Integer argc,
     {
       if (isTileSizeProvided)
       {
-        Handle(Graphic3d_CView) aGraphicView = ViewerTest::CurrentView()->View();
-        Graphic3d_PtrFrameBuffer anOldBuffer = aGraphicView->FBO();
-        Graphic3d_PtrFrameBuffer aNewBuffer  = aGraphicView->FBOCreate (aTileWidth, aTileHeight);
+        Handle(Graphic3d_CView)    aGraphicView = ViewerTest::CurrentView()->View();
+        Handle(Standard_Transient) anOldBuffer  = aGraphicView->FBO();
+        Handle(Standard_Transient) aNewBuffer   = aGraphicView->FBOCreate (aTileWidth, aTileHeight);
         aGraphicView->SetFBO (aNewBuffer);
 
         isPrinted = aView->Print (anDC, 1, 1, 0, Aspect_PA_TILE);
@@ -4593,10 +4667,11 @@ public:
 
   void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
                 const Handle(Prs3d_Presentation)& thePresentation,
-                const Standard_Integer theMode);
+                const Standard_Integer theMode) Standard_OVERRIDE;
 
   void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
-                         const Standard_Integer /*aMode*/){};
+                         const Standard_Integer /*aMode*/) Standard_OVERRIDE
+  {}
 
 private:
 
@@ -7335,6 +7410,33 @@ static int VStereo (Draw_Interpretor& theDI,
 
     Standard_Boolean isActive = ViewerTest_myDefaultCaps.contextStereo;
     theDI << "Stereo " << (isActive ? "ON" : "OFF") << "\n";
+    if (isActive)
+    {
+      TCollection_AsciiString aMode;
+      switch (aView->RenderingParams().StereoMode)
+      {
+        case Graphic3d_StereoMode_QuadBuffer       : aMode = "quadBuffer";       break;
+        case Graphic3d_StereoMode_RowInterlaced    : aMode = "rowInterlaced";    break;
+        case Graphic3d_StereoMode_ColumnInterlaced : aMode = "columnInterlaced"; break;
+        case Graphic3d_StereoMode_ChessBoard       : aMode = "chessBoard";       break;
+        case Graphic3d_StereoMode_SideBySide       : aMode = "sideBySide";       break;
+        case Graphic3d_StereoMode_OverUnder        : aMode = "overUnder";        break;
+        case Graphic3d_StereoMode_SoftPageFlip     : aMode = "softpageflip";     break;
+        case Graphic3d_StereoMode_Anaglyph  :
+          aMode = "anaglyph";
+          switch (aView->RenderingParams().AnaglyphFilter)
+          {
+            case Graphic3d_RenderingParams::Anaglyph_RedCyan_Simple      : aMode.AssignCat (" (redCyanSimple)");      break;
+            case Graphic3d_RenderingParams::Anaglyph_RedCyan_Optimized   : aMode.AssignCat (" (redCyan)");            break;
+            case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Simple   : aMode.AssignCat (" (yellowBlueSimple)");   break;
+            case Graphic3d_RenderingParams::Anaglyph_YellowBlue_Optimized: aMode.AssignCat (" (yellowBlue)");         break;
+            case Graphic3d_RenderingParams::Anaglyph_GreenMagenta_Simple : aMode.AssignCat (" (greenMagentaSimple)"); break;
+            default: break;
+          }
+        default: break;
+      }
+      theDI << "Mode " << aMode << "\n";
+    }
     return 0;
   }
 
@@ -8168,10 +8270,11 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
       case Graphic3d_RM_RAYTRACING:    theDI << "raytrace ";      break;
     }
     theDI << "\n";
+    theDI << "msaa:         " <<  aParams.NbMsaaSamples << "\n";
+    theDI << "rayDepth:     " <<  aParams.RaytracingDepth                             << "\n";
     theDI << "fsaa:         " << (aParams.IsAntialiasingEnabled       ? "on" : "off") << "\n";
     theDI << "shadows:      " << (aParams.IsShadowEnabled             ? "on" : "off") << "\n";
     theDI << "reflections:  " << (aParams.IsReflectionEnabled         ? "on" : "off") << "\n";
-    theDI << "rayDepth:     " <<  aParams.RaytracingDepth                             << "\n";
     theDI << "gleam:        " << (aParams.IsTransparentShadowEnabled  ? "on" : "off") << "\n";
     theDI << "GI:           " << (aParams.IsGlobalIlluminationEnabled ? "on" : "off") << "\n";
     theDI << "blocked RNG:  " << (aParams.CoherentPathTracingMode     ? "on" : "off") << "\n";
@@ -8246,6 +8349,30 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
 
       aParams.Method = Graphic3d_RM_RASTERIZATION;
     }
+    else if (aFlag == "-msaa")
+    {
+      if (toPrint)
+      {
+        theDI << aParams.NbMsaaSamples << " ";
+        continue;
+      }
+      else if (++anArgIter >= theArgNb)
+      {
+        std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
+        return 1;
+      }
+
+      const Standard_Integer aNbSamples = Draw::Atoi (theArgVec[anArgIter]);
+      if (aNbSamples < 0)
+      {
+        std::cerr << "Error: invalid number of MSAA samples " << aNbSamples << ".\n";
+        return 1;
+      }
+      else
+      {
+        aParams.NbMsaaSamples = aNbSamples;
+      }
+    }
     else if (aFlag == "-raydepth"
           || aFlag == "-ray_depth")
     {
@@ -9171,8 +9298,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     __FILE__, VRenderParams, group);
   theCommands.Add("vrenderparams",
     "\n    Manages rendering parameters: "
-    "\n      '-rayTrace'             Enables  GPU ray-tracing"
     "\n      '-raster'               Disables GPU ray-tracing"
+    "\n      '-msaa         0..4'    Specifies number of samples for MSAA"
+    "\n      '-rayTrace'             Enables  GPU ray-tracing"
     "\n      '-rayDepth     0..10'   Defines maximum ray-tracing depth"
     "\n      '-shadows      on|off'  Enables/disables shadows rendering"
     "\n      '-reflections  on|off'  Enables/disables specular reflections"