0027039: Draw Harness, ViewerTest - Fix rubber-band blinking
authorkgv <kgv@opencascade.com>
Fri, 25 Dec 2015 12:53:27 +0000 (15:53 +0300)
committerbugmaster <bugmaster@opencascade.com>
Wed, 13 Jan 2016 12:04:11 +0000 (15:04 +0300)
ViewerTest - eliminate redundant redraw calls.
Configure AIS_RubberBand to use filled style.

AIS_RubberBand - define vertex normals to workaround transparency issue in TKOpenGl.

src/AIS/AIS_RubberBand.cxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx

index 2169e8d..627e0d3 100644 (file)
@@ -42,6 +42,7 @@ AIS_RubberBand::AIS_RubberBand()
 {
   myDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0));
   myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+  myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NOM_PLASTIC);
   myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_EMPTY);
   myDrawer->ShadingAspect()->SetTransparency (1.0);
   myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
@@ -60,6 +61,7 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
 {
   myDrawer->SetLineAspect (new Prs3d_LineAspect (theLineColor, theLineType, theWidth));
   myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+  myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NOM_PLASTIC);
   myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_EMPTY);
   myDrawer->ShadingAspect()->SetTransparency (1.0);
   myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
@@ -80,6 +82,7 @@ AIS_RubberBand::AIS_RubberBand (const Quantity_Color& theLineColor,
 {
   myDrawer->SetLineAspect (new Prs3d_LineAspect (theLineColor, theLineType, theLineWidth));
   myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
+  myDrawer->ShadingAspect()->SetMaterial (Graphic3d_NOM_PLASTIC);
   myDrawer->ShadingAspect()->SetColor (theFillColor);
   myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
   myDrawer->ShadingAspect()->SetTransparency (theTransparency);
@@ -324,7 +327,7 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
   if (myTriangles.IsNull() || myTriangles->VertexNumber() != myPoints.Length() + 1)
   {
     toFill = Standard_True;
-    myTriangles = new Graphic3d_ArrayOfTriangles (aTriangles.Extent() * 3);
+    myTriangles = new Graphic3d_ArrayOfTriangles (aTriangles.Extent() * 3, 0, Standard_True);
   }
 
   Standard_Integer aVertexIndex = 1;
@@ -349,9 +352,11 @@ Standard_Boolean AIS_RubberBand::fillTriangles()
 
     if (toFill)
     {
+      gp_Dir aNorm = gp::DZ();
       for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
       {
-        myTriangles->AddVertex (aPts[anIt].X(), aPts[anIt].Y(), 0.0);
+        myTriangles->AddVertex (aPts[anIt].X(), aPts[anIt].Y(), 0.0,
+                                aNorm.X(), aNorm.Y(), aNorm.Z());
       }
     }
     else
index 298a33e..82efbca 100644 (file)
@@ -201,7 +201,8 @@ Standard_EXPORT const Handle(AIS_RubberBand)& GetRubberBand()
   static Handle(AIS_RubberBand) aBand;
   if (aBand.IsNull())
   {
-    aBand = new AIS_RubberBand();
+    aBand = new AIS_RubberBand (Quantity_NOC_LIGHTBLUE, Aspect_TOL_SOLID, Quantity_NOC_LIGHTBLUE, 0.4, 1.0);
+    aBand->SetDisplayMode (0);
   }
   return aBand;
 }
@@ -1940,10 +1941,11 @@ static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd,
     case WM_MOUSEMOVE:
       if (IsDragged)
       {
+        bool toRedraw = false;
         if (!DragFirst && ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
         {
           ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
-          ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
+          toRedraw = true;
         }
 
         DragFirst = Standard_False;
@@ -1955,7 +1957,11 @@ static LRESULT WINAPI AdvViewerWindowProc( HWND hwnd,
         {
           int aHeight = aRect.bottom - aRect.top;
           GetRubberBand()->SetRectangle (X_ButtonPress, aHeight - Y_ButtonPress, X_Motion, aHeight - Y_Motion);
-          ViewerTest::GetAISContext()->Display (GetRubberBand(), Standard_False);
+          ViewerTest::GetAISContext()->Display (GetRubberBand(), 0, -1, Standard_False, Standard_True, AIS_DS_Displayed);
+          toRedraw = true;
+        }
+        if (toRedraw)
+        {
           ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
         }
       }
@@ -2370,7 +2376,6 @@ int ViewerMainLoop(Standard_Integer argc, const char** argv)
               if (ViewerTest::GetAISContext()->IsDisplayed (GetRubberBand()))
               {
                 ViewerTest::GetAISContext()->Remove (GetRubberBand(), Standard_False);
-                ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
               }
             }
 
@@ -2384,7 +2389,7 @@ int ViewerMainLoop(Standard_Integer argc, const char** argv)
             unsigned int aWidth, aHeight, aBorderWidth, aDepth;
             XGetGeometry (aDisplay, aWindow, &aRoot, &anX, &anY, &aWidth, &aHeight, &aBorderWidth, &aDepth);
             GetRubberBand()->SetRectangle (X_ButtonPress, aHeight - Y_ButtonPress, X_Motion, aHeight - Y_Motion);
-            ViewerTest::GetAISContext()->Display (GetRubberBand(), Standard_False);
+            ViewerTest::GetAISContext()->Display (GetRubberBand(), 0, -1, Standard_False, Standard_True, AIS_DS_Displayed);
             ViewerTest::GetAISContext()->CurrentViewer()->RedrawImmediate();
           }
           else