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