File indexing completed on 2026-09-25 09:19:58
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef _Graphic3d_Aspects_HeaderFile
0015 #define _Graphic3d_Aspects_HeaderFile
0016
0017 #include <Aspect_InteriorStyle.hxx>
0018 #include <Aspect_TypeOfDisplayText.hxx>
0019 #include <Aspect_TypeOfLine.hxx>
0020 #include <Aspect_TypeOfStyleText.hxx>
0021 #include <Font_FontAspect.hxx>
0022 #include <Graphic3d_AlphaMode.hxx>
0023 #include <Graphic3d_MarkerImage.hxx>
0024 #include <Graphic3d_MaterialAspect.hxx>
0025 #include <Graphic3d_HatchStyle.hxx>
0026 #include <Graphic3d_PolygonOffset.hxx>
0027 #include <Graphic3d_ShaderProgram.hxx>
0028 #include <Graphic3d_TextureSet.hxx>
0029 #include <Graphic3d_TypeOfBackfacingModel.hxx>
0030 #include <Graphic3d_TypeOfShadingModel.hxx>
0031 #include <TCollection_HAsciiString.hxx>
0032
0033
0034 class Graphic3d_Aspects : public Standard_Transient
0035 {
0036 DEFINE_STANDARD_RTTIEXT(Graphic3d_Aspects, Standard_Transient)
0037 public:
0038
0039 Standard_EXPORT Graphic3d_Aspects();
0040
0041
0042 Aspect_InteriorStyle InteriorStyle() const { return myInteriorStyle; }
0043
0044
0045 void SetInteriorStyle(const Aspect_InteriorStyle theStyle) { myInteriorStyle = theStyle; }
0046
0047
0048
0049 Graphic3d_TypeOfShadingModel ShadingModel() const { return myShadingModel; }
0050
0051
0052 void SetShadingModel(const Graphic3d_TypeOfShadingModel theShadingModel)
0053 {
0054 myShadingModel = theShadingModel;
0055 }
0056
0057
0058
0059 Graphic3d_AlphaMode AlphaMode() const { return myAlphaMode; }
0060
0061
0062
0063
0064 float AlphaCutoff() const { return myAlphaCutoff; }
0065
0066
0067 void SetAlphaMode(Graphic3d_AlphaMode theMode, float theAlphaCutoff = 0.5f)
0068 {
0069 myAlphaMode = theMode;
0070 myAlphaCutoff = theAlphaCutoff;
0071 }
0072
0073
0074 const Quantity_ColorRGBA& ColorRGBA() const { return myInteriorColor; }
0075
0076
0077 const Quantity_Color& Color() const { return myInteriorColor.GetRGB(); }
0078
0079
0080 void SetColor(const Quantity_Color& theColor) { myInteriorColor.SetRGB(theColor); }
0081
0082
0083 const Quantity_Color& InteriorColor() const { return myInteriorColor.GetRGB(); }
0084
0085
0086 const Quantity_ColorRGBA& InteriorColorRGBA() const { return myInteriorColor; }
0087
0088
0089 void SetInteriorColor(const Quantity_Color& theColor) { myInteriorColor.SetRGB(theColor); }
0090
0091
0092 void SetInteriorColor(const Quantity_ColorRGBA& theColor) { myInteriorColor = theColor; }
0093
0094
0095 const Quantity_Color& BackInteriorColor() const { return myBackInteriorColor.GetRGB(); }
0096
0097
0098 const Quantity_ColorRGBA& BackInteriorColorRGBA() const { return myBackInteriorColor; }
0099
0100
0101 void SetBackInteriorColor(const Quantity_Color& theColor)
0102 {
0103 myBackInteriorColor.SetRGB(theColor);
0104 }
0105
0106
0107 void SetBackInteriorColor(const Quantity_ColorRGBA& theColor) { myBackInteriorColor = theColor; }
0108
0109
0110 const Graphic3d_MaterialAspect& FrontMaterial() const { return myFrontMaterial; }
0111
0112
0113 Graphic3d_MaterialAspect& ChangeFrontMaterial() { return myFrontMaterial; }
0114
0115
0116 void SetFrontMaterial(const Graphic3d_MaterialAspect& theMaterial)
0117 {
0118 myFrontMaterial = theMaterial;
0119 }
0120
0121
0122 const Graphic3d_MaterialAspect& BackMaterial() const { return myBackMaterial; }
0123
0124
0125 Graphic3d_MaterialAspect& ChangeBackMaterial() { return myBackMaterial; }
0126
0127
0128 void SetBackMaterial(const Graphic3d_MaterialAspect& theMaterial)
0129 {
0130 myBackMaterial = theMaterial;
0131 }
0132
0133
0134
0135
0136 Graphic3d_TypeOfBackfacingModel FaceCulling() const { return myFaceCulling; }
0137
0138
0139 void SetFaceCulling(Graphic3d_TypeOfBackfacingModel theCulling) { myFaceCulling = theCulling; }
0140
0141
0142
0143 bool Distinguish() const { return myToDistinguishMaterials; }
0144
0145
0146 void SetDistinguish(bool toDistinguish) { myToDistinguishMaterials = toDistinguish; }
0147
0148
0149 void SetDistinguishOn() { myToDistinguishMaterials = true; }
0150
0151
0152 void SetDistinguishOff() { myToDistinguishMaterials = false; }
0153
0154
0155
0156 bool ToUseVertexColorForBackFaces() const { return myToUseVertexColorForBackFaces; }
0157
0158
0159
0160 void SetUseVertexColorForBackFaces(bool theToUse) { myToUseVertexColorForBackFaces = theToUse; }
0161
0162
0163 const occ::handle<Graphic3d_ShaderProgram>& ShaderProgram() const { return myProgram; }
0164
0165
0166 void SetShaderProgram(const occ::handle<Graphic3d_ShaderProgram>& theProgram)
0167 {
0168 myProgram = theProgram;
0169 }
0170
0171
0172 const occ::handle<Graphic3d_TextureSet>& TextureSet() const { return myTextureSet; }
0173
0174
0175 void SetTextureSet(const occ::handle<Graphic3d_TextureSet>& theTextures)
0176 {
0177 myTextureSet = theTextures;
0178 }
0179
0180
0181
0182 occ::handle<Graphic3d_TextureMap> TextureMap() const
0183 {
0184 return !myTextureSet.IsNull() && !myTextureSet->IsEmpty() ? myTextureSet->First()
0185 : occ::handle<Graphic3d_TextureMap>();
0186 }
0187
0188
0189
0190
0191 Standard_EXPORT void SetTextureMap(const occ::handle<Graphic3d_TextureMap>& theTexture);
0192
0193
0194 bool ToMapTexture() const { return myToMapTexture; }
0195
0196
0197 bool TextureMapState() const { return myToMapTexture; }
0198
0199
0200 void SetTextureMapOn(bool theToMap) { myToMapTexture = theToMap; }
0201
0202
0203 void SetTextureMapOn() { myToMapTexture = true; }
0204
0205
0206 void SetTextureMapOff() { myToMapTexture = false; }
0207
0208
0209 const Graphic3d_PolygonOffset& PolygonOffset() const { return myPolygonOffset; }
0210
0211
0212 void SetPolygonOffset(const Graphic3d_PolygonOffset& theOffset) { myPolygonOffset = theOffset; }
0213
0214
0215 void PolygonOffsets(int& theMode, float& theFactor, float& theUnits) const
0216 {
0217 theMode = myPolygonOffset.Mode;
0218 theFactor = myPolygonOffset.Factor;
0219 theUnits = myPolygonOffset.Units;
0220 }
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238 void SetPolygonOffsets(const int theMode,
0239 const float theFactor = 1.0f,
0240 const float theUnits = 0.0f)
0241 {
0242 myPolygonOffset.Mode = (Aspect_PolygonOffsetMode)(theMode & Aspect_POM_Mask);
0243 myPolygonOffset.Factor = theFactor;
0244 myPolygonOffset.Units = theUnits;
0245 }
0246
0247
0248 public:
0249
0250 Aspect_TypeOfLine LineType() const { return myLineType; }
0251
0252
0253 void SetLineType(Aspect_TypeOfLine theType)
0254 {
0255 myLineType = theType;
0256 myLinePattern = DefaultLinePatternForType(theType);
0257 }
0258
0259
0260 uint16_t LinePattern() const { return myLinePattern; }
0261
0262
0263
0264 void SetLinePattern(uint16_t thePattern)
0265 {
0266 myLineType = DefaultLineTypeForPattern(thePattern);
0267 myLinePattern = thePattern;
0268 }
0269
0270
0271
0272 uint16_t LineStippleFactor() const { return myLineFactor; }
0273
0274
0275 void SetLineStippleFactor(uint16_t theFactor)
0276 {
0277 if (theFactor == 0 || theFactor > 256)
0278 {
0279 throw Standard_OutOfRange("Graphic3d_Aspects::SetLineStippleFactor(), bad factor value");
0280 }
0281 myLineFactor = theFactor;
0282 }
0283
0284
0285 float LineWidth() const { return myLineWidth; }
0286
0287
0288
0289 void SetLineWidth(float theWidth)
0290 {
0291 if (theWidth <= 0.0f)
0292 {
0293 throw Standard_OutOfRange("Bad value for EdgeLineWidth");
0294 }
0295 myLineWidth = theWidth;
0296 }
0297
0298
0299 static uint16_t DefaultLinePatternForType(Aspect_TypeOfLine theType)
0300 {
0301 switch (theType)
0302 {
0303 case Aspect_TOL_DASH:
0304 return 0xFFC0;
0305 case Aspect_TOL_DOT:
0306 return 0xCCCC;
0307 case Aspect_TOL_DOTDASH:
0308 return 0xFF18;
0309 case Aspect_TOL_EMPTY:
0310 return 0x0000;
0311 case Aspect_TOL_SOLID:
0312 return 0xFFFF;
0313 case Aspect_TOL_USERDEFINED:
0314 return 0xFF24;
0315 }
0316 return 0xFFFF;
0317 }
0318
0319
0320 static Aspect_TypeOfLine DefaultLineTypeForPattern(uint16_t thePattern)
0321 {
0322 switch (thePattern)
0323 {
0324 case 0x0000:
0325 return Aspect_TOL_EMPTY;
0326 case 0xFFC0:
0327 return Aspect_TOL_DASH;
0328 case 0xCCCC:
0329 return Aspect_TOL_DOT;
0330 case 0xFF18:
0331 return Aspect_TOL_DOTDASH;
0332 case 0xFFFF:
0333 return Aspect_TOL_SOLID;
0334 case 0xFF24:
0335 return Aspect_TOL_USERDEFINED;
0336 }
0337 return Aspect_TOL_USERDEFINED;
0338 }
0339
0340
0341 public:
0342
0343 Aspect_TypeOfMarker MarkerType() const { return myMarkerType; }
0344
0345
0346 void SetMarkerType(Aspect_TypeOfMarker theType) { myMarkerType = theType; }
0347
0348
0349 float MarkerScale() const { return myMarkerScale; }
0350
0351
0352
0353
0354
0355 void SetMarkerScale(const float theScale)
0356 {
0357 if (theScale <= 0.0f)
0358 {
0359 throw Standard_OutOfRange("Bad value for MarkerScale");
0360 }
0361 myMarkerScale = theScale;
0362 }
0363
0364
0365
0366 const occ::handle<Graphic3d_MarkerImage>& MarkerImage() const { return myMarkerImage; }
0367
0368
0369 void SetMarkerImage(const occ::handle<Graphic3d_MarkerImage>& theImage)
0370 {
0371 myMarkerImage = theImage;
0372 }
0373
0374
0375
0376 bool IsMarkerSprite() const
0377 {
0378 if (myMarkerType == Aspect_TOM_POINT || myMarkerType == Aspect_TOM_EMPTY)
0379 {
0380 return false;
0381 }
0382
0383 return myMarkerType != Aspect_TOM_USERDEFINED || !myMarkerImage.IsNull();
0384 }
0385
0386
0387 public:
0388
0389 const occ::handle<TCollection_HAsciiString>& TextFont() const { return myTextFont; }
0390
0391
0392 void SetTextFont(const occ::handle<TCollection_HAsciiString>& theFont) { myTextFont = theFont; }
0393
0394
0395 Font_FontAspect TextFontAspect() const { return myTextFontAspect; }
0396
0397
0398 void SetTextFontAspect(Font_FontAspect theFontAspect) { myTextFontAspect = theFontAspect; }
0399
0400
0401 Aspect_TypeOfDisplayText TextDisplayType() const { return myTextDisplayType; }
0402
0403
0404 void SetTextDisplayType(Aspect_TypeOfDisplayText theType) { myTextDisplayType = theType; }
0405
0406
0407 const Quantity_ColorRGBA& ColorSubTitleRGBA() const { return myEdgeColor; }
0408
0409
0410 const Quantity_Color& ColorSubTitle() const { return myEdgeColor.GetRGB(); }
0411
0412
0413 void SetColorSubTitle(const Quantity_Color& theColor) { myEdgeColor.SetRGB(theColor); }
0414
0415
0416 void SetColorSubTitle(const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
0417
0418
0419 bool IsTextZoomable() const { return myIsTextZoomable; }
0420
0421
0422 void SetTextZoomable(bool theFlag) { myIsTextZoomable = theFlag; }
0423
0424
0425 Aspect_TypeOfStyleText TextStyle() const { return myTextStyle; }
0426
0427
0428 void SetTextStyle(Aspect_TypeOfStyleText theStyle) { myTextStyle = theStyle; }
0429
0430
0431 float TextAngle() const { return myTextAngle; }
0432
0433
0434 void SetTextAngle(float theAngle) { myTextAngle = (float)theAngle; }
0435
0436
0437 public:
0438
0439 bool ToDrawEdges() const { return myToDrawEdges && myLineType != Aspect_TOL_EMPTY; }
0440
0441
0442 void SetDrawEdges(bool theToDraw)
0443 {
0444 myToDrawEdges = theToDraw;
0445 if (myLineType == Aspect_TOL_EMPTY)
0446 {
0447 myLineType = Aspect_TOL_SOLID;
0448 }
0449 }
0450
0451
0452 void SetEdgeOn() { SetDrawEdges(true); }
0453
0454
0455 void SetEdgeOff() { SetDrawEdges(false); }
0456
0457
0458 const Quantity_Color& EdgeColor() const { return myEdgeColor.GetRGB(); }
0459
0460
0461 const Quantity_ColorRGBA& EdgeColorRGBA() const { return myEdgeColor; }
0462
0463
0464 void SetEdgeColor(const Quantity_Color& theColor) { myEdgeColor.SetRGB(theColor); }
0465
0466
0467 void SetEdgeColor(const Quantity_ColorRGBA& theColor) { myEdgeColor = theColor; }
0468
0469
0470 Aspect_TypeOfLine EdgeLineType() const { return myLineType; }
0471
0472
0473 void SetEdgeLineType(Aspect_TypeOfLine theType) { SetLineType(theType); }
0474
0475
0476 float EdgeWidth() const { return myLineWidth; }
0477
0478
0479 void SetEdgeWidth(double theWidth) { SetLineWidth((float)theWidth); }
0480
0481
0482
0483
0484
0485
0486
0487
0488
0489 bool ToSkipFirstEdge() const { return myToSkipFirstEdge; }
0490
0491
0492
0493 void SetSkipFirstEdge(bool theToSkipFirstEdge) { myToSkipFirstEdge = theToSkipFirstEdge; }
0494
0495
0496
0497 bool ToDrawSilhouette() const { return myToDrawSilhouette; }
0498
0499
0500 void SetDrawSilhouette(bool theToDraw) { myToDrawSilhouette = theToDraw; }
0501
0502 public:
0503
0504 const occ::handle<Graphic3d_HatchStyle>& HatchStyle() const { return myHatchStyle; }
0505
0506
0507 void SetHatchStyle(const occ::handle<Graphic3d_HatchStyle>& theStyle) { myHatchStyle = theStyle; }
0508
0509
0510
0511 void SetHatchStyle(const Aspect_HatchStyle theStyle)
0512 {
0513 if (theStyle == Aspect_HS_SOLID)
0514 {
0515 myHatchStyle.Nullify();
0516 return;
0517 }
0518
0519 myHatchStyle = new Graphic3d_HatchStyle(theStyle);
0520 }
0521
0522 public:
0523
0524 bool IsEqual(const Graphic3d_Aspects& theOther)
0525 {
0526 if (this == &theOther)
0527 {
0528 return true;
0529 }
0530
0531 return myProgram == theOther.myProgram && myTextureSet == theOther.myTextureSet
0532 && myMarkerImage == theOther.myMarkerImage && myInteriorColor == theOther.myInteriorColor
0533 && myBackInteriorColor == theOther.myBackInteriorColor
0534 && myFrontMaterial == theOther.myFrontMaterial
0535 && myBackMaterial == theOther.myBackMaterial
0536 && myInteriorStyle == theOther.myInteriorStyle
0537 && myShadingModel == theOther.myShadingModel && myFaceCulling == theOther.myFaceCulling
0538 && myAlphaMode == theOther.myAlphaMode && myAlphaCutoff == theOther.myAlphaCutoff
0539 && myLineType == theOther.myLineType && myEdgeColor == theOther.myEdgeColor
0540 && myLineWidth == theOther.myLineWidth && myLineFactor == theOther.myLineFactor
0541 && myLinePattern == theOther.myLinePattern && myMarkerType == theOther.myMarkerType
0542 && myMarkerScale == theOther.myMarkerScale && myHatchStyle == theOther.myHatchStyle
0543 && myTextFont == theOther.myTextFont && myPolygonOffset == theOther.myPolygonOffset
0544 && myTextStyle == theOther.myTextStyle && myTextDisplayType == theOther.myTextDisplayType
0545 && myTextFontAspect == theOther.myTextFontAspect && myTextAngle == theOther.myTextAngle
0546 && myToSkipFirstEdge == theOther.myToSkipFirstEdge
0547 && myToDistinguishMaterials == theOther.myToDistinguishMaterials
0548 && myToUseVertexColorForBackFaces == theOther.myToUseVertexColorForBackFaces
0549 && myToDrawEdges == theOther.myToDrawEdges
0550 && myToDrawSilhouette == theOther.myToDrawSilhouette
0551 && myToMapTexture == theOther.myToMapTexture
0552 && myIsTextZoomable == theOther.myIsTextZoomable;
0553 }
0554
0555
0556 Standard_EXPORT virtual void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0557
0558 public:
0559 Standard_DEPRECATED("Deprecated method, FaceCulling() should be used instead")
0560 bool ToSuppressBackFaces() const
0561 {
0562 return myFaceCulling == Graphic3d_TypeOfBackfacingModel_BackCulled
0563 || myFaceCulling == Graphic3d_TypeOfBackfacingModel_Auto;
0564 }
0565
0566 Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used "
0567 "instead")
0568 void SetSuppressBackFaces(bool theToSuppress)
0569 {
0570 myFaceCulling = theToSuppress ? Graphic3d_TypeOfBackfacingModel_Auto
0571 : Graphic3d_TypeOfBackfacingModel_DoubleSided;
0572 }
0573
0574 Standard_DEPRECATED("Deprecated method, FaceCulling() should be used instead")
0575 bool BackFace() const
0576 {
0577 return myFaceCulling == Graphic3d_TypeOfBackfacingModel_BackCulled
0578 || myFaceCulling == Graphic3d_TypeOfBackfacingModel_Auto;
0579 }
0580
0581 Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead")
0582 void AllowBackFace() { myFaceCulling = Graphic3d_TypeOfBackfacingModel_DoubleSided; }
0583
0584 Standard_DEPRECATED("Deprecated method, SetFaceCulling() should be used instead")
0585 void SuppressBackFace() { myFaceCulling = Graphic3d_TypeOfBackfacingModel_Auto; }
0586
0587 protected:
0588 occ::handle<Graphic3d_ShaderProgram> myProgram;
0589 occ::handle<Graphic3d_TextureSet> myTextureSet;
0590 occ::handle<Graphic3d_MarkerImage> myMarkerImage;
0591 occ::handle<Graphic3d_HatchStyle> myHatchStyle;
0592 occ::handle<TCollection_HAsciiString> myTextFont;
0593 Graphic3d_MaterialAspect myFrontMaterial;
0594 Graphic3d_MaterialAspect myBackMaterial;
0595
0596 Quantity_ColorRGBA myInteriorColor;
0597 Quantity_ColorRGBA myBackInteriorColor;
0598 Quantity_ColorRGBA myEdgeColor;
0599
0600 Graphic3d_PolygonOffset myPolygonOffset;
0601 Aspect_InteriorStyle myInteriorStyle;
0602 Graphic3d_TypeOfShadingModel myShadingModel;
0603 Graphic3d_TypeOfBackfacingModel myFaceCulling;
0604 Graphic3d_AlphaMode myAlphaMode;
0605 float myAlphaCutoff;
0606
0607 Aspect_TypeOfLine myLineType;
0608 float myLineWidth;
0609 uint16_t myLineFactor;
0610 uint16_t myLinePattern;
0611
0612 Aspect_TypeOfMarker myMarkerType;
0613 float myMarkerScale;
0614
0615 Aspect_TypeOfStyleText myTextStyle;
0616 Aspect_TypeOfDisplayText myTextDisplayType;
0617 Font_FontAspect myTextFontAspect;
0618 float myTextAngle;
0619
0620 bool myToSkipFirstEdge;
0621 bool myToDistinguishMaterials;
0622 bool myToUseVertexColorForBackFaces;
0623 bool myToDrawEdges;
0624 bool myToDrawSilhouette;
0625 bool myToMapTexture;
0626 bool myIsTextZoomable;
0627 };
0628
0629 #endif