0029076: Visualization - implement element shrinking Shader IR-2019-02-22
authormnv <mnv@opencascade.com>
Wed, 1 Aug 2018 15:09:37 +0000 (18:09 +0300)
committerapn <apn@opencascade.com>
Fri, 22 Feb 2019 13:23:35 +0000 (16:23 +0300)
Aspect_IS_HOLLOW now an alias to Aspect_IS_EMPTY and Aspect_IS_HIDDENLINE does not implicitly enables mesh edges,
so that Graphic3d_AspectFillArea3d::SetDrawEdges() should be set independently.

OpenGl_ShaderManager now provides built-in GLSL programs for drawing mesh edges
in single pass (and on OpenGL ES which does not provide glPolygonMode()).

Graphic3d_RenderingParams::ToEnableAlphaToCoverage is now enabled by default
and properly handled at TKOpenGl level - enables coverage for Graphic3d_AlphaMode_Mask primitives.

OpenGl_PrimitiveArray now uses GLSL programs instead of glPolygonMode() by default,
which can be managed by OpenGl_Caps::usePolygonMode flag (desktop OpenGL only).
glPolygonMode() is also used as fallback regardless OpenGl_Caps::usePolygonMode flag
when GLSL programs are not supported (Geometry Shaders are required)
or stipple line style is required (not implemented within Face GLSL).

vaspects command has been extended by -setInterior -setDrawEdges -setEdgeColor -setEdgeType -setEdgeWidth
arguments replacing vsetinteriorstyle/vsetedgetype/vunsetedgetype commands.
vaspects now accepts arguments without "set" prefix.
ViewerTest::ParseColor() now parses RGBA color.

Redundant command BUC60738 has been removed.
AIS_ColorScale - fixed usage of uninitialized FillArea aspects.

48 files changed:
dox/dev_guides/upgrade/upgrade.md
dox/user_guides/visualization/visualization.md
src/AIS/AIS_ColorScale.cxx
src/AIS/AIS_ColorScale.hxx
src/AIS/AIS_Shape.cxx
src/AIS/AIS_Shape.hxx
src/Aspect/Aspect_InteriorStyle.hxx
src/Graphic3d/Graphic3d_AspectFillArea3d.cxx
src/Graphic3d/Graphic3d_AspectFillArea3d.hxx
src/Graphic3d/Graphic3d_RenderingParams.hxx
src/Graphic3d/Graphic3d_TypeOfLimit.hxx
src/OpenGl/OpenGl_Caps.cxx
src/OpenGl/OpenGl_Caps.hxx
src/OpenGl/OpenGl_Context.cxx
src/OpenGl/OpenGl_Context.hxx
src/OpenGl/OpenGl_GraphicDriver.cxx
src/OpenGl/OpenGl_LineAttributes.cxx
src/OpenGl/OpenGl_MaterialState.hxx
src/OpenGl/OpenGl_PrimitiveArray.cxx
src/OpenGl/OpenGl_SetOfShaderPrograms.hxx
src/OpenGl/OpenGl_ShaderManager.cxx
src/OpenGl/OpenGl_ShaderManager.hxx
src/OpenGl/OpenGl_ShaderObject.cxx
src/OpenGl/OpenGl_ShaderProgram.cxx
src/OpenGl/OpenGl_ShaderProgram.hxx
src/OpenGl/OpenGl_Text.cxx
src/OpenGl/OpenGl_View_Redraw.cxx
src/OpenGl/OpenGl_Workspace.cxx
src/Prs3d/Prs3d_Drawer.cxx
src/Prs3d/Prs3d_Drawer.hxx
src/QABugs/FILES
src/QABugs/QABugs.cxx
src/QABugs/QABugs.hxx
src/QABugs/QABugs_4.cxx [deleted file]
src/ViewerTest/ViewerTest.cxx
src/ViewerTest/ViewerTest.hxx
src/ViewerTest/ViewerTest_ObjectCommands.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
tests/bugs/mesh/bug29751
tests/bugs/vis/buc60738
tests/bugs/vis/bug23363
tests/bugs/vis/bug28306
tests/bugs/vis/bug6897_1
tests/bugs/vis/bug6897_2 [deleted file]
tests/v3d/begin
tests/v3d/glsl/alpha_mask
tests/v3d/glsl/interior1 [new file with mode: 0644]
tests/v3d/glsl/interior2 [new file with mode: 0644]

index 0b9cdf8..f79f937 100644 (file)
@@ -1678,3 +1678,10 @@ Standard_Boolean meshing_new()
 Some public methods of the class BRepFilletAPI_MakeChamfer are released from excess arguments:
 - method Add for symmetric chamfer now takes only 2 arguments: distance and edge;
 - method GetDistAngle now takes only 3 arguments: index of contour, distance and angle.
+
+@subsection upgrade_740_interiorstyles Interior styles
+
+* *Aspect_IS_HOLLOW* is now an alias to *Aspect_IS_EMPTY* and does not implicitly enables drawing mesh edges anymore.
+  Specify Graphic3d_AspectFillArea3d::SetDrawEdges(true) with Graphic3d_AspectFillArea3d::SetInteriorStyle(Aspect_IS_EMPTY) to get previous behavior of Aspect_IS_HOLLOW style.
+* *Aspect_IS_HIDDENLINE* does not implicitly enables drawing mesh edges anymore.
+  Specify Graphic3d_AspectFillArea3d::SetDrawEdges(true) with Graphic3d_AspectFillArea3d::SetInteriorStyle(Aspect_IS_HIDDENLINE) to get previous behavior of Aspect_IS_HIDDENLINE style.
index d278db2..b709ee1 100644 (file)
@@ -1793,12 +1793,11 @@ Create facet attributes.
 Handle(Graphic3d_AspectFillArea3d) aFaceAspect =  new Graphic3d_AspectFillArea3d();
 Graphic3d_MaterialAspect aBrassMaterial (Graphic3d_NOM_BRASS);
 Graphic3d_MaterialAspect aGoldMaterial  (Graphic3d_NOM_GOLD);
-aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID);
+aFaceAspect->SetInteriorStyle (Aspect_IS_SOLID_WIREFRAME);
 aFaceAspect->SetInteriorColor (aMyColor);
 aFaceAspect->SetDistinguishOn ();
 aFaceAspect->SetFrontMaterial (aGoldMaterial);
 aFaceAspect->SetBackMaterial  (aBrassMaterial);
-aFaceAspect->SetEdgeOn();
 ~~~~~
 
 Create text attributes.
index 4317fa0..ee37f00 100644 (file)
@@ -107,6 +107,10 @@ AIS_ColorScale::AIS_ColorScale()
   myTextHeight (20)
 {
   SetDisplayMode (0);
+  myDrawer->SetupOwnShadingAspect();
+  myDrawer->ShadingAspect()->Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
+  myDrawer->ShadingAspect()->Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Opaque);
+  myDrawer->ShadingAspect()->Aspect()->SetInteriorColor (Quantity_NOC_WHITE);
 }
 
 //=======================================================================
@@ -458,15 +462,6 @@ void AIS_ColorScale::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
   const Standard_Integer aBarTop     = myYPos + myHeight - aTitleOffset - aBarYOffset;
   const Standard_Integer aBarHeight  = aBarTop - aBarBottom;
 
-  // draw title
-  if (!myTitle.IsEmpty())
-  {
-    drawText (Prs3d_Root::CurrentGroup (thePrs), myTitle,
-              myXPos + mySpacing,
-              aBarTop + aBarYOffset,
-              Graphic3d_VTA_BOTTOM);
-  }
-
   TColStd_SequenceOfExtendedString aLabels;
   if (myLabelType == Aspect_TOCSD_USER)
   {
@@ -496,11 +491,27 @@ void AIS_ColorScale::Compute (const Handle(PrsMgr_PresentationManager3d)& ,
     aColorBreadth += aTextWidth;
   }
 
+  // draw title
+  Handle(Graphic3d_Group) aLabelsGroup;
+  if (!myTitle.IsEmpty()
+   || !aLabels.IsEmpty())
+  {
+    aLabelsGroup = thePrs->NewGroup();
+    aLabelsGroup->SetGroupPrimitivesAspect (myDrawer->TextAspect()->Aspect());
+  }
+  if (!myTitle.IsEmpty())
+  {
+    drawText (aLabelsGroup, myTitle,
+              myXPos + mySpacing,
+              aBarTop + aBarYOffset,
+              Graphic3d_VTA_BOTTOM);
+  }
+
   // draw colors
   drawColorBar (thePrs, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
 
   // draw Labels
-  drawLabels (thePrs, aLabels, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
+  drawLabels (aLabelsGroup, aLabels, aBarBottom, aBarHeight, aTextWidth, aColorBreadth);
 }
 
 //=======================================================================
@@ -627,7 +638,8 @@ void AIS_ColorScale::drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
     }
   }
 
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
+  Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
+  aGroup->SetGroupPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
   aGroup->AddPrimitiveArray (aTriangles);
 
   const Quantity_Color aFgColor (hasOwnColor ? myDrawer->Color() : Quantity_NOC_WHITE);
@@ -642,7 +654,7 @@ void AIS_ColorScale::drawColorBar (const Handle(Prs3d_Presentation)& thePrs,
 //function : drawLabels
 //purpose  :
 //=======================================================================
-void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
+void AIS_ColorScale::drawLabels (const Handle(Graphic3d_Group)& theGroup,
                                  const TColStd_SequenceOfExtendedString& theLabels,
                                  const Standard_Integer theBarBottom,
                                  const Standard_Integer theBarHeight,
@@ -716,14 +728,14 @@ void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
     Standard_Integer aPos2 = aNbLabels - 1 - i2;
     if (aFilter && !(aPos1 % aFilter))
     {
-      drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i1 + 1),
+      drawText (theGroup, theLabels.Value (i1 + 1),
                 anXLeft, anYBottom + Standard_Integer(i1 * aStepY + anAscent),
                 Graphic3d_VTA_CENTER);
       aLast1 = i1;
     }
     if (aFilter && !(aPos2 % aFilter))
     {
-      drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i2 + 1),
+      drawText (theGroup, theLabels.Value (i2 + 1),
                 anXLeft, anYBottom + Standard_Integer(i2 * aStepY + anAscent),
                 Graphic3d_VTA_CENTER);
       aLast2 = i2;
@@ -746,7 +758,7 @@ void AIS_ColorScale::drawLabels (const Handle(Prs3d_Presentation)& thePrs,
 
   if (i0 != -1)
   {
-    drawText (Prs3d_Root::CurrentGroup (thePrs), theLabels.Value (i0 + 1),
+    drawText (theGroup, theLabels.Value (i0 + 1),
               anXLeft, anYBottom + Standard_Integer(i0 * aStepY + anAscent),
               Graphic3d_VTA_CENTER);
   }
@@ -769,8 +781,8 @@ void AIS_ColorScale::drawFrame (const Handle(Prs3d_Presentation)& thePrs,
   aPrim->AddVertex (theX,            theY, 0.0);
 
   Handle(Graphic3d_AspectLine3d) anAspect = new Graphic3d_AspectLine3d (theColor, Aspect_TOL_SOLID, 1.0);
-  Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (thePrs);
-  aGroup->SetPrimitivesAspect (anAspect);
+  Handle(Graphic3d_Group) aGroup = thePrs->NewGroup();
+  aGroup->SetGroupPrimitivesAspect (anAspect);
   aGroup->AddPrimitiveArray (aPrim);
 }
 
@@ -784,7 +796,6 @@ void AIS_ColorScale::drawText (const Handle(Graphic3d_Group)& theGroup,
                                const Graphic3d_VerticalTextAlignment theVertAlignment)
 {
   const Handle(Prs3d_TextAspect)& anAspect = myDrawer->TextAspect();
-  theGroup->SetPrimitivesAspect (anAspect->Aspect());
   theGroup->Text (theText,
                   gp_Ax2 (gp_Pnt (theX, theY, 0.0), gp::DZ()),
                   anAspect->Height(),
index 4ee7d7b..a71f138 100644 (file)
@@ -406,7 +406,7 @@ private:
   Standard_Integer computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const;
 
   //! Draw labels.
-  void drawLabels (const Handle(Prs3d_Presentation)& thePrs,
+  void drawLabels (const Handle(Graphic3d_Group)& theGroup,
                    const TColStd_SequenceOfExtendedString& theLabels,
                    const Standard_Integer theBarBottom,
                    const Standard_Integer theBarHeight,
index b22bc6e..511acdd 100644 (file)
@@ -350,77 +350,12 @@ bool AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
                           const Quantity_Color&       theColor) const
 {
   bool toRecompute = false;
-  if (!theDrawer->HasOwnShadingAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnLineAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnWireAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnPointAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_BLACK, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnFreeBoundaryAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnUnFreeBoundaryAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnSeenLineAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnFaceBoundaryAspect())
+  toRecompute = theDrawer->SetupOwnShadingAspect() || toRecompute;
+  toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
+
+  if (theDrawer->SetupOwnPointAspect())
   {
     toRecompute = true;
-    theDrawer->SetFaceBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->FaceBoundaryAspect()->Aspect() = *theDrawer->Link()->FaceBoundaryAspect()->Aspect();
-    }
   }
 
   // override color
@@ -614,61 +549,7 @@ void AIS_Shape::UnsetColor()
 bool AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
                           const Standard_Real         theLineWidth) const
 {
-  bool toRecompute = false;
-  if (!theDrawer->HasOwnLineAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnWireAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnFreeBoundaryAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnUnFreeBoundaryAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnSeenLineAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
-    }
-  }
-  if (!theDrawer->HasOwnFaceBoundaryAspect())
-  {
-    toRecompute = true;
-    theDrawer->SetFaceBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->FaceBoundaryAspect()->Aspect() = *theDrawer->Link()->FaceBoundaryAspect()->Aspect();
-    }
-  }
+  bool toRecompute = theDrawer->SetOwnLineAspects();
 
   // override width
   theDrawer->LineAspect()->SetWidth (theLineWidth);
@@ -758,14 +639,7 @@ void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)&     theDrawer,
 {
   const Quantity_Color aColor  = theDrawer->ShadingAspect()->Material     (myCurrentFacingModel).Color();
   const Standard_Real  aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
-  if (!theDrawer->HasOwnShadingAspect())
-  {
-    theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
-    }
-  }
+  theDrawer->SetupOwnShadingAspect();
   theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
 
   if (theToKeepColor)
@@ -889,15 +763,7 @@ void AIS_Shape::UnsetMaterial()
 void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
                                  const Standard_Real         theValue) const
 {
-  if (!theDrawer->HasOwnShadingAspect())
-  {
-    theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
-    if (theDrawer->HasLink())
-    {
-      *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
-    }
-  }
-
+  theDrawer->SetupOwnShadingAspect();
   // override transparency
   theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
 }
index fccbd6e..5bd1f95 100644 (file)
@@ -51,7 +51,7 @@
 //! To generate texture coordinates, appropriate shading attribute should be set before computing presentation in AIS_Shaded display mode:
 //! @code
 //!   Handle(AIS_Shape) aPrs = new AIS_Shape();
-//!   aPrs->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
+//!   aPrs->Attributes()->SetupOwnShadingAspect();
 //!   aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMapOn();
 //!   aPrs->Attributes()->ShadingAspect()->Aspect()->SetTextureMap (new Graphic3d_Texture2Dmanual (Graphic3d_NOT_2D_ALUMINUM));
 //! @endcode
index e69a258..4f5a68e 100644 (file)
 #ifndef _Aspect_InteriorStyle_HeaderFile
 #define _Aspect_InteriorStyle_HeaderFile
 
-//! Definition of interior types for primitive
-//! faces.
-//!
-//! IS_EMPTY    no interior.
-//! IS_HOLLOW   display the boundaries of the surface.
-//! IS_HATCH    display hatched with a hatch style.
-//! IS_SOLID    display the interior entirely filled.
-//! IS_HIDDENLINE       display in hidden lines removed.
-//! IS_POINT            display only vertices.
+//! Interior types for primitive faces.
 enum Aspect_InteriorStyle
 {
-Aspect_IS_EMPTY,
-Aspect_IS_HOLLOW,
-Aspect_IS_HATCH,
-Aspect_IS_SOLID,
-Aspect_IS_HIDDENLINE,
-Aspect_IS_POINT
+  Aspect_IS_EMPTY = -1, //!< no interior
+  Aspect_IS_SOLID =  0, //!< normally filled surface interior
+  Aspect_IS_HATCH,      //!< hatched surface interior
+  Aspect_IS_HIDDENLINE, //!< interior is filled with viewer background color
+  Aspect_IS_POINT,      //!< display only vertices of surface (obsolete)
+
+  // obsolete aliases
+  Aspect_IS_HOLLOW = Aspect_IS_EMPTY, //!< transparent surface interior
 };
 
 #endif // _Aspect_InteriorStyle_HeaderFile
index a4e1cb0..ee15c53 100644 (file)
@@ -32,6 +32,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d()
   myEdgeType            (Aspect_TOL_SOLID),
   myEdgeWidth           (1.0f),
   myHatchStyle          (Handle(Graphic3d_HatchStyle)()),
+  myToSkipFirstEdge     (false),
   myToDistinguishMaterials (false),
   myToDrawEdges         (false),
   myToSuppressBackFaces (true),
@@ -63,6 +64,7 @@ Graphic3d_AspectFillArea3d::Graphic3d_AspectFillArea3d (const Aspect_InteriorSty
   myEdgeType            (theEdgeLineType),
   myEdgeWidth           ((float )theEdgeLineWidth),
   myHatchStyle          (Handle(Graphic3d_HatchStyle)()),
+  myToSkipFirstEdge     (false),
   myToDistinguishMaterials (false),
   myToDrawEdges         (false),
   myToSuppressBackFaces (true),
index 57b4c56..48e2f8e 100644 (file)
@@ -255,19 +255,26 @@ public:
 public:
 
   //! Returns true if edges should be drawn (false by default).
-  bool ToDrawEdges() const { return myToDrawEdges; }
+  bool ToDrawEdges() const { return myToDrawEdges && myEdgeType != Aspect_TOL_EMPTY; }
 
   //! Set if edges should be drawn or not.
-  void SetDrawEdges (bool theToDraw) { myToDrawEdges = theToDraw; }
+  void SetDrawEdges (bool theToDraw)
+  {
+    myToDrawEdges = theToDraw;
+    if (myEdgeType == Aspect_TOL_EMPTY)
+    {
+      myEdgeType = Aspect_TOL_SOLID;
+    }
+  }
 
   //! Returns true if edges should be drawn.
-  bool Edge() const { return myToDrawEdges; }
+  bool Edge() const { return ToDrawEdges(); }
 
   //! The edges of FillAreas are drawn.
-  void SetEdgeOn() { myToDrawEdges = true; }
+  void SetEdgeOn() { SetDrawEdges (true); }
 
   //! The edges of FillAreas are not drawn.
-  void SetEdgeOff() { myToDrawEdges = false; }
+  void SetEdgeOff() { SetDrawEdges (false); }
 
   //! Return color of edges.
   const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
@@ -278,6 +285,9 @@ public:
   //! Modifies the color of the edge of the face
   void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); }
 
+  //! Modifies the color of the edge of the face
+  void SetEdgeColor (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
+
   //! Return edges line type.
   Aspect_TypeOfLine EdgeLineType() const { return myEdgeType; }
 
@@ -298,6 +308,18 @@ public:
     myEdgeWidth = (float )theWidth;
   }
 
+  //! Returns TRUE if drawing element edges should discard first edge in triangle; FALSE by default.
+  //! Graphics hardware works mostly with triangles, so that wireframe presentation will draw triangle edges by default.
+  //! This flag allows rendering wireframe presentation of quad-only array split into triangles.
+  //! For this, quads should be split in specific order, so that the quad diagonal (to be NOT rendered) goes first:
+  //!     1------2
+  //!    /      /   Triangle #1: 2-0-1; Triangle #2: 0-2-3
+  //!   0------3
+  bool ToSkipFirstEdge() const { return myToSkipFirstEdge; }
+
+  //! Set skip first triangle edge flag for drawing wireframe presentation of quads array split into triangles.
+  void SetSkipFirstEdge (bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; }
+
 public:
 
   //! Returns the hatch type used when InteriorStyle is IS_HATCH
@@ -370,6 +392,7 @@ protected:
   Handle(Graphic3d_HatchStyle) myHatchStyle;
 
   Graphic3d_PolygonOffset myPolygonOffset;
+  bool                    myToSkipFirstEdge;
   bool                    myToDistinguishMaterials;
   bool                    myToDrawEdges;
   bool                    myToSuppressBackFaces;
index 6042d89..17bd259 100644 (file)
@@ -94,11 +94,12 @@ public:
   Graphic3d_RenderingParams()
   : Method                      (Graphic3d_RM_RASTERIZATION),
     TransparencyMethod          (Graphic3d_RTM_BLEND_UNORDERED),
+    LineFeather                 (1.0f),
     OitDepthFactor              (0.0f),
     NbMsaaSamples               (0),
     RenderResolutionScale       (1.0f),
     ToEnableDepthPrepass        (Standard_False),
-    ToEnableAlphaToCoverage     (Standard_False),
+    ToEnableAlphaToCoverage     (Standard_True),
     // ray tracing parameters
     IsGlobalIlluminationEnabled (Standard_False),
     RaytracingDepth             (THE_DEFAULT_DEPTH),
@@ -168,12 +169,14 @@ public:
 
   Graphic3d_RenderingMode           Method;                      //!< specifies rendering mode, Graphic3d_RM_RASTERIZATION by default
   Graphic3d_RenderTransparentMethod TransparencyMethod;          //!< specifies rendering method for transparent graphics
+  Standard_ShortReal                LineFeather;                 //!< line feater width in pixels (> 0.0), 1.0 by default;
+                                                                 //!  high values produce blurred results, small values produce sharp (aliased) edges
   Standard_ShortReal                OitDepthFactor;              //!< scalar factor [0-1] controlling influence of depth of a fragment to its final coverage
   Standard_Integer                  NbMsaaSamples;               //!< number of MSAA samples (should be within 0..GL_MAX_SAMPLES, power-of-two number), 0 by default
   Standard_ShortReal                RenderResolutionScale;       //!< rendering resolution scale factor, 1 by default;
                                                                  //!  incompatible with MSAA (e.g. NbMsaaSamples should be set to 0)
   Standard_Boolean                  ToEnableDepthPrepass;        //!< enables/disables depth pre-pass, False by default
-  Standard_Boolean                  ToEnableAlphaToCoverage;     //!< enables/disables alpha to coverage, False by default
+  Standard_Boolean                  ToEnableAlphaToCoverage;     //!< enables/disables alpha to coverage, True by default
 
   Standard_Boolean                  IsGlobalIlluminationEnabled; //!< enables/disables global illumination effects (path tracing)
   Standard_Integer                  SamplesPerPixel;             //!< number of samples per pixel (SPP)
index 772b944..3c0b3c1 100644 (file)
@@ -32,6 +32,7 @@ enum Graphic3d_TypeOfLimit
   Graphic3d_TypeOfLimit_HasBlendedOit,                  //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (without MSAA).
   Graphic3d_TypeOfLimit_HasBlendedOitMsaa,              //!< indicates whether necessary GL extensions for Weighted, Blended OIT available (with MSAA).
   Graphic3d_TypeOfLimit_HasFlatShading,                 //!< indicates whether Flat shading (Graphic3d_TOSM_FACET) is supported
+  Graphic3d_TypeOfLimit_HasMeshEdges,                   //!< indicates whether advanced mesh edges presentation is supported
   Graphic3d_TypeOfLimit_IsWorkaroundFBO,                //!< indicates whether workaround for Intel driver problem with empty FBO for images with big width is applyed.
   Graphic3d_TypeOfLimit_NB                              //!< number of elements in this enumeration
 };
index dc03616..569abf5 100755 (executable)
@@ -28,11 +28,11 @@ OpenGl_Caps::OpenGl_Caps()
 : vboDisable        (Standard_False),
   pntSpritesDisable (Standard_False),
   keepArrayData     (Standard_False),
-#if !defined(GL_ES_VERSION_2_0)
   ffpEnable         (Standard_False),
+  usePolygonMode    (Standard_False),
+#if !defined(GL_ES_VERSION_2_0)
   useSystemBuffer   (Standard_False),
 #else
-  ffpEnable         (Standard_False),
   useSystemBuffer   (Standard_True),
 #endif
   swapInterval      (1),
index c94633a..548a8be 100755 (executable)
@@ -30,7 +30,8 @@ public: //! @name flags to disable particular functionality, should be used only
   Standard_Boolean vboDisable;        //!< flag permits VBO usage, will significantly affect performance (OFF by default)
   Standard_Boolean pntSpritesDisable; //!< flag permits Point Sprites usage, will significantly affect performance (OFF by default)
   Standard_Boolean keepArrayData;     //!< Disables freeing CPU memory after building VBOs (OFF by default)
-  Standard_Boolean ffpEnable;         //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (ON by default on desktop OpenGL and OFF on OpenGL ES)
+  Standard_Boolean ffpEnable;         //!< Enables FFP (fixed-function pipeline), do not use built-in GLSL programs (OFF by default)
+  Standard_Boolean usePolygonMode;    //!< Enables Polygon Mode instead of built-in GLSL programs (OFF by default; unsupported on OpenGL ES)
   Standard_Boolean useSystemBuffer;   //!< Enables usage of system backbuffer for blitting (OFF by default on desktop OpenGL and ON on OpenGL ES for testing)
   Standard_Integer swapInterval;      //!< controls swap interval - 0 for VSync off and 1 for VSync on, 1 by default
 
