]> OCCT Git - occt-copy.git/commitdiff
0031698: Visualization, Graphic3d_Aspects - provide stipple line factor parameter...
authorkgv <kgv@opencascade.com>
Tue, 4 Aug 2020 07:38:58 +0000 (10:38 +0300)
committermsv <msv@opencascade.com>
Thu, 6 Aug 2020 10:31:03 +0000 (13:31 +0300)
Added Graphic3d_AspectLine3d::LineStippleFactor() property.
Added -stippleFactor argument to vaspects command.

src/Graphic3d/Graphic3d_AspectLine3d.cxx
src/Graphic3d/Graphic3d_AspectLine3d.hxx
src/OpenGl/OpenGl_PrimitiveArray.cxx
src/ViewerTest/ViewerTest.cxx
tests/v3d/glsl/stipple_line2

index bb760f3017bc5857994fc81441815081b9dd9349..921e803f8ed690fd4e8fcf60fbc6beed3ce5dc8d 100644 (file)
@@ -25,6 +25,7 @@ Graphic3d_AspectLine3d::Graphic3d_AspectLine3d()
 : myColor (Quantity_NOC_YELLOW),
   myType  (Aspect_TOL_SOLID),
   myWidth (1.0f),
+  myLineFactor  (1),
   myLinePattern (0xFFFF)
 {
   //
@@ -40,6 +41,7 @@ Graphic3d_AspectLine3d::Graphic3d_AspectLine3d (const Quantity_Color&   theColor
 : myColor (theColor),
   myType  (theType),
   myWidth ((float )theWidth),
+  myLineFactor  (1),
   myLinePattern (DefaultLinePatternForType (theType))
 {
   if (myWidth <= 0.0f)
index abf0cd7f22fa719d156ec9232bd182d1b27521e2..6a5cd740b59ba19dfaf3fcc73cda72a2a7f7c8da 100644 (file)
@@ -107,6 +107,19 @@ public:
     return Aspect_TOL_USERDEFINED;
   }
 
+  //! Return a multiplier for each bit in the line stipple pattern within [1, 256] range; 1 by default.
+  uint16_t LineStippleFactor() const { return myLineFactor; }
+
+  //! Set a multiplier for each bit in the line stipple pattern.
+  void SetLineStippleFactor (uint16_t theFactor)
+  {
+    if (theFactor == 0 || theFactor > 256)
+    {
+      throw Standard_OutOfRange ("Graphic3d_Aspects::SetLineStippleFactor(), bad factor value");
+    }
+    myLineFactor = theFactor;
+  }
+
   //! Return line width.
   Standard_ShortReal Width() const { return myWidth; }
 
@@ -141,6 +154,7 @@ public:
 
     return myProgram == theOther.myProgram
         && myType    == theOther.myType
+        && myLineFactor == theOther.myLineFactor
                && myLinePattern == theOther.myLinePattern
         && myColor   == theOther.myColor
         && myWidth   == theOther.myWidth;
@@ -165,6 +179,7 @@ protected:
   Quantity_ColorRGBA myColor;
   Aspect_TypeOfLine  myType;
   Standard_ShortReal myWidth;
+  uint16_t           myLineFactor;
   uint16_t           myLinePattern;
 
 };
index 5de66282ce51998d1e90edffc6b03ab530d00473..d967534b5f5d23e4f16703900dabbaa1adb569fa 100644 (file)
@@ -475,7 +475,7 @@ void OpenGl_PrimitiveArray::drawEdges (const OpenGl_Vec4&              theEdgeCo
   myVboAttribs->BindPositionAttribute (aGlContext);
 
   aGlContext->SetColor4fv   (theEdgeColour);
-  aGlContext->SetLineStipple(anAspect->Aspect()->LinePattern());
+  aGlContext->SetLineStipple((float )anAspect->Aspect()->LineStippleFactor(), anAspect->Aspect()->LinePattern());
   aGlContext->SetLineWidth  (anAspect->Aspect()->Width());
 
   if (!myVboIndices.IsNull())
@@ -835,7 +835,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
     if (myDrawMode == GL_LINES
      || myDrawMode == GL_LINE_STRIP)
     {
-      aCtx->SetLineStipple(anAspectLine->Aspect()->LinePattern());
+      aCtx->SetLineStipple((float )anAspectLine->Aspect()->LineStippleFactor(), anAspectLine->Aspect()->LinePattern());
       aCtx->SetLineWidth  (anAspectLine->Aspect()->Width());
     }
 
index 26eb4d47414420f946efbc2f70e032b5f5fa9c1f..3ca6389f2f93000e702030b1bfc2cbeb1e394499 100644 (file)
@@ -1664,6 +1664,7 @@ struct ViewerTest_AspectsChangeSet
 
   Standard_Integer         ToSetTypeOfLine;
   uint16_t                 StippleLinePattern;
+  uint16_t                 StippleLineFactor;
 
   Standard_Integer         ToSetTypeOfMarker;
   Aspect_TypeOfMarker      TypeOfMarker;
@@ -1710,6 +1711,7 @@ struct ViewerTest_AspectsChangeSet
     LineWidth         (1.0),
     ToSetTypeOfLine   (0),
     StippleLinePattern(0xFFFF),
+    StippleLineFactor (1),
     ToSetTypeOfMarker (0),
     TypeOfMarker      (Aspect_TOM_PLUS),
     ToSetMarkerSize   (0),
@@ -2129,6 +2131,25 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     {
       aChangeSet->ToSetTypeOfLine = -1;
     }
+    else if (anArg == "-setstipplelinefactor"
+          || anArg == "-setstipplefactor"
+          || anArg == "-setlinefactor"
+          || anArg == "-stipplelinefactor"
+          || anArg == "-stipplefactor"
+          || anArg == "-linefactor")
+    {
+      if (aChangeSet->ToSetTypeOfLine == -1)
+      {
+        std::cout << "Error: -setStippleLineFactor requires -setLineType\n";
+        return 1;
+      }
+      if (++anArgIter >= theArgNb)
+      {
+        std::cout << "Error: wrong syntax at " << anArg << "\n";
+        return 1;
+      }
+      aChangeSet->StippleLineFactor = (uint16_t )Draw::Atoi (theArgVec[anArgIter]);
+    }
     else if (anArg == "-setmarkertype"
           || anArg == "-setpointtype")
     {
@@ -2340,6 +2361,7 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
       aChangeSet->LineWidth = 1.0;
       aChangeSet->ToSetTypeOfLine = -1;
       aChangeSet->StippleLinePattern = 0xFFFF;
+      aChangeSet->StippleLineFactor = 1;
       aChangeSet->ToSetTypeOfMarker = -1;
       aChangeSet->TypeOfMarker = Aspect_TOM_PLUS;
       aChangeSet->ToSetMarkerSize = -1;
@@ -2493,10 +2515,15 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
     if (aChangeSet->ToSetTypeOfLine != 0)
     {
       aDrawer->LineAspect()->Aspect()->SetLinePattern           (aChangeSet->StippleLinePattern);
+      aDrawer->LineAspect()->Aspect()->SetLineStippleFactor     (aChangeSet->StippleLineFactor);
       aDrawer->WireAspect()->Aspect()->SetLinePattern           (aChangeSet->StippleLinePattern);
+      aDrawer->WireAspect()->Aspect()->SetLineStippleFactor     (aChangeSet->StippleLineFactor);
       aDrawer->FreeBoundaryAspect()->Aspect()->SetLinePattern   (aChangeSet->StippleLinePattern);
+      aDrawer->FreeBoundaryAspect()->Aspect()->SetLineStippleFactor (aChangeSet->StippleLineFactor);
       aDrawer->UnFreeBoundaryAspect()->Aspect()->SetLinePattern (aChangeSet->StippleLinePattern);
+      aDrawer->UnFreeBoundaryAspect()->Aspect()->SetLineStippleFactor (aChangeSet->StippleLineFactor);
       aDrawer->SeenLineAspect()->Aspect()->SetLinePattern       (aChangeSet->StippleLinePattern);
+      aDrawer->SeenLineAspect()->Aspect()->SetLineStippleFactor (aChangeSet->StippleLineFactor);
     }
     if (aChangeSet->ToSetTypeOfMarker != 0)
     {
@@ -2671,10 +2698,15 @@ static Standard_Integer VAspects (Draw_Interpretor& /*theDI*/,
         if (aChangeSet->ToSetTypeOfLine != 0)
         {
           aDrawer->LineAspect()->Aspect()->SetLinePattern           (aChangeSet->StippleLinePattern);
+          aDrawer->LineAspect()->Aspect()->SetLineStippleFactor     (aChangeSet->StippleLineFactor);
           aDrawer->WireAspect()->Aspect()->SetLinePattern           (aChangeSet->StippleLinePattern);
+          aDrawer->WireAspect()->Aspect()->SetLineStippleFactor     (aChangeSet->StippleLineFactor);
           aDrawer->FreeBoundaryAspect()->Aspect()->SetLinePattern   (aChangeSet->StippleLinePattern);
+          aDrawer->FreeBoundaryAspect()->Aspect()->SetLineStippleFactor (aChangeSet->StippleLineFactor);
           aDrawer->UnFreeBoundaryAspect()->Aspect()->SetLinePattern (aChangeSet->StippleLinePattern);
+          aDrawer->UnFreeBoundaryAspect()->Aspect()->SetLineStippleFactor (aChangeSet->StippleLineFactor);
           aDrawer->SeenLineAspect()->Aspect()->SetLinePattern       (aChangeSet->StippleLinePattern);
+          aDrawer->SeenLineAspect()->Aspect()->SetLineStippleFactor (aChangeSet->StippleLineFactor);
           toRedisplay = Standard_True;
         }
         if (aChangeSet->ToSetTypeOfMarker != 0)
@@ -6254,7 +6286,8 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
       "\n\t\t:          [-setMaterial MatName] [-unsetMaterial]"
       "\n\t\t:          [-setTransparency Transp] [-unsetTransparency]"
       "\n\t\t:          [-setWidth LineWidth] [-unsetWidth]"
-      "\n\t\t:          [-setLineType {solid|dash|dot|dotDash|0xHexPattern}] [-unsetLineType]"
+      "\n\t\t:          [-setLineType {solid|dash|dot|dotDash|0xHexPattern} [-stippleFactor factor]]"
+      "\n\t\t:          [-unsetLineType]"
       "\n\t\t:          [-setMarkerType {.|+|x|O|xcircle|pointcircle|ring1|ring2|ring3|ball|ImagePath}]"
       "\n\t\t:          [-unsetMarkerType]"
       "\n\t\t:          [-setMarkerSize Scale] [-unsetMarkerSize]"
index ba3a3ba33cd94a0bd185808860f226623fcb54ce..d9e45e3c38b7d848e260408658304c55356f3394 100644 (file)
@@ -10,6 +10,6 @@ vclear
 vinit View1
 vdisplay -dispMode 0 b1 b2
 vfit
-vaspects b1 -setLineWidth 4 -setLineType FF00 -setColor RED
-vaspects b2 -setLineWidth 4 -setLineType 00FF -setColor GREEN
+vaspects b1 -setLineWidth 4 -setLineType FF00 -setColor RED   -setStippleLineFactor 2
+vaspects b2 -setLineWidth 4 -setLineType 00FF -setColor GREEN -setStippleLineFactor 2
 vdump $::imagedir/${::casename}_glsl.png