0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / AIS / AIS_Triangulation.cxx
index 189518f..dfc0d1e 100644 (file)
@@ -56,7 +56,7 @@ void AIS_Triangulation::SetTransparency (const Standard_Real theValue)
 
   // override transparency
   myDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
-  myTransparency = theValue;
+  myDrawer->SetTransparency ((Standard_ShortReal )theValue);
 
   updatePresentation();
 }
@@ -67,7 +67,7 @@ void AIS_Triangulation::SetTransparency (const Standard_Real theValue)
 //=======================================================================
 void AIS_Triangulation::UnsetTransparency()
 {
-  myTransparency = 0.0;
+  myDrawer->SetTransparency (0.0f);
   if (!myDrawer->HasOwnShadingAspect())
   {
     return;
@@ -95,38 +95,20 @@ void AIS_Triangulation::updatePresentation()
     // modify shading presentation without re-computation
     const PrsMgr_Presentations&        aPrsList  = Presentations();
     Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
-    for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
+    for (PrsMgr_Presentations::Iterator aPrsIter (aPrsList); aPrsIter.More(); aPrsIter.Next())
     {
-      const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
-      if (aPrsModed.Mode() != AIS_WireFrame)
+      if (aPrsIter.Value()->Mode() != AIS_WireFrame)
       {
         continue;
       }
 
-      const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
-
-      if (IsTransparent())
-      {
-        aPrs->SetDisplayPriority (10); // force highest priority for translucent objects
-      }
-
+      const Handle(Prs3d_Presentation)& aPrs = aPrsIter.Value();
       for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
       {
         const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
-        if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
-        {
-          aGroup->SetGroupPrimitivesAspect (anAreaAsp);
-        }
-      }
-
-      if (!IsTransparent())
-      {
-        aPrs->ResetDisplayPriority();
+        aGroup->SetGroupPrimitivesAspect (anAreaAsp);
       }
     }
-
-    myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
-    myToRecomputeModes.Clear();
   }
 }
 
@@ -138,7 +120,7 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
                                 const Handle(Prs3d_Presentation)& aPresentation,
                                 const Standard_Integer aMode)
 {
-  switch (aMode) 
+  switch (aMode)
   {
     case 0:
       const TColgp_Array1OfPnt& nodes = myTriangulation->Nodes();             //Nodes
@@ -155,7 +137,7 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
       Standard_Integer i;
       Standard_Integer j;
 
-      Standard_Real ambient = aspect->FrontMaterial().Ambient();
+      const Standard_Real ambient = 0.2;
       if (hasVNormals)
       {
         const TShort_Array1OfShortReal& normals = myTriangulation->Normals();
@@ -213,7 +195,7 @@ void AIS_Triangulation::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aP
 
 //=======================================================================
 //function : ComputeSelection
-//purpose  : 
+//purpose  :
 //=======================================================================
 void AIS_Triangulation::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
                                          const Standard_Integer /*aMode*/)
@@ -248,7 +230,7 @@ Handle(TColStd_HArray1OfInteger) AIS_Triangulation::GetColors() const
 
 //=======================================================================
 //function : SetTriangulation
-//purpose  : 
+//purpose  :
 //=======================================================================
 void AIS_Triangulation::SetTriangulation(const Handle(Poly_Triangulation)& aTriangulation)
 {
@@ -257,7 +239,7 @@ void AIS_Triangulation::SetTriangulation(const Handle(Poly_Triangulation)& aTria
 
 //=======================================================================
 //function : GetTriangulation
-//purpose  : 
+//purpose  :
 //=======================================================================
 Handle(Poly_Triangulation) AIS_Triangulation::GetTriangulation() const{
   return myTriangulation;
@@ -265,25 +247,19 @@ Handle(Poly_Triangulation) AIS_Triangulation::GetTriangulation() const{
 
 //=======================================================================
 //function : AttenuateColor
-//purpose  : Attenuates 32-bit color by a given attenuation factor (0...1):
-//           aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
-//           All color components are multiplied by aComponent, the result is then packed again as 32-bit integer.
-//           Color attenuation is applied to the vertex colors in order to have correct visual result 
-//           after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and flat.
+//purpose  :
 //=======================================================================
-
 Graphic3d_Vec4ub AIS_Triangulation::attenuateColor (const Standard_Integer theColor,
                                                     const Standard_Real    theComposition)
 {
+  const Standard_Byte* anRgbx = reinterpret_cast<const Standard_Byte*> (&theColor);
 
-  const Graphic3d_Vec4ub& aColor = *reinterpret_cast<const Graphic3d_Vec4ub*> (&theColor);
   // If IsTranparent() is false alpha value will be ignored anyway.
   Standard_Byte anAlpha = IsTransparent() ? static_cast<Standard_Byte> (255.0 - myDrawer->ShadingAspect()->Aspect()->FrontMaterial().Transparency() * 255.0)
                                           : 255;
 
-  return Graphic3d_Vec4ub ((Standard_Byte)(theComposition * aColor.r()),
-                           (Standard_Byte)(theComposition * aColor.g()),
-                           (Standard_Byte)(theComposition * aColor.b()),
+  return Graphic3d_Vec4ub ((Standard_Byte)(theComposition * anRgbx[0]),
+                           (Standard_Byte)(theComposition * anRgbx[1]),
+                           (Standard_Byte)(theComposition * anRgbx[2]),
                            anAlpha);
 }
-