index b83a2dd..68f6bd7 100644 (file)
@@ -125,6 +125,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
   hasFloatBuffer     (OpenGl_FeatureNotAvailable),
   hasHalfFloatBuffer (OpenGl_FeatureNotAvailable),
   hasSampleVariables (OpenGl_FeatureNotAvailable),
+  hasGeometryStage   (OpenGl_FeatureNotAvailable),
   arbDrawBuffers (Standard_False),
   arbNPTW  (Standard_False),
   arbTexRG (Standard_False),
@@ -193,6 +194,7 @@ OpenGl_Context::OpenGl_Context (const Handle(OpenGl_Caps)& theCaps)
   myResolution (Graphic3d_RenderingParams::THE_DEFAULT_RESOLUTION),
   myResolutionRatio (1.0f),
   myLineWidthScale (1.0f),
+  myLineFeather (1.0f),
   myRenderScale (1.0f),
   myRenderScaleInv (1.0f)
 {
@@ -1422,6 +1424,12 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
     // dFdx/dFdy are completely broken on tested Adreno devices with versions below OpenGl ES 3.1
     hasFlatShading = OpenGl_FeatureNotAvailable;
   }
+
+  hasGeometryStage = IsGlGreaterEqual (3, 2)
+                   ? OpenGl_FeatureInCore
+                   : (CheckExtension ("GL_EXT_geometry_shader") && CheckExtension ("GL_EXT_shader_io_blocks")
+                     ? OpenGl_FeatureInExtensions
+                     : OpenGl_FeatureNotAvailable);
 #else
 
   myTexClamp = IsGlGreaterEqual (1, 2) ? GL_CLAMP_TO_EDGE : GL_CLAMP;
@@ -1446,6 +1454,10 @@ void OpenGl_Context::init (const Standard_Boolean theIsCoreProfile)
                                          CheckExtension ("GL_ARB_color_buffer_float") ? OpenGl_FeatureInExtensions
                                                                                       : OpenGl_FeatureNotAvailable;
 
+  hasGeometryStage = IsGlGreaterEqual (3, 2)
+                   ? OpenGl_FeatureInCore
+                   : OpenGl_FeatureNotAvailable;
+
   hasSampleVariables = IsGlGreaterEqual (4, 0) ? OpenGl_FeatureInCore :
                         arbSampleShading ? OpenGl_FeatureInExtensions
                                          : OpenGl_FeatureNotAvailable;
@@ -3213,9 +3225,18 @@ void OpenGl_Context::SetShadingMaterial (const OpenGl_AspectFace* theAspect,
   // do not update material properties in case of zero reflection mode,
   // because GL lighting will be disabled by OpenGl_PrimitiveArray::DrawArray() anyway.
   const OpenGl_MaterialState& aMatState = myShaderManager->MaterialState();
-  const float anAlphaCutoff = anAspect->AlphaMode() == Graphic3d_AlphaMode_Mask
-                            ? anAspect->AlphaCutoff()
-                            : ShortRealLast();
+  float anAlphaCutoff = anAspect->AlphaMode() == Graphic3d_AlphaMode_Mask
+                      ? anAspect->AlphaCutoff()
+                      : ShortRealLast();
+  if (anAspect->ToDrawEdges())
+  {
+    if (anAspect->InteriorStyle() == Aspect_IS_EMPTY
+     || (anAspect->InteriorStyle() == Aspect_IS_SOLID
+      && anAspect->EdgeColorRGBA().Alpha() < 1.0f))
+    {
+      anAlphaCutoff = 0.285f;
+    }
+  }
   if (theAspect->ShadingModel() == Graphic3d_TOSM_UNLIT)
   {
     if (anAlphaCutoff == aMatState.AlphaCutoff())
@@ -3772,14 +3793,15 @@ bool OpenGl_Context::SetColorMask (bool theToWriteColor)
 // =======================================================================
 bool OpenGl_Context::SetSampleAlphaToCoverage (bool theToEnable)
 {
-  if (myAlphaToCoverage == theToEnable)
+  bool toEnable = myAllowAlphaToCov && theToEnable;
+  if (myAlphaToCoverage == toEnable)
   {
     return myAlphaToCoverage;
   }
 
   if (core15fwd != NULL)
   {
-    if (theToEnable)
+    if (toEnable)
     {
       //core15fwd->core15fwd->glSampleCoverage (1.0f, GL_FALSE);
       core15fwd->glEnable (GL_SAMPLE_ALPHA_TO_COVERAGE);
@@ -3791,6 +3813,6 @@ bool OpenGl_Context::SetSampleAlphaToCoverage (bool theToEnable)
   }
 
   const bool anOldValue = myAlphaToCoverage;
-  myAlphaToCoverage = theToEnable;
+  myAlphaToCoverage = toEnable;
   return anOldValue;
 }
index f9e94d4..97155e5 100644 (file)
@@ -662,6 +662,12 @@ public: //! @name methods to alter or retrieve current state
   //! Enable/disable writing into color buffer (wrapper for glColorMask).
   Standard_EXPORT bool SetColorMask (bool theToWriteColor);
 
+  //! Return TRUE if GL_SAMPLE_ALPHA_TO_COVERAGE usage is allowed.
+  bool AllowSampleAlphaToCoverage() const { return myAllowAlphaToCov; }
+
+  //! Allow GL_SAMPLE_ALPHA_TO_COVERAGE usage.
+  void SetAllowSampleAlphaToCoverage (bool theToEnable) { myAllowAlphaToCov = theToEnable; }
+
   //! Return GL_SAMPLE_ALPHA_TO_COVERAGE state.
   bool SampleAlphaToCoverage() const { return myAlphaToCoverage; }
 
@@ -777,6 +783,9 @@ public: //! @name methods to alter or retrieve current state
   //! Rendering scale factor (inverted value).
   Standard_ShortReal RenderScaleInv() const { return myRenderScaleInv; }
 
+  //! Return scale factor for line width.
+  Standard_ShortReal LineWidthScale() const { return myLineWidthScale; }
+
   //! Set resolution ratio.
   //! Note that this method rounds @theRatio to nearest integer.
   void SetResolution (unsigned int theResolution,
@@ -797,6 +806,12 @@ public: //! @name methods to alter or retrieve current state
     myLineWidthScale  = Max (1.0f, std::floor (theRatio + 0.5f));
   }
 
+  //! Return line feater width in pixels.
+  Standard_ShortReal LineFeather() const { return myLineFeather; }
+
+  //! Set line feater width.
+  void SetLineFeather(Standard_ShortReal theValue) { myLineFeather = theValue; }
+
   //! Return Graphics Driver's vendor.
   const TCollection_AsciiString& Vendor() const { return myVendor; }
 
@@ -848,6 +863,7 @@ public: //! @name extensions
   OpenGl_FeatureFlag     hasFloatBuffer;     //!< Complex flag indicating support of float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_float)
   OpenGl_FeatureFlag     hasHalfFloatBuffer; //!< Complex flag indicating support of half-float color buffer format (desktop OpenGL 3.0, GL_ARB_color_buffer_float, GL_EXT_color_buffer_half_float)
   OpenGl_FeatureFlag     hasSampleVariables; //!< Complex flag indicating support of MSAA variables in GLSL shader (desktop OpenGL 4.0, GL_ARB_sample_shading)
+  OpenGl_FeatureFlag     hasGeometryStage;   //!< Complex flag indicating support of Geometry shader (desktop OpenGL 3.2, OpenGL ES 3.2, GL_EXT_geometry_shader)
   Standard_Boolean       arbDrawBuffers;     //!< GL_ARB_draw_buffers
   Standard_Boolean       arbNPTW;            //!< GL_ARB_texture_non_power_of_two
   Standard_Boolean       arbTexRG;           //!< GL_ARB_texture_rg
@@ -958,6 +974,7 @@ private: //! @name fields tracking current state
                                 myDrawBuffers;     //!< current draw buffers
   unsigned int                  myDefaultVao;      //!< default Vertex Array Object
   Standard_Boolean              myColorMask;       //!< flag indicating writing into color buffer is enabled or disabled (glColorMask)
+  Standard_Boolean              myAllowAlphaToCov; //!< flag allowing   GL_SAMPLE_ALPHA_TO_COVERAGE usage
   Standard_Boolean              myAlphaToCoverage; //!< flag indicating GL_SAMPLE_ALPHA_TO_COVERAGE state
   Standard_Boolean              myIsGlDebugCtx;    //!< debug context initialization state
   TCollection_AsciiString       myVendor;          //!< Graphics Driver's vendor
@@ -966,6 +983,7 @@ private: //! @name fields tracking current state
   Standard_ShortReal            myResolutionRatio; //!< scaling factor for parameters like text size
                                                    //!  to be properly displayed on device (screen / printer)
   Standard_ShortReal            myLineWidthScale;  //!< scaling factor for line width
+  Standard_ShortReal            myLineFeather;     //!< line feater width in pixels
   Standard_ShortReal            myRenderScale;     //!< scaling factor for rendering resolution
   Standard_ShortReal            myRenderScaleInv;  //!< scaling factor for rendering resolution (inverted value)
   OpenGl_Material               myMatFront;        //!< current front material state (cached to reduce GL context updates)
index 6908aa8..9481da9 100644 (file)
@@ -465,6 +465,8 @@ Standard_Integer OpenGl_GraphicDriver::InquireLimit (const Graphic3d_TypeOfLimit
       return !aCtx.IsNull() && aCtx->hasFlatShading != OpenGl_FeatureNotAvailable ? 1 : 0;
     case Graphic3d_TypeOfLimit_IsWorkaroundFBO:
       return !aCtx.IsNull() && aCtx->MaxTextureSize() != aCtx->MaxDumpSizeX() ? 1 : 0;
+    case Graphic3d_TypeOfLimit_HasMeshEdges:
+      return !aCtx.IsNull() && aCtx->hasGeometryStage != OpenGl_FeatureNotAvailable ? 1 : 0;
     case Graphic3d_TypeOfLimit_NB:
       return 0;
   }
index 42a13d9..c4b09b4 100644 (file)
@@ -109,7 +109,11 @@ int OpenGl_LineAttributes::SetTypeOfHatch (const OpenGl_Context*               t
   }
 
 #if !defined(GL_ES_VERSION_2_0)
-  if (theStyle->HatchType() != 0)
+  if (theGlCtx->core11 == NULL)
+  {
+    return 0;
+  }
+  else if (theStyle->HatchType() != 0)
   {
     theGlCtx->core11->glCallList ((GLuint)aGpuListId);
 
@@ -146,7 +150,11 @@ bool OpenGl_LineAttributes::SetEnabled (const OpenGl_Context* theGlCtx,
   const bool anOldIsEnabled = myIsEnabled;
 
 #if !defined(GL_ES_VERSION_2_0)
-  if (theToEnable)
+  if (theGlCtx->core11 == NULL)
+  {
+    return 0;
+  }
+  else if (theToEnable)
   {
     if (myTypeOfHatch != 0)
     {
index daf59c8..64c581c 100644 (file)
@@ -50,6 +50,9 @@ public:
   //! Alpha cutoff value.
   float AlphaCutoff() const { return myAlphaCutoff; }
 
+  //! Return TRUE if alpha test should be enabled.
+  bool HasAlphaCutoff() const { return myAlphaCutoff <= 1.0f; }
+
   //! Distinguish front/back flag.
   bool ToDistinguish() const { return myToDistinguish; }
 
index 8986de7..dc1bad5 100644 (file)
@@ -504,9 +504,8 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4&              theEdgeCo
 
   const OpenGl_AspectLine* anAspectLineOld = theWorkspace->SetAspectLine (theWorkspace->AspectFace()->AspectEdge());
   const OpenGl_AspectLine* anAspect = theWorkspace->ApplyAspectLine();
-
 #if !defined(GL_ES_VERSION_2_0)
-  glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
+  const Standard_Integer aPolyModeOld = aGlContext->SetPolygonMode (GL_LINE);
 #endif
 
   if (aGlContext->core20fwd != NULL)
@@ -580,6 +579,9 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4&              theEdgeCo
 
   // restore line context
   theWorkspace->SetAspectLine (anAspectLineOld);
+#if !defined(GL_ES_VERSION_2_0)
+  aGlContext->SetPolygonMode (aPolyModeOld);
+#endif
 }
 
 // =======================================================================
@@ -801,9 +803,34 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
   // Temporarily disable environment mapping
   Handle(OpenGl_TextureSet) aTextureBack;
   bool toDrawArray = true;
+  int toDrawInteriorEdges = 0; // 0 - no edges, 1 - glsl edges, 2 - polygonMode
   if (myDrawMode > GL_LINE_STRIP)
   {
     toDrawArray = anAspectFace->Aspect()->InteriorStyle() != Aspect_IS_EMPTY;
+    if (anAspectFace->Aspect()->ToDrawEdges())
+    {
+      toDrawInteriorEdges = 1;
+      toDrawArray = true;
+    #if !defined(GL_ES_VERSION_2_0)
+      if (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID
+       || aCtx->hasGeometryStage == OpenGl_FeatureNotAvailable
+       || aCtx->caps->usePolygonMode)
+      {
+        toDrawInteriorEdges = 2;
+        if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_EMPTY)
+        {
+          if (anAspectFace->Aspect()->EdgeLineType() != Aspect_TOL_SOLID)
+          {
+            toDrawArray = false;
+          }
+          else
+          {
+            aCtx->SetPolygonMode (GL_LINE);
+          }
+        }
+      }
+    #endif
+    }
   }
   else if (myDrawMode <= GL_LINE_STRIP)
   {
@@ -867,10 +894,16 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
         const Standard_Boolean toEnableEnvMap = (!aTextures.IsNull() && (aTextures == theWorkspace->EnvironmentTexture()));
         aCtx->ShaderManager()->BindFaceProgram (aTextures,
                                                 aShadingModel,
-                                                anAspectFace->Aspect()->AlphaMode(),
+                                                aCtx->ShaderManager()->MaterialState().HasAlphaCutoff() ? Graphic3d_AlphaMode_Mask : Graphic3d_AlphaMode_Opaque,
+                                                toDrawInteriorEdges == 1 ? anAspectFace->Aspect()->InteriorStyle() : Aspect_IS_SOLID,
                                                 hasVertColor,
                                                 toEnableEnvMap,
+                                                toDrawInteriorEdges == 1,
                                                 anAspectFace->ShaderProgramRes (aCtx));
+        if (toDrawInteriorEdges == 1)
+        {
+          aCtx->ShaderManager()->PushInteriorState (aCtx->ActiveProgram(), anAspectFace->Aspect());
+        }
         break;
       }
     }
@@ -926,24 +959,21 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
   {
     aCtx->BindTextures (aTextureBack);
   }
-  else
+#if !defined(GL_ES_VERSION_2_0)
+  else if (toDrawInteriorEdges == 2)
   {
-    if (anAspectFace->Aspect()->ToDrawEdges()
-     || anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
+    if (anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_HOLLOW
+     && anAspectFace->Aspect()->EdgeLineType()  == Aspect_TOL_SOLID)
+    {
+      aCtx->SetPolygonMode (GL_FILL);
+    }
+    else
     {
       const OpenGl_Vec4& anEdgeColor = theWorkspace->EdgeColor();
       drawEdges (anEdgeColor, theWorkspace);
-
-      // restore OpenGL polygon mode if needed
-    #if !defined(GL_ES_VERSION_2_0)
-      if (anAspectFace->Aspect()->InteriorStyle() >= Aspect_IS_HATCH)
-      {
-        glPolygonMode (GL_FRONT_AND_BACK,
-          anAspectFace->Aspect()->InteriorStyle() == Aspect_IS_POINT ? GL_POINT : GL_FILL);
-      }
-    #endif
     }
   }
+#endif
 }
 
 // =======================================================================
index 9c44813..29000b6 100644 (file)
 //! Standard GLSL program combination bits.
 enum OpenGl_ProgramOptions
 {
-  OpenGl_PO_Point       = 0x001, //!< point marker
-  OpenGl_PO_VertColor   = 0x002, //!< per-vertex color
-  OpenGl_PO_TextureRGB  = 0x004, //!< handle RGB   texturing
-  OpenGl_PO_TextureA    = 0x008, //!< handle Alpha texturing
-  OpenGl_PO_TextureEnv  = 0x010, //!< handle environment map
-  OpenGl_PO_StippleLine = 0x020, //!< stipple line
-  OpenGl_PO_ClipPlanes1 = 0x040, //!< handle 1 clipping plane
-  OpenGl_PO_ClipPlanes2 = 0x080, //!< handle 2 clipping planes
-  //OpenGl_PO_ClipPlanes3 = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle 3 clipping planes - not implemented
-  OpenGl_PO_ClipPlanesN = 0x100, //!< handle N clipping planes
-  OpenGl_PO_ClipChains  = 0x200, //!< handle chains of clipping planes
-  OpenGl_PO_AlphaTest   = 0x400, //!< discard fragment by alpha test (defined by cutoff value)
-  OpenGl_PO_WriteOit    = 0x800, //!< write coverage buffer for Blended Order-Independent Transparency
-  OpenGl_PO_NB          = 0x1000 //!< overall number of combinations
+  OpenGl_PO_Point           = 0x0001, //!< point marker
+  OpenGl_PO_VertColor       = 0x0002, //!< per-vertex color
+  OpenGl_PO_TextureRGB      = 0x0004, //!< handle RGB   texturing
+  OpenGl_PO_TextureA        = 0x0008, //!< handle Alpha texturing
+  OpenGl_PO_TextureEnv      = 0x0010, //!< handle environment map
+  OpenGl_PO_StippleLine     = 0x0020, //!< stipple line
+  OpenGl_PO_ClipPlanes1     = 0x0040, //!< handle 1 clipping plane
+  OpenGl_PO_ClipPlanes2     = 0x0080, //!< handle 2 clipping planes
+  OpenGl_PO_ClipPlanesN     = OpenGl_PO_ClipPlanes1|OpenGl_PO_ClipPlanes2, //!< handle N clipping planes
+  OpenGl_PO_ClipChains      = 0x0100, //!< handle chains of clipping planes
+  OpenGl_PO_MeshEdges       = 0x0200, //!< draw mesh edges (wireframe)
+  OpenGl_PO_AlphaTest       = 0x0400, //!< discard fragment by alpha test (defined by cutoff value)
+  OpenGl_PO_WriteOit        = 0x0800, //!< write coverage buffer for Blended Order-Independent Transparency
+  //
+  OpenGl_PO_NB              = 0x1000, //!< overall number of combinations
+  OpenGl_PO_NeedsGeomShader = OpenGl_PO_MeshEdges,
 };
 
 //! Alias to programs array of predefined length
index 2cb4e08..a6f689b 100644 (file)
@@ -281,6 +281,19 @@ EOL"  {"
 EOL"    discard;"
 EOL"  }";
 
+//! Modify color for Wireframe presentation.
+const char THE_FRAG_WIREFRAME_COLOR[] =
+EOL"vec4 getFinalColor(void)"
+EOL"{"
+EOL"  float aDistance = min (min (EdgeDistance[0], EdgeDistance[1]), EdgeDistance[2]);"
+EOL"  bool isHollow = occWireframeColor.a < 0.0;"
+EOL"  float aMixVal = smoothstep (occLineWidth - occLineFeather * 0.5, occLineWidth + occLineFeather * 0.5, aDistance);"
+EOL"  vec4 aMixColor = isHollow"
+EOL"                 ? vec4 (getColor().rgb, 1.0 - aMixVal)"          // edges only (of interior color)
+EOL"                 : mix (occWireframeColor, getColor(), aMixVal);" // interior + edges
+EOL"  return aMixColor;"
+EOL"}";
+
 #if !defined(GL_ES_VERSION_2_0)
 
   static const GLfloat THE_DEFAULT_AMBIENT[4]    = { 0.0f, 0.0f, 0.0f, 1.0f };
@@ -1130,6 +1143,7 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
       return;
     }
 
+    myContext->SetSampleAlphaToCoverage (false);
     if (myMaterialState.AlphaCutoff() < ShortRealLast())
     {
       glAlphaFunc (GL_GEQUAL, myMaterialState.AlphaCutoff());
@@ -1158,6 +1172,7 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
     return;
   }
 
+  myContext->SetSampleAlphaToCoverage (myMaterialState.HasAlphaCutoff());
   theProgram->SetUniform (myContext,
                           theProgram->GetStateLocation (OpenGl_OCCT_ALPHA_CUTOFF),
                           myMaterialState.AlphaCutoff());
@@ -1168,15 +1183,12 @@ void OpenGl_ShaderManager::PushMaterialState (const Handle(OpenGl_ShaderProgram)
                           theProgram->GetStateLocation (OpenGl_OCCT_DISTINGUISH_MODE),
                           myMaterialState.ToDistinguish() ? 1 : 0);
 
-  const GLint aLocFront = theProgram->GetStateLocation (OpenGl_OCCT_FRONT_MATERIAL);
-  if (aLocFront != OpenGl_ShaderProgram::INVALID_LOCATION)
+  if (const OpenGl_ShaderUniformLocation aLocFront = theProgram->GetStateLocation (OpenGl_OCCT_FRONT_MATERIAL))
   {
     theProgram->SetUniform (myContext, aLocFront, OpenGl_Material::NbOfVec4(),
                             aFrontMat.Packed());
   }
-
-  const GLint aLocBack = theProgram->GetStateLocation (OpenGl_OCCT_BACK_MATERIAL);
-  if (aLocBack != OpenGl_ShaderProgram::INVALID_LOCATION)
+  if (const OpenGl_ShaderUniformLocation aLocBack = theProgram->GetStateLocation (OpenGl_OCCT_BACK_MATERIAL))
   {
     theProgram->SetUniform (myContext, aLocBack,  OpenGl_Material::NbOfVec4(),
                             aBackMat.Packed());
@@ -1212,6 +1224,45 @@ void OpenGl_ShaderManager::PushOitState (const Handle(OpenGl_ShaderProgram)& the
   }
 }
 
+// =======================================================================
+// function : PushInteriorState
+// purpose  :
+// =======================================================================
+void OpenGl_ShaderManager::PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
+                                              const Handle(Graphic3d_AspectFillArea3d)& theAspect) const
+{
+  if (theProgram.IsNull()
+  || !theProgram->IsValid())
+  {
+    return;
+  }
+
+  if (const OpenGl_ShaderUniformLocation aLocViewPort = theProgram->GetStateLocation (OpenGl_OCCT_VIEWPORT))
+  {
+    theProgram->SetUniform (myContext, aLocViewPort, OpenGl_Vec4 ((float )myContext->Viewport()[0], (float )myContext->Viewport()[1], (float )myContext->Viewport()[2], (float )myContext->Viewport()[3]));
+  }
+  if (const OpenGl_ShaderUniformLocation aLocLineWidth = theProgram->GetStateLocation (OpenGl_OCCT_LINE_WIDTH))
+  {
+    theProgram->SetUniform (myContext, aLocLineWidth, theAspect->EdgeWidth() * myContext->LineWidthScale());
+    theProgram->SetUniform (myContext, theProgram->GetStateLocation (OpenGl_OCCT_LINE_FEATHER), myContext->LineFeather() * myContext->LineWidthScale());
+  }
+  if (const OpenGl_ShaderUniformLocation aLocWireframeColor = theProgram->GetStateLocation (OpenGl_OCCT_WIREFRAME_COLOR))
+  {
+    if (theAspect->InteriorStyle() == Aspect_IS_HOLLOW)
+    {
+      theProgram->SetUniform (myContext, aLocWireframeColor, OpenGl_Vec4 (-1.0f, -1.0f, -1.0f, -1.0f));
+    }
+    else
+    {
+      theProgram->SetUniform (myContext, aLocWireframeColor, theAspect->EdgeColorRGBA());
+    }
+  }
+  if (const OpenGl_ShaderUniformLocation aLocQuadModeState = theProgram->GetStateLocation (OpenGl_OCCT_QUAD_MODE_STATE))
+  {
+    theProgram->SetUniform (myContext, aLocQuadModeState, theAspect->ToSkipFirstEdge() ? 1 : 0);
+  }
+}
+
 // =======================================================================
 // function : PushState
 // purpose  : Pushes state of OCCT graphics parameters to the program
@@ -1264,19 +1315,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramFont()
        EOL"}";
 
   Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
-#if !defined(GL_ES_VERSION_2_0)
-  if (myContext->core32 != NULL)
-  {
-    aProgramSrc->SetHeader ("#version 150");
-  }
-#else
-  if (myContext->IsGlGreaterEqual (3, 1))
-  {
-    // prefer "100 es" on OpenGL ES 3.0 devices
-    // and    "300 es" on newer devices (3.1+)
-    aProgramSrc->SetHeader ("#version 300 es");
-  }
-#endif
+  defaultGlslVersion (aProgramSrc, 0);
   aProgramSrc->SetNbLightsMax (0);
   aProgramSrc->SetNbClipPlanesMax (0);
   aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts));
@@ -1482,6 +1521,164 @@ namespace
 
 }
 
