]> OCCT Git - occt.git/commitdiff
0031698: Visualization, Graphic3d_Aspects - provide stipple line factor parameter
authorkgv <kgv@opencascade.com>
Mon, 3 Aug 2020 14:53:18 +0000 (17:53 +0300)
committerbugmaster <bugmaster@opencascade.com>
Fri, 7 Aug 2020 12:17:53 +0000 (15:17 +0300)
Added Graphic3d_Aspects::LineStippleFactor() property.
Adjusted help for vaspects command suggesting a shorter syntax.

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

index e55e56561b16a03099d021173bbac4cf8192b0fd..8648a7ba4af1f57760e20a89a6ece7c592d01742 100644 (file)
@@ -30,6 +30,7 @@ Graphic3d_Aspects::Graphic3d_Aspects()
   myAlphaCutoff         (0.5f),
   myLineType            (Aspect_TOL_SOLID),
   myLineWidth           (1.0f),
+  myLineFactor          (1),
   myLinePattern         (0xFFFF),
   myMarkerType          (Aspect_TOM_POINT),
   myMarkerScale         (1.0f),
index fc519efb0d5c836e0ba3a2bf25ed982c99c8add9..bc024802aaff0414310f4e26b62c8e35ae944c7f 100644 (file)
@@ -254,6 +254,19 @@ public:
     myLinePattern = thePattern;
   }
 
+  //! 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 width for edges in pixels; 1.0 by default.
   Standard_ShortReal LineWidth() const { return myLineWidth; }
 
@@ -503,6 +516,7 @@ public:
         && myLineType  == theOther.myLineType
         && myEdgeColor == theOther.myEdgeColor
         && myLineWidth == theOther.myLineWidth
+        && myLineFactor == theOther.myLineFactor
         && myLinePattern == theOther.myLinePattern
         && myMarkerType == theOther.myMarkerType
         && myMarkerScale == theOther.myMarkerScale
@@ -548,6 +562,7 @@ protected:
 
   Aspect_TypeOfLine            myLineType;
   Standard_ShortReal           myLineWidth;
+  uint16_t                     myLineFactor;
   uint16_t                     myLinePattern;
 
   Aspect_TypeOfMarker          myMarkerType;
