mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0031698: Visualization, Graphic3d_Aspects - provide stipple line factor parameter [OCCT 7.2.0 backport]
Added Graphic3d_AspectLine3d::LineStippleFactor() property. Added -stippleFactor argument to vaspects command.
This commit is contained in:
parent
3d607bc062
commit
68556f75f9
@ -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)
|
||||
|
@ -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;
|
||||
|
||||
};
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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]"
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user