+// =======================================================================
+// function : defaultGlslVersion
+// purpose  :
+// =======================================================================
+int OpenGl_ShaderManager::defaultGlslVersion (const Handle(Graphic3d_ShaderProgram)& theProgram,
+                                              int theBits,
+                                              bool theUsesDerivates) const
+{
+  int aBits = theBits;
+#if !defined(GL_ES_VERSION_2_0)
+  if (myContext->core32 != NULL)
+  {
+    theProgram->SetHeader ("#version 150");
+  }
+  else
+  {
+    if ((theBits & OpenGl_PO_StippleLine) != 0)
+    {
+      if (myContext->IsGlGreaterEqual (3, 0))
+      {
+        theProgram->SetHeader ("#version 130");
+      }
+      else if (myContext->CheckExtension ("GL_EXT_gpu_shader4"))
+      {
+        theProgram->SetHeader ("#extension GL_EXT_gpu_shader4 : enable");
+      }
+      else
+      {
+        aBits = aBits & ~OpenGl_PO_StippleLine;
+      }
+    }
+  }
+  (void )theUsesDerivates;
+#else
+  // prefer "100 es" on OpenGL ES 3.0- devices (save the features unavailable before "300 es")
+  // and    "300 es" on OpenGL ES 3.1+ devices
+  if (myContext->IsGlGreaterEqual (3, 1))
+  {
+    if ((theBits & OpenGl_PO_NeedsGeomShader) != 0)
+    {
+      theProgram->SetHeader (myContext->hasGeometryStage != OpenGl_FeatureInExtensions ? "#version 320 es" : "#version 310 es");
+    }
+    else
+    {
+      theProgram->SetHeader ("#version 300 es");
+    }
+  }
+  else
+  {
+    if ((theBits & OpenGl_PO_WriteOit) != 0
+     || (theBits & OpenGl_PO_StippleLine) != 0)
+    {
+      if (myContext->IsGlGreaterEqual (3, 0))
+      {
+        theProgram->SetHeader ("#version 300 es");
+      }
+      else
+      {
+        aBits = aBits & ~OpenGl_PO_WriteOit;
+        aBits = aBits & ~OpenGl_PO_StippleLine;
+      }
+    }
+    if (theUsesDerivates)
+    {
+      if (myContext->IsGlGreaterEqual (3, 0))
+      {
+        theProgram->SetHeader ("#version 300 es");
+      }
+      else if (myContext->oesStdDerivatives)
+      {
+        theProgram->SetHeader ("#extension GL_OES_standard_derivatives : enable");
+      }
+    }
+  }
+#endif
+  return aBits;
+}
+
+// =======================================================================
+// function : prepareGeomMainSrc
+// purpose  :
+// =======================================================================
+TCollection_AsciiString OpenGl_ShaderManager::prepareGeomMainSrc (OpenGl_ShaderObject::ShaderVariableList& theUnifoms,
+                                                                  OpenGl_ShaderObject::ShaderVariableList& theStageInOuts,
+                                                                  Standard_Integer theBits)
+{
+  if ((theBits & OpenGl_PO_NeedsGeomShader) == 0)
+  {
+    return TCollection_AsciiString();
+  }
+
+  TCollection_AsciiString aSrcMainGeom =
+    EOL"void main()"
+    EOL"{";
+
+  if ((theBits & OpenGl_PO_MeshEdges) != 0)
+  {
+    theUnifoms.Append    (OpenGl_ShaderObject::ShaderVariable ("vec4 occViewport",       Graphic3d_TOS_GEOMETRY));
+    theUnifoms.Append    (OpenGl_ShaderObject::ShaderVariable ("bool occIsQuadMode",     Graphic3d_TOS_GEOMETRY));
+    theUnifoms.Append    (OpenGl_ShaderObject::ShaderVariable ("float occLineWidth",     Graphic3d_TOS_GEOMETRY));
+    theUnifoms.Append    (OpenGl_ShaderObject::ShaderVariable ("float occLineWidth",     Graphic3d_TOS_FRAGMENT));
+    theUnifoms.Append    (OpenGl_ShaderObject::ShaderVariable ("float occLineFeather",   Graphic3d_TOS_FRAGMENT));
+    theUnifoms.Append    (OpenGl_ShaderObject::ShaderVariable ("vec4 occWireframeColor", Graphic3d_TOS_FRAGMENT));
+    theStageInOuts.Append(OpenGl_ShaderObject::ShaderVariable ("vec3 EdgeDistance",      Graphic3d_TOS_GEOMETRY | Graphic3d_TOS_FRAGMENT));
+
+    aSrcMainGeom = TCollection_AsciiString()
+    + EOL"vec3 ViewPortTransform (vec4 theVec)"
+      EOL"{"
+      EOL"  vec3 aWinCoord = theVec.xyz / theVec.w;"
+      EOL"  aWinCoord    = aWinCoord * 0.5 + 0.5;"
+      EOL"  aWinCoord.xy = aWinCoord.xy * occViewport.zw + occViewport.xy;"
+      EOL"  return aWinCoord;"
+      EOL"}"
+    + aSrcMainGeom
+    + EOL"  vec3 aSideA = ViewPortTransform (gl_in[2].gl_Position) - ViewPortTransform (gl_in[1].gl_Position);"
+      EOL"  vec3 aSideB = ViewPortTransform (gl_in[2].gl_Position) - ViewPortTransform (gl_in[0].gl_Position);"
+      EOL"  vec3 aSideC = ViewPortTransform (gl_in[1].gl_Position) - ViewPortTransform (gl_in[0].gl_Position);"
+      EOL"  float aQuadArea = abs (aSideB.x * aSideC.y - aSideB.y * aSideC.x);"
+      EOL"  vec3 aLenABC    = vec3 (length (aSideA), length (aSideB), length (aSideC));"
+      EOL"  vec3 aHeightABC = vec3 (aQuadArea) / aLenABC;"
+      EOL"  aHeightABC = max (aHeightABC, vec3 (10.0 * occLineWidth));" // avoid shrunk presentation disappearing at distance
+      EOL"  float aQuadModeHeightC = occIsQuadMode ? occLineWidth + 1.0 : 0.0;";
+  }
+
+  for (Standard_Integer aVertIter = 0; aVertIter < 3; ++aVertIter)
+  {
+    const TCollection_AsciiString aVertIndex (aVertIter);
+    // pass variables from Vertex shader to Fragment shader through Geometry shader
+    for (OpenGl_ShaderObject::ShaderVariableList::Iterator aVarListIter (theStageInOuts); aVarListIter.More(); aVarListIter.Next())
+    {
+      if (aVarListIter.Value().Stages == (Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT))
+      {
+        const TCollection_AsciiString aVarName = aVarListIter.Value().Name.Token (" ", 2);
+        aSrcMainGeom += TCollection_AsciiString()
+         + EOL"  geomOut." + aVarName + " = geomIn[" + aVertIndex + "]." + aVarName + ";";
+      }
+    }
+
+    if ((theBits & OpenGl_PO_MeshEdges) != 0)
+    {
+      switch (aVertIter)
+      {
+        case 0: aSrcMainGeom += EOL"  EdgeDistance = vec3 (aHeightABC[0], 0.0, aQuadModeHeightC);"; break;
+        case 1: aSrcMainGeom += EOL"  EdgeDistance = vec3 (0.0, aHeightABC[1], aQuadModeHeightC);"; break;
+        case 2: aSrcMainGeom += EOL"  EdgeDistance = vec3 (0.0, 0.0, aHeightABC[2]);"; break;
+      }
+    }
+    aSrcMainGeom += TCollection_AsciiString()
+     + EOL"  gl_Position = gl_in[" + aVertIndex + "].gl_Position;"
+       EOL"  EmitVertex();";
+  }
+  aSrcMainGeom +=
+    EOL"  EndPrimitive();"
+    EOL"}";
+
+  return aSrcMainGeom;
+}
+
 // =======================================================================
 // function : prepareStdProgramUnlit
 // purpose  :
@@ -1490,11 +1687,12 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
                                                                const Standard_Integer        theBits)
 {
   Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
-  TCollection_AsciiString aSrcVert, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha;
-  TCollection_AsciiString aSrcFrag, aSrcFragExtraMain, aSrcFragWriteOit;
+  TCollection_AsciiString aSrcVert, aSrcVertExtraMain, aSrcVertExtraFunc, aSrcGetAlpha, aSrcVertEndMain;
+  TCollection_AsciiString aSrcFrag, aSrcFragExtraMain;
   TCollection_AsciiString aSrcFragGetColor     = EOL"vec4 getColor(void) { return occColor; }";
-  TCollection_AsciiString aSrcFragMainGetColor = EOL"  occSetFragColor (getColor());";
+  TCollection_AsciiString aSrcFragMainGetColor = EOL"  occSetFragColor (getFinalColor());";
   OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
+
   if ((theBits & OpenGl_PO_Point) != 0)
   {
   #if defined(GL_ES_VERSION_2_0)
@@ -1578,7 +1776,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
       EOL"  PositionWorld = occModelWorldMatrix * occVertex;"
       EOL"  Position      = occWorldViewMatrix * PositionWorld;";
 
-    if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
+    if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
+    {
+      aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
+      aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
+                         ? THE_FRAG_CLIP_CHAINS_N
+                         : THE_FRAG_CLIP_PLANES_N;
+    }
+    else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
     {
       aNbClipPlanes = 1;
       aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
@@ -1590,50 +1795,17 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
                          ? THE_FRAG_CLIP_CHAINS_2
                          : THE_FRAG_CLIP_PLANES_2;
     }
-    else
-    {
-      aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
-      aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
-                          ? THE_FRAG_CLIP_CHAINS_N
-                          : THE_FRAG_CLIP_PLANES_N;
-    }
   }
   if ((theBits & OpenGl_PO_WriteOit) != 0)
   {
     aProgramSrc->SetNbFragmentOutputs (2);
     aProgramSrc->SetWeightOitOutput (true);
-  #if defined(GL_ES_VERSION_2_0)
-    if (myContext->IsGlGreaterEqual (3, 0))
-    {
-      aProgramSrc->SetHeader ("#version 300 es");
-    }
-  #endif
   }
 
-  TCollection_AsciiString aSrcVertEndMain;
   if ((theBits & OpenGl_PO_StippleLine) != 0)
   {
-    bool hasGlslBitOps = false;
-  #if defined(GL_ES_VERSION_2_0)
-    if (myContext->IsGlGreaterEqual (3, 0))
-    {
-      aProgramSrc->SetHeader ("#version 300 es");
-      hasGlslBitOps = true;
-    }
-  #else
-    if (myContext->IsGlGreaterEqual (3, 0))
-    {
-      aProgramSrc->SetHeader ("#version 130");
-      hasGlslBitOps = true;
-    }
-    else if(myContext->CheckExtension("GL_EXT_gpu_shader4"))
-    {
-      aProgramSrc->SetHeader ("#extension GL_EXT_gpu_shader4 : enable");
-      hasGlslBitOps = true;
-    }
-  #endif
-
-    if (hasGlslBitOps)
+    const Standard_Integer aBits = defaultGlslVersion (aProgramSrc, theBits);
+    if ((aBits & OpenGl_PO_StippleLine) != 0)
     {
       aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("int   uPattern", Graphic3d_TOS_FRAGMENT));
       aUniforms.Append (OpenGl_ShaderObject::ShaderVariable ("float uFactor",  Graphic3d_TOS_FRAGMENT));
@@ -1645,7 +1817,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
         EOL"  float aRotatePoint = gl_FragCoord.x * sin (anAngle) + gl_FragCoord.y * cos (anAngle);"
         EOL"  uint  aBit         = uint (floor (aRotatePoint / uFactor + 0.5)) & 15U;"
         EOL"  if ((uint (uPattern) & (1U << aBit)) == 0U) discard;"
-        EOL"  vec4 aColor = getColor();"
+        EOL"  vec4 aColor = getFinalColor();"
         EOL"  if (aColor.a <= 0.1) discard;"
         EOL"  occSetFragColor (aColor);";
     }
@@ -1664,6 +1836,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
     + aSrcVertEndMain
     + EOL"}";
 
+  TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
+  aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
+    ? THE_FRAG_WIREFRAME_COLOR
+    : EOL"#define getFinalColor getColor";
+
   aSrcFrag =
       aSrcFragGetColor
     + aSrcGetAlpha
@@ -1671,28 +1848,16 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramUnlit (Handle(OpenGl_Sha
       EOL"{"
     + aSrcFragExtraMain
     + aSrcFragMainGetColor
-    + aSrcFragWriteOit
     + EOL"}";
 
-#if !defined(GL_ES_VERSION_2_0)
-  if (myContext->core32 != NULL)
-  {
-    aProgramSrc->SetHeader ("#version 150");
-  }
-#else
-  if (myContext->IsGlGreaterEqual (3, 1))
-  {
-    // prefer "100 es" on OpenGL ES 3.0 devices
-    // and    "300 es" on newer devices (3.1+)
-    aProgramSrc->SetHeader ("#version 300 es");
-  }
-#endif
+  defaultGlslVersion (aProgramSrc, theBits);
   aProgramSrc->SetNbLightsMax (0);
   aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
   aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
-  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts));
-  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
-
+  const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
   TCollection_AsciiString aKey;
   if (!Create (aProgramSrc, aKey, theProgram))
   {
@@ -1881,7 +2046,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
 {
   Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
   TCollection_AsciiString aSrcVert, aSrcVertColor, aSrcVertExtraMain;
-  TCollection_AsciiString aSrcFrag, aSrcFragExtraMain, aSrcFragWriteOit;
+  TCollection_AsciiString aSrcFrag, aSrcFragExtraMain;
   TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return gl_FrontFacing ? FrontColor : BackColor; }";
   OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
 
@@ -1934,7 +2099,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
       EOL"  PositionWorld = aPositionWorld;"
       EOL"  Position      = aPosition;";
 
-    if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
+    if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
+    {
+      aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
+      aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
+                         ? THE_FRAG_CLIP_CHAINS_N
+                         : THE_FRAG_CLIP_PLANES_N;
+    }
+    else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
     {
       aNbClipPlanes = 1;
       aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
@@ -1946,24 +2118,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
                           ? THE_FRAG_CLIP_CHAINS_2
                           : THE_FRAG_CLIP_PLANES_2;
     }
-    else
-    {
-      aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
-      aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
-                         ? THE_FRAG_CLIP_CHAINS_N
-                         : THE_FRAG_CLIP_PLANES_N;
-    }
   }
   if ((theBits & OpenGl_PO_WriteOit) != 0)
   {
     aProgramSrc->SetNbFragmentOutputs (2);
     aProgramSrc->SetWeightOitOutput (true);
-  #if defined(GL_ES_VERSION_2_0)
-    if (myContext->IsGlGreaterEqual (3, 0))
-    {
-      aProgramSrc->SetHeader ("#version 300 es");
-    }
-  #endif
   }
 
   aStageInOuts.Append (OpenGl_ShaderObject::ShaderVariable ("vec4 FrontColor", Graphic3d_TOS_VERTEX | Graphic3d_TOS_FRAGMENT));
@@ -1988,33 +2147,27 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramGouraud (Handle(OpenGl_S
     + EOL"  gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
       EOL"}";
 
+  TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
+  aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
+    ? THE_FRAG_WIREFRAME_COLOR
+    : EOL"#define getFinalColor getColor";
+
   aSrcFrag = TCollection_AsciiString()
     + aSrcFragGetColor
     + EOL"void main()"
       EOL"{"
     + aSrcFragExtraMain
-    + EOL"  occSetFragColor (getColor());"
-    + aSrcFragWriteOit
+    + EOL"  occSetFragColor (getFinalColor());"
     + EOL"}";
 
-#if !defined(GL_ES_VERSION_2_0)
-  if (myContext->core32 != NULL)
-  {
-    aProgramSrc->SetHeader ("#version 150");
-  }
-#else
-  if (myContext->IsGlGreaterEqual (3, 1))
-  {
-    // prefer "100 es" on OpenGL ES 3.0 devices
-    // and    "300 es" on newer devices (3.1+)
-    aProgramSrc->SetHeader ("#version 300 es");
-  }
-#endif
+  defaultGlslVersion (aProgramSrc, theBits);
   aProgramSrc->SetNbLightsMax (aNbLights);
   aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
   aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
-  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts));
-  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
+  const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
   TCollection_AsciiString aKey;
   if (!Create (aProgramSrc, aKey, theProgram))
   {
@@ -2052,10 +2205,9 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
                             "Warning: applied workaround for flat shading normal computation using dFdx/dFdy on Adreno");
   }
 #endif
-
   Handle(Graphic3d_ShaderProgram) aProgramSrc = new Graphic3d_ShaderProgram();
   TCollection_AsciiString aSrcVert, aSrcVertExtraFunc, aSrcVertExtraMain;
-  TCollection_AsciiString aSrcFrag, aSrcFragExtraOut, aSrcFragGetVertColor, aSrcFragExtraMain, aSrcFragWriteOit;
+  TCollection_AsciiString aSrcFrag, aSrcFragExtraOut, aSrcFragGetVertColor, aSrcFragExtraMain;
   TCollection_AsciiString aSrcFragGetColor = EOL"vec4 getColor(void) { return " thePhongCompLight "; }";
   OpenGl_ShaderObject::ShaderVariableList aUniforms, aStageInOuts;
   if ((theBits & OpenGl_PO_Point) != 0)
@@ -2103,7 +2255,14 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
   int aNbClipPlanes = 0;
   if ((theBits & OpenGl_PO_ClipPlanesN) != 0)
   {
-    if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
+    if ((theBits & OpenGl_PO_ClipPlanesN) == OpenGl_PO_ClipPlanesN)
+    {
+      aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
+      aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
+                         ? THE_FRAG_CLIP_CHAINS_N
+                         : THE_FRAG_CLIP_PLANES_N;
+    }
+    else if ((theBits & OpenGl_PO_ClipPlanes1) != 0)
     {
       aNbClipPlanes = 1;
       aSrcFragExtraMain += THE_FRAG_CLIP_PLANES_1;
@@ -2115,13 +2274,6 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
                          ? THE_FRAG_CLIP_CHAINS_2
                          : THE_FRAG_CLIP_PLANES_2;
     }
-    else
-    {
-      aNbClipPlanes = Graphic3d_ShaderProgram::THE_MAX_CLIP_PLANES_DEFAULT;
-      aSrcFragExtraMain += (theBits & OpenGl_PO_ClipChains) != 0
-                         ? THE_FRAG_CLIP_CHAINS_N
-                         : THE_FRAG_CLIP_PLANES_N;
-    }
   }
   if ((theBits & OpenGl_PO_WriteOit) != 0)
   {
@@ -2158,6 +2310,11 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
     + EOL"  gl_Position = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;"
       EOL"}";
 
+  TCollection_AsciiString aSrcGeom = prepareGeomMainSrc (aUniforms, aStageInOuts, theBits);
+  aSrcFragGetColor += (theBits & OpenGl_PO_MeshEdges) != 0
+    ? THE_FRAG_WIREFRAME_COLOR
+    : EOL"#define getFinalColor getColor";
+
   Standard_Integer aNbLights = 0;
   const TCollection_AsciiString aLights = stdComputeLighting (aNbLights, (theBits & OpenGl_PO_VertColor) != 0);
   aSrcFrag = TCollection_AsciiString()
@@ -2170,39 +2327,17 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramPhong (Handle(OpenGl_Sha
       EOL"void main()"
       EOL"{"
     + aSrcFragExtraMain
-    + EOL"  occSetFragColor (getColor());"
-    + aSrcFragWriteOit
+    + EOL"  occSetFragColor (getFinalColor());"
     + EOL"}";
 
-#if !defined(GL_ES_VERSION_2_0)
-  if (myContext->core32 != NULL)
-  {
-    aProgramSrc->SetHeader ("#version 150");
-  }
-#else
-  if (myContext->IsGlGreaterEqual (3, 1))
-  {
-    // prefer "100 es" on OpenGL ES 3.0 devices
-    // and    "300 es" on newer devices (3.1+)
-    aProgramSrc->SetHeader ("#version 300 es");
-  }
-  else if (isFlatNormal)
-  {
-    if (myContext->IsGlGreaterEqual (3, 0))
-    {
-      aProgramSrc->SetHeader ("#version 300 es");
-    }
-    else if (myContext->oesStdDerivatives)
-    {
-      aProgramSrc->SetHeader ("#extension GL_OES_standard_derivatives : enable");
-    }
-  }
-#endif
+  defaultGlslVersion (aProgramSrc, theBits, isFlatNormal);
   aProgramSrc->SetNbLightsMax (aNbLights);
   aProgramSrc->SetNbClipPlanesMax (aNbClipPlanes);
   aProgramSrc->SetAlphaTest ((theBits & OpenGl_PO_AlphaTest) != 0);
-  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts));
-  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts));
+  const Standard_Integer aNbGeomInputVerts = !aSrcGeom.IsEmpty() ? 3 : 0;
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcGeom, Graphic3d_TOS_GEOMETRY, aUniforms, aStageInOuts, "geomIn", "geomOut", aNbGeomInputVerts));
+  aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcFrag, Graphic3d_TOS_FRAGMENT, aUniforms, aStageInOuts, "", "", aNbGeomInputVerts));
   TCollection_AsciiString aKey;
   if (!Create (aProgramSrc, aKey, theProgram))
   {
@@ -2379,20 +2514,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramStereo (Handle(OpenGl_Sh
     }
   }
 
-#if !defined(GL_ES_VERSION_2_0)
-  if (myContext->core32 != NULL)
-  {
-    aProgramSrc->SetHeader ("#version 150");
-  }
-#else
-  if (myContext->IsGlGreaterEqual (3, 1))
-  {
-    // prefer "100 es" on OpenGL ES 3.0 devices
-    // and    "300 es" on newer devices (3.1+)
-    aProgramSrc->SetHeader ("#version 300 es");
-  }
-#endif
-
+  defaultGlslVersion (aProgramSrc, 0);
   aProgramSrc->SetNbLightsMax (0);
   aProgramSrc->SetNbClipPlanesMax (0);
   aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts));
@@ -2437,20 +2559,7 @@ Standard_Boolean OpenGl_ShaderManager::prepareStdProgramBoundBox()
     EOL"  occSetFragColor (occColor);"
     EOL"}";
 
-#if !defined(GL_ES_VERSION_2_0)
-  if (myContext->core32 != NULL)
-  {
-    aProgramSrc->SetHeader ("#version 150");
-  }
-#else
-  if (myContext->IsGlGreaterEqual (3, 1))
-  {
-    // prefer "100 es" on OpenGL ES 3.0 devices
-    // and    "300 es" on newer devices (3.1+)
-    aProgramSrc->SetHeader ("#version 300 es");
-  }
-#endif
-
+  defaultGlslVersion (aProgramSrc, 0);
   aProgramSrc->SetNbLightsMax (0);
   aProgramSrc->SetNbClipPlanesMax (0);
   aProgramSrc->AttachShader (OpenGl_ShaderObject::CreateFromSource (aSrcVert, Graphic3d_TOS_VERTEX,   aUniforms, aStageInOuts));
index 98b1e6a..131005c 100644 (file)
@@ -84,10 +84,23 @@ public:
 
   //! Bind program for filled primitives rendering
   Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
-                                    const Graphic3d_TypeOfShadingModel  theShadingModel,
-                                    const Graphic3d_AlphaMode           theAlphaMode,
-                                    const Standard_Boolean              theHasVertColor,
-                                    const Standard_Boolean              theEnableEnvMap,
+                                    Graphic3d_TypeOfShadingModel theShadingModel,
+                                    Graphic3d_AlphaMode theAlphaMode,
+                                    Standard_Boolean theHasVertColor,
+                                    Standard_Boolean theEnableEnvMap,
+                                    const Handle(OpenGl_ShaderProgram)& theCustomProgram)
+  {
+    return BindFaceProgram (theTextures, theShadingModel, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, theEnableEnvMap, false, theCustomProgram);
+  }
+
+  //! Bind program for filled primitives rendering
+  Standard_Boolean BindFaceProgram (const Handle(OpenGl_TextureSet)& theTextures,
+                                    Graphic3d_TypeOfShadingModel theShadingModel,
+                                    Graphic3d_AlphaMode theAlphaMode,
+                                    Aspect_InteriorStyle theInteriorStyle,
+                                    Standard_Boolean theHasVertColor,
+                                    Standard_Boolean theEnableEnvMap,
+                                    Standard_Boolean theEnableMeshEdges,
                                     const Handle(OpenGl_ShaderProgram)& theCustomProgram)
   {
     if (!theCustomProgram.IsNull()
@@ -100,7 +113,7 @@ public:
                                                         && (theTextures.IsNull() || theTextures->IsModulate())
                                                         ? theShadingModel
                                                         : Graphic3d_TOSM_UNLIT;
-    const Standard_Integer        aBits    = getProgramBits (theTextures, theAlphaMode, theHasVertColor, theEnableEnvMap);
+    const Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theInteriorStyle, theHasVertColor, theEnableEnvMap, theEnableMeshEdges);
     Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (aShadeModelOnFace, aBits);
     return bindProgramWithState (aProgram);
   }
@@ -119,7 +132,7 @@ public:
       return bindProgramWithState (theCustomProgram);
     }
 
-    Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, theHasVertColor, false);
+    Standard_Integer aBits = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false);
     if (theLineType != Aspect_TOL_SOLID)
     {
       aBits |= OpenGl_PO_StippleLine;
@@ -142,7 +155,7 @@ public:
       return bindProgramWithState (theCustomProgram);
     }
 
-    const Standard_Integer        aBits    = getProgramBits (theTextures, theAlphaMode, theHasVertColor, false) | OpenGl_PO_Point;
+    const Standard_Integer        aBits    = getProgramBits (theTextures, theAlphaMode, Aspect_IS_SOLID, theHasVertColor, false, false) | OpenGl_PO_Point;
     Handle(OpenGl_ShaderProgram)& aProgram = getStdProgram (theShadingModel, aBits);
     return bindProgramWithState (aProgram);
   }
@@ -301,6 +314,12 @@ public:
   //! Pushes current state of material to specified program.
   void PushMaterialState (const Handle(OpenGl_ShaderProgram)& theProgram) const;
 
