1 // Copyright (c) 2019 OPEN CASCADE SAS 2 // 3 // This file is part of Open CASCADE Technology software library. 4 // 5 // This library is free software; you can redistribute it and/or modify it under 6 // the terms of the GNU Lesser General Public License version 2.1 as published 7 // by the Free Software Foundation, with special exception defined in the file 8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 9 // distribution for complete text of the license and disclaimer of any warranty. 10 // 11 // Alternatively, this file may be used under the terms of Open CASCADE 12 // commercial license or contractual agreement. 13 14 #ifndef _Graphic3d_Aspects_HeaderFile 15 #define _Graphic3d_Aspects_HeaderFile 16 17 #include <Aspect_PolygonOffsetMode.hxx> 18 #include <Aspect_InteriorStyle.hxx> 19 #include <Aspect_TypeOfDisplayText.hxx> 20 #include <Aspect_TypeOfLine.hxx> 21 #include <Aspect_TypeOfMarker.hxx> 22 #include <Aspect_TypeOfStyleText.hxx> 23 #include <Font_FontAspect.hxx> 24 #include <Font_NameOfFont.hxx> 25 #include <Graphic3d_AlphaMode.hxx> 26 #include <Graphic3d_MarkerImage.hxx> 27 #include <Graphic3d_MaterialAspect.hxx> 28 #include <Graphic3d_HatchStyle.hxx> 29 #include <Graphic3d_PolygonOffset.hxx> 30 #include <Graphic3d_ShaderProgram.hxx> 31 #include <Graphic3d_TextureMap.hxx> 32 #include <Graphic3d_TextureSet.hxx> 33 #include <Graphic3d_TypeOfBackfacingModel.hxx> 34 #include <Graphic3d_TypeOfShadingModel.hxx> 35 #include <TCollection_HAsciiString.hxx> 36 37 //! This class defines graphic attributes. 38 class Graphic3d_Aspects : public Standard_Transient 39 { 40 DEFINE_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient) 41 public: 42 43 //! Creates a context table for drawing primitives defined with the following default values: 44 Standard_EXPORT Graphic3d_Aspects(); 45 46 //! Return interior rendering style; Aspect_IS_SOLID by default. InteriorStyle() const47 Aspect_InteriorStyle InteriorStyle() const { return myInteriorStyle; } 48 49 //! Modifies the interior type used for rendering SetInteriorStyle(const Aspect_InteriorStyle theStyle)50 void SetInteriorStyle (const Aspect_InteriorStyle theStyle) { myInteriorStyle = theStyle; } 51 52 //! Returns shading model; Graphic3d_TypeOfShadingModel_DEFAULT by default. 53 //! Graphic3d_TOSM_DEFAULT means that Shading Model set as default for entire Viewer will be used. ShadingModel() const54 Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; } 55 56 //! Sets shading model SetShadingModel(const Graphic3d_TypeOfShadingModel theShadingModel)57 void SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel) { myShadingModel = theShadingModel; } 58 59 //! Returns the way how alpha value should be treated (Graphic3d_AlphaMode_BlendAuto by default, for backward compatibility). AlphaMode() const60 Graphic3d_AlphaMode AlphaMode() const { return myAlphaMode; } 61 62 //! Returns alpha cutoff threshold, for discarding fragments within Graphic3d_AlphaMode_Mask mode (0.5 by default). 63 //! If the alpha value is greater than or equal to this value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent. AlphaCutoff() const64 Standard_ShortReal AlphaCutoff() const { return myAlphaCutoff; } 65 66 //! Defines the way how alpha value should be treated. SetAlphaMode(Graphic3d_AlphaMode theMode,Standard_ShortReal theAlphaCutoff=0.5f)67 void SetAlphaMode (Graphic3d_AlphaMode theMode, Standard_ShortReal theAlphaCutoff = 0.5f) 68 { 69 myAlphaMode = theMode; 70 myAlphaCutoff = theAlphaCutoff; 71 } 72 73 //! Return color ColorRGBA() const74 const Quantity_ColorRGBA& ColorRGBA() const { return myInteriorColor; } 75 76 //! Return the color. Color() const77 const Quantity_Color& Color() const { return myInteriorColor.GetRGB(); } 78 79 //! Modifies the color. SetColor(const Quantity_Color & theColor)80 void SetColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB(theColor); } 81 82 //! Return interior color. InteriorColor() const83 const Quantity_Color& InteriorColor() const { return myInteriorColor.GetRGB(); } 84 85 //! Return interior color. InteriorColorRGBA() const86 const Quantity_ColorRGBA& InteriorColorRGBA() const { return myInteriorColor; } 87 88 //! Modifies the color of the interior of the face SetInteriorColor(const Quantity_Color & theColor)89 void SetInteriorColor (const Quantity_Color& theColor) { myInteriorColor.SetRGB (theColor); } 90 91 //! Modifies the color of the interior of the face SetInteriorColor(const Quantity_ColorRGBA & theColor)92 void SetInteriorColor (const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; } 93 94 //! Return back interior color. BackInteriorColor() const95 const Quantity_Color& BackInteriorColor() const { return myBackInteriorColor.GetRGB(); } 96 97 //! Return back interior color. BackInteriorColorRGBA() const98 const Quantity_ColorRGBA& BackInteriorColorRGBA() const { return myBackInteriorColor; } 99 100 //! Modifies the color of the interior of the back face SetBackInteriorColor(const Quantity_Color & theColor)101 void SetBackInteriorColor (const Quantity_Color& theColor) { myBackInteriorColor.SetRGB (theColor); } 102 103 //! Modifies the color of the interior of the back face SetBackInteriorColor(const Quantity_ColorRGBA & theColor)104 void SetBackInteriorColor (const Quantity_ColorRGBA& theColor) { myBackInteriorColor = theColor; } 105 106 //! Returns the surface material of external faces FrontMaterial() const107 const Graphic3d_MaterialAspect& FrontMaterial() const { return myFrontMaterial; } 108 109 //! Returns the surface material of external faces ChangeFrontMaterial()110 Graphic3d_MaterialAspect& ChangeFrontMaterial() { return myFrontMaterial; } 111 112 //! Modifies the surface material of external faces SetFrontMaterial(const Graphic3d_MaterialAspect & theMaterial)113 void SetFrontMaterial (const Graphic3d_MaterialAspect& theMaterial) { myFrontMaterial = theMaterial; } 114 115 //! Returns the surface material of internal faces BackMaterial() const116 const Graphic3d_MaterialAspect& BackMaterial() const { return myBackMaterial; } 117 118 //! Returns the surface material of internal faces ChangeBackMaterial()119 Graphic3d_MaterialAspect& ChangeBackMaterial() { return myBackMaterial; } 120 121 //! Modifies the surface material of internal faces SetBackMaterial(const Graphic3d_MaterialAspect & theMaterial)122 void SetBackMaterial (const Graphic3d_MaterialAspect& theMaterial) { myBackMaterial = theMaterial; } 123 124 //! Return face culling mode; Graphic3d_FaceCulling_BackClosed by default. 125 //! A back-facing polygon is defined as a polygon whose 126 //! vertices are in a clockwise order with respect to screen coordinates. FaceCulling() const127 Graphic3d_TypeOfBackfacingModel FaceCulling() const { return myFaceCulling; } 128 129 //! Set face culling mode. SetFaceCulling(Graphic3d_TypeOfBackfacingModel theCulling)130 void SetFaceCulling (Graphic3d_TypeOfBackfacingModel theCulling) { myFaceCulling = theCulling; } 131 132 //! Returns true if material properties should be distinguished for back and front faces (false by default). Distinguish() const133 bool Distinguish() const { return myToDistinguishMaterials; } 134 135 //! Set material distinction between front and back faces. SetDistinguish(bool toDistinguish)136 void SetDistinguish (bool toDistinguish) { myToDistinguishMaterials = toDistinguish; } 137 138 //! Allows material distinction between front and back faces. SetDistinguishOn()139 void SetDistinguishOn() { myToDistinguishMaterials = true; } 140 141 //! Forbids material distinction between front and back faces. SetDistinguishOff()142 void SetDistinguishOff() { myToDistinguishMaterials = false; } 143 144 //! Return shader program. Handle(Graphic3d_ShaderProgram)145 const Handle(Graphic3d_ShaderProgram)& ShaderProgram() const { return myProgram; } 146 147 //! Sets up OpenGL/GLSL shader program. SetShaderProgram(const Handle (Graphic3d_ShaderProgram)& theProgram)148 void SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram) { myProgram = theProgram; } 149 150 //! Return texture array to be mapped. Handle(Graphic3d_TextureSet)151 const Handle(Graphic3d_TextureSet)& TextureSet() const { return myTextureSet; } 152 153 //! Setup texture array to be mapped. SetTextureSet(const Handle (Graphic3d_TextureSet)& theTextures)154 void SetTextureSet (const Handle(Graphic3d_TextureSet)& theTextures) { myTextureSet = theTextures; } 155 156 //! Return texture to be mapped. 157 //Standard_DEPRECATED("Deprecated method, TextureSet() should be used instead") TextureMap() const158 Handle(Graphic3d_TextureMap) TextureMap() const 159 { 160 return !myTextureSet.IsNull() && !myTextureSet->IsEmpty() 161 ? myTextureSet->First() 162 : Handle(Graphic3d_TextureMap)(); 163 } 164 165 //! Assign texture to be mapped. 166 //! See also SetTextureMapOn() to actually activate texture mapping. 167 //Standard_DEPRECATED("Deprecated method, SetTextureSet() should be used instead") 168 Standard_EXPORT void SetTextureMap (const Handle(Graphic3d_TextureMap)& theTexture); 169 170 //! Return true if texture mapping is enabled (false by default). ToMapTexture() const171 bool ToMapTexture() const { return myToMapTexture; } 172 173 //! Return true if texture mapping is enabled (false by default). TextureMapState() const174 bool TextureMapState() const { return myToMapTexture; } 175 176 //! Enable or disable texture mapping (has no effect if texture is not set). SetTextureMapOn(bool theToMap)177 void SetTextureMapOn (bool theToMap) { myToMapTexture = theToMap; } 178 179 //! Enable texture mapping (has no effect if texture is not set). SetTextureMapOn()180 void SetTextureMapOn() { myToMapTexture = true; } 181 182 //! Disable texture mapping. SetTextureMapOff()183 void SetTextureMapOff() { myToMapTexture = false; } 184 185 //! Returns current polygon offsets settings. PolygonOffset() const186 const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; } 187 188 //! Sets polygon offsets settings. SetPolygonOffset(const Graphic3d_PolygonOffset & theOffset)189 void SetPolygonOffset (const Graphic3d_PolygonOffset& theOffset) { myPolygonOffset = theOffset; } 190 191 //! Returns current polygon offsets settings. PolygonOffsets(Standard_Integer & theMode,Standard_ShortReal & theFactor,Standard_ShortReal & theUnits) const192 void PolygonOffsets (Standard_Integer& theMode, 193 Standard_ShortReal& theFactor, 194 Standard_ShortReal& theUnits) const 195 { 196 theMode = myPolygonOffset.Mode; 197 theFactor = myPolygonOffset.Factor; 198 theUnits = myPolygonOffset.Units; 199 } 200 201 //! Sets up OpenGL polygon offsets mechanism. 202 //! <aMode> parameter can contain various combinations of 203 //! Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means 204 //! that polygon offsets are not changed). 205 //! If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits> 206 //! arguments are used by graphic renderer to calculate a depth offset value: 207 //! 208 //! offset = <aFactor> * m + <aUnits> * r, where 209 //! m - maximum depth slope for the polygon currently being displayed, 210 //! r - minimum window coordinates depth resolution (implementation-specific) 211 //! 212 //! Default settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0. 213 //! 214 //! Negative offset values move polygons closer to the viewport, 215 //! while positive values shift polygons away. 216 //! Consult OpenGL reference for details (glPolygonOffset function description). SetPolygonOffsets(const Standard_Integer theMode,const Standard_ShortReal theFactor=1.0f,const Standard_ShortReal theUnits=0.0f)217 void SetPolygonOffsets (const Standard_Integer theMode, 218 const Standard_ShortReal theFactor = 1.0f, 219 const Standard_ShortReal theUnits = 0.0f) 220 { 221 myPolygonOffset.Mode = (Aspect_PolygonOffsetMode )(theMode & Aspect_POM_Mask); 222 myPolygonOffset.Factor = theFactor; 223 myPolygonOffset.Units = theUnits; 224 } 225 226 //! @name parameters specific to Line primitive rendering 227 public: 228 229 //! Return line type; Aspect_TOL_SOLID by default. LineType() const230 Aspect_TypeOfLine LineType() const { return myLineType; } 231 232 //! Modifies the line type SetLineType(Aspect_TypeOfLine theType)233 void SetLineType (Aspect_TypeOfLine theType) 234 { 235 myLineType = theType; 236 myLinePattern = DefaultLinePatternForType (theType); 237 } 238 239 //! Return custom stipple line pattern; 0xFFFF by default. LinePattern() const240 uint16_t LinePattern() const { return myLinePattern; } 241 242 //! Modifies the stipple line pattern, and changes line type to Aspect_TOL_USERDEFINED for non-standard pattern. SetLinePattern(uint16_t thePattern)243 void SetLinePattern (uint16_t thePattern) 244 { 245 myLineType = DefaultLineTypeForPattern (thePattern); 246 myLinePattern = thePattern; 247 } 248 249 //! Return a multiplier for each bit in the line stipple pattern within [1, 256] range; 1 by default. LineStippleFactor() const250 uint16_t LineStippleFactor() const { return myLineFactor; } 251 252 //! Set a multiplier for each bit in the line stipple pattern. SetLineStippleFactor(uint16_t theFactor)253 void SetLineStippleFactor (uint16_t theFactor) 254 { 255 if (theFactor == 0 || theFactor > 256) 256 { 257 throw Standard_OutOfRange ("Graphic3d_Aspects::SetLineStippleFactor(), bad factor value"); 258 } 259 myLineFactor = theFactor; 260 } 261 262 //! Return width for edges in pixels; 1.0 by default. LineWidth() const263 Standard_ShortReal LineWidth() const { return myLineWidth; } 264 265 //! Modifies the line thickness 266 //! Warning: Raises Standard_OutOfRange if the width is a negative value. SetLineWidth(Standard_ShortReal theWidth)267 void SetLineWidth (Standard_ShortReal theWidth) 268 { 269 if (theWidth <= 0.0f) 270 { 271 throw Standard_OutOfRange ("Bad value for EdgeLineWidth"); 272 } 273 myLineWidth = theWidth; 274 } 275 276 //! Return stipple line pattern for line type. DefaultLinePatternForType(Aspect_TypeOfLine theType)277 static uint16_t DefaultLinePatternForType (Aspect_TypeOfLine theType) 278 { 279 switch (theType) 280 { 281 case Aspect_TOL_DASH: return 0xFFC0; 282 case Aspect_TOL_DOT: return 0xCCCC; 283 case Aspect_TOL_DOTDASH: return 0xFF18; 284 case Aspect_TOL_EMPTY: return 0x0000; 285 case Aspect_TOL_SOLID: return 0xFFFF; 286 case Aspect_TOL_USERDEFINED: return 0xFF24; 287 } 288 return 0xFFFF; 289 } 290 291 //! Return line type for stipple line pattern. DefaultLineTypeForPattern(uint16_t thePattern)292 static Aspect_TypeOfLine DefaultLineTypeForPattern (uint16_t thePattern) 293 { 294 switch (thePattern) 295 { 296 case 0x0000: return Aspect_TOL_EMPTY; 297 case 0xFFC0: return Aspect_TOL_DASH; 298 case 0xCCCC: return Aspect_TOL_DOT; 299 case 0xFF18: return Aspect_TOL_DOTDASH; 300 case 0xFFFF: return Aspect_TOL_SOLID; 301 case 0xFF24: return Aspect_TOL_USERDEFINED; 302 } 303 return Aspect_TOL_USERDEFINED; 304 } 305 306 //! @name parameters specific to Point (Marker) primitive rendering 307 public: 308 309 //! Return marker type; Aspect_TOM_POINT by default. MarkerType() const310 Aspect_TypeOfMarker MarkerType() const { return myMarkerType; } 311 312 //! Modifies the type of marker. SetMarkerType(Aspect_TypeOfMarker theType)313 void SetMarkerType (Aspect_TypeOfMarker theType) { myMarkerType = theType; } 314 315 //! Return marker scale factor; 1.0 by default. MarkerScale() const316 Standard_ShortReal MarkerScale() const { return myMarkerScale; } 317 318 //! Modifies the scale factor. 319 //! Marker type Aspect_TOM_POINT is not affected by the marker size scale factor. 320 //! It is always the smallest displayable dot. 321 //! Warning: Raises Standard_OutOfRange if the scale is a negative value. SetMarkerScale(const Standard_ShortReal theScale)322 void SetMarkerScale (const Standard_ShortReal theScale) 323 { 324 if (theScale <= 0.0f) 325 { 326 throw Standard_OutOfRange ("Bad value for MarkerScale"); 327 } 328 myMarkerScale = theScale; 329 } 330 331 //! Returns marker's image texture. 332 //! Could be null handle if marker aspect has been initialized as default type of marker. Handle(Graphic3d_MarkerImage)333 const Handle(Graphic3d_MarkerImage)& MarkerImage() const { return myMarkerImage; } 334 335 //! Set marker's image texture. SetMarkerImage(const Handle (Graphic3d_MarkerImage)& theImage)336 void SetMarkerImage (const Handle(Graphic3d_MarkerImage)& theImage) { myMarkerImage = theImage; } 337 338 //! Returns TRUE if marker should be drawn using marker sprite (either user-provided or generated). IsMarkerSprite() const339 bool IsMarkerSprite() const 340 { 341 if (myMarkerType == Aspect_TOM_POINT 342 || myMarkerType == Aspect_TOM_EMPTY) 343 { 344 return false; 345 } 346 347 return myMarkerType != Aspect_TOM_USERDEFINED 348 || !myMarkerImage.IsNull(); 349 } 350 351 //! @name parameters specific to text rendering 352 public: 353 354 //! Returns the font; NULL string by default. Handle(TCollection_HAsciiString)355 const Handle(TCollection_HAsciiString)& TextFont() const { return myTextFont; } 356 357 //! Modifies the font. SetTextFont(const Handle (TCollection_HAsciiString)& theFont)358 void SetTextFont (const Handle(TCollection_HAsciiString)& theFont) { myTextFont = theFont; } 359 360 //! Returns text FontAspect TextFontAspect() const361 Font_FontAspect TextFontAspect() const { return myTextFontAspect; } 362 363 //! Turns usage of Aspect text SetTextFontAspect(Font_FontAspect theFontAspect)364 void SetTextFontAspect (Font_FontAspect theFontAspect) { myTextFontAspect = theFontAspect; } 365 366 //! Returns display type; Aspect_TODT_NORMAL by default. TextDisplayType() const367 Aspect_TypeOfDisplayText TextDisplayType() const { return myTextDisplayType; } 368 369 //! Sets display type. SetTextDisplayType(Aspect_TypeOfDisplayText theType)370 void SetTextDisplayType (Aspect_TypeOfDisplayText theType) { myTextDisplayType = theType; } 371 372 //! Returns text background/shadow color; equals to EdgeColor() property. ColorSubTitleRGBA() const373 const Quantity_ColorRGBA& ColorSubTitleRGBA() const { return myEdgeColor; } 374 375 //! Return text background/shadow color; equals to EdgeColor() property. ColorSubTitle() const376 const Quantity_Color& ColorSubTitle() const { return myEdgeColor.GetRGB(); } 377 378 //! Modifies text background/shadow color; equals to EdgeColor() property. SetColorSubTitle(const Quantity_Color & theColor)379 void SetColorSubTitle (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); } 380 381 //! Modifies text background/shadow color; equals to EdgeColor() property. SetColorSubTitle(const Quantity_ColorRGBA & theColor)382 void SetColorSubTitle (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; } 383 384 //! Returns TRUE when the Text Zoomable is on. IsTextZoomable() const385 bool IsTextZoomable() const { return myIsTextZoomable; } 386 387 //! Turns usage of text zoomable on/off SetTextZoomable(bool theFlag)388 void SetTextZoomable (bool theFlag) { myIsTextZoomable = theFlag; } 389 390 //! Returns the text style; Aspect_TOST_NORMAL by default. TextStyle() const391 Aspect_TypeOfStyleText TextStyle() const { return myTextStyle; } 392 393 //! Modifies the style of the text. SetTextStyle(Aspect_TypeOfStyleText theStyle)394 void SetTextStyle (Aspect_TypeOfStyleText theStyle) { myTextStyle = theStyle; } 395 396 //! Returns Angle of degree TextAngle() const397 Standard_ShortReal TextAngle() const { return myTextAngle; } 398 399 //! Turns usage of text rotated SetTextAngle(Standard_ShortReal theAngle)400 void SetTextAngle (Standard_ShortReal theAngle) { myTextAngle = (Standard_ShortReal )theAngle; } 401 402 //! @name parameters specific to Mesh Edges (of triangulation primitive) rendering 403 public: 404 405 //! Returns true if mesh edges should be drawn (false by default). ToDrawEdges() const406 bool ToDrawEdges() const { return myToDrawEdges && myLineType != Aspect_TOL_EMPTY; } 407 408 //! Set if mesh edges should be drawn or not. SetDrawEdges(bool theToDraw)409 void SetDrawEdges (bool theToDraw) 410 { 411 myToDrawEdges = theToDraw; 412 if (myLineType == Aspect_TOL_EMPTY) 413 { 414 myLineType = Aspect_TOL_SOLID; 415 } 416 } 417 418 //! The edges of FillAreas are drawn. SetEdgeOn()419 void SetEdgeOn() { SetDrawEdges (true); } 420 421 //! The edges of FillAreas are not drawn. SetEdgeOff()422 void SetEdgeOff() { SetDrawEdges (false); } 423 424 //! Return color of edges. EdgeColor() const425 const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); } 426 427 //! Return color of edges. EdgeColorRGBA() const428 const Quantity_ColorRGBA& EdgeColorRGBA() const { return myEdgeColor; } 429 430 //! Modifies the color of the edge of the face SetEdgeColor(const Quantity_Color & theColor)431 void SetEdgeColor (const Quantity_Color& theColor) { myEdgeColor.SetRGB (theColor); } 432 433 //! Modifies the color of the edge of the face SetEdgeColor(const Quantity_ColorRGBA & theColor)434 void SetEdgeColor (const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; } 435 436 //! Return edges line type (same as LineType()). EdgeLineType() const437 Aspect_TypeOfLine EdgeLineType() const { return myLineType; } 438 439 //! Modifies the edge line type (same as SetLineType()) SetEdgeLineType(Aspect_TypeOfLine theType)440 void SetEdgeLineType (Aspect_TypeOfLine theType) { SetLineType (theType); } 441 442 //! Return width for edges in pixels (same as LineWidth()). EdgeWidth() const443 Standard_ShortReal EdgeWidth() const { return myLineWidth; } 444 445 //! Modifies the edge thickness (same as SetLineWidth()) SetEdgeWidth(Standard_Real theWidth)446 void SetEdgeWidth (Standard_Real theWidth) { SetLineWidth ((Standard_ShortReal )theWidth); } 447 448 //! Returns TRUE if drawing element edges should discard first edge in triangle; FALSE by default. 449 //! Graphics hardware works mostly with triangles, so that wireframe presentation will draw triangle edges by default. 450 //! This flag allows rendering wireframe presentation of quad-only array split into triangles. 451 //! For this, quads should be split in specific order, so that the quad diagonal (to be NOT rendered) goes first: 452 //! 1------2 453 //! / / Triangle #1: 2-0-1; Triangle #2: 0-2-3 454 //! 0------3 ToSkipFirstEdge() const455 bool ToSkipFirstEdge() const { return myToSkipFirstEdge; } 456 457 //! Set skip first triangle edge flag for drawing wireframe presentation of quads array split into triangles. SetSkipFirstEdge(bool theToSkipFirstEdge)458 void SetSkipFirstEdge (bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; } 459 460 //! Returns TRUE if silhouette (outline) should be drawn (with edge color and width); FALSE by default. ToDrawSilhouette() const461 bool ToDrawSilhouette() const { return myToDrawSilhouette; } 462 463 //! Enables/disables drawing silhouette (outline). SetDrawSilhouette(bool theToDraw)464 void SetDrawSilhouette (bool theToDraw) { myToDrawSilhouette = theToDraw; } 465 466 public: 467 468 //! Returns the hatch type used when InteriorStyle is IS_HATCH Handle(Graphic3d_HatchStyle)469 const Handle(Graphic3d_HatchStyle)& HatchStyle() const { return myHatchStyle; } 470 471 //! Modifies the hatch type used when InteriorStyle is IS_HATCH SetHatchStyle(const Handle (Graphic3d_HatchStyle)& theStyle)472 void SetHatchStyle (const Handle(Graphic3d_HatchStyle)& theStyle) { myHatchStyle = theStyle; } 473 474 //! Modifies the hatch type used when InteriorStyle is IS_HATCH 475 //! @warning This method always creates a new handle for a given hatch style SetHatchStyle(const Aspect_HatchStyle theStyle)476 void SetHatchStyle (const Aspect_HatchStyle theStyle) 477 { 478 if (theStyle == Aspect_HS_SOLID) 479 { 480 myHatchStyle.Nullify(); 481 return; 482 } 483 484 myHatchStyle = new Graphic3d_HatchStyle (theStyle); 485 } 486 487 public: 488 489 //! Check for equality with another aspects. IsEqual(const Graphic3d_Aspects & theOther)490 bool IsEqual (const Graphic3d_Aspects& theOther) 491 { 492 if (this == &theOther) 493 { 494 return true; 495 } 496 497 return myProgram == theOther.myProgram 498 && myTextureSet == theOther.myTextureSet 499 && myMarkerImage == theOther.myMarkerImage 500 && myInteriorColor == theOther.myInteriorColor 501 && myBackInteriorColor == theOther.myBackInteriorColor 502 && myFrontMaterial == theOther.myFrontMaterial 503 && myBackMaterial == theOther.myBackMaterial 504 && myInteriorStyle == theOther.myInteriorStyle 505 && myShadingModel == theOther.myShadingModel 506 && myFaceCulling == theOther.myFaceCulling 507 && myAlphaMode == theOther.myAlphaMode 508 && myAlphaCutoff == theOther.myAlphaCutoff 509 && myLineType == theOther.myLineType 510 && myEdgeColor == theOther.myEdgeColor 511 && myLineWidth == theOther.myLineWidth 512 && myLineFactor == theOther.myLineFactor 513 && myLinePattern == theOther.myLinePattern 514 && myMarkerType == theOther.myMarkerType 515 && myMarkerScale == theOther.myMarkerScale 516 && myHatchStyle == theOther.myHatchStyle 517 && myTextFont == theOther.myTextFont 518 && myPolygonOffset == theOther.myPolygonOffset 519 && myTextStyle == theOther.myTextStyle 520 && myTextDisplayType == theOther.myTextDisplayType 521 && myTextFontAspect == theOther.myTextFontAspect 522 && myTextAngle == theOther.myTextAngle 523 && myToSkipFirstEdge == theOther.myToSkipFirstEdge 524 && myToDistinguishMaterials == theOther.myToDistinguishMaterials 525 && myToDrawEdges == theOther.myToDrawEdges 526 && myToDrawSilhouette == theOther.myToDrawSilhouette 527 && myToMapTexture == theOther.myToMapTexture 528 && myIsTextZoomable == theOther.myIsTextZoomable; 529 } 530 531 //! Dumps the content of me into the stream 532 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const; 533 534 public: 535 536 Standard_DEPRECATED("Deprecated method, FaceCulling() should be used instead") ToSuppressBackFaces() const537 bool ToSuppressBackFaces() const 538 { 539 return myFaceCulling == Graphic3d_TypeOfBackfacingModel_BackCulled 540 || myFaceCulling == Graphic3d_TypeOfBackfacingModel_Auto; 541 } 542 543 Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead") SetSuppressBackFaces(bool theToSuppress)544 void SetSuppressBackFaces (bool theToSuppress) { myFaceCulling = theToSuppress ? Graphic3d_TypeOfBackfacingModel_Auto : Graphic3d_TypeOfBackfacingModel_DoubleSided; } 545 546 Standard_DEPRECATED("Deprecated method, FaceCulling() should be used instead") BackFace() const547 bool BackFace() const 548 { 549 return myFaceCulling == Graphic3d_TypeOfBackfacingModel_BackCulled 550 || myFaceCulling == Graphic3d_TypeOfBackfacingModel_Auto; 551 } 552 553 Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead") AllowBackFace()554 void AllowBackFace() { myFaceCulling = Graphic3d_TypeOfBackfacingModel_DoubleSided; } 555 556 Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead") SuppressBackFace()557 void SuppressBackFace() { myFaceCulling = Graphic3d_TypeOfBackfacingModel_Auto; } 558 559 protected: 560 561 Handle(Graphic3d_ShaderProgram) myProgram; 562 Handle(Graphic3d_TextureSet) myTextureSet; 563 Handle(Graphic3d_MarkerImage) myMarkerImage; 564 Handle(Graphic3d_HatchStyle) myHatchStyle; 565 Handle(TCollection_HAsciiString) myTextFont; 566 Graphic3d_MaterialAspect myFrontMaterial; 567 Graphic3d_MaterialAspect myBackMaterial; 568 569 Quantity_ColorRGBA myInteriorColor; 570 Quantity_ColorRGBA myBackInteriorColor; 571 Quantity_ColorRGBA myEdgeColor; 572 573 Graphic3d_PolygonOffset myPolygonOffset; 574 Aspect_InteriorStyle myInteriorStyle; 575 Graphic3d_TypeOfShadingModel myShadingModel; 576 Graphic3d_TypeOfBackfacingModel myFaceCulling; 577 Graphic3d_AlphaMode myAlphaMode; 578 Standard_ShortReal myAlphaCutoff; 579 580 Aspect_TypeOfLine myLineType; 581 Standard_ShortReal myLineWidth; 582 uint16_t myLineFactor; 583 uint16_t myLinePattern; 584 585 Aspect_TypeOfMarker myMarkerType; 586 Standard_ShortReal myMarkerScale; 587 588 Aspect_TypeOfStyleText myTextStyle; 589 Aspect_TypeOfDisplayText myTextDisplayType; 590 Font_FontAspect myTextFontAspect; 591 Standard_ShortReal myTextAngle; 592 593 bool myToSkipFirstEdge; 594 bool myToDistinguishMaterials; 595 bool myToDrawEdges; 596 bool myToDrawSilhouette; 597 bool myToMapTexture; 598 bool myIsTextZoomable; 599 600 }; 601 602 DEFINE_STANDARD_HANDLE(Graphic3d_Aspects, Standard_Transient) 603 604 #endif // _Graphic3d_Aspects_HeaderFile 605