1 -- Created on: 1992-09-18
2 -- Created by: Odile Olivier
3 -- Copyright (c) 1992-1999 Matra Datavision
4 -- Copyright (c) 1999-2012 OPEN CASCADE SAS
6 -- The content of this file is subject to the Open CASCADE Technology Public
7 -- License Version 6.5 (the "License"). You may not use the content of this file
8 -- except in compliance with the License. Please obtain a copy of the License
9 -- at http://www.opencascade.org and read it completely before using this file.
11 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 -- The Original Code and all software distributed under the License is
15 -- distributed on an "AS IS" basis, without warranty of any kind, and the
16 -- Initial Developer hereby disclaims all such warranties, including without
17 -- limitation, any warranties of merchantability, fitness for a particular
18 -- purpose or non-infringement. Please see the License for the specific terms
19 -- and conditions governing the rights and limitations under the License.
23 class Drawer from AIS inherits Drawer from Prs3d
26 -- A framework to manage display attributes of interactive objects.
27 -- An interactive object can have a certain number of
28 -- display attributes specific to it. These include
29 -- visualization mode, color, material
30 -- and so on. To deal with this information, the
31 -- interactive context has a Drawer attribute manager
32 -- which is valid by default for the objects it
33 -- controls. When an interactive object is visualized, the
34 -- required graphic display attributes are first taken from
35 -- its own Drawer if it has the ones required, or from the
36 -- context drawer for those it does not have them.
37 -- The set of display attributes of an interactive object is
38 -- stocked in an AIS_Drawer, which is, in fact, a
39 -- Prs3d_Drawer with the possibility of a link to another
40 -- display attribute manager. This drawer then manages
41 -- the stocked graphic display attributes by specifying
42 -- how the presentation algorithms compute the
43 -- presentation of a specific kind of object. These
44 -- factors involved include color, width and type of line,
45 -- and maximal chordal deviation. The Drawer includes
46 -- instances of the aspect classes providing the default
48 -- Prs3d_Drawer completes AIS_Drawer by adding
49 -- functions for setting deviation angle and deviation
50 -- coefficient in presentations using hidden line removal.
54 DatumAspect from Prs3d,
55 LineAspect from Prs3d,
56 TextAspect from Prs3d,
57 PointAspect from Prs3d,
58 ShadingAspect from Prs3d,
60 LengthAspect from Prs3d,
61 AngleAspect from Prs3d,
62 PlaneAspect from Prs3d,
63 RadiusAspect from Prs3d,
64 ArrowAspect from Prs3d,
65 TypeOfDeflection from Aspect,
66 NameOfColor from Quantity,
67 PlaneAngle from Quantity,
72 Create returns mutable Drawer from AIS;
74 -- Constructs an empty attribute management framework.
75 TypeOfDeflection(me) returns TypeOfDeflection from Aspect
78 -- Returns the type of chordal deflection: relative to the
79 -- size of the object or absolute.
81 MaximalChordialDeviation (me) returns Length from Quantity
82 ---Purpose: Returns the maximal chordal deviation. The default
83 -- value is 0.1. Drawings of curves or patches are
84 -- made with respect to an absolute maximal chordal deviation.
88 ------------------------------------------------------------
89 SetDeviationCoefficient(me: mutable) ;
90 ---Purpose: Sets the hasOwnDeviationCoefficient flag to Standard_False
93 SetHLRDeviationCoefficient(me: mutable) ;
94 ---Purpose: Sets the deviation coefficient aCoefficient for
95 -- removal of hidden lines created by different
96 -- viewpoints in different presentations. The Default value is 0.02.
99 SetDeviationAngle(me: mutable) ;
100 ---Purpose: Sets the hasOwnDeviationAngle flag to Standard_False
103 SetHLRAngle(me: mutable) ;
104 ---Purpose: Sets the angle of maximum chordal deviation for
105 -- removal of hidden lines created by different viewpoints
106 -- in different presentations. The default value is 20*PI/180.
109 SetDeviationCoefficient(me: mutable; aCoefficient: Real from Standard )
110 ---Purpose: Sets the hasOwnDeviationCoefficient flag to Standard_True,
111 -- sets myOwnDeviationCoefficient and myPreviousDeviationCoefficient
114 SetHLRDeviationCoefficient(me: mutable; aCoefficient: Real from Standard )
115 ---Purpose: Sets the hasOwnHLRDeviationCoefficient flag to Standard_True,
116 -- sets myOwnHLRDeviationCoefficient and myPreviousHLRDeviationCoefficient
119 SetDeviationAngle(me: mutable; anAngle: Real from Standard ) is redefined ;
120 ---Purpose: Sets the hasOwnDeviationAngle flag to Standard_True,
121 -- sets myOwnDeviationAngle and myPreviousDeviationAngle
123 SetHLRAngle(me: mutable; anAngle: Real from Standard )
124 ---Purpose: Sets the hasOwnHLRDeviationAngle flag to Standard_True,
125 -- sets myOwnHLRDeviationAngle and myPreviousHLRDeviationAngle
128 SetTypeOfHLR(me: mutable; theTypeOfHLR: TypeOfHLR from Prs3d)
130 ---Purpose: Sets the type of HLR algorithm
131 -- used by drawer's interactive objects
134 TypeOfHLR(me) returns TypeOfHLR from Prs3d
136 ---Purpose: Returns the type of HLR algorithm currently in use.
139 DeviationCoefficient(me) returns Real from Standard
140 ---Purpose: Drawings of curves or patches are made with respect
141 -- to a maximal chordal deviation. A Deviation coefficient
142 -- is used in the shading display mode. The shape is
143 -- seen decomposed into triangles. These are used to
144 -- calculate reflection of light from the surface of the
145 -- object. The triangles are formed from chords of the
146 -- curves in the shape. The deviation coefficient gives
147 -- the highest value of the angle with which a chord can
148 -- deviate from a tangent to a curve. If this limit is
149 -- reached, a new triangle is begun.
150 -- This deviation is absolute and is set through the
151 -- method: SetMaximalChordialDeviation. The default value is 0.001.
152 -- In drawing shapes, however, you are allowed to ask
153 -- for a relative deviation. This deviation will be:
154 -- SizeOfObject * DeviationCoefficient.
157 HLRDeviationCoefficient(me) returns Real from Standard
158 ---Purpose: Returns the real number value of the HLR deviation
159 -- coefficient in this framework, if the flag
160 -- hasOwnHLRDeviationCoefficient is true.
161 -- If hasOwnHLRDeviationCoefficient is false, the
162 -- shape's HLR deviation coefficient is used.
163 -- A Deviation coefficient is used in the shading display
164 -- mode. The shape is seen decomposed into triangles.
165 -- These are used to calculate reflection of light from the
166 -- surface of the object.
167 -- The triangles are formed from chords of the curves in
168 -- the shape. The deviation coefficient give the highest
169 -- value of the angle with which a chord can deviate
170 -- from a tangent to a curve. If this limit is reached, a
171 -- new triangle is begun.
172 -- To find the hidden lines, hidden line display mode
173 -- entails recalculation of the view at each different
174 -- projector perspective.
175 -- Since hidden lines entail calculations of more than
176 -- usual complexity to decompose them into these
177 -- triangles, a deviation coefficient allowing greater
178 -- tolerance is used. This increases efficiency in calculation.
179 -- The Default value is 0.02.
183 DeviationAngle(me) returns Real from Standard
184 ---Purpose: Returns myOwnDeviationAngle if hasOwnDeviationAngle is True
185 -- else gets myDeviationAngle field from Prs3d_Drawer
188 HLRAngle(me) returns Real from Standard
189 ---Purpose: Returns the real number value of the deviation angle
190 -- in hidden line removal views. The default value is 20*PI/180.
194 PreviousDeviationCoefficient(me) returns Real from Standard
195 ---Purpose: Saves the previous value used for the chordal
196 -- deviation coefficient. The default value is 0.1.
200 PreviousHLRDeviationCoefficient(me) returns Real from Standard
201 ---Purpose: returns myPreviousHLRDeviationCoefficient
205 PreviousDeviationAngle(me) returns Real from Standard
206 ---Purpose: returns myPreviousDeviationAngle
210 PreviousHLRDeviationAngle(me) returns Real from Standard
211 ---Purpose: returns myPreviousHLRDeviationAngle
215 IsOwnDeviationCoefficient(me) returns Boolean from Standard;
216 ---Purpose: Returns true if the there is a local setting for deviation
217 -- coefficient in this framework for a specific interactive object.
220 IsOwnHLRDeviationCoefficient(me) returns Boolean from Standard;
221 ---Purpose: Returns true if the there is a setting for HLR deviation
222 -- coefficient in this framework for a specific interactive object.
225 IsOwnDeviationAngle(me) returns Boolean from Standard;
226 ---Purpose: Returns true if the there is a local setting for deviation
227 -- angle in this framework for a specific interactive object.
230 IsOwnHLRDeviationAngle(me) returns Boolean from Standard;
231 ---Purpose: Returns true if the there is a setting for HLR deviation
232 -- angle in this framework for a specific interactive object.
235 Discretisation(me) returns Integer from Standard
237 ---Purpose: Draws algorithms using discretisation, a default
238 -- number of points has been set to 17. You can use the
239 -- method Prs3d_Drawer_SetDiscretisation to change this value.
241 MaximalParameterValue(me) returns Real from Standard
244 -- Sets the maximum value allowed for the first and last
245 -- parameters of an infinite curve. By default, this value is 500000.
247 IsoOnPlane(me) returns Boolean from Standard
248 ---Purpose: returns True if the drawing of isos on planes is enabled.
253 -- Attributes for the U Isoparametric lines of patches.
255 UIsoAspect (me:mutable) returns mutable IsoAspect from Prs3d
256 ---Purpose: Defines the attributes which are used when drawing an
257 -- U isoparametric curve of a face. Defines the number
258 -- of U isoparametric curves to be drawn for a single face.
259 -- The LineAspect for U isoparametric lines can be edited
260 -- (methods SetColor, SetTypeOfLine, SetWidth, SetNumber)
261 -- The default values are:
262 -- COLOR : Quantity_NOC_GRAY75
263 -- TYPE OF LINE: Aspect_TOL_SOLID
265 -- These attributes are used by the following algorithms:
266 -- Prs3d_WFDeflectionSurface
267 -- Prs3d_WFDeflectionRestrictedFace
273 -- Attributes for the V Isoparametric line of patches.
276 VIsoAspect (me:mutable) returns mutable IsoAspect from Prs3d
277 ---Purpose: Defines the attributes which are used when drawing an
278 -- V isoparametric curve of a face. Defines the number
279 -- of V isoparametric curves to be drawn for a single face.
280 -- The LineAspect for V isoparametric lines can be edited
281 -- (methods SetColor, SetTypeOfLine, SetWidth, SetNumber)
282 -- The default values are:
283 -- COLOR : Quantity_NOC_GRAY82
284 -- TYPE OF LINE: Aspect_TOL_SOLID
286 -- These attributes are used by the following algorithms:
287 -- Prs3d_WFDeflectionSurface
288 -- Prs3d_WFDeflectionRestrictedFace
292 -- Attributes for the free boundaries
294 FreeBoundaryAspect (me:mutable) returns mutable LineAspect from Prs3d
295 ---Purpose: Returns a link with
296 -- Prs3d_Drawer_FreeBoundaryAspect. Stores the
297 -- values for presentation of free boundaries, in other
298 -- words, boundaries which are not shared . The
299 -- LineAspect for the free boundaries can be edited. The
300 -- default values are: Color: Quantity_NOC_GREEN
301 -- Type of line: Aspect_TOL_SOLID Width: 1.
302 -- These attributes are used by Prs3d_WFShape.
306 FreeBoundaryDraw(me) returns Boolean from Standard
307 ---Purpose: returns True if the drawing of the free boundaries is enabled.
311 -- Attributes for the wires
313 WireAspect (me:mutable) returns mutable LineAspect from Prs3d
314 ---Purpose: Returns a link with Prs3d_Drawer_WireAspect.
315 -- This method provides wire aspect settings.
316 -- The LineAspect for wires can be edited. The default values are:
317 -- Color: Quantity_NOC_RED
318 -- Type of line: Aspect_TOL_SOLID
320 -- These attributes are used by the following algorithms:
324 HasLineAspect (me) returns Boolean from Standard
325 ---Purpose: Returns true if the Interactive Object has a line
326 -- visualization aspect.
330 HasWireAspect (me) returns Boolean from Standard
331 ---Purpose: Returns true if the Drawer has a wire aspect setting active.
335 WireDraw(me) returns Boolean from Standard
336 ---Purpose: Returns a link with Prs3d_Drawer_WireDraw. This
337 -- method returns true if drawing of wires is enabled.
338 -- The default setting is true.
342 -- Attributes for the unfree boundaries
344 UnFreeBoundaryAspect (me:mutable) returns mutable LineAspect from Prs3d
345 ---Purpose: Returns a link with
346 -- Prs3d_Drawer_UnFreeBoundaryAspect, which
347 -- provides settings for shared boundary line aspects.
348 -- The LineAspect for shared boundaries can be edited.
349 -- The default values are:
350 -- Color: Quantity_NOC_YELLOW
351 -- Type of line: Aspect_TOL_SOLID
353 -- These attributes are used by the following algorithms:
358 UnFreeBoundaryDraw(me) returns Boolean from Standard
359 ---Purpose: Returns True if the drawing of the shared boundaries
360 -- is enabled. True is the default setting.
365 -- Attributes for the lines.
368 LineAspect(me:mutable) returns mutable LineAspect from Prs3d
369 ---Purpose: Returns a link with Prs3d_Drawer_LineAspect,
370 -- which provides settings for line aspects. These
371 -- settings can be edited. The default values are:
372 -- Color: Quantity_NOC_YELLOW
373 -- Type of line: Aspect_TOL_SOLID
375 -- These attributes are used by the following algorithms:
384 HasTextAspect(me) returns Boolean from Standard
387 TextAspect(me:mutable) returns mutable TextAspect from Prs3d
389 -- Color: Quantity_NOC_YELLOW
392 LineArrowDraw(me) returns Boolean from Standard
393 ---Purpose: Returns True if the drawing of an arrow at the end of
394 -- each line is enabled. The default setting is False.
397 ArrowAspect(me:mutable) returns mutable ArrowAspect from Prs3d
402 -- Attributes for the points
404 PointAspect(me:mutable) returns mutable PointAspect from Prs3d
405 ---Purpose: Returns the point aspect setting. The default values
406 -- are: Color: Quantity_NOC_YELLOW
407 -- Type of marker: Aspect_TOM_PLUS
409 -- These attributes are used by the following algorithms:
413 HasPointAspect (me) returns Boolean from Standard
414 ---Purpose: Returns true if the Drawer has a point aspect setting active.
419 -- Attributes for the faces:
421 ShadingAspect (me:mutable) returns mutable ShadingAspect from Prs3d
423 -- Returns a link with Prs3d_Drawer_ShadingAspect,
424 -- which provides settings for shading aspects.
425 -- These settings can be edited. The default values are:
426 -- Color: Quantity_NOC_YELLOW
427 -- Material: Graphic3d_NOM_BRASS
428 -- hading aspect is obtained through decomposition of
429 -- 3D faces into triangles, each side of each triangle
430 -- being a chord of the corresponding curved edge in
431 -- the face. Reflection of light in each projector
432 -- perspective is then calculated for each of the
433 -- resultant triangular planes.
436 HasShadingAspect (me) returns Boolean from Standard
438 ---Purpose: Returns True if the Drawer has shading aspect active.
441 ShadingAspectGlobal(me) returns Boolean from Standard
443 ---Purpose: Provides the attributes for hidden line removal.
446 DrawHiddenLine(me) returns Boolean from Standard
447 ---Purpose: Returns Standard_True if the hidden lines are to be drawn.
448 -- By default the hidden lines are not drawn.
451 HiddenLineAspect(me:mutable) returns mutable LineAspect from Prs3d
452 ---Purpose: Returns a link with
453 -- Prs3d_Drawer_HiddenLineAspect, which provides
454 -- settings for hidden line aspects.
455 -- These settings can be edited. The default values are:
456 -- Color: Quantity_NOC_YELLOW
457 -- Type of line: Aspect_TOL_DASH
462 SeenLineAspect(me:mutable) returns mutable LineAspect from Prs3d
463 ---Purpose: Returns a link with
464 -- Prs3d_Drawer_SeenLineAspect, which provides
465 -- settings for seen line aspects.
466 -- These settings can be edited. The default values are:
467 -- Color: Quantity_NOC_YELLOW
468 -- Type of line: Aspect_TOL_SOLID
473 HasPlaneAspect(me) returns Boolean from Standard;
476 PlaneAspect(me:mutable) returns mutable PlaneAspect from Prs3d
479 -- Returns a link with Prs3d_Drawer_PlaneAspect.
480 -- This method provides settings for the appearance of planes.
483 VectorAspect(me:mutable) returns mutable LineAspect from Prs3d
484 ---Purpose: Returns a link with Prs3d_Drawer_VectorAspect,
485 -- which provides settings for the appearance of vectors.
486 -- These settings can be edited. The default values are:
487 -- Color: Quantity_NOC_SKYBLUE
488 -- Type of line: Aspect_TOL_SOLID Width: 1.
491 SetFaceBoundaryDraw (me : mutable;
492 theIsEnabled : Boolean from Standard)
494 ---Purpose: Enables or disables drawing of face boundaries for shading presentations.
495 -- The method sets drawing flag owned by the drawer that will be used during
496 -- visualization instead of the one set in link.
497 -- theIsEnabled is a boolean flag indicating whether the face boundaries should be
500 IsFaceBoundaryDraw (me) returns Boolean from Standard
502 ---Purpose: Checks whether the drawing of face boundaries is enabled or not.
504 SetFaceBoundaryAspect (me : mutable;
505 theAspect : LineAspect from Prs3d)
507 ---Purpose: Sets line aspect for face boundaries.
508 -- The method sets line aspect owned by the drawer that will be used during
509 -- visualization instead of the one set in link.
510 -- theAspect is the line aspect that determines the look of the face boundaries.
512 FaceBoundaryAspect (me : mutable) returns mutable LineAspect from Prs3d
514 ---Purpose: Returns line aspect of face boundaries.
516 IsOwnFaceBoundaryDraw (me) returns Boolean from Standard
518 ---Purpose: Returns true if the drawer has its own attribute for
519 -- "draw face boundaries" flag that overrides the one in the link.
522 IsOwnFaceBoundaryAspect (me) returns Boolean from Standard
524 ---Purpose: Returns true if the drawer has its own attribute for
525 -- face boundaries aspect that overrides the one in the link.
528 -- Attributes for the presentation of a Datum.
531 HasDatumAspect(me) returns Boolean from Standard;
534 DatumAspect(me:mutable) returns mutable DatumAspect from Prs3d
535 ---Purpose: Returns a link with Prs3d_Drawer_DatumAspect,
536 -- which provides settings for the appearance of datums.
537 -- These settings can be edited. The default values for
538 -- the three axes are:
539 -- Color: Quantity_NOC_PEACHPUFF
540 -- Type of line: Aspect_TOL_SOLID Width: 1.
544 -- Attributes for the presentation of a Length.
547 LengthAspect(me:mutable) returns mutable LengthAspect from Prs3d
548 ---Purpose: Returns a link with Prs3d_Drawer_LengthAspect,
549 -- which provides settings for the appearance of lengths.
552 HasLengthAspect (me) returns Boolean from Standard
554 ---Purpose: Returns true if the Drawer has a length aspect setting active.
558 -- Attributes for the presentation of a Angle.
561 AngleAspect(me:mutable) returns mutable AngleAspect from Prs3d
562 ---Purpose: Returns a link with Prs3d_Drawer_AngleAspect,
563 -- which provides settings for lines used to display angles.
566 HasAngleAspect (me) returns Boolean from Standard
568 ---Purpose: Returns true if the Drawer has an angle aspect
573 -- Attributes for the presentation of a Radius.
576 RadiusAspect(me) returns mutable RadiusAspect from Prs3d
577 ---Purpose: Returns a link with Prs3d_Drawer_RadiusAspect,
578 -- which provides settings for lines which serve to display radii.
581 -- Attributes for the sections
583 SectionAspect (me:mutable) returns mutable LineAspect from Prs3d
584 ---Purpose: Returns a link with Prs3d_Drawer_SectionAspect,
585 -- which provides settings for wires which highlight sections.
586 -- The LineAspect for the wire can be edited.
587 -- The default values are:
588 -- Color: Quantity_NOC_ORANGE
589 -- Type of line: Aspect_TOL_SOLID
591 -- These attributes are used by the following algorithms:
595 Link(me:mutable) returns any Drawer from Prs3d
597 ---C++: return const&
599 HasLink(me) returns Boolean from Standard
603 Link (me:mutable; aDrawer: Drawer from Prs3d)
608 ClearLocalAttributes(me:mutable) is virtual;
609 ---Purpose: Removes attributes stored in a Local Context.
611 WasLastLocal(me) returns Boolean from Standard;
613 ---Purpose: Returns true if the last called attribute was local; false if it was global.
615 HasLocalAttributes(me) returns Boolean from Standard;
618 -- Returns true if a Local Context has stored attributes
619 -- for Interactive Objects.
622 myLink : Drawer from Prs3d;
623 hasLocalAttributes : Boolean from Standard;
625 myhasOwnDeviationCoefficient : Boolean from Standard;
626 myOwnDeviationCoefficient : Real from Standard;
627 myPreviousDeviationCoefficient : Real from Standard;
629 myhasOwnHLRDeviationCoefficient : Boolean from Standard;
630 myOwnHLRDeviationCoefficient : Real from Standard;
631 myPreviousHLRDeviationCoefficient: Real from Standard;
633 myhasOwnDeviationAngle : Boolean from Standard;
634 myOwnDeviationAngle : Real from Standard;
635 myPreviousDeviationAngle : Real from Standard;
637 myhasOwnHLRDeviationAngle : Boolean from Standard;
638 myOwnHLRDeviationAngle : Real from Standard;
639 myPreviousHLRDeviationAngle : Real from Standard;
640 myHasOwnFaceBoundaryDraw : Boolean from Standard;