+public:
+
+  //! Setup interior style line edges variables.
+  Standard_EXPORT void PushInteriorState (const Handle(OpenGl_ShaderProgram)& theProgram,
+                                          const Handle(Graphic3d_AspectFillArea3d)& theAspect) const;
+
 public:
 
   //! Returns state of OIT uniforms.
@@ -411,12 +430,43 @@ public:
 
 protected:
 
+  //! Define clipping planes program bits.
+  Standard_Integer getClipPlaneBits() const
+  {
+    const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn();
+    if (aNbPlanes <= 0)
+    {
+      return 0;
+    }
+
+    Standard_Integer aBits = 0;
+    if (myContext->Clipping().HasClippingChains())
+    {
+      aBits |= OpenGl_PO_ClipChains;
+    }
+
+    if (aNbPlanes == 1)
+    {
+      aBits |= OpenGl_PO_ClipPlanes1;
+    }
+    else if (aNbPlanes == 2)
+    {
+      aBits |= OpenGl_PO_ClipPlanes2;
+    }
+    else
+    {
+      aBits |= OpenGl_PO_ClipPlanesN;
+    }
+    return aBits;
+  }
+
   //! Define program bits.
   Standard_Integer getProgramBits (const Handle(OpenGl_TextureSet)& theTextures,
                                    Graphic3d_AlphaMode theAlphaMode,
+                                   Aspect_InteriorStyle theInteriorStyle,
                                    Standard_Boolean theHasVertColor,
-                                   Standard_Boolean theEnableEnvMap)
-
+                                   Standard_Boolean theEnableEnvMap,
+                                   Standard_Boolean theEnableMeshEdges) const
   {
     Standard_Integer aBits = 0;
     if (theAlphaMode == Graphic3d_AlphaMode_Mask)
@@ -424,22 +474,14 @@ protected:
       aBits |= OpenGl_PO_AlphaTest;
     }
 
-    const Standard_Integer aNbPlanes = myContext->Clipping().NbClippingOrCappingOn();
-    if (aNbPlanes > 0)
+    aBits |= getClipPlaneBits();
+    if (theEnableMeshEdges
+     && myContext->hasGeometryStage != OpenGl_FeatureNotAvailable)
     {
-      aBits |= OpenGl_PO_ClipPlanesN;
-      if (myContext->Clipping().HasClippingChains())
-      {
-        aBits |= OpenGl_PO_ClipChains;
-      }
-
-      if (aNbPlanes == 1)
-      {
-        aBits |= OpenGl_PO_ClipPlanes1;
-      }
-      else if (aNbPlanes == 2)
+      aBits |= OpenGl_PO_MeshEdges;
+      if (theInteriorStyle == Aspect_IS_HOLLOW)
       {
-        aBits |= OpenGl_PO_ClipPlanes2;
+        aBits |= OpenGl_PO_AlphaTest;
       }
     }
 
@@ -454,7 +496,8 @@ protected:
     {
       aBits |= theTextures->First()->IsAlpha() ? OpenGl_PO_TextureA : OpenGl_PO_TextureRGB;
     }
-    if (theHasVertColor)
+    if (theHasVertColor
+     && theInteriorStyle != Aspect_IS_HIDDENLINE)
     {
       aBits |= OpenGl_PO_VertColor;
     }
@@ -555,6 +598,16 @@ protected:
   //! Prepare standard GLSL program for bounding box.
   Standard_EXPORT Standard_Boolean prepareStdProgramBoundBox();
 
+  //! Prepare GLSL version header.
+  Standard_EXPORT Standard_Integer defaultGlslVersion (const Handle(Graphic3d_ShaderProgram)& theProgram,
+                                                       Standard_Integer theBits,
+                                                       bool theUsesDerivates = false) const;
+
+  //! Prepare GLSL source for geometry shader according to parameters.
+  Standard_EXPORT TCollection_AsciiString prepareGeomMainSrc (OpenGl_ShaderObject::ShaderVariableList& theUnifoms,
+                                                              OpenGl_ShaderObject::ShaderVariableList& theStageInOuts,
+                                                              Standard_Integer theBits);
+
 protected:
 
   //! Packed properties of light source
index e954cd1..2e0c2b3 100755 (executable)
@@ -58,6 +58,11 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
                                                                       const TCollection_AsciiString& theOutName,
                                                                       Standard_Integer theNbGeomInputVerts)
 {
+  if (theSource.IsEmpty())
+  {
+    return Handle(Graphic3d_ShaderObject)();
+  }
+
   TCollection_AsciiString aSrcUniforms, aSrcInOuts, aSrcInStructs, aSrcOutStructs;
   for (ShaderVariableList::Iterator anUniformIter (theUniforms); anUniformIter.More(); anUniformIter.Next())
   {
@@ -90,12 +95,15 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
     const Standard_Boolean hasGeomStage = theNbGeomInputVerts > 0
                                        && aStageLower <  Graphic3d_TOS_GEOMETRY
                                        && aStageUpper >= Graphic3d_TOS_GEOMETRY;
+    const Standard_Boolean isAllStagesVar = aStageLower == Graphic3d_TOS_VERTEX
+                                         && aStageUpper == Graphic3d_TOS_FRAGMENT;
     if (hasGeomStage
     || !theInName.IsEmpty()
     || !theOutName.IsEmpty())
     {
       if (aSrcInStructs.IsEmpty()
-       && aSrcOutStructs.IsEmpty())
+       && aSrcOutStructs.IsEmpty()
+       && isAllStagesVar)
       {
         if (theType == aStageLower)
         {
@@ -113,8 +121,9 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
       }
     }
 
-    if (!aSrcInStructs.IsEmpty()
-     || !aSrcOutStructs.IsEmpty())
+    if (isAllStagesVar
+     && (!aSrcInStructs.IsEmpty()
+      || !aSrcOutStructs.IsEmpty()))
     {
       if (!aSrcInStructs.IsEmpty())
       {
@@ -138,6 +147,12 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
     }
   }
 
+  if (theType == Graphic3d_TOS_GEOMETRY)
+  {
+    aSrcUniforms.Prepend (TCollection_AsciiString()
+                        + "\nlayout (triangles) in;"
+                          "\nlayout (triangle_strip, max_vertices = " + theNbGeomInputVerts + ") out;");
+  }
   if (!aSrcInStructs.IsEmpty()
    && theType == Graphic3d_TOS_GEOMETRY)
   {
@@ -153,10 +168,10 @@ Handle(Graphic3d_ShaderObject) OpenGl_ShaderObject::CreateFromSource (TCollectio
     }
     aSrcInStructs += ";";
   }
-  else if (!aSrcOutStructs.IsEmpty())
+  if (!aSrcOutStructs.IsEmpty())
   {
     aSrcOutStructs += "\n}";
-    if (!theInName.IsEmpty())
+    if (!theOutName.IsEmpty())
     {
       aSrcOutStructs += " ";
       aSrcOutStructs += theOutName;
index 52030ba..334d05b 100755 (executable)
@@ -75,7 +75,13 @@ Standard_CString OpenGl_ShaderProgram::PredefinedKeywords[] =
   "occOitDepthFactor",     // OpenGl_OCCT_OIT_DEPTH_FACTOR
 
   "occTexTrsf2d",          // OpenGl_OCCT_TEXTURE_TRSF2D
-  "occPointSize"           // OpenGl_OCCT_POINT_SIZE
+  "occPointSize",          // OpenGl_OCCT_POINT_SIZE
+
+  "occViewport",           // OpenGl_OCCT_VIEWPORT
+  "occLineWidth",          // OpenGl_OCCT_LINE_WIDTH
+  "occLineFeather",        // OpenGl_OCCT_LINE_FEATHER
+  "occWireframeColor",     // OpenGl_OCCT_WIREFRAME_COLOR
+  "occIsQuadMode",         // OpenGl_OCCT_QUAD_MODE_STATE
 };
 
 namespace
@@ -159,10 +165,6 @@ OpenGl_ShaderProgram::OpenGl_ShaderProgram (const Handle(Graphic3d_ShaderProgram
   myHasTessShader (false)
 {
   memset (myCurrentState, 0, sizeof (myCurrentState));
-  for (GLint aVar = 0; aVar < OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES; ++aVar)
-  {
-    myStateLocations[aVar] = INVALID_LOCATION;
-  }
 }
 
 // =======================================================================
@@ -191,13 +193,12 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
 
   // detect the minimum GLSL version required for defined Shader Objects
 #if defined(GL_ES_VERSION_2_0)
-  if (myHasTessShader
-  || (aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
+  if (myHasTessShader)
   {
     if (!theCtx->IsGlGreaterEqual (3, 2))
     {
       theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
-                           "Error! Geometry and Tessellation shaders require OpenGL ES 3.2+");
+                           "Error! Tessellation shader requires OpenGL ES 3.2+");
       return false;
     }
     else if (aHeaderVer.IsEmpty())
@@ -205,6 +206,34 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
       aHeaderVer = "#version 320 es";
     }
   }
+  else if ((aShaderMask & Graphic3d_TOS_GEOMETRY) != 0)
+  {
+    switch (theCtx->hasGeometryStage)
+    {
+      case OpenGl_FeatureNotAvailable:
+      {
+        theCtx->PushMessage (GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 0, GL_DEBUG_SEVERITY_HIGH,
+                             "Error! Geometry shader requires OpenGL ES 3.2+ or GL_EXT_geometry_shader");
+        return false;
+      }
+      case OpenGl_FeatureInExtensions:
+      {
+        if (aHeaderVer.IsEmpty())
+        {
+          aHeaderVer = "#version 310 es";
+        }
+        break;
+      }
+      case OpenGl_FeatureInCore:
+      {
+        if (aHeaderVer.IsEmpty())
+        {
+          aHeaderVer = "#version 320 es";
+        }
+        break;
+      }
+    }
+  }
   else if ((aShaderMask & Graphic3d_TOS_COMPUTE) != 0)
   {
     if (!theCtx->IsGlGreaterEqual (3, 1))
@@ -331,6 +360,13 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
       }
 #endif
     }
+#if defined(GL_ES_VERSION_2_0)
+    if (theCtx->hasGeometryStage == OpenGl_FeatureInExtensions)
+    {
+      anExtensions += "#extension GL_EXT_geometry_shader : enable\n"
+                      "#extension GL_EXT_shader_io_blocks : enable\n";
+    }
+#endif
 
     TCollection_AsciiString aPrecisionHeader;
     if (anIter.Value()->Type() == Graphic3d_TOS_FRAGMENT)
@@ -434,19 +470,13 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
   // set uniform defaults
   const Handle(OpenGl_ShaderProgram)& anOldProgram = theCtx->ActiveProgram();
   theCtx->core20fwd->glUseProgram (myProgramID);
+  if (const OpenGl_ShaderUniformLocation aLocTexEnable = GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE))
   {
-    const GLint aLocTexEnable = GetStateLocation (OpenGl_OCCT_TEXTURE_ENABLE);
-    if (aLocTexEnable != INVALID_LOCATION)
-    {
-      SetUniform (theCtx, aLocTexEnable, 0); // Off
-    }
+    SetUniform (theCtx, aLocTexEnable, 0); // Off
   }
+  if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, "occActiveSampler"))
   {
-    const GLint aLocSampler = GetUniformLocation (theCtx, "occActiveSampler");
-    if (aLocSampler != INVALID_LOCATION)
-    {
-      SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
-    }
+    SetUniform (theCtx, aLocSampler, GLint(Graphic3d_TextureUnit_0));
   }
 
   const TCollection_AsciiString aSamplerNamePrefix ("occSampler");
@@ -454,8 +484,7 @@ Standard_Boolean OpenGl_ShaderProgram::Initialize (const Handle(OpenGl_Context)&
   for (GLint aUnitIter = 0; aUnitIter < aNbUnitsMax; ++aUnitIter)
   {
     const TCollection_AsciiString aName = aSamplerNamePrefix + aUnitIter;
-    const GLint aLocSampler = GetUniformLocation (theCtx, aName.ToCString());
-    if (aLocSampler != INVALID_LOCATION)
+    if (const OpenGl_ShaderUniformLocation aLocSampler = GetUniformLocation (theCtx, aName.ToCString()))
     {
       SetUniform (theCtx, aLocSampler, aUnitIter);
     }
@@ -645,12 +674,12 @@ Standard_Boolean OpenGl_ShaderProgram::ApplyVariables(const Handle(OpenGl_Contex
 // function : GetUniformLocation
 // purpose  : Returns location (index) of the specific uniform variable
 // =======================================================================
-GLint OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
-                                                const GLchar*                 theName) const
+OpenGl_ShaderUniformLocation OpenGl_ShaderProgram::GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
+                                                                       const GLchar*                 theName) const
 {
-  return myProgramID != NO_PROGRAM
-       ? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
-       : INVALID_LOCATION;
+  return OpenGl_ShaderUniformLocation (myProgramID != NO_PROGRAM
+                                     ? theCtx->core20fwd->glGetUniformLocation (myProgramID, theName)
+                                     : INVALID_LOCATION);
 }
 
 // =======================================================================
@@ -665,19 +694,6 @@ GLint OpenGl_ShaderProgram::GetAttributeLocation (const Handle(OpenGl_Context)&
        : INVALID_LOCATION;
 }
 
-// =======================================================================
-// function : GetStateLocation
-// purpose  : Returns location of the OCCT state uniform variable
-// =======================================================================
-GLint OpenGl_ShaderProgram::GetStateLocation (const GLuint theVariable) const
-{
-  if (theVariable < OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES)
-  {
-    return myStateLocations[theVariable];
-  }
-  return INVALID_LOCATION;
-}
-
 // =======================================================================
 // function : GetUniform
 // purpose  : Returns the value of the integer uniform variable
index 3251670..261a2f1 100755 (executable)
@@ -75,6 +75,13 @@ enum OpenGl_StateVariable
   OpenGl_OCCT_TEXTURE_TRSF2D,
   OpenGl_OCCT_POINT_SIZE,
 
+  // Wireframe state
+  OpenGl_OCCT_VIEWPORT,
+  OpenGl_OCCT_LINE_WIDTH,
+  OpenGl_OCCT_LINE_FEATHER,
+  OpenGl_OCCT_WIREFRAME_COLOR,
+  OpenGl_OCCT_QUAD_MODE_STATE,
+
   // DON'T MODIFY THIS ITEM (insert new items before it)
   OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES
 };
@@ -133,6 +140,34 @@ enum OpenGl_UniformStateType
   OpenGl_UniformStateType_NB
 };
 
+//! Simple class represents GLSL program variable location.
+class OpenGl_ShaderUniformLocation
+{
+public:
+  //! Invalid location of uniform/attribute variable.
+  static const GLint INVALID_LOCATION = -1;
+public:
+
+  //! Construct an invalid location.
+  OpenGl_ShaderUniformLocation() : myLocation (INVALID_LOCATION) {}
+
+  //! Constructor with initialization.
+  explicit OpenGl_ShaderUniformLocation (GLint theLocation) : myLocation (theLocation) {}
+
+  //! Note you may safely put invalid location in functions like glUniform* - the data passed in will be silently ignored.
+  //! @return true if location is not equal to -1.
+  bool IsValid() const { return myLocation != INVALID_LOCATION; }
+
+  //! Return TRUE for non-invalid location.
+  operator bool() const { return myLocation != INVALID_LOCATION; }
+
+  //! Convert operators help silently put object to GL functions like glUniform*.
+  operator GLint() const { return myLocation; }
+
+private:
+  GLint myLocation;
+};
+
 //! Wrapper for OpenGL program object.
 class OpenGl_ShaderProgram : public OpenGl_NamedResource
 {
@@ -270,15 +305,15 @@ private:
 public:
 
   //! Returns location of the specific uniform variable.
-  Standard_EXPORT GLint GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
-                                            const GLchar*                 theName) const;
+  Standard_EXPORT OpenGl_ShaderUniformLocation GetUniformLocation (const Handle(OpenGl_Context)& theCtx,
+                                                                   const GLchar*                 theName) const;
 
   //! Returns index of the generic vertex attribute by variable name.
   Standard_EXPORT GLint GetAttributeLocation (const Handle(OpenGl_Context)& theCtx,
                                               const GLchar*                 theName) const;
 
   //! Returns location of the OCCT state uniform variable.
-  Standard_EXPORT GLint GetStateLocation (const GLuint theVariable) const;
+  const OpenGl_ShaderUniformLocation& GetStateLocation (OpenGl_StateVariable theVariable) const { return myStateLocations[theVariable]; }
 
 public:
 
@@ -603,7 +638,7 @@ protected:
   Standard_Size myCurrentState[OpenGl_UniformStateType_NB]; //!< defines last modification for variables of each state type
 
   //! Stores locations of OCCT state uniform variables.
-  GLint myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
+  OpenGl_ShaderUniformLocation myStateLocations[OpenGl_OCCT_NUMBER_OF_STATE_VARIABLES];
 
 };
 
index 3ca3e6a..db29f33 100644 (file)
@@ -393,10 +393,22 @@ void OpenGl_Text::Render (const Handle(OpenGl_Context)& theCtx,
                           const OpenGl_AspectText&      theTextAspect,
                           const unsigned int            theResolution) const
 {
+  const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
+#if !defined(GL_ES_VERSION_2_0)
+  const Standard_Integer aPrevPolygonMode  = theCtx->SetPolygonMode (GL_FILL);
+  const bool             aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
+#endif
+
   render (theCtx, theTextAspect,
           theTextAspect.Aspect()->ColorRGBA(),
           theTextAspect.Aspect()->ColorSubTitleRGBA(),
           theResolution);
+
+#if !defined(GL_ES_VERSION_2_0)
+  theCtx->SetPolygonMode         (aPrevPolygonMode);
+  theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
+#endif
+  theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
 }
 
 // =======================================================================
@@ -771,9 +783,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   {
     glDisable (GL_LIGHTING);
   }
-
-  const Standard_Integer aPrevPolygonMode  = theCtx->SetPolygonMode (GL_FILL);
-  const bool             aPrevHatchingMode = theCtx->SetPolygonHatchEnabled (false);
 #endif
 
   // setup depth test
@@ -806,7 +815,6 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   // setup blending
   glEnable (GL_BLEND);
   glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-  const bool anAlphaToCoverageOld = theCtx->SetSampleAlphaToCoverage (false);
 
   // extra drawings
   switch (theTextAspect.Aspect()->DisplayType())
@@ -904,11 +912,7 @@ void OpenGl_Text::render (const Handle(OpenGl_Context)& theCtx,
   glDisable (GL_STENCIL_TEST);
 #if !defined(GL_ES_VERSION_2_0)
   glDisable (GL_COLOR_LOGIC_OP);
-
-  theCtx->SetPolygonMode         (aPrevPolygonMode);
-  theCtx->SetPolygonHatchEnabled (aPrevHatchingMode);
 #endif
-  theCtx->SetSampleAlphaToCoverage (anAlphaToCoverageOld);
 
   // model view matrix was modified
   theCtx->WorldViewState.Pop();
index ceecfea..edeed69 100644 (file)
@@ -167,6 +167,7 @@ void OpenGl_View::Redraw()
   Graphic3d_Camera::Projection aProjectType = myCamera->ProjectionType();
   Handle(OpenGl_Context)       aCtx         = myWorkspace->GetGlContext();
   aCtx->FrameStats()->FrameStart (myWorkspace->View(), false);
+  aCtx->SetLineFeather (myRenderParams.LineFeather);
 
   // release pending GL resources
   aCtx->ReleaseDelayed();
@@ -878,7 +879,9 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
   // ==================================
 
   const Handle(OpenGl_Context)& aContext = myWorkspace->GetGlContext();
-  aContext->SetSampleAlphaToCoverage (myRenderParams.ToEnableAlphaToCoverage);
+  aContext->SetAllowSampleAlphaToCoverage (myRenderParams.ToEnableAlphaToCoverage
+                                        && theOutputFBO != NULL
+                                        && theOutputFBO->NbSamples() != 0);
 
 #if !defined(GL_ES_VERSION_2_0)
   // Disable current clipping planes
@@ -1043,6 +1046,7 @@ void OpenGl_View::render (Graphic3d_Camera::Projection theProjection,
   }
 
   myWorkspace->ResetAppliedAspect();
+  aContext->SetAllowSampleAlphaToCoverage (false);
   aContext->SetSampleAlphaToCoverage (false);
 
   // reset FFP state for safety
index ab9fa99..e441c89 100644 (file)
@@ -155,7 +155,7 @@ OpenGl_Workspace::OpenGl_Workspace (OpenGl_View* theView, const Handle(OpenGl_Wi
   #endif
   }
 
-  myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Mask, 0.285f);
+  myFontFaceAspect.Aspect()->SetAlphaMode (Graphic3d_AlphaMode_Blend, 0.285f);
   myFontFaceAspect.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
 
   myNoneCulling .Aspect()->SetSuppressBackFaces (false);
@@ -193,6 +193,14 @@ Standard_Boolean OpenGl_Workspace::Activate()
   {
     myGlContext->ShaderManager()->PushState (Handle(OpenGl_ShaderProgram)());
   }
+
+#if !defined(GL_ES_VERSION_2_0)
+  // font GLSL program has embedded discard, while FFP needs alpha test
+  myFontFaceAspect.Aspect()->SetAlphaMode ((!myGlContext->caps->ffpEnable && myGlContext->core11 != NULL)
+                                          ? Graphic3d_AlphaMode_Blend
+                                          : Graphic3d_AlphaMode_Mask,
+                                           0.285f);
+#endif
   return Standard_True;
 }
 
@@ -316,60 +324,38 @@ const OpenGl_AspectFace* OpenGl_Workspace::ApplyAspectFace()
   }
   myAspectFaceAppliedWithHL = myHighlightStyle;
 
-#if !defined(GL_ES_VERSION_2_0)
+  // Aspect_POM_None means: do not change current settings
+  if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
+  {
+    myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
+  }
+
   const Aspect_InteriorStyle anIntstyle = myAspectFaceSet->Aspect()->InteriorStyle();
   if (myAspectFaceApplied.IsNull()
    || myAspectFaceApplied->InteriorStyle() != anIntstyle)
   {
-    switch (anIntstyle)
-    {
-      case Aspect_IS_EMPTY:
-      case Aspect_IS_HOLLOW:
-      {
-        myGlContext->SetPolygonMode (GL_LINE);
-        break;
-      }
-      case Aspect_IS_HATCH:
-      {
-        myGlContext->SetPolygonMode (GL_FILL);
-        myGlContext->SetPolygonHatchEnabled (true);
-        break;
-      }
-      case Aspect_IS_SOLID:
-      case Aspect_IS_HIDDENLINE:
-      {
-        myGlContext->SetPolygonMode (GL_FILL);
-        myGlContext->SetPolygonHatchEnabled (false);
-        break;
-      }
-      case Aspect_IS_POINT:
-      {
-        myGlContext->SetPolygonMode (GL_POINT);
-        break;
-      }
-    }
+  #if !defined(GL_ES_VERSION_2_0)
+    myGlContext->SetPolygonMode (anIntstyle == Aspect_IS_POINT ? GL_POINT : GL_FILL);
+    myGlContext->SetPolygonHatchEnabled (anIntstyle == Aspect_IS_HATCH);
+  #endif
   }
 
+#if !defined(GL_ES_VERSION_2_0)
   if (anIntstyle == Aspect_IS_HATCH)
   {
     myGlContext->SetPolygonHatchStyle (myAspectFaceSet->Aspect()->HatchStyle());
   }
 #endif
 
-  // Aspect_POM_None means: do not change current settings
-  if ((myAspectFaceSet->Aspect()->PolygonOffset().Mode & Aspect_POM_None) != Aspect_POM_None)
-  {
-    myGlContext->SetPolygonOffset (myAspectFaceSet->Aspect()->PolygonOffset());
-  }
-
   // Case of hidden line
-  if (myAspectFaceSet->Aspect()->InteriorStyle() == Aspect_IS_HIDDENLINE)
+  if (anIntstyle == Aspect_IS_HIDDENLINE)
   {
     // copy all values including line edge aspect
     *myAspectFaceHl.Aspect() = *myAspectFaceSet->Aspect();
     myAspectFaceHl.SetAspectEdge (myAspectFaceSet->AspectEdge());
     myAspectFaceHl.Aspect()->SetShadingModel (Graphic3d_TOSM_UNLIT);
     myAspectFaceHl.Aspect()->SetInteriorColor (myView->BackgroundColor().GetRGB());
+    myAspectFaceHl.Aspect()->SetDistinguish (false);
     myAspectFaceHl.SetNoLighting();
     myAspectFaceSet = &myAspectFaceHl;
   }
index e9a4df2..8d4bb7a 100644 (file)
 
 IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes)
 
+namespace
+{
+  static const Quantity_NameOfColor THE_DEF_COLOR_FreeBoundary   = Quantity_NOC_GREEN;
+  static const Quantity_NameOfColor THE_DEF_COLOR_UnFreeBoundary = Quantity_NOC_YELLOW;
+  static const Quantity_NameOfColor THE_DEF_COLOR_FaceBoundary   = Quantity_NOC_BLACK;
+  static const Quantity_NameOfColor THE_DEF_COLOR_Wire           = Quantity_NOC_RED;
+  static const Quantity_NameOfColor THE_DEF_COLOR_Line           = Quantity_NOC_YELLOW;
+  static const Quantity_NameOfColor THE_DEF_COLOR_SeenLine       = Quantity_NOC_YELLOW;
+  static const Quantity_NameOfColor THE_DEF_COLOR_HiddenLine     = Quantity_NOC_YELLOW;
+  static const Quantity_NameOfColor THE_DEF_COLOR_Vector         = Quantity_NOC_SKYBLUE;
+  static const Quantity_NameOfColor THE_DEF_COLOR_Section        = Quantity_NOC_ORANGE;
+}
+
 // =======================================================================
 // function : Prs3d_Drawer
 // purpose  :