index 2b8cb2f437e3dfb0d1c387c79b81498ad60e3174..c943f915880a99763ac5c060c4fb627d03757c70 100644 (file)
@@ -535,7 +535,7 @@ void OpenGl_PrimitiveArray::drawEdges (const Handle(OpenGl_Workspace)& theWorksp
   aGlContext->SetColor4fv (theWorkspace->EdgeColor().a() >= 0.1f
                          ? theWorkspace->EdgeColor()
                          : theWorkspace->View()->BackgroundColor());
-  aGlContext->SetLineStipple(anAspect->Aspect()->LinePattern());
+  aGlContext->SetLineStipple((float )anAspect->Aspect()->LineStippleFactor(), anAspect->Aspect()->LinePattern());
   aGlContext->SetLineWidth  (anAspect->Aspect()->EdgeWidth());
 
   if (!myVboIndices.IsNull())
@@ -1035,7 +1035,7 @@ void OpenGl_PrimitiveArray::Render (const Handle(OpenGl_Workspace)& theWorkspace
       if (myDrawMode == GL_LINES
        || myDrawMode == GL_LINE_STRIP)
       {
-        aCtx->SetLineStipple(anAspectFace->Aspect()->LinePattern());
+        aCtx->SetLineStipple((float )anAspectFace->Aspect()->LineStippleFactor(), anAspectFace->Aspect()->LinePattern());
         aCtx->SetLineWidth  (anAspectFace->Aspect()->LineWidth());
       }
 
index 0da47452b0dac9da4546dd3b62bbd9bbddd9299b..d28ac98fa0fb9da668ba059ec2000e5fde55c617 100644 (file)
@@ -1863,6 +1863,7 @@ struct ViewerTest_AspectsChangeSet
 
   Standard_Integer             ToSetTypeOfLine;
   uint16_t                     StippleLinePattern;
+  uint16_t                     StippleLineFactor;
 
   Standard_Integer             ToSetTypeOfMarker;
   Aspect_TypeOfMarker          TypeOfMarker;
@@ -1949,6 +1950,7 @@ struct ViewerTest_AspectsChangeSet
     LineWidth         (1.0),
     ToSetTypeOfLine   (0),
     StippleLinePattern(0xFFFF),
+    StippleLineFactor (1),
     ToSetTypeOfMarker (0),
     TypeOfMarker      (Aspect_TOM_PLUS),
     ToSetMarkerSize   (0),
@@ -2131,10 +2133,15 @@ struct ViewerTest_AspectsChangeSet
       {
         toRecompute = theDrawer->SetOwnLineAspects() || toRecompute;
         theDrawer->LineAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->LineAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
         theDrawer->WireAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->WireAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
         theDrawer->FreeBoundaryAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->FreeBoundaryAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
         theDrawer->UnFreeBoundaryAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->UnFreeBoundaryAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
         theDrawer->SeenLineAspect()->Aspect()->SetLinePattern (StippleLinePattern);
+        theDrawer->SeenLineAspect()->Aspect()->SetLineStippleFactor (StippleLineFactor);
       }
     }
     if (ToSetTypeOfMarker != 0)
@@ -2904,6 +2911,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)
+      {
+        Message::SendFail() << "Error: -setStippleLineFactor requires -setLineType";
+        return 1;
+      }
+      if (++anArgIter >= theArgNb)
+      {
+        Message::SendFail() << "Error: wrong syntax at " << anArg;
+        return 1;
+      }
+      aChangeSet->StippleLineFactor = (uint16_t )Draw::Atoi (theArgVec[anArgIter]);
+    }
     else if (anArg == "-setmarkertype"
           || anArg == "-markertype"
           || anArg == "-setpointtype"
@@ -3338,6 +3364,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;
@@ -6747,46 +6774,44 @@ void ViewerTest::Commands(Draw_Interpretor& theCommands)
                  __FILE__,VSubInt,group);
 
   theCommands.Add("vaspects",
-              "vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults]"
-      "\n\t\t:          [-setVisibility 0|1]"
-      "\n\t\t:          [-setColor ColorName] [-setcolor R G B] [-unsetColor]"
-      "\n\t\t:          [-setBackFaceColor Color]"
-      "\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:          [-setMarkerType {.|+|x|O|xcircle|pointcircle|ring1|ring2|ring3|ball|ImagePath}]"
+              "vaspects [-noupdate|-update] [name1 [name2 [...]] | -defaults] [-subshapes subname1 [subname2 [...]]]"
+      "\n\t\t:          [-visibility {0|1}]"
+      "\n\t\t:          [-color {ColorName | R G B}] [-unsetColor]"
+      "\n\t\t:          [-backfaceColor Color]"
+      "\n\t\t:          [-material MatName] [-unsetMaterial]"
+      "\n\t\t:          [-transparency Transp] [-unsetTransparency]"
+      "\n\t\t:          [-width LineWidth] [-unsetWidth]"
+      "\n\t\t:          [-lineType {solid|dash|dot|dotDash|0xHexPattern} [-stippleFactor factor]]"
+      "\n\t\t:          [-unsetLineType]"
+      "\n\t\t:          [-markerType {.|+|x|O|xcircle|pointcircle|ring1|ring2|ring3|ball|ImagePath}]"
       "\n\t\t:          [-unsetMarkerType]"
-      "\n\t\t:          [-setMarkerSize Scale] [-unsetMarkerSize]"
-      "\n\t\t:          [-freeBoundary {off/on | 0/1}]"
-      "\n\t\t:          [-setFreeBoundaryWidth Width] [-unsetFreeBoundaryWidth]"
-      "\n\t\t:          [-setFreeBoundaryColor {ColorName | R G B}] [-unsetFreeBoundaryColor]"
-      "\n\t\t:          [-subshapes subname1 [subname2 [...]]]"
-      "\n\t\t:          [-isoontriangulation 0|1]"
-      "\n\t\t:          [-setMaxParamValue {value}]"
-      "\n\t\t:          [-setSensitivity {selection_mode} {value}]"
-      "\n\t\t:          [-setShadingModel {unlit|flat|gouraud|phong}]"
+      "\n\t\t:          [-markerSize Scale] [-unsetMarkerSize]"
+      "\n\t\t:          [-freeBoundary {0|1}]"
+      "\n\t\t:          [-freeBoundaryWidth Width] [-unsetFreeBoundaryWidth]"
+      "\n\t\t:          [-freeBoundaryColor {ColorName | R G B}] [-unsetFreeBoundaryColor]"
+      "\n\t\t:          [-isoOnTriangulation 0|1]"
+      "\n\t\t:          [-maxParamValue {value}]"
+      "\n\t\t:          [-sensitivity {selection_mode} {value}]"
+      "\n\t\t:          [-shadingModel {unlit|flat|gouraud|phong|pbr|pbr_facet}]"
       "\n\t\t:          [-unsetShadingModel]"
-      "\n\t\t:          [-setInterior {solid|hatch|hidenline|point}]"
-      "\n\t\t:          [-unsetInterior] [-setHatch HatchStyle]"
-      "\n\t\t:          [-setFaceBoundaryDraw {0|1}] [-setMostContinuity {c0|c1|c2|c3|cn}"
-      "\n\t\t:          [-setFaceBoundaryWidth LineWidth] [-setFaceBoundaryColor R G B] [-setFaceBoundaryType LineType]"
-      "\n\t\t:          [-setDrawEdges {0|1}] [-setEdgeType LineType] [-setEdgeColor R G B] [-setQuadEdges {0|1}]"
-      "\n\t\t:          [-setDrawSilhouette {0|1}]"
-      "\n\t\t:          [-setAlphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
+      "\n\t\t:          [-interior {solid|hatch|hidenline|point}] [-setHatch HatchStyle]"
+      "\n\t\t:          [-unsetInterior]"
+      "\n\t\t:          [-faceBoundaryDraw {0|1}] [-mostContinuity {c0|c1|c2|c3|cn}]"
+      "\n\t\t:          [-faceBoundaryWidth LineWidth] [-faceBoundaryColor R G B] [-faceBoundaryType LineType]"
+      "\n\t\t:          [-drawEdges {0|1}] [-edgeType LineType] [-edgeColor R G B] [-quadEdges {0|1}]"
+      "\n\t\t:          [-drawSilhouette {0|1}]"
+      "\n\t\t:          [-alphaMode {opaque|mask|blend|blendauto} [alphaCutOff=0.5]]"
       "\n\t\t:          [-dumpJson]"
       "\n\t\t:          [-dumpCompact {0|1}]"
       "\n\t\t:          [-dumpDepth depth]"
-      "\n\t\t:          [-freeBoundary {off/on | 0/1}]"
       "\n\t\t: Manage presentation properties of all, selected or named objects."
-      "\n\t\t: When -subshapes is specified than following properties will be"
-      "\n\t\t: assigned to specified sub-shapes."
+      "\n\t\t: When -subshapes is specified than following properties will be assigned to specified sub-shapes."
       "\n\t\t: When -defaults is specified than presentation properties will be"
       "\n\t\t: assigned to all objects that have not their own specified properties"
       "\n\t\t: and to all objects to be displayed in the future."
-      "\n\t\t: If -defaults is used there should not be any objects' names and -subshapes specifier."
+      "\n\t\t: If -defaults is used there should not be any objects' names nor -subshapes specifier."
       "\n\t\t: See also vlistcolors and vlistmaterials to list named colors and materials"
-      "\n\t\t: accepted by arguments -setMaterial and -setColor",
+      "\n\t\t: accepted by arguments -material and -color",
                  __FILE__,VAspects,group);
 
   theCommands.Add("vsetcolor",
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