0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / Prs3d / Prs3d_Drawer.hxx
CommitLineData
6262338c 1// Copyright (c) 1995-1999 Matra Datavision
2// Copyright (c) 1999-2014 OPEN CASCADE SAS
3//
4// This file is part of Open CASCADE Technology software library.
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License version 2.1 as published
8// by the Free Software Foundation, with special exception defined in the file
9// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10// distribution for complete text of the license and disclaimer of any warranty.
11//
12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
14
15#ifndef _Prs3d_Drawer_HeaderFile
16#define _Prs3d_Drawer_HeaderFile
17
18#include <Standard.hxx>
ec357c5c 19#include <Standard_Type.hxx>
6262338c 20
6262338c 21#include <Standard_Integer.hxx>
22#include <Standard_Boolean.hxx>
6262338c 23#include <Aspect_TypeOfDeflection.hxx>
fb66bb28 24#include <Graphic3d_GroupAspect.hxx>
f838dac4 25#include <Graphic3d_PresentationAttributes.hxx>
fb66bb28 26#include <Graphic3d_ShaderProgram.hxx>
6262338c 27#include <Standard_Real.hxx>
6262338c 28#include <Prs3d_VertexDrawMode.hxx>
6262338c 29#include <Prs3d_DimensionUnits.hxx>
30#include <Prs3d_TypeOfHLR.hxx>
25e59720 31#include <Standard_Transient.hxx>
0493ffd0 32#include <GeomAbs_Shape.hxx>
6262338c 33
34class Prs3d_IsoAspect;
35class Prs3d_LineAspect;
36class Prs3d_TextAspect;
37class Prs3d_ShadingAspect;
38class Prs3d_PointAspect;
39class Prs3d_PlaneAspect;
40class Prs3d_ArrowAspect;
41class Prs3d_DatumAspect;
42class Prs3d_DimensionAspect;
43class TCollection_AsciiString;
44
f838dac4 45DEFINE_STANDARD_HANDLE(Prs3d_Drawer, Graphic3d_PresentationAttributes)
6262338c 46
47//! A graphic attribute manager which governs how
48//! objects such as color, width, line thickness and deflection are displayed.
49//! A drawer includes an instance of the Aspect classes with particular default values.
f838dac4 50class Prs3d_Drawer : public Graphic3d_PresentationAttributes
6262338c 51{
f838dac4 52 DEFINE_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes)
6262338c 53public:
54
55 //! Default constructor.
56 Standard_EXPORT Prs3d_Drawer();
57
58 //! Sets the type of chordal deflection.
59 //! This indicates whether the deflection value is absolute or relative to the size of the object.
60 Standard_EXPORT void SetTypeOfDeflection (const Aspect_TypeOfDeflection theTypeOfDeflection);
61
62 //! Returns the type of chordal deflection.
63 //! This indicates whether the deflection value is absolute or relative to the size of the object.
64 Aspect_TypeOfDeflection TypeOfDeflection() const
65 {
66 return HasOwnTypeOfDeflection() || myLink.IsNull()
67 ? myTypeOfDeflection
68 : myLink->TypeOfDeflection();
69 }
70
71 //! Returns true if the drawer has a type of deflection setting active.
72 Standard_Boolean HasOwnTypeOfDeflection() const { return myHasOwnTypeOfDeflection; }
73
74 //! Defines the maximal chordial deviation when drawing any curve.
75 //! Even if the type of deviation is set to TOD_Relative, this value is used by:
76 //! Prs3d_DeflectionCurve
77 //! Prs3d_WFDeflectionSurface
78 //! Prs3d_WFDeflectionRestrictedFace
ee2be2a8 79 Standard_EXPORT void SetMaximalChordialDeviation (const Standard_Real theChordialDeviation);
6262338c 80
81 //! Returns the maximal chordal deviation. The default value is 0.1.
82 //! Drawings of curves or patches are made with respect to an absolute maximal chordal deviation.
ee2be2a8 83 Standard_Real MaximalChordialDeviation() const
6262338c 84 {
85 return HasOwnMaximalChordialDeviation() || myLink.IsNull()
86 ? myChordialDeviation
87 : myLink->MaximalChordialDeviation();
88 }
89
90 //! Returns true if the drawer has a maximal chordial deviation setting active.
91 Standard_Boolean HasOwnMaximalChordialDeviation() const { return myHasOwnChordialDeviation; }
92
93 //! Sets the type of HLR algorithm used by drawer's interactive objects
94 Standard_EXPORT void SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR);
95
96 //! Returns the type of HLR algorithm currently in use.
97 Standard_EXPORT Prs3d_TypeOfHLR TypeOfHLR();
98
99 //! Returns true if the type of HLR is not equal to Prs3d_TOH_NotSet.
100 Standard_Boolean HasOwnTypeOfHLR() const { return (myTypeOfHLR != Prs3d_TOH_NotSet); }
101
102 //! Defines the maximum value allowed for the first and last
103 //! parameters of an infinite curve.
104 Standard_EXPORT void SetMaximalParameterValue (const Standard_Real theValue);
105
106 //! Sets the maximum value allowed for the first and last
107 //! parameters of an infinite curve. By default, this value is 500000.
108 Standard_Real MaximalParameterValue() const
109 {
110 return HasOwnMaximalParameterValue() || myLink.IsNull()
111 ? myMaximalParameterValue
112 : myLink->MaximalParameterValue();
113 }
114
115 //! Returns true if the drawer has a maximum value allowed for the first and last
116 //! parameters of an infinite curve setting active.
117 Standard_Boolean HasOwnMaximalParameterValue() const { return myHasOwnMaximalParameterValue; }
118
119 //! Sets IsoOnPlane on or off by setting the parameter theIsEnabled to true or false.
120 Standard_EXPORT void SetIsoOnPlane (const Standard_Boolean theIsEnabled);
121
122 //! Returns True if the drawing of isos on planes is enabled.
123 Standard_Boolean IsoOnPlane() const
124 {
125 return HasOwnIsoOnPlane() || myLink.IsNull()
126 ? myIsoOnPlane
127 : myLink->IsoOnPlane();
128 }
129
130 //! Returns true if the drawer has IsoOnPlane setting active.
131 Standard_Boolean HasOwnIsoOnPlane() const { return myHasOwnIsoOnPlane; }
132
5ad8c033 133 //! Returns True if the drawing of isos on triangulation is enabled.
134 Standard_Boolean IsoOnTriangulation() const
135 {
136 return HasOwnIsoOnTriangulation() || myLink.IsNull()
137 ? myIsoOnTriangulation
138 : myLink->IsoOnTriangulation();
139 }
140
141 //! Returns true if the drawer has IsoOnTriangulation setting active.
142 Standard_Boolean HasOwnIsoOnTriangulation() const { return myHasOwnIsoOnTriangulation; }
143
144 //! Enables or disables isolines on triangulation by setting the parameter theIsEnabled to true or false.
145 Standard_EXPORT void SetIsoOnTriangulation (const Standard_Boolean theToEnable);
146
6262338c 147 //! Sets the discretisation parameter theValue.
148 Standard_EXPORT void SetDiscretisation (const Standard_Integer theValue);
149
150 //! Returns the discretisation setting.
151 Standard_Integer Discretisation() const
152 {
153 return HasOwnDiscretisation() || myLink.IsNull()
154 ? myNbPoints
155 : myLink->Discretisation();
156 }
157
158 //! Returns true if the drawer has discretisation setting active.
159 Standard_Boolean HasOwnDiscretisation() const { return myHasOwnNbPoints; }
160
161 //! Sets the deviation coefficient theCoefficient.
162 //! Also sets the hasOwnDeviationCoefficient flag to Standard_True and myPreviousDeviationCoefficient
163 Standard_EXPORT void SetDeviationCoefficient (const Standard_Real theCoefficient);
164
165 //! Returns the deviation coefficient.
166 //! Drawings of curves or patches are made with respect
167 //! to a maximal chordal deviation. A Deviation coefficient
168 //! is used in the shading display mode. The shape is
169 //! seen decomposed into triangles. These are used to
170 //! calculate reflection of light from the surface of the
171 //! object. The triangles are formed from chords of the
172 //! curves in the shape. The deviation coefficient gives
173 //! the highest value of the angle with which a chord can
174 //! deviate from a tangent to a curve. If this limit is
175 //! reached, a new triangle is begun.
176 //! This deviation is absolute and is set through the
177 //! method: SetMaximalChordialDeviation. The default value is 0.001.
178 //! In drawing shapes, however, you are allowed to ask
179 //! for a relative deviation. This deviation will be:
180 //! SizeOfObject * DeviationCoefficient.
181 Standard_Real DeviationCoefficient() const
182 {
183 return HasOwnDeviationCoefficient() || myLink.IsNull()
184 ? myDeviationCoefficient
185 : myLink->DeviationCoefficient();
186 }
187
188 //! Sets the hasOwnDeviationCoefficient flag to Standard_False
189 void SetDeviationCoefficient()
190 {
191 myHasOwnDeviationCoefficient = Standard_False;
192 }
193
194 //! Returns true if there is a local setting for deviation
195 //! coefficient in this framework for a specific interactive object.
196 Standard_Boolean HasOwnDeviationCoefficient() const { return myHasOwnDeviationCoefficient; }
197
198 //! Saves the previous value used for the chordal
199 //! deviation coefficient.
200 Standard_Real PreviousDeviationCoefficient() const
201 {
202 return myHasOwnDeviationCoefficient
203 ? myPreviousDeviationCoefficient
204 : 0.0;
205 }
206
83b0f13a 207 //! Updates the previous value used for the chordal deviation coefficient to the current state.
208 void UpdatePreviousDeviationCoefficient()
209 {
210 if (myHasOwnDeviationCoefficient)
211 {
212 myPreviousDeviationCoefficient = DeviationCoefficient();
213 }
214 }
215
6262338c 216 //! Sets the deviation angle theAngle.
217 //! Also sets the hasOwnDeviationAngle flag to Standard_True, and myPreviousDeviationAngle.
218 Standard_EXPORT void SetDeviationAngle (const Standard_Real theAngle);
219
67441d0c 220 //! Returns the value for deviation angle in radians, 20 * M_PI / 180 by default.
6262338c 221 Standard_Real DeviationAngle() const
222 {
223 return HasOwnDeviationAngle() || myLink.IsNull()
224 ? myDeviationAngle
225 : myLink->DeviationAngle();
226 }
227
228 //! Sets the hasOwnDeviationAngle flag to Standard_False
229 void SetDeviationAngle()
230 {
231 myHasOwnDeviationAngle = Standard_False;
232 }
233
234 //! Returns true if the there is a local setting for deviation
235 //! angle in this framework for a specific interactive object.
236 Standard_Boolean HasOwnDeviationAngle() const { return myHasOwnDeviationAngle; }
237
238 //! Returns the previous deviation angle
239 Standard_Real PreviousDeviationAngle() const
240 {
241 return myHasOwnDeviationAngle
242 ? myPreviousDeviationAngle
243 : 0.0;
244 }
245
83b0f13a 246 //! Updates the previous deviation angle to the current value
247 void UpdatePreviousDeviationAngle()
248 {
249 if (myHasOwnDeviationAngle)
250 {
251 myPreviousDeviationAngle = DeviationAngle();
252 }
253 }
254
4c513386 255 //! Sets IsAutoTriangulated on or off by setting the parameter theIsEnabled to true or false.
256 //! If this flag is True automatic re-triangulation with deflection-check logic will be applied.
257 //! Else this feature will be disable and triangulation is expected to be computed by application itself
258 //! and no shading presentation at all if unavailable.
259 Standard_EXPORT void SetAutoTriangulation (const Standard_Boolean theIsEnabled);
260
261 //! Returns True if automatic triangulation is enabled.
262 Standard_Boolean IsAutoTriangulation() const
263 {
264 return HasOwnIsAutoTriangulation() || myLink.IsNull()
265 ? myIsAutoTriangulated
266 : myLink->IsAutoTriangulation();
267 }
268
269 //! Returns true if the drawer has IsoOnPlane setting active.
270 Standard_Boolean HasOwnIsAutoTriangulation() const { return myHasOwnIsAutoTriangulated; }
271
6262338c 272 //! Defines the attributes which are used when drawing an
273 //! U isoparametric curve of a face. Defines the number
274 //! of U isoparametric curves to be drawn for a single face.
275 //! The LineAspect for U isoparametric lines can be edited
276 //! (methods SetColor, SetTypeOfLine, SetWidth, SetNumber)
277 //! The default values are:
278 //! COLOR : Quantity_NOC_GRAY75
279 //! TYPE OF LINE: Aspect_TOL_SOLID
280 //! WIDTH : 0.5
281 //!
282 //! These attributes are used by the following algorithms:
283 //! Prs3d_WFDeflectionSurface
284 //! Prs3d_WFDeflectionRestrictedFace
285 Standard_EXPORT const Handle(Prs3d_IsoAspect)& UIsoAspect();
286
287 Standard_EXPORT void SetUIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect);
288
289 //! Returns true if the drawer has its own attribute for
290 //! UIso aspect that overrides the one in the link.
291 Standard_Boolean HasOwnUIsoAspect() const { return myHasOwnUIsoAspect; }
292
293 //! Defines the attributes which are used when drawing an
294 //! V isoparametric curve of a face. Defines the number
295 //! of V isoparametric curves to be drawn for a single face.
296 //! The LineAspect for V isoparametric lines can be edited
297 //! (methods SetColor, SetTypeOfLine, SetWidth, SetNumber)
298 //! The default values are:
299 //! COLOR : Quantity_NOC_GRAY82
300 //! TYPE OF LINE: Aspect_TOL_SOLID
301 //! WIDTH : 0.5
302 //!
303 //! These attributes are used by the following algorithms:
304 //! Prs3d_WFDeflectionSurface
305 //! Prs3d_WFDeflectionRestrictedFace
306 Standard_EXPORT const Handle(Prs3d_IsoAspect)& VIsoAspect();
307
308 //! Sets the appearance of V isoparameters - theAspect.
309 Standard_EXPORT void SetVIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect);
310
311 //! Returns true if the drawer has its own attribute for
312 //! VIso aspect that overrides the one in the link.
313 Standard_Boolean HasOwnVIsoAspect() const { return myHasOwnVIsoAspect; }
314
315 //! Returns wire aspect settings.
316 //! The LineAspect for the free boundaries can be edited.
317 //! The default values are:
318 //! Color: Quantity_NOC_GREEN
319 //! Type of line: Aspect_TOL_SOLID
320 //! Width: 1.0
321 //! These attributes are used by the algorithm Prs3d_WFShape.
322 Standard_EXPORT const Handle(Prs3d_LineAspect)& WireAspect();
323
324 //! Sets the parameter theAspect for display of wires.
325 Standard_EXPORT void SetWireAspect (const Handle(Prs3d_LineAspect)& theAspect);
326
327 //! Returns true if the drawer has its own attribute for
328 //! wire aspect that overrides the one in the link.
329 Standard_Boolean HasOwnWireAspect() const { return myHasOwnWireAspect; }
330
331 //! Sets WireDraw on or off by setting the parameter theIsEnabled to true or false.
332 Standard_EXPORT void SetWireDraw(const Standard_Boolean theIsEnabled);
333
334 //! Returns True if the drawing of the wire is enabled.
335 Standard_Boolean WireDraw() const
336 {
337 return HasOwnWireDraw() || myLink.IsNull()
338 ? myWireDraw
339 : myLink->WireDraw();
340 }
341
342 //! Returns true if the drawer has its own attribute for
343 //! "draw wires" flag that overrides the one in the link.
344 Standard_Boolean HasOwnWireDraw() const { return myHasOwnWireDraw; }
345
346 //! Returns the point aspect setting. The default values are
347 //! Color: Quantity_NOC_YELLOW
348 //! Type of marker: Aspect_TOM_PLUS
349 //! Scale: 1.0
350 //! These attributes are used by the algorithms Prs3d_Point.
351 Standard_EXPORT const Handle(Prs3d_PointAspect)& PointAspect();
352
353 //! Sets the parameter theAspect for display attributes of points
354 Standard_EXPORT void SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect);
355
356 //! Returns true if the drawer has its own attribute for
357 //! point aspect that overrides the one in the link.
358 Standard_Boolean HasOwnPointAspect() const { return myHasOwnPointAspect; }
359
2a332745 360 //! Sets own point aspect.
361 //! Returns FALSE if the drawer already has its own attribute for point aspect.
362 Standard_EXPORT Standard_Boolean SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
363
6262338c 364 //! Returns settings for line aspects.
365 //! These settings can be edited. The default values are:
366 //! Color: Quantity_NOC_YELLOW
367 //! Type of line: Aspect_TOL_SOLID
368 //! Width: 1.0
369 //! These attributes are used by the following algorithms:
370 //! Prs3d_Curve
371 //! Prs3d_Line
372 //! Prs3d_HLRShape
373 Standard_EXPORT const Handle(Prs3d_LineAspect)& LineAspect();
374
375 //! Sets the parameter theAspect for display attributes of lines.
376 Standard_EXPORT void SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
377
378 //! Returns true if the drawer has its own attribute for
379 //! line aspect that overrides the one in the link.
380 Standard_Boolean HasOwnLineAspect() const { return myHasOwnLineAspect; }
381
2a332745 382 //! Sets own line aspects.
383 //! Returns FALSE if own line aspect are already set.
384 Standard_EXPORT Standard_Boolean SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
385
386 //! Sets own line aspects for datums.
387 //! Returns FALSE if own line for datums are already set.
388 Standard_EXPORT Standard_Boolean SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
389
6262338c 390 //! Returns settings for text aspect.
391 //! These settings can be edited. The default value is:
392 //! - Color: Quantity_NOC_YELLOW
393 Standard_EXPORT const Handle(Prs3d_TextAspect)& TextAspect();
394
395 //! Sets the parameter theAspect for display attributes of text.
396 Standard_EXPORT void SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect);
397
398 //! Returns true if the drawer has its own attribute for
399 //! text aspect that overrides the one in the link.
400 Standard_Boolean HasOwnTextAspect() const { return myHasOwnTextAspect; }
401
402 //! Returns settings for shading aspects.
403 //! These settings can be edited. The default values are:
404 //! - Color: Quantity_NOC_YELLOW
405 //! - Material: Graphic3d_NOM_BRASS
406 //! Shading aspect is obtained through decomposition of
407 //! 3d faces into triangles, each side of each triangle
408 //! being a chord of the corresponding curved edge in the face.
409 //! Reflection of light in each projector perspective is then calculated for each of the
410 //! resultant triangular planes.
411 Standard_EXPORT const Handle(Prs3d_ShadingAspect)& ShadingAspect();
412
413 //! Sets the parameter theAspect for display attributes of shading.
414 Standard_EXPORT void SetShadingAspect (const Handle(Prs3d_ShadingAspect)& theAspect);
415
416 //! Returns true if the drawer has its own attribute for
417 //! shading aspect that overrides the one in the link.
418 Standard_Boolean HasOwnShadingAspect() const { return myHasOwnShadingAspect; }
419
2a332745 420 //! Sets own shading aspect.
421 //! Returns FALSE if the drawer already has its own attribute for shading aspect.
422 Standard_EXPORT Standard_Boolean SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
423
6262338c 424 //! Returns settings for seen line aspects.
425 //! These settings can be edited. The default values are:
426 //! Color: Quantity_NOC_YELLOW
427 //! Type of line: Aspect_TOL_SOLID
428 //! Width: 1.0
429 Standard_EXPORT const Handle(Prs3d_LineAspect)& SeenLineAspect();
430
431 //! Sets the parameter theAspect for the display of seen lines in hidden line removal mode.
432 Standard_EXPORT void SetSeenLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
433
434 //! Returns true if the drawer has its own attribute for
435 //! seen line aspect that overrides the one in the link.
436 Standard_Boolean HasOwnSeenLineAspect() const { return myHasOwnSeenLineAspect; }
437
438 //! Returns settings for the appearance of planes.
439 Standard_EXPORT const Handle(Prs3d_PlaneAspect)& PlaneAspect();
440
441 //! Sets the parameter theAspect for the display of planes.
442 Standard_EXPORT void SetPlaneAspect (const Handle(Prs3d_PlaneAspect)& theAspect);
443
444 //! Returns true if the drawer has its own attribute for
445 //! plane aspect that overrides the one in the link.
446 Standard_Boolean HasOwnPlaneAspect() const { return myHasOwnPlaneAspect; }
447
448 //! Returns the attributes for display of arrows.
449 Standard_EXPORT const Handle(Prs3d_ArrowAspect)& ArrowAspect();
450
451 //! Sets the parameter theAspect for display attributes of arrows.
452 Standard_EXPORT void SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect);
453
454 //! Returns true if the drawer has its own attribute for
455 //! arrow aspect that overrides the one in the link.
456 Standard_Boolean HasOwnArrowAspect() const { return myHasOwnArrowAspect; }
457
458 //! Enables the drawing of an arrow at the end of each line.
459 //! By default the arrows are not drawn.
460 Standard_EXPORT void SetLineArrowDraw (const Standard_Boolean theIsEnabled);
461
462 //! Returns True if drawing an arrow at the end of each edge is enabled
463 //! and False otherwise (the default).
464 Standard_Boolean LineArrowDraw() const
465 {
466 return HasOwnLineArrowDraw() || myLink.IsNull()
467 ? myLineArrowDraw
468 : myLink->LineArrowDraw();
469 }
470
471 //! Returns true if the drawer has its own attribute for
472 //! "draw arrow" flag that overrides the one in the link.
473 Standard_Boolean HasOwnLineArrowDraw() const
474 {
475 return myHasOwnLineArrowDraw;
476 }
477
478 //! Returns settings for hidden line aspects.
479 //! These settings can be edited. The default values are:
480 //! Color: Quantity_NOC_YELLOW
481 //! Type of line: Aspect_TOL_DASH
482 //! Width: 1.0
483 Standard_EXPORT const Handle(Prs3d_LineAspect)& HiddenLineAspect();
484
485 //! Sets the parameter theAspect for the display of hidden lines in hidden line removal mode.
486 Standard_EXPORT void SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
487
488 //! Returns true if the drawer has its own attribute for
489 //! hidden lines aspect that overrides the one in the link.
490 Standard_Boolean HasOwnHiddenLineAspect() const { return myHasOwnHiddenLineAspect; }
491
492 //! Returns Standard_True if the hidden lines are to be drawn.
493 //! By default the hidden lines are not drawn.
494 Standard_Boolean DrawHiddenLine() const
495 {
496 return HasOwnDrawHiddenLine() || myLink.IsNull()
497 ? myDrawHiddenLine
498 : myLink->DrawHiddenLine();
499 }
500
501 //! Enables the DrawHiddenLine function.
502 Standard_EXPORT void EnableDrawHiddenLine();
503
504 //! Disables the DrawHiddenLine function.
505 Standard_EXPORT void DisableDrawHiddenLine();
506
507 //! Returns true if the drawer has its own attribute for
508 //! "draw hidden lines" flag that overrides the one in the link.
509 Standard_Boolean HasOwnDrawHiddenLine() const { return myHasOwnDrawHiddenLine; }
510
511 //! Returns settings for the appearance of vectors.
512 //! These settings can be edited. The default values are:
513 //! Color: Quantity_NOC_SKYBLUE
514 //! Type of line: Aspect_TOL_SOLID
515 //! Width: 1.0
516 Standard_EXPORT const Handle(Prs3d_LineAspect)& VectorAspect();
517
518 //! Sets the modality theAspect for the display of vectors.
519 Standard_EXPORT void SetVectorAspect (const Handle(Prs3d_LineAspect)& theAspect);
520
521 //! Returns true if the drawer has its own attribute for
522 //! vector aspect that overrides the one in the link.
523 Standard_Boolean HasOwnVectorAspect() const { return myHasOwnVectorAspect; }
524
525 //! Sets the mode of visualization of vertices of a TopoDS_Shape instance.
526 //! By default, only stand-alone vertices (not belonging topologically to an edge) are drawn,
527 //! that corresponds to Prs3d_VDM_Standalone mode.
528 //! Switching to Prs3d_VDM_Standalone mode makes all shape's vertices visible.
529 //! To inherit this parameter from the global drawer instance ("the link") when it is present,
530 //! Prs3d_VDM_Inherited value should be used.
531 Standard_EXPORT void SetVertexDrawMode (const Prs3d_VertexDrawMode theMode);
532
533 //! Returns the current mode of visualization of vertices of a TopoDS_Shape instance.
534 Standard_EXPORT Prs3d_VertexDrawMode VertexDrawMode();
535
536 //! Returns true if the vertex draw mode is not equal to <b>Prs3d_VDM_Inherited</b>.
537 //! This means that individual vertex draw mode value (i.e. not inherited from the global
538 //! drawer) is used for a specific interactive object.
539 Standard_Boolean HasOwnVertexDrawMode() const { return (myVertexDrawMode != Prs3d_VDM_Inherited); }
540
541 //! Returns settings for the appearance of datums.
542 //! These settings can be edited. The default values for the three axes are:
543 //! Color: Quantity_NOC_PEACHPUFF
544 //! Type of line: Aspect_TOL_SOLID
545 //! Width: 1.0
546 Standard_EXPORT const Handle(Prs3d_DatumAspect)& DatumAspect();
547
548 //! Sets the modality theAspect for the display of datums.
549 Standard_EXPORT void SetDatumAspect (const Handle(Prs3d_DatumAspect)& theAspect);
550
551 //! Returns true if the drawer has its own attribute for
552 //! datum aspect that overrides the one in the link.
553 Standard_Boolean HasOwnDatumAspect() const { return myHasOwnDatumAspect; }
554
555 //! The LineAspect for the wire can be edited.
556 //! The default values are:
557 //! Color: Quantity_NOC_ORANGE
558 //! Type of line: Aspect_TOL_SOLID
559 //! Width: 1.0
560 //! These attributes are used by the algorithm Prs3d_WFShape.
561 Standard_EXPORT const Handle(Prs3d_LineAspect)& SectionAspect();
562
563 //! Sets the parameter theAspect for display attributes of sections.
564 Standard_EXPORT void SetSectionAspect (const Handle(Prs3d_LineAspect)& theAspect);
565
566 //! Returns true if the drawer has its own attribute for
567 //! section aspect that overrides the one in the link.
568 Standard_Boolean HasOwnSectionAspect() const { return myHasOwnSectionAspect; }
569
570 //! Sets the parameter theAspect for the display of free boundaries.
571 //! The method sets aspect owned by the drawer that will be used during
572 //! visualization instead of the one set in link.
573 Standard_EXPORT void SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect);
574
575 //! Returns the values for presentation of free boundaries,
576 //! in other words, boundaries which are not shared.
577 //! The LineAspect for the free boundaries can be edited.
578 //! The default values are:
579 //! Color: Quantity_NOC_GREEN
580 //! Type of line: Aspect_TOL_SOLID
581 //! Width: 1.0
582 //! These attributes are used by the algorithm Prs3d_WFShape
583 Standard_EXPORT const Handle(Prs3d_LineAspect)& FreeBoundaryAspect();
584
585 //! Returns true if the drawer has its own attribute for
586 //! free boundaries aspect that overrides the one in the link.
587 Standard_Boolean HasOwnFreeBoundaryAspect() const { return myHasOwnFreeBoundaryAspect; }
588
589 //! Enables or disables drawing of free boundaries for shading presentations.
590 //! The method sets drawing flag owned by the drawer that will be used during
591 //! visualization instead of the one set in link.
592 //! theIsEnabled is a boolean flag indicating whether the free boundaries should be
593 //! drawn or not.
594 Standard_EXPORT void SetFreeBoundaryDraw (const Standard_Boolean theIsEnabled);
595
596 //! Returns True if the drawing of the free boundaries is enabled
597 //! True is the default setting.
598 Standard_Boolean FreeBoundaryDraw() const
599 {
600 return HasOwnFreeBoundaryDraw() || myLink.IsNull()
601 ? myFreeBoundaryDraw
602 : myLink->FreeBoundaryDraw();
603 }
604
605 //! Returns true if the drawer has its own attribute for
606 //! "draw free boundaries" flag that overrides the one in the link.
607 Standard_Boolean HasOwnFreeBoundaryDraw() const { return myHasOwnFreeBoundaryDraw; }
608
609 //! Sets the parameter theAspect for the display of shared boundaries.
610 //! The method sets aspect owned by the drawer that will be used during
611 //! visualization instead of the one set in link.
612 Standard_EXPORT void SetUnFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect);
613
614 //! Returns settings for shared boundary line aspects.
615 //! The LineAspect for the unfree boundaries can be edited.
616 //! The default values are:
617 //! Color: Quantity_NOC_YELLOW
618 //! Type of line: Aspect_TOL_SOLID
619 //! Width: 1.
620 //! These attributes are used by the algorithm Prs3d_WFShape
621 Standard_EXPORT const Handle(Prs3d_LineAspect)& UnFreeBoundaryAspect();
622
623 //! Returns true if the drawer has its own attribute for
624 //! unfree boundaries aspect that overrides the one in the link.
625 Standard_Boolean HasOwnUnFreeBoundaryAspect() const { return myHasOwnUnFreeBoundaryAspect; }
626
627 //! Enables or disables drawing of shared boundaries for shading presentations.
628 //! The method sets drawing flag owned by the drawer that will be used during
629 //! visualization instead of the one set in link.
630 //! theIsEnabled is a boolean flag indicating whether the shared boundaries should be drawn or not.
631 Standard_EXPORT void SetUnFreeBoundaryDraw (const Standard_Boolean theIsEnabled);
632
633 //! Returns True if the drawing of the shared boundaries is enabled.
634 //! True is the default setting.
635 Standard_Boolean UnFreeBoundaryDraw() const
636 {
637 return HasOwnUnFreeBoundaryDraw() || myLink.IsNull()
638 ? myUnFreeBoundaryDraw
639 : myLink->UnFreeBoundaryDraw();
640 }
641
642 //! Returns true if the drawer has its own attribute for
643 //! "draw shared boundaries" flag that overrides the one in the link.
644 Standard_Boolean HasOwnUnFreeBoundaryDraw() const { return myHasOwnUnFreeBoundaryDraw; }
645
646 //! Sets line aspect for face boundaries.
647 //! The method sets line aspect owned by the drawer that will be used during
648 //! visualization instead of the one set in link.
649 //! theAspect is the line aspect that determines the look of the face boundaries.
650 Standard_EXPORT void SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect);
651
652 //! Returns line aspect of face boundaries.
653 Standard_EXPORT const Handle(Prs3d_LineAspect)& FaceBoundaryAspect();
654
655 //! Returns true if the drawer has its own attribute for
656 //! face boundaries aspect that overrides the one in the link.
657 Standard_Boolean HasOwnFaceBoundaryAspect() const { return myHasOwnFaceBoundaryAspect; }
658
0493ffd0 659 //! Sets own face boundary aspect.
660 //! Returns FALSE if the drawer already has its own attribute for face boundary aspect.
661 Standard_EXPORT Standard_Boolean SetupOwnFaceBoundaryAspect (const Handle(Prs3d_Drawer)& theDefaults = Handle(Prs3d_Drawer)());
662
6262338c 663 //! Enables or disables face boundary drawing for shading presentations.
664 //! The method sets drawing flag owned by the drawer that will be used during
665 //! visualization instead of the one set in link.
666 //! theIsEnabled is a boolean flag indicating whether the face boundaries should be drawn or not.
667 Standard_EXPORT void SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled);
668
669 //! Checks whether the face boundary drawing is enabled or not.
670 Standard_Boolean FaceBoundaryDraw() const
671 {
672 return HasOwnFaceBoundaryDraw() || myLink.IsNull()
673 ? myFaceBoundaryDraw
674 : myLink->FaceBoundaryDraw();
675 }
676
677 //! Returns true if the drawer has its own attribute for
678 //! "draw face boundaries" flag that overrides the one in the link.
679 Standard_Boolean HasOwnFaceBoundaryDraw() const { return myHasOwnFaceBoundaryDraw; }
680
0493ffd0 681 //! Returns true if the drawer has its own attribute for face boundaries upper edge continuity class that overrides the one in the link.
682 Standard_Boolean HasOwnFaceBoundaryUpperContinuity() const { return myFaceBoundaryUpperContinuity != -1; }
683
684 //! Get the most edge continuity class; GeomAbs_CN by default (all edges).
685 GeomAbs_Shape FaceBoundaryUpperContinuity() const
686 {
687 return HasOwnFaceBoundaryUpperContinuity()
688 ? (GeomAbs_Shape )myFaceBoundaryUpperContinuity
689 : (!myLink.IsNull()
690 ? myLink->FaceBoundaryUpperContinuity()
691 : GeomAbs_CN);
692 }
693
694 //! Set the most edge continuity class for face boundaries.
695 void SetFaceBoundaryUpperContinuity (GeomAbs_Shape theMostAllowedEdgeClass) { myFaceBoundaryUpperContinuity = theMostAllowedEdgeClass; }
696
697 //! Unset the most edge continuity class for face boundaries.
698 void UnsetFaceBoundaryUpperContinuity() { myFaceBoundaryUpperContinuity = -1; }
699
6262338c 700 //! Returns settings for the appearance of dimensions.
701 Standard_EXPORT const Handle(Prs3d_DimensionAspect)& DimensionAspect();
702
703 //! Sets the settings for the appearance of dimensions.
704 //! The method sets aspect owned by the drawer that will be used during
705 //! visualization instead of the one set in link.
706 Standard_EXPORT void SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theAspect);
707
708 //! Returns true if the drawer has its own attribute for
709 //! the appearance of dimensions that overrides the one in the link.
710 Standard_Boolean HasOwnDimensionAspect() const { return myHasOwnDimensionAspect; }
711
712 //! Sets dimension length model units for computing of dimension presentation.
713 //! The method sets value owned by the drawer that will be used during
714 //! visualization instead of the one set in link.
715 Standard_EXPORT void SetDimLengthModelUnits (const TCollection_AsciiString& theUnits);
716
717 //! Sets dimension angle model units for computing of dimension presentation.
718 //! The method sets value owned by the drawer that will be used during
719 //! visualization instead of the one set in link.
720 Standard_EXPORT void SetDimAngleModelUnits (const TCollection_AsciiString& theUnits);
721
722 //! Returns length model units for the dimension presentation.
723 const TCollection_AsciiString& DimLengthModelUnits() const
724 {
725 return HasOwnDimLengthModelUnits() || myLink.IsNull()
726 ? myDimensionModelUnits.GetLengthUnits()
727 : myLink->DimLengthModelUnits();
728 }
729
730 //! Returns angle model units for the dimension presentation.
731 const TCollection_AsciiString& DimAngleModelUnits() const
732 {
733 return HasOwnDimAngleModelUnits() || myLink.IsNull()
734 ? myDimensionModelUnits.GetAngleUnits()
735 : myLink->DimAngleModelUnits();
736 }
737
738 //! Returns true if the drawer has its own attribute for
739 //! dimension length model units that overrides the one in the link.
740 Standard_Boolean HasOwnDimLengthModelUnits() const { return myHasOwnDimLengthModelUnits; }
741
742 //! Returns true if the drawer has its own attribute for
743 //! dimension angle model units that overrides the one in the link.
744 Standard_Boolean HasOwnDimAngleModelUnits() const { return myHasOwnDimAngleModelUnits; }
745
746 //! Sets length units in which value for dimension presentation is displayed.
747 //! The method sets value owned by the drawer that will be used during
748 //! visualization instead of the one set in link.
749 Standard_EXPORT void SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits);
750
751 //! Sets angle units in which value for dimension presentation is displayed.
752 //! The method sets value owned by the drawer that will be used during
753 //! visualization instead of the one set in link.
754 Standard_EXPORT void SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits);
755
756 //! Returns length units in which dimension presentation is displayed.
757 const TCollection_AsciiString& DimLengthDisplayUnits() const
758 {
759 return HasOwnDimLengthDisplayUnits() || myLink.IsNull()
760 ? myDimensionDisplayUnits.GetLengthUnits()
761 : myLink->DimLengthDisplayUnits();
762 }
763
764 //! Returns angle units in which dimension presentation is displayed.
765 const TCollection_AsciiString& DimAngleDisplayUnits() const
766 {
767 return HasOwnDimAngleDisplayUnits() || myLink.IsNull()
768 ? myDimensionDisplayUnits.GetAngleUnits()
769 : myLink->DimAngleDisplayUnits();
770 }
771
772 //! Returns true if the drawer has its own attribute for
773 //! length units in which dimension presentation is displayed
774 //! that overrides the one in the link.
775 Standard_Boolean HasOwnDimLengthDisplayUnits() const { return myHasOwnDimLengthDisplayUnits; }
776
777 //! Returns true if the drawer has its own attribute for
778 //! angle units in which dimension presentation is displayed
779 //! that overrides the one in the link.
780 Standard_Boolean HasOwnDimAngleDisplayUnits() const { return myHasOwnDimAngleDisplayUnits; }
781
782 //! Returns the drawer to which the current object references.
783 const Handle(Prs3d_Drawer)& Link() { return myLink; }
784
785 //! Returns true if the current object has a link on the other drawer.
786 Standard_Boolean HasLink() const { return !myLink.IsNull(); }
787
788 //! Sets theDrawer as a link to which the current object references.
f838dac4 789 void Link (const Handle(Prs3d_Drawer)& theDrawer) { SetLink (theDrawer); }
790
791 //! Sets theDrawer as a link to which the current object references.
792 void SetLink (const Handle(Prs3d_Drawer)& theDrawer) { myLink = theDrawer; }
6262338c 793
794 //! Removes local attributes.
795 Standard_EXPORT void ClearLocalAttributes();
796
fb66bb28 797 //! Assign shader program for specified type of primitives.
798 //! @param theProgram new program to set (might be NULL)
799 //! @param theAspect the type of primitives
800 //! @param theToOverrideDefaults if true then non-overridden attributes using defaults will be allocated and copied from the Link;
801 //! otherwise, only already customized attributes will be changed
8e0a2b19 802 //! @return TRUE if presentation should be recomputed after creating aspects not previously customized (if theToOverrideDefaults is also TRUE)
803 Standard_EXPORT bool SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
fb66bb28 804 const Graphic3d_GroupAspect theAspect,
805 const bool theToOverrideDefaults = false);
806
dc89236f 807 //! Sets Shading Model type for the shading aspect.
808 Standard_EXPORT bool SetShadingModel (Graphic3d_TypeOfShadingModel theModel,
809 bool theToOverrideDefaults = false);
810
0904aa63 811 //! Dumps the content of me into the stream
bc73b006 812 Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE;
0904aa63 813
67441d0c 814public: //! @name deprecated methods
815
816 Standard_DEPRECATED("SetDeviationAngle() should be used instead")
817 void SetHLRAngle (const Standard_Real theAngle) { SetDeviationAngle (theAngle); }
818
819 Standard_DEPRECATED("DeviationAngle() should be used instead")
820 Standard_Real HLRAngle() const { return DeviationAngle(); }
821
822 Standard_DEPRECATED("SetDeviationAngle() should be used instead")
823 void SetHLRAngle() { SetDeviationAngle(); }
824
825 Standard_DEPRECATED("HasOwnDeviationAngle() should be used instead")
826 Standard_Boolean HasOwnHLRDeviationAngle() const { return HasOwnDeviationAngle(); }
827
828 Standard_DEPRECATED("PreviousDeviationAngle() should be used instead")
829 Standard_Real PreviousHLRDeviationAngle() const { return PreviousDeviationAngle(); }
830
6262338c 831protected:
832
833 Handle(Prs3d_Drawer) myLink;
834
835 Standard_Integer myNbPoints;
836 Standard_Boolean myHasOwnNbPoints;
837 Standard_Real myMaximalParameterValue;
838 Standard_Boolean myHasOwnMaximalParameterValue;
ee2be2a8 839 Standard_Real myChordialDeviation;
6262338c 840 Standard_Boolean myHasOwnChordialDeviation;
841 Aspect_TypeOfDeflection myTypeOfDeflection;
842 Standard_Boolean myHasOwnTypeOfDeflection;
843 Prs3d_TypeOfHLR myTypeOfHLR;
844 Standard_Real myDeviationCoefficient;
845 Standard_Real myPreviousDeviationCoefficient;
846 Standard_Boolean myHasOwnDeviationCoefficient;
6262338c 847 Standard_Real myDeviationAngle;
848 Standard_Boolean myHasOwnDeviationAngle;
849 Standard_Real myPreviousDeviationAngle;
6262338c 850 Standard_Boolean myIsoOnPlane;
851 Standard_Boolean myHasOwnIsoOnPlane;
5ad8c033 852 Standard_Boolean myIsoOnTriangulation;
853 Standard_Boolean myHasOwnIsoOnTriangulation;
4c513386 854 Standard_Boolean myIsAutoTriangulated;
855 Standard_Boolean myHasOwnIsAutoTriangulated;
6262338c 856
857 Handle(Prs3d_IsoAspect) myUIsoAspect;
858 Standard_Boolean myHasOwnUIsoAspect;
859 Handle(Prs3d_IsoAspect) myVIsoAspect;
860 Standard_Boolean myHasOwnVIsoAspect;
861 Handle(Prs3d_LineAspect) myWireAspect;
862 Standard_Boolean myHasOwnWireAspect;
863 Standard_Boolean myWireDraw;
864 Standard_Boolean myHasOwnWireDraw;
865 Handle(Prs3d_PointAspect) myPointAspect;
866 Standard_Boolean myHasOwnPointAspect;
867 Handle(Prs3d_LineAspect) myLineAspect;
868 Standard_Boolean myHasOwnLineAspect;
869 Handle(Prs3d_TextAspect) myTextAspect;
870 Standard_Boolean myHasOwnTextAspect;
871 Handle(Prs3d_ShadingAspect) myShadingAspect;
872 Standard_Boolean myHasOwnShadingAspect;
6262338c 873 Handle(Prs3d_PlaneAspect) myPlaneAspect;
874 Standard_Boolean myHasOwnPlaneAspect;
875 Handle(Prs3d_LineAspect) mySeenLineAspect;
876 Standard_Boolean myHasOwnSeenLineAspect;
877 Handle(Prs3d_ArrowAspect) myArrowAspect;
878 Standard_Boolean myHasOwnArrowAspect;
879 Standard_Boolean myLineArrowDraw;
880 Standard_Boolean myHasOwnLineArrowDraw;
881 Handle(Prs3d_LineAspect) myHiddenLineAspect;
882 Standard_Boolean myHasOwnHiddenLineAspect;
883 Standard_Boolean myDrawHiddenLine;
884 Standard_Boolean myHasOwnDrawHiddenLine;
885 Handle(Prs3d_LineAspect) myVectorAspect;
886 Standard_Boolean myHasOwnVectorAspect;
887 Prs3d_VertexDrawMode myVertexDrawMode;
888 Handle(Prs3d_DatumAspect) myDatumAspect;
889 Standard_Boolean myHasOwnDatumAspect;
890 Handle(Prs3d_LineAspect) mySectionAspect;
891 Standard_Boolean myHasOwnSectionAspect;
892
893 Handle(Prs3d_LineAspect) myFreeBoundaryAspect;
894 Standard_Boolean myHasOwnFreeBoundaryAspect;
895 Standard_Boolean myFreeBoundaryDraw;
896 Standard_Boolean myHasOwnFreeBoundaryDraw;
897 Handle(Prs3d_LineAspect) myUnFreeBoundaryAspect;
898 Standard_Boolean myHasOwnUnFreeBoundaryAspect;
899 Standard_Boolean myUnFreeBoundaryDraw;
900 Standard_Boolean myHasOwnUnFreeBoundaryDraw;
901 Handle(Prs3d_LineAspect) myFaceBoundaryAspect;
0493ffd0 902 Standard_Integer myFaceBoundaryUpperContinuity; //!< the most edge continuity class (GeomAbs_Shape) to be included to face boundaries presentation, or -1 if undefined
6262338c 903 Standard_Boolean myHasOwnFaceBoundaryAspect;
904 Standard_Boolean myFaceBoundaryDraw;
905 Standard_Boolean myHasOwnFaceBoundaryDraw;
906
907 Handle(Prs3d_DimensionAspect) myDimensionAspect;
908 Standard_Boolean myHasOwnDimensionAspect;
909 Prs3d_DimensionUnits myDimensionModelUnits;
910 Standard_Boolean myHasOwnDimLengthModelUnits;
911 Standard_Boolean myHasOwnDimAngleModelUnits;
912 Prs3d_DimensionUnits myDimensionDisplayUnits;
913 Standard_Boolean myHasOwnDimLengthDisplayUnits;
914 Standard_Boolean myHasOwnDimAngleDisplayUnits;
6262338c 915};
916
f838dac4 917Standard_DEPRECATED("Class name is deprecated - use Prs3d_Drawer instead")
918typedef Prs3d_Drawer Graphic3d_HighlightStyle;
919
6262338c 920#endif // _Prs3d_Drawer_HeaderFile