@@ -270,7 +283,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FreeBoundaryAspect()
     }
     if (myFreeBoundaryAspect.IsNull())
     {
-      myFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
+      myFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FreeBoundary, Aspect_TOL_SOLID, 1.0);
     }
   }
   return myFreeBoundaryAspect;
@@ -313,7 +326,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::UnFreeBoundaryAspect()
     }
     if (myUnFreeBoundaryAspect.IsNull())
     {
-      myUnFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
+      myUnFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_UnFreeBoundary, Aspect_TOL_SOLID, 1.0);
     }
   }
   return myUnFreeBoundaryAspect;
@@ -356,7 +369,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FaceBoundaryAspect()
     }
     if (myFaceBoundaryAspect.IsNull())
     {
-      myFaceBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
+      myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0);
     }
   }
   return myFaceBoundaryAspect;
@@ -539,7 +552,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::WireAspect()
     }
     if (myWireAspect.IsNull())
     {
-      myWireAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+      myWireAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Wire, Aspect_TOL_SOLID, 1.0);
     }
   }
   return myWireAspect;
@@ -588,6 +601,30 @@ const Handle(Prs3d_PointAspect)& Prs3d_Drawer::PointAspect()
   return myPointAspect;
 }
 
+// =======================================================================
+// function : SetupOwnPointAspect
+// purpose  :
+// =======================================================================
+Standard_Boolean Prs3d_Drawer::SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults)
+{
+  if (myHasOwnPointAspect)
+  {
+    return Standard_False;
+  }
+
+  myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
+  if (!theDefaults.IsNull() && theDefaults != this)
+  {
+    *myPointAspect->Aspect() = *theDefaults->PointAspect()->Aspect();
+  }
+  else if (!myLink.IsNull())
+  {
+    *myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
+  }
+  myHasOwnPointAspect = Standard_True;
+  return Standard_True;
+}
+
 // =======================================================================
 // function : SetPointAspect
 // purpose  :
@@ -614,7 +651,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::LineAspect()
     }
     if (myLineAspect.IsNull())
     {
-      myLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
+      myLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Line, Aspect_TOL_SOLID, 1.0);
     }
   }
   return myLineAspect;
@@ -684,6 +721,30 @@ const Handle(Prs3d_ShadingAspect)& Prs3d_Drawer::ShadingAspect()
   return myShadingAspect;
 }
 
+// =======================================================================
+// function : SetupOwnShadingAspect
+// purpose  :
+// =======================================================================
+Standard_Boolean Prs3d_Drawer::SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults)
+{
+  if (myHasOwnShadingAspect)
+  {
+    return Standard_False;
+  }
+
+  myShadingAspect = new Prs3d_ShadingAspect();
+  if (!theDefaults.IsNull() && theDefaults != this)
+  {
+    *myShadingAspect->Aspect() = *theDefaults->ShadingAspect()->Aspect();
+  }
+  else if (!myLink.IsNull())
+  {
+    *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
+  }
+  myHasOwnShadingAspect = Standard_True;
+  return Standard_True;
+}
+
 // =======================================================================
 // function : SetShadingAspect
 // purpose  :
@@ -742,7 +803,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SeenLineAspect()
     }
     if (mySeenLineAspect.IsNull())
     {
-      mySeenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
+      mySeenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_SeenLine, Aspect_TOL_SOLID, 1.0);
     }
   }
   return mySeenLineAspect;
@@ -817,7 +878,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::HiddenLineAspect()
     }
     if (myHiddenLineAspect.IsNull())
     {
-      myHiddenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_DASH, 1.0);
+      myHiddenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_HiddenLine, Aspect_TOL_DASH, 1.0);
     }
   }
   return myHiddenLineAspect;
@@ -871,7 +932,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::VectorAspect()
     }
     if (myVectorAspect.IsNull())
     {
-      myVectorAspect = new Prs3d_LineAspect (Quantity_NOC_SKYBLUE, Aspect_TOL_SOLID, 1.0);
+      myVectorAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Vector, Aspect_TOL_SOLID, 1.0);
     }
   }
   return myVectorAspect;
@@ -966,7 +1027,7 @@ const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SectionAspect()
     }
     if (mySectionAspect.IsNull())
     {
-      mySectionAspect = new Prs3d_LineAspect (Quantity_NOC_ORANGE, Aspect_TOL_SOLID, 1.0);
+      mySectionAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Section, Aspect_TOL_SOLID, 1.0);
     }
   }
   return mySectionAspect;
@@ -1059,17 +1120,156 @@ void Prs3d_Drawer::ClearLocalAttributes()
   myTypeOfHLR      = Prs3d_TOH_NotSet;
 }
 
-//! Copy line aspect defaults from the Link.
-inline void copyLineAspect (const Handle(Prs3d_Drawer)&     theLink,
-                            Handle(Prs3d_LineAspect)&       theAspect,
-                            const Handle(Prs3d_LineAspect)& theBaseAspect)
+// =======================================================================
+// function : SetOwnLineAspects
+// purpose  :
+// =======================================================================
+Standard_Boolean Prs3d_Drawer::SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults)
+{
+  bool isUpdateNeeded = false;
+  const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
+  if (!myHasOwnUIsoAspect)
+  {
+    isUpdateNeeded = true;
+    myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
+    if (!aLink.IsNull())
+    {
+      *myUIsoAspect->Aspect() = *aLink->UIsoAspect()->Aspect();
+      myUIsoAspect->SetNumber (aLink->UIsoAspect()->Number());
+    }
+    myHasOwnUIsoAspect = true;
+  }
+  if (!myHasOwnVIsoAspect)
+  {
+    isUpdateNeeded = true;
+    myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
+    if (!aLink.IsNull())
+    {
+      *myVIsoAspect->Aspect() = *aLink->VIsoAspect()->Aspect();
+      myUIsoAspect->SetNumber (aLink->VIsoAspect()->Number());
+    }
+    myHasOwnVIsoAspect = true;
+  }
+  if (!myHasOwnWireAspect)
+  {
+    isUpdateNeeded = true;
+    myWireAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Wire, Aspect_TOL_SOLID, 1.0);
+    myHasOwnWireAspect = true;
+    if (!aLink.IsNull())
+    {
+      *myWireAspect->Aspect() = *aLink->WireAspect()->Aspect();
+    }
+  }
+  if (!myHasOwnLineAspect)
+  {
+    isUpdateNeeded = true;
+    myLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Line, Aspect_TOL_SOLID, 1.0);
+    myHasOwnLineAspect = true;
+    if (!aLink.IsNull())
+    {
+      *myLineAspect->Aspect() = *aLink->LineAspect()->Aspect();
+    }
+  }
+  if (!myHasOwnSeenLineAspect)
+  {
+    isUpdateNeeded = true;
+    mySeenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_SeenLine, Aspect_TOL_SOLID, 1.0);
+    myHasOwnSeenLineAspect = true;
+    if (!aLink.IsNull())
+    {
+      *mySeenLineAspect->Aspect() = *aLink->SeenLineAspect()->Aspect();
+    }
+  }
+  if (!myHasOwnHiddenLineAspect)
+  {
+    isUpdateNeeded = true;
+    myHiddenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_HiddenLine, Aspect_TOL_DASH, 1.0);
+    myHasOwnHiddenLineAspect = true;
+    if (!aLink.IsNull())
+    {
+      *myHiddenLineAspect->Aspect() = *aLink->HiddenLineAspect()->Aspect();
+    }
+  }
+  if (!myHasOwnFreeBoundaryAspect)
+  {
+    isUpdateNeeded = true;
+    myFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FreeBoundary, Aspect_TOL_SOLID, 1.0);
+    myHasOwnFreeBoundaryAspect = true;
+    if (!aLink.IsNull())
+    {
+      *myFreeBoundaryAspect->Aspect() = *aLink->FreeBoundaryAspect()->Aspect();
+    }
+  }
+  if (!myHasOwnUnFreeBoundaryAspect)
+  {
+    isUpdateNeeded = true;
+    myUnFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_UnFreeBoundary, Aspect_TOL_SOLID, 1.0);
+    myHasOwnUnFreeBoundaryAspect = true;
+    if (!aLink.IsNull())
+    {
+      *myUnFreeBoundaryAspect->Aspect() = *aLink->UnFreeBoundaryAspect()->Aspect();
+    }
+  }
+  if (!myHasOwnFaceBoundaryAspect)
+  {
+    isUpdateNeeded = true;
+    myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0);
+    myHasOwnFaceBoundaryAspect = true;
+    if (!aLink.IsNull())
+    {
+      *myFaceBoundaryAspect->Aspect() = *aLink->FaceBoundaryAspect()->Aspect();
+    }
+  }
+  return isUpdateNeeded;
+}
+
+// =======================================================================
+// function : SetOwnDatumAspects
+// purpose  :
+// =======================================================================
+Standard_Boolean Prs3d_Drawer::SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults)
 {
-  Handle(Prs3d_LineAspect) aBaseAspect = theBaseAspect;
-  if (!theLink.IsNull())
+  bool isUpdateNeeded = false;
+  const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
+  if (!myHasOwnVectorAspect)
+  {
+    isUpdateNeeded = true;
+    myVectorAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Vector, Aspect_TOL_SOLID, 1.0);
+    myHasOwnVectorAspect = true;
+    if (!aLink.IsNull())
+    {
+      *myVectorAspect->Aspect() = *aLink->VectorAspect()->Aspect();
+    }
+  }
+  if (!myHasOwnSectionAspect)
+  {
+    isUpdateNeeded = true;
+    mySectionAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Section, Aspect_TOL_SOLID, 1.0);
+    myHasOwnSectionAspect = true;
+    if (!aLink.IsNull())
+    {
+      *mySectionAspect->Aspect() = *aLink->SectionAspect()->Aspect();
+    }
+  }
+  if (!myHasOwnPlaneAspect)
+  {
+    isUpdateNeeded = true;
+    myPlaneAspect = new Prs3d_PlaneAspect();
+    myHasOwnPlaneAspect = true;
+  }
+  if (!myHasOwnArrowAspect)
+  {
+    isUpdateNeeded = true;
+    myArrowAspect = new Prs3d_ArrowAspect();
+    myHasOwnArrowAspect = true;
+  }
+  if (!myHasOwnDatumAspect)
   {
-    theAspect = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
-    *theAspect->Aspect() = *aBaseAspect->Aspect();
+    isUpdateNeeded = true;
+    myDatumAspect = new Prs3d_DatumAspect();
+    myHasOwnDatumAspect = true;
   }
+  return isUpdateNeeded;
 }
 
 //! Assign the shader program.
@@ -1100,103 +1300,8 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
     {
       if (theToOverrideDefaults)
       {
-        if (!myHasOwnUIsoAspect)
-        {
-          isUpdateNeeded = true;
-          Handle(Prs3d_IsoAspect) anAspect = UIsoAspect();
-          if (!myLink.IsNull())
-          {
-            myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
-            *myUIsoAspect->Aspect() = *anAspect->Aspect();
-            myUIsoAspect->SetNumber (anAspect->Number());
-          }
-          myHasOwnUIsoAspect = true;
-        }
-        if (!myHasOwnVIsoAspect)
-        {
-          isUpdateNeeded = true;
-          Handle(Prs3d_IsoAspect) anAspect = VIsoAspect();
-          if (!myLink.IsNull())
-          {
-            myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
-            *myVIsoAspect->Aspect() = *anAspect->Aspect();
-            myUIsoAspect->SetNumber (anAspect->Number());
-          }
-          myHasOwnVIsoAspect = true;
-        }
-        if (!myHasOwnWireAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, myWireAspect, WireAspect());
-          myHasOwnWireAspect = true;
-        }
-        if (!myHasOwnLineAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, myLineAspect, LineAspect());
-          myHasOwnLineAspect = true;
-        }
-        if (!myHasOwnSeenLineAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, mySeenLineAspect, SeenLineAspect());
-          myHasOwnSeenLineAspect = true;
-        }
-        if (!myHasOwnHiddenLineAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, myHiddenLineAspect, HiddenLineAspect());
-          myHasOwnHiddenLineAspect = true;
-        }
-        if (!myHasOwnVectorAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, myVectorAspect, VectorAspect());
-          myHasOwnVectorAspect = true;
-        }
-        if (!myHasOwnSectionAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, mySectionAspect, SectionAspect());
-          myHasOwnSectionAspect = true;
-        }
-        if (!myHasOwnFreeBoundaryAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, myFreeBoundaryAspect, FreeBoundaryAspect());
-          myHasOwnFreeBoundaryAspect = true;
-        }
-        if (!myHasOwnUnFreeBoundaryAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, myUnFreeBoundaryAspect, UnFreeBoundaryAspect());
-          myHasOwnUnFreeBoundaryAspect = true;
-        }
-        if (!myHasOwnFaceBoundaryAspect)
-        {
-          isUpdateNeeded = true;
-          copyLineAspect (myLink, myFaceBoundaryAspect, FaceBoundaryAspect());
-          myHasOwnFaceBoundaryAspect = true;
-        }
-
-        if (!myHasOwnPlaneAspect)
-        {
-          isUpdateNeeded = true;
-          myPlaneAspect = new Prs3d_PlaneAspect();
-          myHasOwnPlaneAspect = true;
-        }
-        if (!myHasOwnArrowAspect)
-        {
-          isUpdateNeeded = true;
-          myArrowAspect = new Prs3d_ArrowAspect();
-          myHasOwnArrowAspect = true;
-        }
-        if (!myHasOwnDatumAspect)
-        {
-          isUpdateNeeded = true;
-          myDatumAspect = new Prs3d_DatumAspect();
-          myHasOwnDatumAspect = true;
-        }
+        isUpdateNeeded = SetOwnLineAspects()  || isUpdateNeeded;
+        isUpdateNeeded = SetOwnDatumAspects() || isUpdateNeeded;
       }
 
       setAspectProgram (theProgram, myHasOwnUIsoAspect, myUIsoAspect);
@@ -1245,15 +1350,9 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
     case Graphic3d_ASPECT_MARKER:
     {
       if (theToOverrideDefaults
-      && !myHasOwnPointAspect)
+       && SetupOwnPointAspect())
       {
         isUpdateNeeded = true;
-        myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
-        myHasOwnPointAspect = true;
-        if (!myLink.IsNull())
-        {
-          *myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
-        }
       }
 
       setAspectProgram (theProgram, myHasOwnPointAspect, myPointAspect);
@@ -1262,15 +1361,9 @@ bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theP
     case Graphic3d_ASPECT_FILL_AREA:
     {
       if (theToOverrideDefaults
-      && !myHasOwnShadingAspect)
+       && SetupOwnShadingAspect())
       {
         isUpdateNeeded = true;
-        myShadingAspect = new Prs3d_ShadingAspect();
-        myHasOwnShadingAspect = true;
-        if (!myLink.IsNull())
-        {
-          *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
-        }
       }
       setAspectProgram (theProgram, myHasOwnShadingAspect, myShadingAspect);
       return isUpdateNeeded;
@@ -1289,15 +1382,9 @@ bool Prs3d_Drawer::SetShadingModel (Graphic3d_TypeOfShadingModel theModel,
   bool isUpdateNeeded = false;
 
   if (theToOverrideDefaults
-  && !myHasOwnShadingAspect)
+   && SetupOwnShadingAspect())
   {
     isUpdateNeeded  = true;
-    myShadingAspect = new Prs3d_ShadingAspect();
-    myHasOwnShadingAspect = true;
-    if (!myLink.IsNull())
-    {
-      *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
-    }
   }
 
   if (!myShadingAspect.IsNull()
index dabfc1c..a2a80ac 100644 (file)
@@ -439,6 +439,10 @@ public:
   //! point aspect that overrides the one in the link.
   Standard_Boolean HasOwnPointAspect() const { return myHasOwnPointAspect; }
 
+  //! Sets own point aspect.
+  //! Returns FALSE if the drawer already has its own attribute for point aspect.
+  Standard_EXPORT Standard_Boolean SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
   //! Returns settings for line aspects.
   //! These settings can be edited. The default values are:
   //!   Color: Quantity_NOC_YELLOW
@@ -457,6 +461,14 @@ public:
   //! line aspect that overrides the one in the link.
   Standard_Boolean HasOwnLineAspect() const { return myHasOwnLineAspect; }
 
+  //! Sets own line aspects.
+  //! Returns FALSE if own line aspect are already set.
+  Standard_EXPORT Standard_Boolean SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
+  //! Sets own line aspects for datums.
+  //! Returns FALSE if own line for datums are already set.
+  Standard_EXPORT Standard_Boolean SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
   //! Returns settings for text aspect.
   //! These settings can be edited. The default value is:
   //! - Color: Quantity_NOC_YELLOW
@@ -487,6 +499,10 @@ public:
   //! shading aspect that overrides the one in the link.
   Standard_Boolean HasOwnShadingAspect() const { return myHasOwnShadingAspect; }
 
+  //! Sets own shading aspect.
+  //! Returns FALSE if the drawer already has its own attribute for shading aspect.
+  Standard_EXPORT Standard_Boolean SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
+
   //! Returns settings for seen line aspects.
   //! These settings can be edited. The default values are:
   //!   Color: Quantity_NOC_YELLOW
index 7e13b24..fd015d2 100644 (file)
@@ -3,7 +3,6 @@ QABugs.hxx
 QABugs_1.cxx
 QABugs_2.cxx
 QABugs_3.cxx
-QABugs_4.cxx
 QABugs_5.cxx
 QABugs_6.cxx
 QABugs_7.cxx
index 9449d71..1a9cd06 100644 (file)
@@ -19,7 +19,6 @@ void QABugs::Commands(Draw_Interpretor& theCommands) {
   QABugs::Commands_1(theCommands);
   QABugs::Commands_2(theCommands);
   QABugs::Commands_3(theCommands);
-  QABugs::Commands_4(theCommands);
   QABugs::Commands_5(theCommands);
   QABugs::Commands_6(theCommands);
   QABugs::Commands_7(theCommands);
index bfd1a98..fbe9086 100644 (file)
@@ -40,9 +40,7 @@ public:
   Standard_EXPORT static void Commands_2 (Draw_Interpretor& DI);
   
   Standard_EXPORT static void Commands_3 (Draw_Interpretor& DI);
-  
-  Standard_EXPORT static void Commands_4 (Draw_Interpretor& DI);
-  
+
   Standard_EXPORT static void Commands_5 (Draw_Interpretor& DI);
   
   Standard_EXPORT static void Commands_6 (Draw_Interpretor& DI);
diff --git a/src/QABugs/QABugs_4.cxx b/src/QABugs/QABugs_4.cxx
deleted file mode 100644 (file)
index 63d376f..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-// Created on: 2002-03-19
-// Created by: QA Admin
-// Copyright (c) 2002-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.
-
-#include <QABugs.hxx>
-
-#include <Draw_Interpretor.hxx>
-#include <DBRep.hxx>
-#include <DrawTrSurf.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <ViewerTest.hxx>
-#include <AIS_Shape.hxx>
-#include <TopoDS_Shape.hxx>
-
-#include <BRepPrimAPI_MakeSphere.hxx>
-#include <Graphic3d_AspectFillArea3d.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_ShadingAspect.hxx>
-
-//#include <AcisData_AcisModel.hxx>
-#include <TopTools_HSequenceOfShape.hxx>
-
-static Standard_Integer BUC60738 (Draw_Interpretor& di, Standard_Integer /*argc*/, const char ** argv)
-{
-  
-  Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext();
-  if(aContext.IsNull()) { 
-    di << "use 'vinit' command before " << argv[0] << "\n";
-    return -1;
-  }
-  
-  TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(-40,0,0),20).Shape();
-  Handle(AIS_Shape) theAISShape = new AIS_Shape(theSphere);
-
-  //display mode = Shading
-  theAISShape->SetDisplayMode(1);
-
-  //get the drawer
-  Handle(Prs3d_Drawer) theDrawer = theAISShape->Attributes();
-  Handle(Prs3d_ShadingAspect) theShadingAspect = theDrawer->ShadingAspect();
-  Handle(Graphic3d_AspectFillArea3d) theAspectFillArea3d = theShadingAspect->Aspect();
-
-  //allow to display the edges
-  theAspectFillArea3d->SetEdgeOn();
-  //set the style to Dash
-
-  //but the style is not set to dash : it is always solid
-  theAspectFillArea3d->SetEdgeLineType (Aspect_TOL_DASH); 
-  theAspectFillArea3d->SetEdgeColor(Quantity_Color(Quantity_NOC_GREEN)); 
-  theAspectFillArea3d->SetInteriorStyle(Aspect_IS_EMPTY);
-  theShadingAspect->SetAspect(theAspectFillArea3d);
-  theDrawer->SetShadingAspect(theShadingAspect);
-  theAISShape->SetAttributes(theDrawer);
-
-  aContext->Display (theAISShape, Standard_True);
-  
-  return 0;
-}
-
-void QABugs::Commands_4(Draw_Interpretor& theCommands) {
-  const char *group = "QABugs";
-
-  theCommands.Add("BUC60738","BUC60738",__FILE__,BUC60738,group);
-
-  return;
-}
index 96bbcae..8fe1b64 100644 (file)
@@ -93,51 +93,65 @@ Quantity_NameOfColor ViewerTest::GetColorFromName (const Standard_CString theNam
   return aColor;
 }
 
+
 //=======================================================================
-//function : ParseColor
+//function : parseColor
 //purpose  :
 //=======================================================================
-
-Standard_Integer ViewerTest::ParseColor (Standard_Integer  theArgNb,
+Standard_Integer ViewerTest::parseColor (Standard_Integer  theArgNb,
                                          const char**      theArgVec,
-                                         Quantity_Color&   theColor)
+                                         Quantity_ColorRGBA& theColor,
+                                         bool theToParseAlpha)
 {
   Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
   if (theArgNb >= 1
    && Quantity_Color::ColorFromName (theArgVec[0], aColor))
   {
-    theColor = aColor;
+    theColor = Quantity_ColorRGBA (aColor);
+    if (theArgNb >= 2
+     && theToParseAlpha)
+    {
+      const TCollection_AsciiString anAlphaStr (theArgVec[1]);
+      if (anAlphaStr.IsRealValue())
+      {
+        float anAlpha = (float )anAlphaStr.RealValue();
+        if (anAlpha < 0.0f || anAlpha > 1.0f)
+        {
+          std::cout << "Syntax error: alpha should be within range 0..1!\n";
+          return 0;
+        }
+        return 2;
+      }
+    }
     return 1;
   }
   else if (theArgNb >= 3)
   {
-    const TCollection_AsciiString anRgbStr[3] =
-    {
-      theArgVec[0],
-      theArgVec[1],
-      theArgVec[2]
-    };
-    if (!anRgbStr[0].IsRealValue()
-     || !anRgbStr[1].IsRealValue()
-     || !anRgbStr[2].IsRealValue())
+    Graphic3d_Vec4 anRgba;
+    Standard_Integer aNbComps = Min (theArgNb, theToParseAlpha ? 4 : 3);
+    for (int aCompIter = 0; aCompIter < aNbComps; ++aCompIter)
     {
-      return 0;
-    }
+      const TCollection_AsciiString anRgbaStr (theArgVec[aCompIter]);
+      if (!anRgbaStr.IsRealValue())
+      {
+        if (aCompIter == 3)
+        {
+          anRgba.a() = 1.0f;
+          aNbComps = 3;
+          break;
+        }
+        return 0;
+      }
 
-    Graphic3d_Vec4d anRgb;
-    anRgb.x() = anRgbStr[0].RealValue();
-    anRgb.y() = anRgbStr[1].RealValue();
-    anRgb.z() = anRgbStr[2].RealValue();
-    if (anRgb.x() < 0.0 || anRgb.x() > 1.0
-     || anRgb.y() < 0.0 || anRgb.y() > 1.0
-     || anRgb.z() < 0.0 || anRgb.z() > 1.0)
-    {
-      std::cout << "Error: RGB color values should be within range 0..1!\n";
-      return 0;
+      anRgba[aCompIter] = (float )anRgbaStr.RealValue();
+      if (anRgba[aCompIter] < 0.0 || anRgba[aCompIter] > 1.0)
+      {
+        std::cout << "Error: RGBA color values should be within range 0..1!\n";
+        return 0;
+      }
     }
-
-    theColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
-    return 3;
+    theColor = Quantity_ColorRGBA (anRgba);
+    return aNbComps;
   }
 
   return 0;
@@ -212,15 +226,19 @@ Standard_Boolean ViewerTest::ParseLineType (Standard_CString   theArg,
   {
     theType = Aspect_TOL_DOTDASH;
   }
-  else
+  else if (aTypeStr.IsIntegerValue())
   {
-    const int aTypeInt = Draw::Atoi (theArg);
+    const int aTypeInt = aTypeStr.IntegerValue();
     if (aTypeInt < -1 || aTypeInt >= Aspect_TOL_USERDEFINED)
     {
       return Standard_False;
     }
     theType = (Aspect_TypeOfLine )aTypeInt;
   }
+  else
+  {
+    return Standard_False;
+  }
   return Standard_True;
 }
 
@@ -1492,106 +1510,52 @@ private:
 
 };
 
-//==============================================================================
-//function : VInteriorStyle
-//purpose  : sets interior style of the a selected or named or displayed shape
-//==============================================================================
-static int VSetInteriorStyle (Draw_Interpretor& theDI,
-                              Standard_Integer  theArgNb,
-                              const char**      theArgVec)
+//! Parse interior style name.
+static bool parseInteriorStyle (const TCollection_AsciiString& theArg,
+                                Aspect_InteriorStyle& theStyle)
 {
-  const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
-  ViewerTest_AutoUpdater anUpdateTool (aCtx, ViewerTest::CurrentView());
-  if (aCtx.IsNull())
-  {
-    std::cerr << "Error: no active view!\n";
-    return 1;
-  }
-
-  Standard_Integer anArgIter = 1;
-  for (; anArgIter < theArgNb; ++anArgIter)
-  {
-    if (!anUpdateTool.parseRedrawMode (theArgVec[anArgIter]))
-    {
-      break;
-    }
-  }
-  TCollection_AsciiString aName;
-  if (theArgNb - anArgIter == 2)
-  {
-    aName = theArgVec[anArgIter++];
-  }
-  else if (theArgNb - anArgIter != 1)
-  {
-    std::cout << "Error: wrong number of arguments! See usage:\n";
-    theDI.PrintHelp (theArgVec[0]);
-    return 1;
-  }
-  Aspect_InteriorStyle    anInterStyle = Aspect_IS_SOLID;
-  TCollection_AsciiString aStyleArg (theArgVec[anArgIter++]);
-  aStyleArg.LowerCase();
-  if (aStyleArg == "empty")
+  TCollection_AsciiString anArg (theArg);
+  anArg.LowerCase();
+  if (anArg == "empty")
   {
-    anInterStyle = Aspect_IS_EMPTY;
+    theStyle = Aspect_IS_EMPTY;
   }
-  else if (aStyleArg == "hollow")
+  else if (anArg == "hollow")
   {
-    anInterStyle = Aspect_IS_HOLLOW;
+    theStyle = Aspect_IS_HOLLOW;
   }
-  else if (aStyleArg == "hatch")
+  else if (anArg == "solid")
   {
-    anInterStyle = Aspect_IS_HATCH;
+    theStyle = Aspect_IS_SOLID;
   }
-  else if (aStyleArg == "solid")
+  else if (anArg == "hatch")
   {
-    anInterStyle = Aspect_IS_SOLID;
+    theStyle = Aspect_IS_HATCH;
   }
-  else if (aStyleArg == "hiddenline")
+  else if (anArg == "hiddenline"
+        || anArg == "hidden-line"
+        || anArg == "hidden_line")
   {
-    anInterStyle = Aspect_IS_HIDDENLINE;
+    theStyle = Aspect_IS_HIDDENLINE;
   }
-  else if (aStyleArg == "point")
+  else if (anArg == "point")
   {
-    anInterStyle = Aspect_IS_POINT;
+    theStyle = Aspect_IS_POINT;
   }
-  else
+  else if (theArg.IsIntegerValue())
   {
-    const Standard_Integer anIntStyle = aStyleArg.IntegerValue();
-    if (anIntStyle < Aspect_IS_EMPTY
-     || anIntStyle > Aspect_IS_POINT)
+    const Standard_Integer anIntStyle = theArg.IntegerValue();
+    if (anIntStyle < Aspect_IS_EMPTY || anIntStyle > Aspect_IS_POINT)
     {
-      std::cout << "Error: style must be within a range [0 (Aspect_IS_EMPTY), "
-                << Aspect_IS_POINT << " (Aspect_IS_POINT)]\n";
-      return 1;
+      return false;
     }
-    anInterStyle = (Aspect_InteriorStyle )anIntStyle;
+    theStyle = (Aspect_InteriorStyle)anIntStyle;
   }
-
-  if (!aName.IsEmpty()
-   && !GetMapOfAIS().IsBound2 (aName))
-  {
-    std::cout << "Error: object " << aName << " is not displayed!\n";
-    return 1;
-  }
-
-  for (ViewTest_PrsIter anIter (aName); anIter.More(); anIter.Next())
+  else
   {
-    const Handle(AIS_InteractiveObject)& anIO = anIter.Current();
-    if (!anIO.IsNull())
-    {
-      const Handle(Prs3d_Drawer)& aDrawer        = anIO->Attributes();
-      Handle(Prs3d_ShadingAspect) aShadingAspect = aDrawer->ShadingAspect();
-      Handle(Graphic3d_AspectFillArea3d) aFillAspect = aShadingAspect->Aspect();
-      aFillAspect->SetInteriorStyle (anInterStyle);
-      if (anInterStyle == Aspect_IS_HATCH
-       && aFillAspect->HatchStyle().IsNull())
-      {
-        aFillAspect->SetHatchStyle (Aspect_HS_VERTICAL);
-      }
-      aCtx->RecomputePrsOnly (anIO, Standard_False, Standard_True);
-    }
+    return false;
   }
-  return 0;
+  return true;
 }
 
 //! Auxiliary structure for VAspects
@@ -1652,6 +1616,21 @@ struct ViewerTest_AspectsChangeSet
   Graphic3d_TypeOfShadingModel ShadingModel;
   TCollection_AsciiString      ShadingModelName;
 
+  Standard_Integer             ToSetInterior;
+  Aspect_InteriorStyle         InteriorStyle;
+
+  Standard_Integer             ToSetDrawEdges;
+  Standard_Integer             ToSetQuadEdges;
+
+  Standard_Integer             ToSetEdgeColor;
+  Quantity_ColorRGBA           EdgeColor;
+
+  Standard_Integer             ToSetEdgeWidth;
+  Standard_Real                EdgeWidth;
+
+  Standard_Integer             ToSetTypeOfEdge;
+  Aspect_TypeOfLine            TypeOfEdge;
+
   //! Empty constructor
   ViewerTest_AspectsChangeSet()
   : ToSetVisibility   (0),
@@ -1687,7 +1666,16 @@ struct ViewerTest_AspectsChangeSet
     ToSetHatch                 (0),
     StdHatchStyle              (-1),
     ToSetShadingModel          (0),
-    ShadingModel               (Graphic3d_TOSM_DEFAULT)
+    ShadingModel               (Graphic3d_TOSM_DEFAULT),
+    ToSetInterior              (0),
+    InteriorStyle              (Aspect_IS_SOLID),
+    ToSetDrawEdges    (0),
+    ToSetQuadEdges    (0),
+    ToSetEdgeColor    (0),
+    ToSetEdgeWidth    (0),
+    EdgeWidth         (1.0),
+    ToSetTypeOfEdge   (0),
+    TypeOfEdge        (Aspect_TOL_SOLID)
     {}
 
   //! @return true if no changes have been requested
@@ -1705,7 +1693,13 @@ struct ViewerTest_AspectsChangeSet
         && ToSetMaxParamValue     == 0
         && ToSetSensitivity       == 0
         && ToSetHatch             == 0
-        && ToSetShadingModel      == 0;
+        && ToSetShadingModel      == 0
+        && ToSetInterior          == 0
+        && ToSetDrawEdges         == 0
+        && ToSetQuadEdges         == 0
+        && ToSetEdgeColor         == 0
+        && ToSetEdgeWidth         == 0
+        && ToSetTypeOfEdge        == 0;
   }
 
   //! @return true if properties are valid
