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