mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
0031174: Visualization - support user-provided stipple line patterns
This commit is contained in:
@@ -39,6 +39,6 @@ Graphic3d_AspectLine3d::Graphic3d_AspectLine3d (const Quantity_Color& theColor,
|
||||
{
|
||||
myShadingModel = Graphic3d_TOSM_UNLIT;
|
||||
myInteriorColor.SetRGB (theColor);
|
||||
myLineType = theType;
|
||||
SetLineType (theType);
|
||||
SetLineWidth ((float)theWidth);
|
||||
}
|
||||
|
@@ -46,7 +46,7 @@ public:
|
||||
Aspect_TypeOfLine Type() const { return myLineType; }
|
||||
|
||||
//! Modifies the type of line.
|
||||
void SetType (const Aspect_TypeOfLine theType) { myLineType = theType; }
|
||||
void SetType (const Aspect_TypeOfLine theType) { SetLineType (theType); }
|
||||
|
||||
//! Return line width.
|
||||
Standard_ShortReal Width() const { return myLineWidth; }
|
||||
|
@@ -30,6 +30,7 @@ Graphic3d_Aspects::Graphic3d_Aspects()
|
||||
myAlphaCutoff (0.5f),
|
||||
myLineType (Aspect_TOL_SOLID),
|
||||
myLineWidth (1.0f),
|
||||
myLinePattern (0xFFFF),
|
||||
myMarkerType (Aspect_TOM_POINT),
|
||||
myMarkerScale (1.0f),
|
||||
myTextStyle (Aspect_TOST_NORMAL),
|
||||
|
@@ -238,7 +238,21 @@ public:
|
||||
Aspect_TypeOfLine LineType() const { return myLineType; }
|
||||
|
||||
//! Modifies the line type
|
||||
void SetLineType (Aspect_TypeOfLine theType) { myLineType = theType; }
|
||||
void SetLineType (Aspect_TypeOfLine theType)
|
||||
{
|
||||
myLineType = theType;
|
||||
myLinePattern = DefaultLinePatternForType (theType);
|
||||
}
|
||||
|
||||
//! Return custom stipple line pattern; 0xFFFF by default.
|
||||
uint16_t LinePattern() const { return myLinePattern; }
|
||||
|
||||
//! Modifies the stipple line pattern, and changes line type to Aspect_TOL_USERDEFINED for non-standard pattern.
|
||||
void SetLinePattern (uint16_t thePattern)
|
||||
{
|
||||
myLineType = DefaultLineTypeForPattern (thePattern);
|
||||
myLinePattern = thePattern;
|
||||
}
|
||||
|
||||
//! Return width for edges in pixels; 1.0 by default.
|
||||
Standard_ShortReal LineWidth() const { return myLineWidth; }
|
||||
@@ -254,6 +268,36 @@ public:
|
||||
myLineWidth = theWidth;
|
||||
}
|
||||
|
||||
//! Return stipple line pattern for line type.
|
||||
static uint16_t DefaultLinePatternForType (Aspect_TypeOfLine theType)
|
||||
{
|
||||
switch (theType)
|
||||
{
|
||||
case Aspect_TOL_DASH: return 0xFFC0;
|
||||
case Aspect_TOL_DOT: return 0xCCCC;
|
||||
case Aspect_TOL_DOTDASH: return 0xFF18;
|
||||
case Aspect_TOL_EMPTY: return 0x0000;
|
||||
case Aspect_TOL_SOLID: return 0xFFFF;
|
||||
case Aspect_TOL_USERDEFINED: return 0xFF24;
|
||||
}
|
||||
return 0xFFFF;
|
||||
}
|
||||
|
||||
//! Return line type for stipple line pattern.
|
||||
static Aspect_TypeOfLine DefaultLineTypeForPattern (uint16_t thePattern)
|
||||
{
|
||||
switch (thePattern)
|
||||
{
|
||||
case 0x0000: return Aspect_TOL_EMPTY;
|
||||
case 0xFFC0: return Aspect_TOL_DASH;
|
||||
case 0xCCCC: return Aspect_TOL_DOT;
|
||||
case 0xFF18: return Aspect_TOL_DOTDASH;
|
||||
case 0xFFFF: return Aspect_TOL_SOLID;
|
||||
case 0xFF24: return Aspect_TOL_USERDEFINED;
|
||||
}
|
||||
return Aspect_TOL_USERDEFINED;
|
||||
}
|
||||
|
||||
//! @name parameters specific to Point (Marker) primitive rendering
|
||||
public:
|
||||
|
||||
@@ -388,7 +432,7 @@ public:
|
||||
Aspect_TypeOfLine EdgeLineType() const { return myLineType; }
|
||||
|
||||
//! Modifies the edge line type (same as SetLineType())
|
||||
void SetEdgeLineType (Aspect_TypeOfLine theType) { myLineType = theType; }
|
||||
void SetEdgeLineType (Aspect_TypeOfLine theType) { SetLineType (theType); }
|
||||
|
||||
//! Return width for edges in pixels (same as LineWidth()).
|
||||
Standard_ShortReal EdgeWidth() const { return myLineWidth; }
|
||||
@@ -459,6 +503,7 @@ public:
|
||||
&& myLineType == theOther.myLineType
|
||||
&& myEdgeColor == theOther.myEdgeColor
|
||||
&& myLineWidth == theOther.myLineWidth
|
||||
&& myLinePattern == theOther.myLinePattern
|
||||
&& myMarkerType == theOther.myMarkerType
|
||||
&& myMarkerScale == theOther.myMarkerScale
|
||||
&& myHatchStyle == theOther.myHatchStyle
|
||||
@@ -502,6 +547,7 @@ protected:
|
||||
|
||||
Aspect_TypeOfLine myLineType;
|
||||
Standard_ShortReal myLineWidth;
|
||||
uint16_t myLinePattern;
|
||||
|
||||
Aspect_TypeOfMarker myMarkerType;
|
||||
Standard_ShortReal myMarkerScale;
|
||||
|
Reference in New Issue
Block a user