@@ -1771,6 +1765,210 @@ struct ViewerTest_AspectsChangeSet
     return isOk;
   }
 
+  //! Apply aspects to specified drawer.
+  bool Apply (const Handle(Prs3d_Drawer)& theDrawer)
+  {
+    bool toRecompute = false;
+    const Handle(Prs3d_Drawer)& aDefDrawer = ViewerTest::GetAISContext()->DefaultDrawer();
+    if (ToSetShowFreeBoundary != 0)
+    {
+      theDrawer->SetFreeBoundaryDraw (ToSetShowFreeBoundary == 1);
+      toRecompute = true;
+    }
+    if (ToSetFreeBoundaryWidth != 0)
+    {
+      if (ToSetFreeBoundaryWidth != -1
+       || theDrawer->HasOwnFreeBoundaryAspect())
+      {
+        if (!theDrawer->HasOwnFreeBoundaryAspect())
+        {
+          Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+          *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
+          theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
+          toRecompute = true;
+        }
+        theDrawer->FreeBoundaryAspect()->SetWidth (FreeBoundaryWidth);
+      }
+    }
+    if (ToSetFreeBoundaryColor != 0)
+    {
+      Handle(Prs3d_LineAspect) aBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+      *aBoundaryAspect->Aspect() = *theDrawer->FreeBoundaryAspect()->Aspect();
+      aBoundaryAspect->SetColor (FreeBoundaryColor);
+      theDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
+      toRecompute = true;
+    }
+    if (ToSetTypeOfLine != 0)
+    {
+      if (ToSetTypeOfLine != -1
+       || theDrawer->HasOwnLineAspect()
+       || theDrawer->HasOwnWireAspect()
+       || theDrawer->HasOwnFreeBoundaryAspect()
+       || theDrawer->HasOwnUnFreeBoundaryAspect()
+       || theDrawer->HasOwnSeenLineAspect())
+      {
+        toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
+        theDrawer->LineAspect()->SetTypeOfLine           (TypeOfLine);
+        theDrawer->WireAspect()->SetTypeOfLine           (TypeOfLine);
+        theDrawer->FreeBoundaryAspect()->SetTypeOfLine   (TypeOfLine);
+        theDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (TypeOfLine);
+        theDrawer->SeenLineAspect()->SetTypeOfLine       (TypeOfLine);
+      }
+    }
+    if (ToSetTypeOfMarker != 0)
+    {
+      if (ToSetTypeOfMarker != -1
+       || theDrawer->HasOwnPointAspect())
+      {
+        toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
+        theDrawer->PointAspect()->SetTypeOfMarker (TypeOfMarker);
+        theDrawer->PointAspect()->Aspect()->SetMarkerImage (MarkerImage.IsNull() ? Handle(Graphic3d_MarkerImage)() : new Graphic3d_MarkerImage (MarkerImage));
+      }
+    }
+    if (ToSetMarkerSize != 0)
+    {
+      if (ToSetMarkerSize != -1
+       || theDrawer->HasOwnPointAspect())
+      {
+        toRecompute = theDrawer->SetupOwnPointAspect (aDefDrawer) || toRecompute;
+        theDrawer->PointAspect()->SetScale (MarkerSize);
+        toRecompute = true;
+      }
+    }
+    if (ToSetMaxParamValue != 0)
+    {
+      if (ToSetMaxParamValue != -1
+       || theDrawer->HasOwnMaximalParameterValue())
+      {
+        theDrawer->SetMaximalParameterValue (MaxParamValue);
+        toRecompute = true;
+      }
+    }
+    if (ToSetShadingModel != 0)
+    {
+      if (ToSetShadingModel != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetShadingModel (ShadingModel);
+      }
+    }
+    if (ToSetAlphaMode != 0)
+    {
+      if (ToSetAlphaMode != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetAlphaMode (AlphaMode, AlphaCutoff);
+      }
+    }
+    if (ToSetHatch != 0)
+    {
+      if (ToSetHatch != -1
+      ||  theDrawer->HasOwnShadingAspect())
+      {
+        theDrawer->SetupOwnShadingAspect (aDefDrawer);
+        Handle(Graphic3d_AspectFillArea3d) anAsp = theDrawer->ShadingAspect()->Aspect();
+        if (ToSetHatch == -1)
+        {
+          anAsp->SetInteriorStyle (Aspect_IS_SOLID);
+        }
+        else
+        {
+          anAsp->SetInteriorStyle (Aspect_IS_HATCH);
+          if (!PathToHatchPattern.IsEmpty())
+          {
+            Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
+            if (anImage->Load (TCollection_AsciiString (PathToHatchPattern.ToCString())))
+            {
+              anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
+            }
+            else
+            {
+              std::cout << "Error: cannot load the following image: " << PathToHatchPattern << "\n";
+            }
+          }
+          else if (StdHatchStyle != -1)
+          {
+            anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)StdHatchStyle));
+          }
+        }
+        toRecompute = true;
+      }
+    }
+    if (ToSetInterior != 0)
+    {
+      if (ToSetInterior != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (InteriorStyle);
+        if (InteriorStyle == Aspect_IS_HATCH
+         && theDrawer->ShadingAspect()->Aspect()->HatchStyle().IsNull())
+        {
+          theDrawer->ShadingAspect()->Aspect()->SetHatchStyle (Aspect_HS_VERTICAL);
+        }
+      }
+    }
+    if (ToSetDrawEdges != 0)
+    {
+      if (ToSetDrawEdges != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetDrawEdges == 1);
+      }
+    }
+    if (ToSetQuadEdges != 0)
+    {
+      if (ToSetQuadEdges != -1
+          || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetSkipFirstEdge (ToSetQuadEdges == 1);
+      }
+    }
+    if (ToSetEdgeWidth != 0)
+    {
+      if (ToSetEdgeWidth != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetEdgeWidth (EdgeWidth);
+      }
+    }
+    if (ToSetTypeOfEdge != 0)
+    {
+      if (ToSetTypeOfEdge != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        theDrawer->ShadingAspect()->Aspect()->SetEdgeLineType (TypeOfEdge);
+        if (ToSetInterior == 0)
+        {
+          theDrawer->ShadingAspect()->Aspect()->SetDrawEdges (ToSetTypeOfEdge == 1
+                                                           && TypeOfEdge != Aspect_TOL_EMPTY);
+        }
+      }
+    }
+    if (ToSetEdgeColor != 0)
+    {
+      if (ToSetEdgeColor != -1
+       || theDrawer->HasOwnShadingAspect())
+      {
+        toRecompute = theDrawer->SetupOwnShadingAspect (aDefDrawer) || toRecompute;
+        if (ToSetEdgeColor == -1)
+        {
+          theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (theDrawer->ShadingAspect()->Aspect()->InteriorColor());
+        }
+        else
+        {
+          theDrawer->ShadingAspect()->Aspect()->SetEdgeColor (EdgeColor);
+        }
+      }
+    }
+    return toRecompute;
+  }
 };
 
 //==============================================================================
@@ -1827,6 +2025,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
   ViewerTest_AspectsChangeSet* aChangeSet = &aChanges.ChangeLast();
 
   // parse syntax of legacy commands
+  bool toParseAliasArgs = false;
   if (aCmdName == "vsetwidth")
   {
     if (aNames.IsEmpty()
@@ -1862,33 +2061,18 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     }
     else if (aNames.Length() >= 3)
     {
-      const TCollection_AsciiString anRgbStr[3] =
+      const char* anArgVec[3] =
       {
-        aNames.Value (aNames.Upper() - 2),
-        aNames.Value (aNames.Upper() - 1),
-        aNames.Value (aNames.Upper() - 0)
+        aNames.Value (aNames.Upper() - 2).ToCString(),
+        aNames.Value (aNames.Upper() - 1).ToCString(),
+        aNames.Value (aNames.Upper() - 0).ToCString(),
       };
-      isOk = anRgbStr[0].IsRealValue()
-          && anRgbStr[1].IsRealValue()
-          && anRgbStr[2].IsRealValue();
-      if (isOk)
-      {
-        Graphic3d_Vec4d anRgb;
-        anRgb.x() = anRgbStr[0].RealValue();
-        anRgb.y() = anRgbStr[1].RealValue();
-        anRgb.z() = anRgbStr[2].RealValue();
-        if (anRgb.x() < 0.0 || anRgb.x() > 1.0
-         || anRgb.y() < 0.0 || anRgb.y() > 1.0
-         || anRgb.z() < 0.0 || anRgb.z() > 1.0)
-        {
-          std::cout << "Error: RGB color values should be within range 0..1!\n";
-          return 1;
-        }
-        aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
-        aNames.Remove (aNames.Length());
-        aNames.Remove (aNames.Length());
-        aNames.Remove (aNames.Length());
-      }
+
+      Standard_Integer aNbParsed = ViewerTest::ParseColor (3, anArgVec, aChangeSet->Color);
+      isOk = aNbParsed == 3;
+      aNames.Remove (aNames.Length());
+      aNames.Remove (aNames.Length());
+      aNames.Remove (aNames.Length());
     }
     if (!isOk)
     {
@@ -1932,13 +2116,42 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
   {
     aChangeSet->ToSetMaterial = -1;
   }
+  else if (aCmdName == "vsetinteriorstyle")
+  {
+    if (aNames.IsEmpty()
+    || !aNames.Last().IsRealValue())
+    {
+      std::cout << "Error: not enough arguments!\n";
+      return 1;
+    }
+    aChangeSet->ToSetInterior = 1;
+    if (!parseInteriorStyle (aNames.Last(), aChangeSet->InteriorStyle))
+    {
+      std::cout << "Error: wrong syntax at " << aNames.Last() << "\n";
+      return 1;
+    }
+    aNames.Remove (aNames.Length());
+  }
+  else if (aCmdName == "vsetedgetype")
+  {
+    aChangeSet->ToSetDrawEdges = 1;
+    toParseAliasArgs = true;
+  }
+  else if (aCmdName == "vunsetedgetype")
+  {
+    aChangeSet->ToSetDrawEdges  = -1;
+    aChangeSet->ToSetEdgeColor  = -1;
+    aChangeSet->ToSetTypeOfEdge = -1;
+    aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
+  }
   else if (anArgIter >= theArgNb)
   {
     std::cout << "Error: not enough arguments!\n";
     return 1;
   }
 
-  if (!aChangeSet->IsEmpty())
+  if (!aChangeSet->IsEmpty()
+   && !toParseAliasArgs)
   {
     anArgIter = theArgNb;
   }
@@ -1947,24 +2160,53 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     TCollection_AsciiString anArg = theArgVec[anArgIter];
     anArg.LowerCase();
     if (anArg == "-setwidth"
-     || anArg == "-setlinewidth")
+     || anArg == "-width"
+     || anArg == "-setlinewidth"
+     || anArg == "-linewidth"
+     || anArg == "-setedgewidth"
+     || anArg == "-setedgeswidth"
+     || anArg == "-edgewidth"
+     || anArg == "-edgeswidth")
     {
       if (++anArgIter >= theArgNb)
       {
         std::cout << "Error: wrong syntax at " << anArg << "\n";
         return 1;
       }
-      aChangeSet->ToSetLineWidth = 1;
-      aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]);
+      if (anArg == "-setedgewidth"
+       || anArg == "-setedgeswidth"
+       || anArg == "-edgewidth"
+       || anArg == "-edgeswidth"
+       || aCmdName == "vsetedgetype")
+      {
+        aChangeSet->ToSetEdgeWidth = 1;
+        aChangeSet->EdgeWidth = Draw::Atof (theArgVec[anArgIter]);
+      }
+      else
+      {
+        aChangeSet->ToSetLineWidth = 1;
+        aChangeSet->LineWidth = Draw::Atof (theArgVec[anArgIter]);
+      }
     }
     else if (anArg == "-unsetwidth"
-          || anArg == "-unsetlinewidth")
+          || anArg == "-unsetlinewidth"
+          || anArg == "-unsetedgewidth")
     {
-      aChangeSet->ToSetLineWidth = -1;
-      aChangeSet->LineWidth = 1.0;
+      if (anArg == "-unsetedgewidth")
+      {
+        aChangeSet->ToSetEdgeWidth = -1;
+        aChangeSet->EdgeWidth = 1.0;
+      }
+      else
+      {
+        aChangeSet->ToSetLineWidth = -1;
+        aChangeSet->LineWidth = 1.0;
+      }
     }
     else if (anArg == "-settransp"
-          || anArg == "-settransparency")
+          || anArg == "-settransparency"
+          || anArg == "-transparency"
+          || anArg == "-transp")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -1980,7 +2222,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         aChangeSet->Transparency = 0.0;
       }
     }
-    else if (anArg == "-setalphamode")
+    else if (anArg == "-setalphamode"
+          || anArg == "-alphamode")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2028,7 +2271,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       }
     }
     else if (anArg == "-setvis"
-          || anArg == "-setvisibility")
+          || anArg == "-setvisibility"
+          || anArg == "-visibility")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2039,7 +2283,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetVisibility = 1;
       aChangeSet->Visibility = Draw::Atoi (theArgVec[anArgIter]);
     }
-    else if (anArg == "-setalpha")
+    else if (anArg == "-setalpha"
+          || anArg == "-alpha")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2070,77 +2315,82 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetTransparency = -1;
       aChangeSet->Transparency = 0.0;
     }
-    else if (anArg == "-setcolor")
+    else if (anArg == "-setcolor"
+          || anArg == "-color")
     {
-      Standard_Integer aNbComps  = 0;
-      Standard_Integer aCompIter = anArgIter + 1;
-      for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
+      Quantity_Color aColor;
+      Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb  - anArgIter - 1,
+                                                           theArgVec + anArgIter + 1,
+                                                           aColor);
+      if (aNbParsed == 0)
       {
-        if (theArgVec[aCompIter][0] == '-')
-        {
-          break;
-        }
+        std::cout << "Syntax error at '" << anArg << "'\n";
+        return 1;
       }
-      switch (aNbComps)
+      anArgIter += aNbParsed;
+      if (aCmdName == "vsetedgetype")
       {
-        case 1:
-        {
-          Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
-          Standard_CString     aName  = theArgVec[anArgIter + 1];
-          if (!Quantity_Color::ColorFromName (aName, aColor))
-          {
-            std::cout << "Error: unknown color name '" << aName << "'\n";
-            return 1;
-          }
-          aChangeSet->Color = aColor;
-          break;
-        }
-        case 3:
-        {
-          Graphic3d_Vec3d anRgb;
-          anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]);
-          anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]);
-          anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]);
-          if (anRgb.x() < 0.0 || anRgb.x() > 1.0
-           || anRgb.y() < 0.0 || anRgb.y() > 1.0
-           || anRgb.z() < 0.0 || anRgb.z() > 1.0)
-          {
-            std::cout << "Error: RGB color values should be within range 0..1!\n";
-            return 1;
-          }
-          aChangeSet->Color.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
-          break;
-        }
-        default:
-        {
-          std::cout << "Error: wrong syntax at " << anArg << "\n";
-          return 1;
-        }
+        aChangeSet->ToSetEdgeColor = 1;
+        aChangeSet->EdgeColor = Quantity_ColorRGBA (aColor);
+      }
+      else
+      {
+        aChangeSet->ToSetColor = 1;
+        aChangeSet->Color = aColor;
       }
-      aChangeSet->ToSetColor = 1;
-      anArgIter += aNbComps;
     }
-    else if (anArg == "-setlinetype")
+    else if (anArg == "-setlinetype"
+          || anArg == "-linetype"
+          || anArg == "-setedgetype"
+          || anArg == "-setedgestype"
+          || anArg == "-edgetype"
+          || anArg == "-edgestype"
+          || anArg == "-type")
     {
       if (++anArgIter >= theArgNb)
       {
         std::cout << "Error: wrong syntax at " << anArg << "\n";
         return 1;
       }
-      if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aChangeSet->TypeOfLine))
+      Aspect_TypeOfLine aLineType = Aspect_TOL_EMPTY;
+      if (!ViewerTest::ParseLineType (theArgVec[anArgIter], aLineType))
       {
         std::cout << "Error: wrong syntax at " << anArg << "\n";
         return 1;
       }
-
-      aChangeSet->ToSetTypeOfLine = 1;
+      if (anArg == "-setedgetype"
+       || anArg == "-setedgestype"
+       || anArg == "-edgetype"
+       || anArg == "-edgestype"
+       || aCmdName == "vsetedgetype")
+      {
+        aChangeSet->TypeOfEdge = aLineType;
+        aChangeSet->ToSetTypeOfEdge = 1;
+      }
+      else
+      {
+        aChangeSet->TypeOfLine = aLineType;
+        aChangeSet->ToSetTypeOfLine = 1;
+      }
     }
-    else if (anArg == "-unsetlinetype")
+    else if (anArg == "-unsetlinetype"
+          || anArg == "-unsetedgetype"
+          || anArg == "-unsetedgestype")
     {
-      aChangeSet->ToSetTypeOfLine = -1;
+      if (anArg == "-unsetedgetype"
+       || anArg == "-unsetedgestype")
+      {
+        aChangeSet->ToSetTypeOfEdge = -1;
+      }
+      else
+      {
+        aChangeSet->ToSetTypeOfLine = -1;
+      }
     }
     else if (anArg == "-setmarkertype"
-          || anArg == "-setpointtype")
+          || anArg == "-markertype"
+          || anArg == "-setpointtype"
+          || anArg == "-pointtype")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2161,7 +2411,9 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetTypeOfMarker = -1;
     }
     else if (anArg == "-setmarkersize"
-          || anArg == "-setpointsize")
+          || anArg == "-markersize"
+          || anArg == "-setpointsize"
+          || anArg == "-pointsize")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2183,7 +2435,9 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->Color = DEFAULT_COLOR;
     }
     else if (anArg == "-setmat"
-          || anArg == "-setmaterial")
+          || anArg == "-mat"
+          || anArg == "-setmaterial"
+          || anArg == "-material")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2242,7 +2496,9 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         return 1;
       }
     }
