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