-    else if (anArg == "-freeboundary"
+    else if (anArg == "-setfreeboundary"
+          || anArg == "-freeboundary"
+          || anArg == "-setfb"
           || anArg == "-fb")
     {
       if (++anArgIter >= theArgNb)
@@ -2269,7 +2525,9 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       }
     }
     else if (anArg == "-setfreeboundarywidth"
-          || anArg == "-setfbwidth")
+          || anArg == "-freeboundarywidth"
+          || anArg == "-setfbwidth"
+          || anArg == "-fbwidth")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2286,55 +2544,20 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->FreeBoundaryWidth = 1.0;
     }
     else if (anArg == "-setfreeboundarycolor"
-          || anArg == "-setfbcolor")
+          || anArg == "-freeboundarycolor"
+          || anArg == "-setfbcolor"
+          || anArg == "-fbcolor")
     {
-      Standard_Integer aNbComps  = 0;
-      Standard_Integer aCompIter = anArgIter + 1;
-      for (; aCompIter < theArgNb; ++aCompIter, ++aNbComps)
+      Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb  - anArgIter - 1,
+                                                           theArgVec + anArgIter + 1,
+                                                           aChangeSet->FreeBoundaryColor);
+      if (aNbParsed == 0)
       {
-        if (theArgVec[aCompIter][0] == '-')
-        {
-          break;
-        }
-      }
-      switch (aNbComps)
-      {
-        case 1:
-        {
-          Quantity_NameOfColor aColor = Quantity_NOC_BLACK;
-          Standard_CString     aName  = theArgVec[anArgIter + 1];
-          if (!Quantity_Color::ColorFromName (aName, aColor))
-          {
-            std::cout << "Error: unknown free boundary color name '" << aName << "'\n";
-            return 1;
-          }
-          aChangeSet->FreeBoundaryColor = aColor;
-          break;
-        }
-        case 3:
-        {
-          Graphic3d_Vec3d anRgb;
-          anRgb.x() = Draw::Atof (theArgVec[anArgIter + 1]);
-          anRgb.y() = Draw::Atof (theArgVec[anArgIter + 2]);
-          anRgb.z() = Draw::Atof (theArgVec[anArgIter + 3]);
-          if (anRgb.x() < 0.0 || anRgb.x() > 1.0
-           || anRgb.y() < 0.0 || anRgb.y() > 1.0
-           || anRgb.z() < 0.0 || anRgb.z() > 1.0)
-          {
-            std::cout << "Error: free boundary RGB color values should be within range 0..1!\n";
-            return 1;
-          }
-          aChangeSet->FreeBoundaryColor.SetValues (anRgb.x(), anRgb.y(), anRgb.z(), Quantity_TOC_RGB);
-          break;
-        }
-        default:
-        {
-          std::cout << "Error: wrong syntax at " << anArg << "\n";
-          return 1;
-        }
+        std::cout << "Syntax error at '" << anArg << "'\n";
+        return 1;
       }
+      anArgIter += aNbParsed;
       aChangeSet->ToSetFreeBoundaryColor = 1;
-      anArgIter += aNbComps;
     }
     else if (anArg == "-unsetfreeboundarycolor"
           || anArg == "-unsetfbcolor")
@@ -2342,39 +2565,9 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetFreeBoundaryColor = -1;
       aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
     }
-    else if (anArg == "-unset")
-    {
-      aChangeSet->ToSetVisibility = 1;
-      aChangeSet->Visibility = 1;
-      aChangeSet->ToSetLineWidth = -1;
-      aChangeSet->LineWidth = 1.0;
-      aChangeSet->ToSetTypeOfLine = -1;
-      aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
-      aChangeSet->ToSetTypeOfMarker = -1;
-      aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
-      aChangeSet->ToSetMarkerSize = -1;
-      aChangeSet->MarkerSize = 1.0;
-      aChangeSet->ToSetTransparency = -1;
-      aChangeSet->Transparency = 0.0;
-      aChangeSet->ToSetAlphaMode = -1;
-      aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
-      aChangeSet->AlphaCutoff = 0.5f;
-      aChangeSet->ToSetColor = -1;
-      aChangeSet->Color = DEFAULT_COLOR;
-      aChangeSet->ToSetMaterial = -1;
-      aChangeSet->Material = Graphic3d_NOM_DEFAULT;
-      aChangeSet->ToSetShowFreeBoundary = -1;
-      aChangeSet->ToSetFreeBoundaryColor = -1;
-      aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
-      aChangeSet->ToSetFreeBoundaryWidth = -1;
-      aChangeSet->FreeBoundaryWidth = 1.0;
-      aChangeSet->ToSetHatch = -1;
-      aChangeSet->StdHatchStyle = -1;
-      aChangeSet->PathToHatchPattern.Clear();
-      aChangeSet->ToSetShadingModel = -1;
-      aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
-    }
-    else if (anArg == "-isoontriangulation"
+    else if (anArg == "-setisoontriangulation"
+          || anArg == "-isoontriangulation"
+          || anArg == "-setisoontriang"
           || anArg == "-isoontriang")
     {
       if (++anArgIter >= theArgNb)
@@ -2400,7 +2593,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         return 1;
       }
     }
-    else if (anArg == "-setmaxparamvalue")
+    else if (anArg == "-setmaxparamvalue"
+          || anArg == "-maxparamvalue")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2410,7 +2604,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetMaxParamValue = 1;
       aChangeSet->MaxParamValue = Draw::Atof (theArgVec[anArgIter]);
     }
-    else if (anArg == "-setsensitivity")
+    else if (anArg == "-setsensitivity"
+          || anArg == "-sensitivity")
     {
       if (isDefaults)
       {
@@ -2433,7 +2628,8 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->SelectionMode = Draw::Atoi (theArgVec[++anArgIter]);
       aChangeSet->Sensitivity = Draw::Atoi (theArgVec[++anArgIter]);
     }
-    else if (anArg == "-sethatch")
+    else if (anArg == "-sethatch"
+          || anArg == "-hatch")
     {
       if (isDefaults)
       {
@@ -2465,7 +2661,10 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         aChangeSet->PathToHatchPattern = anArgHatch;
       }
     }
-    else if (anArg == "-setshadingmodel")
+    else if (anArg == "-setshadingmodel"
+          || anArg == "-setshading"
+          || anArg == "-shadingmodel"
+          || anArg == "-shading")
     {
       if (++anArgIter >= theArgNb)
       {
@@ -2485,6 +2684,113 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->ToSetShadingModel = -1;
       aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
     }
+    else if (anArg == "-setinterior"
+          || anArg == "-setinteriorstyle"
+          || anArg == "-interior"
+          || anArg == "-interiorstyle")
+    {
+      if (++anArgIter >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+      aChangeSet->ToSetInterior = 1;
+      if (!parseInteriorStyle (theArgVec[anArgIter], aChangeSet->InteriorStyle))
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+    }
+    else if (anArg == "-unsetinterior")
+    {
+      aChangeSet->ToSetInterior = -1;
+      aChangeSet->InteriorStyle = Aspect_IS_SOLID;
+    }
+    else if (anArg == "-setdrawedges"
+          || anArg == "-setdrawedge"
+          || anArg == "-drawedges"
+          || anArg == "-drawedge"
+          || anArg == "-edges")
+    {
+      bool toDrawEdges = true;
+      if (anArgIter + 1 < theArgNb
+       && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], toDrawEdges))
+      {
+        ++anArgIter;
+      }
+      aChangeSet->ToSetDrawEdges = toDrawEdges ? 1 : -1;
+    }
+    else if (anArg == "-setquadedges"
+          || anArg == "-setquads"
+          || anArg == "-quads"
+          || anArg == "-skipfirstedge")
+    {
+      bool isQuadMode = true;
+      if (anArgIter + 1 < theArgNb
+       && ViewerTest::ParseOnOff (theArgVec[anArgIter + 1], isQuadMode))
+      {
+        ++anArgIter;
+      }
+      aChangeSet->ToSetQuadEdges = isQuadMode ? 1 : -1;
+    }
+    else if (anArg == "-setedgecolor"
+          || anArg == "-setedgescolor"
+          || anArg == "-edgecolor"
+          || anArg == "-edgescolor")
+    {
+      Standard_Integer aNbParsed = ViewerTest::ParseColor (theArgNb  - anArgIter - 1,
+                                                           theArgVec + anArgIter + 1,
+                                                           aChangeSet->EdgeColor);
+      if (aNbParsed == 0)
+      {
+        std::cout << "Syntax error at '" << anArg << "'\n";
+        return 1;
+      }
+      anArgIter += aNbParsed;
+      aChangeSet->ToSetEdgeColor = 1;
+    }
+    else if (anArg == "-unset")
+    {
+      aChangeSet->ToSetVisibility = 1;
+      aChangeSet->Visibility = 1;
+      aChangeSet->ToSetLineWidth = -1;
+      aChangeSet->LineWidth = 1.0;
+      aChangeSet->ToSetTypeOfLine = -1;
+      aChangeSet->TypeOfLine = Aspect_TOL_SOLID;
+      aChangeSet->ToSetTypeOfMarker = -1;
+      aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
+      aChangeSet->ToSetMarkerSize = -1;
+      aChangeSet->MarkerSize = 1.0;
+      aChangeSet->ToSetTransparency = -1;
+      aChangeSet->Transparency = 0.0;
+      aChangeSet->ToSetAlphaMode = -1;
+      aChangeSet->AlphaMode = Graphic3d_AlphaMode_BlendAuto;
+      aChangeSet->AlphaCutoff = 0.5f;
+      aChangeSet->ToSetColor = -1;
+      aChangeSet->Color = DEFAULT_COLOR;
+      aChangeSet->ToSetMaterial = -1;
+      aChangeSet->Material = Graphic3d_NOM_DEFAULT;
+      aChangeSet->ToSetShowFreeBoundary = -1;
+      aChangeSet->ToSetFreeBoundaryColor = -1;
+      aChangeSet->FreeBoundaryColor = DEFAULT_FREEBOUNDARY_COLOR;
+      aChangeSet->ToSetFreeBoundaryWidth = -1;
+      aChangeSet->FreeBoundaryWidth = 1.0;
+      aChangeSet->ToSetHatch = -1;
+      aChangeSet->StdHatchStyle = -1;
+      aChangeSet->PathToHatchPattern.Clear();
+      aChangeSet->ToSetShadingModel = -1;
+      aChangeSet->ShadingModel = Graphic3d_TOSM_DEFAULT;
+      aChangeSet->ToSetInterior = -1;
+      aChangeSet->InteriorStyle = Aspect_IS_SOLID;
+      aChangeSet->ToSetDrawEdges = -1;
+      aChangeSet->ToSetQuadEdges = -1;
+      aChangeSet->ToSetEdgeColor = -1;
+      aChangeSet->EdgeColor = Quantity_ColorRGBA (DEFAULT_COLOR);
+      aChangeSet->ToSetEdgeWidth = -1;
+      aChangeSet->EdgeWidth = 1.0;
+      aChangeSet->ToSetTypeOfEdge = -1;
+      aChangeSet->TypeOfEdge = Aspect_TOL_SOLID;
+    }
     else
     {
       std::cout << "Error: wrong syntax at " << anArg << "\n";
@@ -2506,7 +2812,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
   if (isDefaults)
   {
     const Handle(Prs3d_Drawer)& aDrawer = aCtx->DefaultDrawer();
-
+    aChangeSet->Apply (aDrawer);
     if (aChangeSet->ToSetLineWidth != 0)
     {
       aDrawer->LineAspect()->SetWidth (aChangeSet->LineWidth);
@@ -2523,65 +2829,18 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aDrawer->WireAspect()->SetColor           (aChangeSet->Color);
       aDrawer->PointAspect()->SetColor          (aChangeSet->Color);
     }
-    if (aChangeSet->ToSetTypeOfLine != 0)
-    {
-      aDrawer->LineAspect()->SetTypeOfLine           (aChangeSet->TypeOfLine);
-      aDrawer->WireAspect()->SetTypeOfLine           (aChangeSet->TypeOfLine);
-      aDrawer->FreeBoundaryAspect()->SetTypeOfLine   (aChangeSet->TypeOfLine);
-      aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
-      aDrawer->SeenLineAspect()->SetTypeOfLine       (aChangeSet->TypeOfLine);
-    }
-    if (aChangeSet->ToSetTypeOfMarker != 0)
-    {
-      aDrawer->PointAspect()->SetTypeOfMarker (aChangeSet->TypeOfMarker);
-      aDrawer->PointAspect()->Aspect()->SetMarkerImage (aChangeSet->MarkerImage.IsNull()
-                                                      ? Handle(Graphic3d_MarkerImage)()
-                                                      : new Graphic3d_MarkerImage (aChangeSet->MarkerImage));
-    }
-    if (aChangeSet->ToSetMarkerSize != 0)
-    {
-      aDrawer->PointAspect()->SetScale (aChangeSet->MarkerSize);
-    }
     if (aChangeSet->ToSetTransparency != 0)
     {
       aDrawer->ShadingAspect()->SetTransparency (aChangeSet->Transparency);
     }
-    if (aChangeSet->ToSetAlphaMode != 0)
-    {
-      aDrawer->ShadingAspect()->Aspect()->SetAlphaMode (aChangeSet->AlphaMode, aChangeSet->AlphaCutoff);
-    }
     if (aChangeSet->ToSetMaterial != 0)
     {
       aDrawer->ShadingAspect()->SetMaterial (aChangeSet->Material);
     }
-    if (aChangeSet->ToSetShowFreeBoundary == 1)
-    {
-      aDrawer->SetFreeBoundaryDraw (Standard_True);
-    }
-    else if (aChangeSet->ToSetShowFreeBoundary == -1)
-    {
-      aDrawer->SetFreeBoundaryDraw (Standard_False);
-    }
-    if (aChangeSet->ToSetFreeBoundaryWidth != 0)
-    {
-      aDrawer->FreeBoundaryAspect()->SetWidth (aChangeSet->FreeBoundaryWidth);
-    }
-    if (aChangeSet->ToSetFreeBoundaryColor != 0)
-    {
-      aDrawer->FreeBoundaryAspect()->SetColor (aChangeSet->FreeBoundaryColor);
-    }
     if (aChangeSet->ToEnableIsoOnTriangulation != -1)
     {
       aDrawer->SetIsoOnTriangulation (aChangeSet->ToEnableIsoOnTriangulation == 1);
     }
-    if (aChangeSet->ToSetMaxParamValue != 0)
-    {
-      aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
-    }
-    if (aChangeSet->ToSetShadingModel == 1)
-    {
-      aDrawer->ShadingAspect()->Aspect()->SetShadingModel (aChangeSet->ShadingModel);
-    }
 
     // redisplay all objects in context
     for (ViewTest_PrsIter aPrsIter (aNames); aPrsIter.More(); aPrsIter.Next())
@@ -2686,117 +2945,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       }
       if (!aDrawer.IsNull())
       {
-        if (aChangeSet->ToSetShowFreeBoundary == 1)
-        {
-          aDrawer->SetFreeBoundaryDraw (Standard_True);
-          toRedisplay = Standard_True;
-        }
-        else if (aChangeSet->ToSetShowFreeBoundary == -1)
-        {
-          aDrawer->SetFreeBoundaryDraw (Standard_False);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetFreeBoundaryWidth != 0)
-        {
-          Handle(Prs3d_LineAspect) aBoundaryAspect =
-              new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
-          *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect();
-          aBoundaryAspect->SetWidth (aChangeSet->FreeBoundaryWidth);
-          aDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetFreeBoundaryColor != 0)
-        {
-          Handle(Prs3d_LineAspect) aBoundaryAspect =
-              new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
-          *aBoundaryAspect->Aspect() = *aDrawer->FreeBoundaryAspect()->Aspect();
-          aBoundaryAspect->SetColor (aChangeSet->FreeBoundaryColor);
-          aDrawer->SetFreeBoundaryAspect (aBoundaryAspect);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetTypeOfLine != 0)
-        {
-          aDrawer->LineAspect()->SetTypeOfLine           (aChangeSet->TypeOfLine);
-          aDrawer->WireAspect()->SetTypeOfLine           (aChangeSet->TypeOfLine);
-          aDrawer->FreeBoundaryAspect()->SetTypeOfLine   (aChangeSet->TypeOfLine);
-          aDrawer->UnFreeBoundaryAspect()->SetTypeOfLine (aChangeSet->TypeOfLine);
-          aDrawer->SeenLineAspect()->SetTypeOfLine       (aChangeSet->TypeOfLine);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetTypeOfMarker != 0)
-        {
-          Handle(Prs3d_PointAspect) aMarkerAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
-          *aMarkerAspect->Aspect() = *aDrawer->PointAspect()->Aspect();
-          aMarkerAspect->SetTypeOfMarker (aChangeSet->TypeOfMarker);
-          aMarkerAspect->Aspect()->SetMarkerImage (aChangeSet->MarkerImage.IsNull()
-                                                 ? Handle(Graphic3d_MarkerImage)()
-                                                 : new Graphic3d_MarkerImage (aChangeSet->MarkerImage));
-          aDrawer->SetPointAspect (aMarkerAspect);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetMarkerSize != 0)
-        {
-          Handle(Prs3d_PointAspect) aMarkerAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
-          *aMarkerAspect->Aspect() = *aDrawer->PointAspect()->Aspect();
-          aMarkerAspect->SetScale (aChangeSet->MarkerSize);
-          aDrawer->SetPointAspect (aMarkerAspect);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetMaxParamValue != 0)
-        {
-          aDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
-        }
-        if (aChangeSet->ToSetHatch != 0)
-        {
-          if (!aDrawer->HasOwnShadingAspect())
-          {
-            aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
-            *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
-          }
-
-          Handle(Graphic3d_AspectFillArea3d) anAsp = aDrawer->ShadingAspect()->Aspect();
-          if (aChangeSet->ToSetHatch == -1)
-          {
-            anAsp->SetInteriorStyle (Aspect_IS_SOLID);
-          }
-          else
-          {
-            anAsp->SetInteriorStyle (Aspect_IS_HATCH);
-            if (!aChangeSet->PathToHatchPattern.IsEmpty())
-            {
-              Handle(Image_AlienPixMap) anImage = new Image_AlienPixMap();
-              if (anImage->Load (TCollection_AsciiString (aChangeSet->PathToHatchPattern.ToCString())))
-              {
-                anAsp->SetHatchStyle (new Graphic3d_HatchStyle (anImage));
-              }
-              else
-              {
-                std::cout << "Error: cannot load the following image: " << aChangeSet->PathToHatchPattern << std::endl;
-                return 1;
-              }
-            }
-            else if (aChangeSet->StdHatchStyle != -1)
-            {
-              anAsp->SetHatchStyle (new Graphic3d_HatchStyle ((Aspect_HatchStyle)aChangeSet->StdHatchStyle));
-            }
-          }
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetShadingModel != 0)
-        {
-          aDrawer->SetShadingModel ((aChangeSet->ToSetShadingModel == -1) ? Graphic3d_TOSM_DEFAULT : aChangeSet->ShadingModel, aChangeSet->ToSetShadingModel != -1);
-          toRedisplay = Standard_True;
-        }
-        if (aChangeSet->ToSetAlphaMode != 0)
-        {
-          if (!aDrawer->HasOwnShadingAspect())
-          {
-            aDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
-            *aDrawer->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
-          }
-          aDrawer->ShadingAspect()->Aspect()->SetAlphaMode (aChangeSet->AlphaMode, aChangeSet->AlphaCutoff);
-          toRedisplay = Standard_True;
-        }
+        toRedisplay = aChangeSet->Apply (aDrawer) || toRedisplay;
       }
 
       for (aChangesIter.Next(); aChangesIter.More(); aChangesIter.Next())
@@ -2806,6 +2955,11 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
              aSubShapeIter.More(); aSubShapeIter.Next())
         {
           const TopoDS_Shape& aSubShape = aSubShapeIter.Value();
+          if (!aChangeSet->IsEmpty())
+          {
+            Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
+            aChangeSet->Apply (aCurColDrawer);
+          }
           if (aChangeSet->ToSetVisibility == 1)
           {
             Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
@@ -2828,20 +2982,10 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
           {
             aColoredPrs->UnsetCustomAspects (aSubShape, Standard_True);
           }
-          if (aChangeSet->ToSetMaxParamValue != 0)
-          {
-            Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
-            aCurColDrawer->SetMaximalParameterValue (aChangeSet->MaxParamValue);
-          }
           if (aChangeSet->ToSetSensitivity != 0)
           {
             aCtx->SetSelectionSensitivity (aPrs, aChangeSet->SelectionMode, aChangeSet->Sensitivity);
           }
-          if (aChangeSet->ToSetShadingModel != 0)
-          {
-            Handle(AIS_ColoredDrawer) aCurColDrawer = aColoredPrs->CustomAspects (aSubShape);
-            aCurColDrawer->SetShadingModel ((aChangeSet->ToSetShadingModel == -1) ? Graphic3d_TOSM_DEFAULT : aChangeSet->ShadingModel, aChangeSet->ToSetShadingModel != -1);
-          }
         }
       }
       if (toDisplay)
@@ -2856,6 +3000,10 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       {
         aCtx->Redisplay (aColoredPrs, Standard_False);
       }
+      else
+      {
+        aPrs->SynchronizeAspects();
+      }
     }
   }
   return 0;
@@ -3827,14 +3975,10 @@ Standard_Integer VTexture (Draw_Interpretor& theDi, Standard_Integer theArgsNb,
       aTextureSetNew = aTextureSetOld;
     }
 
-    if (!aTexturedIO->Attributes()->HasOwnShadingAspect())
+    if (aTexturedIO->Attributes()->SetupOwnShadingAspect (aCtx->DefaultDrawer())
+     && aTexturedShape.IsNull())
     {
-      if (aTexturedShape.IsNull())
-      {
-        aTexturedIO->SetToUpdate();
-      }
-      aTexturedIO->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
-      *aTexturedIO->Attributes()->ShadingAspect()->Aspect() = *aCtx->DefaultDrawer()->ShadingAspect()->Aspect();
+      aTexturedIO->SetToUpdate();
     }
 
     toComputeUV = !aTextureSetNew.IsNull() && aTextureSetOld.IsNull();
@@ -5857,9 +6001,11 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
       "\n\t\t:          [-isoontriangulation 0|1]"
       "\n\t\t:          [-setMaxParamValue {value}]"
       "\n\t\t:          [-setSensitivity {selection_mode} {value}]"
-      "\n\t\t:          [-setHatch HatchStyle]"
       "\n\t\t:          [-setShadingModel {color|flat|gouraud|phong}]"
       "\n\t\t:          [-unsetShadingModel]"
+      "\n\t\t:          [-setInterior {solid|hatch|hidenline|point}]"
+      "\n\t\t:          [-unsetInterior] [-setHatch HatchStyle]"
+      "\n\t\t:          [-setDrawEdges {0|1}] [-setEdgeType LineType] [-setEdgeColor R G B] [-setQuadEdges {0|1}]"
       "\n\t\t:          [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
       "\n\t\t: Manage presentation properties of all, selected or named objects."
       "\n\t\t: When -subshapes is specified than following properties will be"
@@ -5912,13 +6058,23 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
 
   theCommands.Add("vunsetwidth",
                  "vunsetwidth [-noupdate|-update] [name]"
-      "\n\t\t: Alias for vaspects -unsetwidth [name] width.",
+      "\n\t\t: Alias for vaspects -unsetwidth [name].",
                  __FILE__,VAspects,group);
 
   theCommands.Add("vsetinteriorstyle",
-                 "vsetinteriorstyle [-noupdate|-update] [name] style"
-      "\n\t\t: Where style is: 0 = EMPTY, 1 = HOLLOW, 2 = HATCH, 3 = SOLID, 4 = HIDDENLINE.",
-                 __FILE__,VSetInteriorStyle,group);
+    "vsetinteriorstyle [-noupdate|-update] [name] Style"
+    "\n\t\t: Alias for vaspects -setInterior [name] Style.",
+                 __FILE__,VAspects,group);
+
+  theCommands.Add ("vsetedgetype",
+    "vsetedgetype [name] [-type {solid, dash, dot}] [-color R G B] [-width value]"
+    "\n\t\t: Alias for vaspects [name] -setEdgeType Type.",
+      __FILE__, VAspects, group);
+
+  theCommands.Add ("vunsetedgetype",
+    "vunsetedgetype [name]"
+    "\n\t\t: Alias for vaspects [name] -unsetEdgeType.",
+      __FILE__, VAspects, group);
 
   theCommands.Add("vsensdis",
       "vsensdis : Display active entities (sensitive entities of one of the standard types corresponding to active selection modes)."
index 0685bbf..2c5cdcd 100644 (file)
@@ -28,7 +28,7 @@
 #include <TColStd_HArray1OfTransient.hxx>
 #include <TopTools_ListOfShape.hxx>
 #include <TopTools_HArray1OfShape.hxx>
-#include <Quantity_Color.hxx>
+#include <Quantity_ColorRGBA.hxx>
 
 class AIS_InteractiveContext;
 class AIS_InteractiveObject;
@@ -152,14 +152,32 @@ public:
 
   Standard_EXPORT static Quantity_NameOfColor GetColorFromName (const Standard_CString name);
 
-  //! Parses color argument(s) specified within theArgVec[0], theArgVec[1] and theArgVec[2].
+  //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
   //! Handles either color specified by name (single argument)
-  //! or by RGB components (3 arguments) in range 0..1.
+  //! or by RGB(A) components (3-4 arguments) in range 0..1.
   //! The result is stored in theColor on success.
+  //! Returns number of handled arguments (1, 3 or 4) or 0 on syntax error.
+  static Standard_Integer ParseColor (Standard_Integer  theArgNb,
+                                      const char**      theArgVec,
+                                      Quantity_ColorRGBA& theColor)
+  {
+    return parseColor (theArgNb, theArgVec, theColor, true);
+  }
+
+  //! Parses RGB color argument(s).
   //! Returns number of handled arguments (1 or 3) or 0 on syntax error.
-  Standard_EXPORT static Standard_Integer ParseColor (Standard_Integer theArgNb,
-                                                      const char**     theArgVec,
-                                                      Quantity_Color&  theColor);
+  static Standard_Integer ParseColor (Standard_Integer theArgNb,
+                                      const char**     theArgVec,
+                                      Quantity_Color&  theColor)
+  {
+    Quantity_ColorRGBA anRgba;
+    Standard_Integer aNbParsed = parseColor (theArgNb, theArgVec, anRgba, false);
+    if (aNbParsed != 0)
+    {
+      theColor = anRgba.GetRGB();
+    }
+    return aNbParsed;
+  }
 
   //! redraws all defined views.
   Standard_EXPORT static void RedrawAllViews();
@@ -197,6 +215,16 @@ public:
 
 private:
 
+  //! Parses RGB(A) color argument(s) specified within theArgVec[0], theArgVec[1], theArgVec[2] and theArgVec[3].
+  //! Handles either color specified by name (single argument)
+  //! or by RGB(A) components (3-4 arguments) in range 0..1.
+  //! The result is stored in theColor on success.
+  //! Returns number of handled arguments (1, 3 or 4) or 0 on syntax error.
+  Standard_EXPORT static Standard_Integer parseColor (Standard_Integer  theArgNb,
+                                                      const char**      theArgVec,
+                                                      Quantity_ColorRGBA& theColor,
+                                                      bool theToParseAlpha);
+
   //! Returns a window class that implements standard behavior of
   //! all windows of the ViewerTest. This includes usual Open CASCADE
   //! view conventions for mouse buttons (e.g. Ctrl+MB1 for zoom,
index d3713c1..c0317b7 100644 (file)
@@ -3031,14 +3031,7 @@ static int VDrawSphere (Draw_Interpretor& /*di*/, Standard_Integer argc, const c
                                       aMat,
                                       aMat);
   Handle(Prs3d_ShadingAspect) aShAsp = new Prs3d_ShadingAspect();
-  if (toShowEdges)
-  {
-    anAspect->SetEdgeOn();
-  }
-  else
-  {
-    anAspect->SetEdgeOff();
-  }
+  anAspect->SetDrawEdges (toShowEdges);
   aShAsp->SetAspect (anAspect);
   aShape->Attributes()->SetShadingAspect (aShAsp);
 
@@ -5562,177 +5555,6 @@ static int VFont (Draw_Interpretor& theDI,
   return 0;
 }
 
-//=======================================================================
-//function : VSetEdgeType
-//purpose  : Edges type management
-//=======================================================================
-
-static int VSetEdgeType (Draw_Interpretor& theDI,
-                         Standard_Integer  theArgNum,
-                         const char**      theArgs)
-{
-  if (theArgNum < 4 || theArgNum > 9)
-  {
-    theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
-          << theArgs[0] << "' for more information.\n";
-    return 1;
-  }
-
-  Standard_Boolean isForceRedisplay = Standard_False;
-
-  // Get shape name
-  TCollection_AsciiString aName(theArgs[1]);
-  Handle(AIS_InteractiveObject) anObject;
-  if (!GetMapOfAIS().Find2 (aName, anObject))
-  {
-    theDI <<  theArgs[0] << " error: wrong object name.\n";
-    return 1;
-  }
-  
-  // Enable triangle edge mode
-  if (!anObject->Attributes()->HasOwnShadingAspect())
-  {
-    anObject->Attributes()->SetShadingAspect (new Prs3d_ShadingAspect());
-    *anObject->Attributes()->ShadingAspect()->Aspect() = *anObject->Attributes()->Link()->ShadingAspect()->Aspect();
-  }
-  const Handle(Prs3d_ShadingAspect)& aFillAreaAspect = anObject->Attributes()->ShadingAspect();
-  aFillAreaAspect->Aspect()->SetEdgeOn();
-
-  // Parse parameters
-  for (Standard_Integer anIt = 2; anIt < theArgNum; ++anIt)
-  {
-    TCollection_AsciiString aParam ((theArgs[anIt]));
-    if (aParam.Value (1) == '-' && !aParam.IsRealValue())
-    {
-      if (aParam.IsEqual ("-type"))
-      {
-        if (theArgNum <= anIt + 1)
-        {
-          theDI <<  theArgs[0] << " error: wrong number of values for parameter '"
-                << aParam.ToCString() << "'.\n";
-          return 1;
-        }
-
-        ++anIt;
-        Aspect_TypeOfLine aTypeEnum = Aspect_TOL_SOLID;
-        if (!ViewerTest::ParseLineType (theArgs[anIt], aTypeEnum))
-        {
-          std::cout << "Syntax error: wrong line type: '" << theArgs[anIt] << "'.\n";
-          return 1;
-        }
-        anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeLineType (aTypeEnum);
-      }
-      else if (aParam.IsEqual ("-color"))
-      {
-        if (theArgNum <= anIt + 3)
-        {
-          theDI <<  theArgs[0] << " error: wrong number of values for parameter '"
-                << aParam.ToCString() << "'.\n";
-          return 1;
-        }
-
-        Standard_Real aR = Draw::Atof(theArgs[++anIt]);
-        Standard_Real aG = Draw::Atof(theArgs[++anIt]);
-        Standard_Real aB = Draw::Atof(theArgs[++anIt]);
-        Quantity_Color aColor = Quantity_Color (aR > 1 ? aR / 255.0 : aR,
-                                                aG > 1 ? aG / 255.0 : aG,
-                                                aB > 1 ? aB / 255.0 : aB,
-                                                Quantity_TOC_RGB);
-
-        aFillAreaAspect->Aspect()->SetEdgeColor (aColor);
-      }
-      else if (aParam.IsEqual ("-force"))
-      {
-        isForceRedisplay = Standard_True;
-      }
-      else
-      {
-        theDI <<  theArgs[0] << " error: unknown parameter '"
-              << aParam.ToCString() << "'.\n";
-        return 1;
-      }
-    }
-  }
-
-  // Update shape presentation as aspect parameters were changed
-  if (isForceRedisplay)
-  {
-    ViewerTest::GetAISContext()->Redisplay (anObject, Standard_False);
-  }
-  else
-  {
-    anObject->SetAspect (aFillAreaAspect);
-  }
-
-  //Update view
-  ViewerTest::CurrentView()->Redraw();
-
-  return 0;
-}
-
-//=======================================================================
-//function : VUnsetEdgeType
-//purpose  : Unsets edges visibility in shading mode
-//=======================================================================
-
-static int VUnsetEdgeType (Draw_Interpretor& theDI,
-                         Standard_Integer  theArgNum,
-                         const char**      theArgs)
-{
-  if (theArgNum != 2 && theArgNum != 3)
-  {
-    theDI << theArgs[0] << " error: wrong number of parameters. Type 'help "
-          << theArgs[0] << "' for more information.\n";
-    return 1;
-  }
-
-  Standard_Boolean isForceRedisplay = Standard_False;
-
-  // Get shape name
-  TCollection_AsciiString aName (theArgs[1]);
-  Handle(AIS_InteractiveObject) anObject;
-  if (!GetMapOfAIS().Find2 (aName, anObject))
-  {
-    theDI <<  theArgs[0] << " error: wrong object name.\n";
-    return 1;
-  }
-
-  // Enable trianle edge mode
-  anObject->Attributes()->ShadingAspect()->Aspect()->SetEdgeOff();
-
-  // Parse parameters
-  if (theArgNum == 3)
-  {
-    TCollection_AsciiString aParam ((theArgs[2]));
-    if (aParam.IsEqual ("-force"))
-    {
-      isForceRedisplay = Standard_True;
-    }
-    else
-    {
-       theDI <<  theArgs[0] << " error: unknown parameter '"
-              << aParam.ToCString() << "'.\n";
-       return 1;
-    }
-  }
-
-  // Update shape presentation as aspect parameters were changed
-  if (isForceRedisplay)
-  {
-    ViewerTest::GetAISContext()->Redisplay (anObject, Standard_False);
-  }
-  else
-  {
-    anObject->SetAspect (anObject->Attributes()->ShadingAspect());
-  }
-
-  //Update view
-  ViewerTest::CurrentView()->Redraw();
-
-  return 0;
-}
-
-
 //=======================================================================
 //function : VVertexMode
 //purpose  : Switches vertex display mode for AIS_Shape or displays the current value
@@ -6639,18 +6461,6 @@ void ViewerTest::ObjectCommands(Draw_Interpretor& theCommands)
                             "vfont [-add pathToFont [fontName] [regular,bold,italic,boldItalic=undefined] [singleStroke]]"
                    "\n\t\t:        [-find fontName [regular,bold,italic,boldItalic=undefined]] [-verbose {on|off}]",
                    __FILE__, VFont, group);
-  
-  theCommands.Add ("vsetedgetype",
-                   "vsetedgetype usage:\n"
-                   "vsetedgetype ShapeName [-force] [-type {solid, dash, dot}] [-color R G B] "
-                   "\n\t\t:        Sets edges type and color for input shape",
-                   __FILE__, VSetEdgeType, group);
-
-  theCommands.Add ("vunsetedgetype",
-                   "vunsetedgetype usage:\n"
-                   "vunsetedgetype ShapeName [-force]"
-                   "\n\t\t:        Unsets edges type and color for input shape",
-                   __FILE__, VUnsetEdgeType, group);
 
   theCommands.Add ("vvertexmode",
                    "vvertexmode [name | -set {isolated | all | inherited} [name1 name2 ...]]\n"
index 4fae1a9..7d04971 100644 (file)
@@ -5923,6 +5923,7 @@ static int VCaps (Draw_Interpretor& theDI,
     theDI << "Sprites: " << (aCaps->pntSpritesDisable ? "0" : "1") << "\n";
     theDI << "SoftMode:" << (aCaps->contextNoAccel    ? "1" : "0") << "\n";
     theDI << "FFP:     " << (aCaps->ffpEnable         ? "1" : "0") << "\n";
+    theDI << "PolygonMode: " << (aCaps->usePolygonMode ? "1" : "0") << "\n";
     theDI << "VSync:   " <<  aCaps->swapInterval                   << "\n";
     theDI << "Compatible:" << (aCaps->contextCompatible ? "1" : "0") << "\n";
     theDI << "Stereo:  " << (aCaps->contextStereo ? "1" : "0") << "\n";
@@ -5961,6 +5962,16 @@ static int VCaps (Draw_Interpretor& theDI,
       }
       aCaps->ffpEnable = toEnable;
     }
+    else if (anArgCase == "-polygonmode")
+    {
+      Standard_Boolean toEnable = Standard_True;
+      if (++anArgIter < theArgNb
+      && !ViewerTest::ParseOnOff (theArgVec[anArgIter], toEnable))
+      {
+        --anArgIter;
+      }
+      aCaps->usePolygonMode = toEnable;
+    }
     else if (anArgCase == "-vbo")
     {
       Standard_Boolean toEnable = Standard_True;
@@ -10566,6 +10577,30 @@ static Standard_Integer VRenderParams (Draw_Interpretor& theDI,
         aParams.NbMsaaSamples = aNbSamples;
       }
     }
+    else if (aFlag == "-linefeather"
+          || aFlag == "-edgefeather"
+          || aFlag == "-feather")
+    {
+      if (toPrint)
+      {
+        theDI << " " << aParams.LineFeather << " ";
+        continue;
+      }
+      else if (++anArgIter >= theArgNb)
+      {
+        std::cerr << "Error: wrong syntax at argument '" << anArg << "'\n";
+        return 1;
+      }
+
+      TCollection_AsciiString aParam = theArgVec[anArgIter];
+      const Standard_ShortReal aFeather = (Standard_ShortReal) Draw::Atof (theArgVec[anArgIter]);
+      if (aFeather <= 0.0f)
+      {
+        std::cerr << "Error: invalid value of line width feather " << aFeather << ". Should be > 0\n";
+        return 1;
+      }
+      aParams.LineFeather = aFeather;
+    }
     else if (aFlag == "-oit")
     {
       if (toPrint)
@@ -12590,7 +12625,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "\n\t\t:  greenMagentaSimple",
     __FILE__, VStereo, group);
   theCommands.Add ("vcaps",
-            "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}]"
+            "vcaps [-vbo {0|1}] [-sprites {0|1}] [-ffp {0|1}] [-polygonMode {0|1}]"
     "\n\t\t:       [-compatibleProfile {0|1}]"
     "\n\t\t:       [-vsync {0|1}] [-useWinBuffer {0|1}]"
     "\n\t\t:       [-quadBuffer {0|1}] [-stereo {0|1}]"
@@ -12599,6 +12634,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "\n\t\t:  FFP      - use fixed-function pipeline instead of"
     "\n\t\t:             built-in GLSL programs"
     "\n\t\t:            (requires compatible profile)"
+    "\n\t\t:  polygonMode - use Polygon Mode instead of built-in GLSL programs"
     "\n\t\t:  VBO      - use Vertex Buffer Object (copy vertex"
     "\n\t\t:             arrays to GPU memory)"
     "\n\t\t:  sprite   - use textured sprites instead of bitmaps"
@@ -12893,6 +12929,7 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands)
     "\n    Manages rendering parameters: "
     "\n      '-raster'                   Disables GPU ray-tracing"
     "\n      '-msaa         0..4'        Specifies number of samples for MSAA"
+    "\n      '-lineFeather  > 0'         Sets line feather factor"
     "\n      '-oit          off|0.0-1.0' Enables/disables OIT and sets depth weight factor"
     "\n      '-depthPrePass on|off'      Enables/disables depth pre-pass"
     "\n      '-alphatocoverage on|off'   Enables/disables alpha to coverage (needs MSAA)"
index f8e2594..ac02e7d 100644 (file)
@@ -10,11 +10,12 @@ bcut result sp b1
 trotate result 0 0 0 1 0 0 45
 incmesh result 0.1
 
-vinit
+vclear
+vinit View1
+vaxo
 vdefaults -autoTriang 0
-vdisplay result
-vsetinteriorstyle 1
-vsetdispmode 1
+vdisplay -dispMode 1 result
+vaspects result -setInteriorStyle HOLLOW -setDrawEdges 1
 vfit
 
 set log [tricheck result]
index 5a6277e..b7e55c1 100755 (executable)
@@ -2,23 +2,17 @@ puts "========================"
 puts "BUC60738"                
 puts "========================"
 puts ""                                  
-puts "=================================="
-puts "It takes visual check for this BUG"
-puts "=================================="
-                        
-vinit
-BUC60738
-vfit
-vsetdispmode 1
-
 
-set x_coord 261
-set y_coord 314
+vclear
+vinit View1
+vaxo
 
-checkcolor $x_coord $y_coord 0 1 0
-
-if {$stat != 1} {
-   puts "Error : The style of edge is NOT dash"
-}
+psphere s 20
+ttranslate s -40 0 0
+vdisplay -dispMode 1 s
+vfit
+vaspects s -setInteriorStyle HOLLOW -setDrawEdges 1 -setEdgeType DASH -setEdgeColor GREEN
 
-checkview -screenshot -3d -path ${imagedir}/${test_image}.png
+checkcolor 261 314 0 1 0
+if {$stat != 1} { puts "Error : The style of edge is NOT dash" }
+vdump $imagedir/${casename}.png
index 042b14f..eb307c6 100755 (executable)
@@ -1,27 +1,18 @@
 puts "============"
-puts "OCC23363"
+puts "0023363: Lost gradient background when switching to the hollow interior style"
 puts "============"
 puts ""
-####################################################################################
-# [Regression] Lost gradient background when switching to the hollow interior style
-####################################################################################
 
-set BugNumber OCC23363
-
-vinit
+vclear
+vinit View1
+vaxo
 vsetgradientbg 250 0 0 0 255 0 2
 pcylinder p 100 200
-vdisplay p
-vsetdispmode p 1
-vsetinteriorstyle p 1
+vdisplay -dispMode 1 p
+vaspects p -setInteriorStyle HOLLOW -setDrawEdges 1
 
-puts ""
 set color1 [vreadpixel 10 0 rgb]
 set rd1 [lindex $color1 0]
-if { $rd1 == 0 } {
-  puts "Faulty ${BugNumber}"
-} else {
-  puts "OK ${BugNumber}"
-}
+if { $rd1 == 0 } { puts "Faulty ${BugNumber}" }
 
 checkview -screenshot -3d -path ${imagedir}/${test_image}.png
index 8acdc74..d3ec639 100644 (file)
@@ -7,10 +7,8 @@ vclear
 vinit View1
 pload MODELING VISUALIZATION
 box b 10 10 10
-vclear
-vinit View1
 vdisplay -dispMode 1 b
 vfit
-vsetinteriorstyle b 2
+vaspects b -setInteriorStyle HATCH
 
 vdump $imagedir/${casename}.png
index 981739b..a7a86ce 100644 (file)
@@ -1,30 +1,22 @@
 puts "============"
-puts "CR6987"
+puts "0006897: Impossible to change edge line type in 3D View"
 puts "============"
 puts ""
-#######################################################################
-#  Impossible to change edge line type in 3D View
-#######################################################################
 
-pload VISUALIZATION
+pload MODELING VISUALIZATION
+vclear
+vinit View1
+vaxo
 
-set anImage1 $imagedir/${casename}_1.png
-set anImage2 $imagedir/${casename}_2.png
-set anImage3 $imagedir/${casename}_3.png
-
-vinit
 box b 1 1 1
-vdisplay b
+vdisplay -dispMode 1 b
 vfit
-vsetdispmode b 1
-vsetedgetype b -type DASH -color 10 255 10
-vdump $anImage1
-
-vsetinteriorstyle b EMPTY
-vdump $anImage2
 
-vsetinteriorstyle b SOLID
-vunsetedgetype b
-vdump $anImage3
+vaspects b -setInteriorStyle SOLID
+vdump $imagedir/${casename}_3.png
 
+vaspects b -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeType DASH -setEdgeColor 0.392 1.0 0.392
+vdump $imagedir/${casename}_1.png
 
+vaspects b -setInteriorStyle HOLLOW -setDrawEdges 1
+vdump $imagedir/${casename}_2.png
diff --git a/tests/bugs/vis/bug6897_2 b/tests/bugs/vis/bug6897_2
deleted file mode 100644 (file)
index ae0d520..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-puts "============"
-puts "CR6987"
-puts "============"
-puts ""
-##########################################################################
-# Impossible to change edge line type in 3D View
-# Tests forced redisplay of object after aspect parameter's been changed
-##########################################################################
-
-pload VISUALIZATION
-
-set anImage1 $imagedir/${casename}_1.png
-set anImage2 $imagedir/${casename}_2.png
-
-vinit
-box b 1 1 1
-vdisplay b
-vfit
-vsetdispmode b 1
-vsetedgetype b -type DASH -color 10 255 10 -force
-vdump $anImage1
-
-vunsetedgetype b -force
-vdump $anImage2
\ No newline at end of file
index d6a4e9a..0818770 100755 (executable)
@@ -1,8 +1,8 @@
 cpulimit 300
 set group "v3d"
 
-pload VISUALIZATION
-pload TOPTEST
+pload VISUALIZATION TOPTEST
+vgldebug -glslWarn 1
 
 if { [info exists imagedir] == 0 } {
   set imagedir .
index 1cfc0bb..f8d32db 100644 (file)
@@ -31,7 +31,7 @@ vdump $::imagedir/${::casename}_msaa2.png
 vrenderparams -msaa 2 -alphaToCoverage 1
 vdump $::imagedir/${::casename}_msaa2_cov.png
 
-vrenderparams -msaa 8 -alphaToCoverage 1
+vrenderparams -msaa 8 -alphaToCoverage 0
 vdump $::imagedir/${::casename}_msaa8.png
 
 vrenderparams -msaa 8 -alphaToCoverage 1
diff --git a/tests/v3d/glsl/interior1 b/tests/v3d/glsl/interior1
new file mode 100644 (file)
index 0000000..eb95ada
--- /dev/null
@@ -0,0 +1,72 @@
+puts "============"
+puts "0029076: Visualization - implement element shrinking Shader"
+puts "Test case on spheres"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION
+vclear
+vclose ALL
+vinit View1 -width 768 -height 409
+vdefaults -autoTriang 0
+vzbufftrihedron
+psphere s1 2
+psphere s2 1
+psphere s3 1
+psphere s4 1
+psphere s5 1
+compound s1 s2 s3 s4 s5 c
+incmesh c 1.0
+vdisplay -dispMode 1 s1 s2 s3 s4 s5
+vsetlocation s2 -1.3 -1.3  1.3
+vsetlocation s3  1.3  1.3  1.3
+vsetlocation s4  1.3 -1.3  0.0
+vsetlocation s5 -1.3 -1.3 -1.3
+vrotate 0.0 0.5 0.0
+vrotate 0.4 0.0 0.0
+vfit
+
+vaspects  s1 -setShadingModel PHONG -setInteriorStyle HOLLOW -setDrawEdges 1 -color GRAY80
+vdrawtext t1 " s1: phong hollow-edges " -pos 2 0 0 -disptype SUBTITLE -color BLACK -subColor GRAY80
+
+vaspects  s2 -setShadingModel GOURAUD -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor YELLOW
+vdrawtext t2 " s2: gouraud solid-edges " -pos -1.3 -1.3 2.5 -halign CENTER -disptype SUBTITLE -color BLACK -subColor YELLOW
+
+vaspects  s3 -setShadingModel PHONG -setInteriorStyle SOLID -setDrawEdges 1 -edgeWidth 2 -setEdgeColor BLUE1
+vdrawtext t3 " s3: phong solid-edges " -pos 1.3 1.3 2.5 -halign CENTER -disptype SUBTITLE -color WHITE -subColor BLUE1
+
+vaspects  s4 -setShadingModel GOURAUD -setInteriorStyle HIDDENLINE -setDrawEdges 1 -setEdgeColor RED
+vdrawtext t4 " s4: hiddenline-edges " -pos 1.3 -1.3 -1.3 -halign CENTER -disptype SUBTITLE -color BLACK -subColor RED
+
+vaspects  s5 -setShadingModel FLAT -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor 0 1 0 0 -edgeWidth 3
+vdrawtext t5 " s5: flat solid-edges " -pos -1.3 -1.3 -2.5 -halign CENTER -disptype SUBTITLE -color BLACK -subColor GREEN
+
+vrenderparams -msaa 0
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_ortho_polmode.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_ortho_glsl.png
+
+vrenderparams -msaa 4
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_ortho_polmode_msaa.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_ortho_glsl_msaa.png
+
+vcamera -persp
+vzoom 0.8
+vrenderparams -msaa 0
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_persp_polmode.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_persp_glsl.png
+
+vrenderparams -msaa 4
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_persp_polmode_msaa.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_persp_glsl_msaa.png
diff --git a/tests/v3d/glsl/interior2 b/tests/v3d/glsl/interior2
new file mode 100644 (file)
index 0000000..b852e5b
--- /dev/null
@@ -0,0 +1,69 @@
+puts "============"
+puts "0029076: Visualization - implement element shrinking Shader"
+puts "Test case on boxes"
+puts "============"
+puts ""
+
+pload MODELING VISUALIZATION
+vclear
+vclose ALL
+vinit View1 -width 768 -height 409
+vzbufftrihedron
+vsetgradientbg 180 200 255 180 180 180 2
+box b1 -2 0  2 1 0.2 1
+box b2  2 0  2 1 0.2 1
+box b3  0 0  0 1 0.2 1
+box b4 -2 0 -2 1 0.2 1
+box b5  2 0 -2 1 0.2 1
+vdisplay -dispMode 1 b1 b2 b3 b4 b5
+vfit
+
+vaspects  b1 -setShadingModel PHONG -setInteriorStyle HOLLOW -setDrawEdges 1 -color BLACK
+vdrawtext t1 " b1: phong hollow-edges " -pos -2 0 2 -halign RIGHT -disptype SUBTITLE -color WHITE -subColor BLACK
+
+vaspects  b2 -setShadingModel GOURAUD -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor YELLOW
+vdrawtext t2 " b2: gouraud solid-edges " -pos 2 0 2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor YELLOW
+
+vaspects  b3 -setShadingModel PHONG -setInteriorStyle SOLID -setDrawEdges 1 -edgeWidth 2 -setEdgeColor BLUE1
+vdrawtext t3 " b3: phong solid-edges " -pos 0 0 0 -halign RIGHT -disptype SUBTITLE -color WHITE -subColor BLUE1
+
+vaspects  b4 -setShadingModel GOURAUD -setInteriorStyle HIDDENLINE -setDrawEdges 1 -setEdgeColor RED
+vdrawtext t4 " b4: hiddenline-edges " -pos -2 0 -2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor RED
+
+vaspects  b5 -setShadingModel FLAT -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor 0 1 0 0 -edgeWidth 3
+vdrawtext t5 " b5: flat solid-edges " -pos 2 0 -2 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor GREEN
+
+vdrawparray p6 triangles v 0 0 0 v 0 1 0 v 1 1 0 v 1 0 0 v 2 1 0 v 2 0 0 e 3 e 1 e 2 e 1 e 3 e 4 e 5 e 4 e 3 e 4 e 5 e 6
+vlocation p6 -setLocation 2 1 0
+vaspects p6 -setInteriorStyle SOLID -setDrawEdges 1 -setEdgeColor FIREBRICK -setEdgeWidth 4 -setQuadEdges 1
+vdrawtext t6 " p6: quads " -pos 2 1 -0.4 -halign RIGHT -disptype SUBTITLE -color BLACK -subColor FIREBRICK
+
+vrenderparams -msaa 0
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_ortho_polmode.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_ortho_glsl.png
+
+vrenderparams -msaa 4
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_ortho_polmode_msaa.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_ortho_glsl_msaa.png
+
+vcamera -persp
+vzoom 0.7
+vrenderparams -msaa 0
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_persp_polmode.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_persp_glsl.png
+
+vrenderparams -msaa 4
+vcaps -polygonMode 1
+vdump $imagedir/${casename}_persp_polmode_msaa.png
+
+vcaps -polygonMode 0
+vdump $imagedir/${casename}_persp_glsl_msaa.png