1 -- Created on: 1996-12-11
2 -- Created by: Robert COUBLANC
3 -- Copyright (c) 1996-1999 Matra Datavision
4 -- Copyright (c) 1999-2014 OPEN CASCADE SAS
6 -- This file is part of Open CASCADE Technology software library.
8 -- This library is free software; you can redistribute it and/or modify it under
9 -- the terms of the GNU Lesser General Public License version 2.1 as published
10 -- by the Free Software Foundation, with special exception defined in the file
11 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 -- distribution for complete text of the license and disclaimer of any warranty.
14 -- Alternatively, this file may be used under the terms of Open CASCADE
15 -- commercial license or contractual agreement.
17 deferred class InteractiveObject from AIS inherits SelectableObject from SelectMgr
20 -- Defines a class of objects with display and selection services.
21 -- Entities which are visualized and selected are
22 -- Interactive Objects. You can make use of classes of
23 -- standard Interactive Objects for which all necessary
24 -- methods have already been programmed, or you can
25 -- implement your own classes of Interactive Objects.
26 -- Specific attributes of entities such as arrow aspect for
27 -- dimensions must be loaded in a Drawer. This Drawer
28 -- is then applied to the Interactive Object in view.
29 -- There are four types of Interactive Object in AIS: the
30 -- construction element or Datum, the Relation, which
31 -- includes both dimensions and constraints, the Object,
32 -- and finally, when the object is of an unknown type, the None type.
33 -- Inside these categories, a signature, or index,
34 -- provides the possibility of additional characterization.
35 -- By default, the Interactive Object has a None type
36 -- and a signature of 0. If you want to give a particular
37 -- type and signature to your interactive object, you must
38 -- redefine the methods, Signature and Type.
40 -- In the case of attribute methods, methods for
41 -- standard attributes are virtual. They must be
42 -- redefined by the inheriting classes. Setcolor for a
43 -- point and Setcolor for a plane, for example, do not
44 -- affect the same attributes in the Drawer.
48 NameOfColor from Quantity,
51 ListOfTransient from TColStd,
52 ListOfInteger from TColStd,
54 NameOfMaterial from Graphic3d,
55 MaterialAspect from Graphic3d,
58 TypeOfPresentation3d from PrsMgr,
59 InteractiveContext from AIS,
60 KindOfInteractive from AIS,
61 TypeOfFacingModel from Aspect,
62 Transformation from Geom,
63 Presentation from Prs3d,
64 BasicAspect from Prs3d,
65 -- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
66 PresentationManager from PrsMgr,
67 Presentation from PrsMgr
68 -- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
71 Initialize (aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView) ;
72 ---Purpose: The TypeOfPresention3d means that the interactive object
73 -- may have a presentation dependant of the view of Display
77 ---Category: Virtual methods to be redefined...
79 Type (me) returns KindOfInteractive from AIS is virtual;
81 -- Returns the kind of Interactive Object:
86 -- By default, the interactive object has a None type.
87 -- Because specific shapes entail different behavior
88 -- according to their sub-shapes, you may need to
89 -- create a Local Context. This will allow you to
90 -- specify the additional characteristics which you
91 -- need to handle these shapes.
93 Signature(me) returns Integer from Standard is virtual;
94 ---Purpose: Specifies additional characteristics of Interactive
95 -- Objects. A signature is, in fact, an index with integer
96 -- values assigned different properties.
97 -- This method is frequently used in conjuction with
98 -- Type to give a particular type and signature to an
99 -- Interactive Object. By default, the Interactive Object
100 -- has a None type and a signature of 0. Among the
101 -- datums, this signature is attributed to the shape
102 -- The remaining datums have the following default signatures:
103 -- - Point signature 1
104 -- - Axis signature 2
105 -- - Trihedron signature 3
106 -- - PlaneTrihedron signature 4
107 -- - Line signature 5
108 -- - Circle signature 6
109 -- - Plane signature 7.
112 AcceptShapeDecomposition(me) returns Boolean from Standard is virtual;
114 ---Purpose: Informs the graphic context that the interactive Object
115 -- may be decomposed into sub-shapes for dynamic selection.
116 -- The most used Interactive Object is AIS_Shape.
117 -- Activation methods for standard selection modes are
118 -- proposed in the Interactive Context. These include
119 -- selection by vertex or by edges. For datums with the
120 -- same behavior as AIS_Shape, such as vetices and
121 -- edges, we must redefine the virtual method so that
122 -- AcceptShapeDecomposition returns false.
123 -- Rule for selection :
124 -- Mode 0 : Selection of the interactive Object itself
125 -- Mode 1 : Selection of vertices
126 -- Mode 2 : Selection Of Edges
127 -- Mode 3 : Selection Of Wires
128 -- Mode 4 : Selection Of Faces ...
131 SetCurrentFacingModel(me: mutable;
132 aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_BOTH_SIDE);
133 ---Purpose: change the current facing model apply on polygons for
134 -- SetColor(), SetTransparency(), SetMaterial() methods
135 -- default facing model is Aspect_TOFM_TWO_SIDE. This mean that attributes is
136 -- applying both on the front and back face.
138 CurrentFacingModel(me) returns TypeOfFacingModel from Aspect;
139 ---Purpose: Returns the current facing model which is in effect.
141 SetColor(me:mutable;aColor:Color from Quantity) is virtual;
143 SetColor(me:mutable;aColor:NameOfColor from Quantity) is virtual;
144 ---Purpose: only the interactive obj knowns which Drawer attribute
145 -- is affected by the color (ex: for a wire, it's the
146 -- wireaspect field of the drawer, but for a vertex, only
147 -- the point aspect field is affected by the color)
148 -- WARNING : Do not forget to set the corresponding fields
149 -- here (hasOwnColor and myOwnColor)
151 UnsetColor(me:mutable) is virtual;
152 ---Purpose: Removes color settings. Only the Interactive Object
153 -- knows which Drawer attribute is affected by the color
154 -- setting. For a wire, for example, wire aspect is the
155 -- attribute affected. For a vertex, however, only point
156 -- aspect is affected by the color setting.
158 SetWidth(me:mutable; aValue:Real from Standard) is virtual;
159 ---Purpose: Allows you to provide the setting aValue for width.
160 -- Only the Interactive Object knows which Drawer
161 -- attribute is affected by the width setting.
163 UnsetWidth(me:mutable) is virtual;
165 AcceptDisplayMode(me;aMode:Integer from Standard) returns Boolean from Standard is virtual;
166 ---Purpose: Returns true if the class of objects accepts the display mode aMode.
167 -- The interactive context can have a default mode of
168 -- representation for the set of Interactive Objects. This
169 -- mode may not be accepted by a given class of
170 -- objects. Consequently, this virtual method allowing us
171 -- to get information about the class in question must be implemented.
172 DefaultDisplayMode(me) returns Integer from Standard is virtual;
173 ---Purpose: Returns the default display mode. This method is to
174 -- be implemented when the main mode is not mode 0.
177 Redisplay (me:mutable; AllModes:Boolean from Standard =Standard_False);
178 ---Purpose: Updates the active presentation; if <AllModes> = Standard_True
179 -- all the presentations inside are recomputed.
182 SetInfiniteState(me:mutable;aFlag:Boolean from Standard = Standard_True);
183 ---Purpose: Sets the infinite state flag aFlage.
184 -- if <aFlag> = True , the interactiveObject is
185 -- considered as infinite, i.e. its graphic presentations
186 -- are not taken in account for View FitAll...
188 IsInfinite(me) returns Boolean from Standard;
191 -- Returns true if the interactive object is infinite. In this
192 -- case, its graphic presentations are not taken into
193 -- account in the fit-all view.
196 ---Category: Link To InteractiveContext
198 HasInteractiveContext(me) returns Boolean from Standard;
199 ---Purpose: Indicates whether the Interactive Object has a pointer
200 -- to an interactive context.
202 GetContext(me) returns InteractiveContext from AIS;
203 ---Purpose: Returns the context pointer to the interactive context.
205 SetContext(me:mutable; aCtx : InteractiveContext from AIS) is virtual;
206 ---Purpose: Sets the interactive context aCtx and provides a link
207 -- to the default drawing tool or "Drawer" if there is none.
209 HasOwner (me) returns Boolean from Standard;
210 ---Purpose: Returns true if the object has an owner attributed to it.
211 -- The owner can be a shape for a set of sub-shapes or
212 -- a sub-shape for sub-shapes which it is composed of,
213 -- and takes the form of a transient.
215 GetOwner (me) returns any Transient from Standard;
216 ---Purpose: Returns the owner of the Interactive Object.
217 -- The owner can be a shape for a set of sub-shapes or
218 -- a sub-shape for sub-shapes which it is composed of,
219 -- and takes the form of a transient.
220 -- There are two types of owners:
221 -- - Direct owners, decomposition shapes such as
222 -- edges, wires, and faces.
223 -- - Users, presentable objects connecting to sensitive
224 -- primitives, or a shape which has been decomposed.
226 ---C++: return const&
230 SetOwner (me : mutable;
231 ApplicativeEntity : Transient from Standard);
232 ---Purpose: Allows you to attribute the owner ApplicativeEntity to
233 -- an Interactive Object. This can be a shape for a set of
234 -- sub-shapes or a sub-shape for sub-shapes which it
235 -- is composed of. The owner takes the form of a transient.
238 ClearOwner(me:mutable);
239 ---Purpose: Each Interactive Object has methods which allow us
240 -- to attribute an Owner to it in the form of a Transient.
241 -- This method removes the owner from the graphic entity.
244 HasUsers(me) returns Boolean from Standard;
246 Users(me) returns ListOfTransient from TColStd;
248 ---C++: return const&
251 AddUser(me:mutable; aUser : Transient from Standard);
253 ClearUsers(me:mutable);
257 ---Category: "STANDARD" LOCAL ATTRIBUTES :
259 -- -Local DisplayMode
261 -- -width of lines or points
262 -- -typeOfLine or Marker Aspect
263 -- -material name (if needed)
264 -- -transparency (if needed)
266 -- Specific attributes of entities (such as
267 -- arrow aspect for dimensions) must be
268 -- loaded in a Drawer; this drawer is then
269 -- applied to InteractiveObject WARNING :
270 -- Here the Methods for standard attributes
271 -- are virtual and do nothing they must be
272 -- redefined by the inheriting classes
273 -- (setcolor for a point and setcolor for a plane
274 -- don't affect the same attributes in the Drawer)
278 returns Boolean from Standard;
280 -- Returns true if the Interactive Object has a display
281 -- mode setting. Otherwise, it is displayed in Neutral Point.
284 SetDisplayMode(me : mutable; aMode : Integer from Standard);
285 ---Purpose: Sets the display mode aMode for the interactive object.
286 -- An object can have its own temporary display mode,
287 -- which is different from that proposed by the interactive context.
288 -- The range of possibilities currently proposed is the following:
291 -- This range can, however, be extended through the creation of new display modes.
293 UnsetDisplayMode(me : mutable);
294 ---Purpose: Removes display mode settings from the interactive object.
300 ---Purpose: Returns the display mode setting of the Interactive Object.
301 -- The range of possibilities is the following:
304 -- This range can, however, be extended through the
305 -- creation of new display modes.
308 HasSelectionMode(me) returns Boolean from Standard;
309 ---Purpose: Allows you to change the selection mode of an
310 -- Interactive Object.
311 -- The default selection mode setting is 0.
312 -- For shapes, for example, the selection modes are as follows:
313 -- - mode 0 - selection of the shape itself
314 -- - mode 1 - selection of vertices
315 -- - mode 2 - selection of edges
316 -- - mode 3 - selection of wires
317 -- - mode 4 - selection of faces
318 -- - mode 5 - selection of shells
319 -- - mode 6 - selection of solids
320 -- - mode 7 - selection of compounds
321 -- For trihedra, on the other hand, the selection modes are the following four:
322 -- - mode 0 - selection of a trihedron
323 -- - mode 1 - selection of its origin
324 -- - mode 2 - selection of its axes
325 -- - mode 3 - selection of its planes
327 SelectionMode(me) returns Integer from Standard;
328 ---Purpose: Returns the selection mode of the interactive object.
330 SetSelectionMode(me:mutable; aMode: Integer from Standard);
331 ---Purpose: You can change the default selection mode index
332 -- aMode of an Interactive Object.
333 -- This is only of interest if you decide that mode 0
334 -- adopted by convention will not do.
336 UnsetSelectionMode(me:mutable);
337 ---Purpose: You can change the default selection mode index of
338 -- an Interactive Object.
339 -- This is only of interest if you decide that the 0 mode
340 -- adopted by convention will not do.
344 SelectionPriority(me) returns Integer from Standard;
346 ---Purpose: Returns the selection priority setting. -1 indicates that there is none.
347 -- You can modify the selection priority of an owner to
348 -- make one entity more selectionable than another one.
349 -- The default selection priority for an owner is 5, for
350 -- example. To increase selection priority, choose a
351 -- setting between 5 and 10. An entity with priority 7 will
352 -- take priority over one with a setting of 6 if both
353 -- objects are selected at the same time.
354 -- You could give vertices priority 8, edges priority 7,
355 -- faces priority 6, and shapes priority 5. If a vertex, an
356 -- edge and a face are simultaneously detected during
357 -- selection, only the vertex will then be highlighted.
358 -- For trihedra, for example, the default priorities are the following four:
359 -- - priority 1 - a trihedron
360 -- - priority 5 - its origin
361 -- - priority 3 - its axes
362 -- - priority 2 - its planes
364 SetSelectionPriority(me:mutable; aPriority : Integer from Standard);
366 ---Purpose: Allows you to provide a setting aPriority for selection priority.
367 -- You can modify selection priority of an owner to make
368 -- one entity more selectionable than another one. The
369 -- default selection priority for an owner is 5, for
370 -- example. To increase selection priority, choose a
371 -- setting between 5 and 10. An entity with priority 7 will
372 -- take priority over one with a setting of 6.
374 UnsetSelectionPriority(me:mutable);
376 ---Purpose: Removes the setting for selection priority. SelectionPriority then returns -1.
378 HasSelectionPriority(me) returns Boolean from Standard;
380 ---Purpose: Returns true if there is a setting for selection priority.
381 -- You can modify selection priority of an owner to make
382 -- one entity more selectionable than another one. The
383 -- default selection priority for an owner is 5, for
384 -- example. To increase selection priority, choose a
385 -- setting between 5 and 10. An entity with priority 7 will
386 -- take priority over one with a setting of 6.
388 HasHilightMode(me) returns Boolean from Standard;
390 ---Purpose: Returns true if the Interactive Object is in highlight mode.
392 HilightMode(me) returns Integer from Standard ;
394 ---Purpose: Returns the setting for highlight mode.
395 -- At dynamic detection, the presentation echoed by the
396 -- Interactive Context, is by default the presentation
397 -- already on the screen. You can specify a Highlight
398 -- presentation mode which is valid no matter what the
399 -- active representation of the object. It makes no
400 -- difference whether this choice is temporary or
401 -- definitive. To do this, we use the following functions:
403 -- - UnSetHilightMode
404 -- In the case of a shape, whether it is visualized in
405 -- wireframe presentation or with shading, we want to
406 -- systematically highlight the wireframe presentation.
407 -- Consequently, we set the highlight mode to 0.
409 SetHilightMode(me:mutable;anIndex : Integer from Standard);
411 ---Purpose: Sets the highlight mode anIndex for the interactive object.
412 -- If, for example, you want to systematically highlight
413 -- the wireframe presentation of a shape - whether
414 -- visualized in wireframe presentation or with shading -
415 -- you set the highlight mode to 0.
417 UnsetHilightMode(me:mutable);
419 ---Purpose: Allows the user to take a given Prs for hilight
420 -- ex : for a shape which would be displayed in shading mode
421 -- the hilight Prs is the wireframe mode.
422 -- if No specific hilight mode is defined, the displayed Prs
423 -- will be the hilighted one.
425 HasColor (me) returns Boolean from Standard;
427 ---Purpose: Returns true if the Interactive Object has color.
429 Color(me) returns NameOfColor from Quantity is virtual;
431 ---Purpose: Returns the color setting of the Interactive Object.
433 Color(me; aColor: out Color from Quantity) is virtual;
436 HasWidth(me) returns Boolean from Standard;
438 ---Purpose: Returns true if the Interactive Object has width.
440 Width(me) returns Real from Standard ;
441 --- Purpose: Returns the width setting of the Interactive Object.
443 HasMaterial(me) returns Boolean from Standard ;
444 ---Purpose: Returns true if the Interactive Object has a setting for material.
445 Material(me) returns NameOfMaterial from Graphic3d is virtual;
446 ---Purpose: Returns the current material setting.
447 -- This will be on of the following materials:
455 SetMaterial(me:mutable;aName:NameOfMaterial from Graphic3d) is virtual;
456 ---Purpose: Sets the name aName for material defining this
457 -- display attribute for the interactive object.
458 -- Material aspect determines shading aspect, color and
459 -- transparency of visible entities.
462 SetMaterial(me:mutable;aName:MaterialAspect from Graphic3d) is virtual;
463 --- Purpose: Sets the material aMat defining this display attribute
464 -- for the interactive object.
465 -- Material aspect determines shading aspect, color and
466 -- transparency of visible entities.
468 UnsetMaterial(me:mutable) is virtual;
469 ---Purpose: Removes the setting for material.
471 SetTransparency(me:mutable;aValue : Real from Standard=0.6) is virtual;
472 ---Purpose: Attributes a setting aValue for transparency.
473 -- The transparency value should be between 0.0 and 1.0.
474 -- At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
475 -- Warning At a value of 1.0, there may be nothing visible.
477 IsTransparent(me) returns Boolean from Standard;
479 ---Purpose: Returns true if there is a transparency setting.
481 Transparency(me) returns Real from Standard is virtual;
482 ---Purpose: Returns the transparency setting.
483 -- This will be between 0.0 and 1.0.
484 -- At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
486 UnsetTransparency(me:mutable) is virtual;
487 ---Purpose: Removes the transparency setting. The object is opaque by default.
489 SetAttributes(me:mutable; aDrawer: Drawer from AIS) is virtual;
490 ---Purpose: Initializes the drawing tool aDrawer.
492 Attributes(me) returns any Drawer from AIS;
493 ---C++: return const&
495 ---Purpose: Returns the attributes settings.
497 UnsetAttributes(me:mutable) is virtual;
498 ---Purpose: Clears settings provided by the drawing tool aDrawer.
500 ---Category: information about Prs to be recomputed
501 -- after local attributes change... to be removed...
503 RecomputeEveryPrs(me) returns Boolean is virtual private;
505 MustRecomputePrs(me;aMode : Integer from Standard) is private;
507 ListOfRecomputeModes(me)returns ListOfInteger from TColStd is private;
508 ---C++: return const&
509 SetRecomputeOk(me:mutable) is private;
511 State(me:mutable;theState: Integer from Standard) ;
513 State(me) returns Integer from Standard ;
516 HasPresentation ( me ) returns Boolean from Standard
519 ---Purpose: Returns TRUE when this object has a presentation
520 -- in the current DisplayMode()
521 ---Category: Inquire transformation method
523 Presentation ( me ) returns Presentation from Prs3d
526 ---Purpose: Returns the current presentation of this object
527 -- according to the current DisplayMode()
528 ---Category: Inquire transformation method
530 SetAspect ( me : mutable; anAspect: any BasicAspect from Prs3d;
531 globalChange: Boolean from Standard = Standard_True)
534 ---Purpose: Sets the graphic basic aspect to the current presentation.
535 -- When <globalChange> is TRUE , the full object presentation
537 -- When <globalChange> is FALSE , only the current group
538 -- of the object presentation is changed.
539 ---Category: Graphic attributes management
541 -- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
542 SetPolygonOffsets ( me : mutable;
543 aMode : Integer from Standard;
544 aFactor : ShortReal from Standard = 1.0;
545 aUnits : ShortReal from Standard = 0.0 ) is virtual;
547 ---Purpose: Sets up polygon offsets for this object.
548 -- It modifies all existing presentations of <anObj> (if any),
549 -- so it is reasonable to call this method after <anObj> has been displayed.
550 -- Otherwise, Compute() method should pass Graphic3d_AspectFillArea3d
551 -- aspect from <myDrawer> to Graphic3d_Group to make polygon offsets work.
553 -- <aMode> parameter can contain various combinations of
554 -- Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means
555 -- that polygon offsets are not changed).
556 -- If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits>
557 -- arguments are used by graphic renderer to calculate a depth offset value:
559 -- offset = <aFactor> * m + <aUnits> * r, where
560 -- m - maximum depth slope for the polygon currently being displayed,
561 -- r - minimum window coordinates depth resolution (implementation-specific).
563 -- Deafult settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0.
565 -- Negative offset values move polygons closer to the viewport,
566 -- while positive values shift polygons away.
567 -- Consult OpenGL reference for details (glPolygonOffset function description).
569 -- NOTE: This method has a side effect - it creates own shading aspect
570 -- if not yet created, so it is better to set up object material,
571 -- color, etc. first.
572 ---Category: Graphic attributes management
574 HasPolygonOffsets ( me )
575 returns Boolean from Standard
578 ---Purpose: Returns Standard_True if <myDrawer> has non-null shading aspect
579 ---Category: Inquire methods
582 aMode : out Integer from Standard;
583 aFactor : out ShortReal from Standard;
584 aUnits : out ShortReal from Standard ) is virtual;
586 ---Purpose: Retrieves current polygon offsets settings from <myDrawer>.
587 ---Category: Inquire methods
591 myCTXPtr : PToContext from AIS;
593 -- The reference to applicative World...
595 myOwner : Transient from Standard;
596 myUsers : ListOfTransient from TColStd;
598 -- The Information Fields
600 myDrawer : Drawer from AIS is protected ;
601 myTransparency : Real from Standard is protected;
602 myOwnColor : Color from Quantity is protected;
603 myOwnMaterial : NameOfMaterial from Graphic3d is protected;
604 ---myOwnMaterial : NameOfPhysicalMaterial from Graphic3d is protected;
605 mySelPriority : Integer from Standard;
606 myDisplayMode : Integer from Standard ;
607 mySelectionMode : Integer from Standard;
608 myHilightMode : Integer from Standard is protected;
609 myOwnWidth : Real from Standard is protected;
610 myInfiniteState : Boolean from Standard is protected;
611 hasOwnColor : Boolean from Standard is protected;
612 hasOwnMaterial : Boolean from Standard is protected ;
613 myCurrentFacingModel: TypeOfFacingModel from Aspect is protected;
615 -- the management field (to be removed)...
616 myRecomputeEveryPrs : Boolean from Standard is protected;
618 myToRecomputeModes : ListOfInteger from TColStd is protected;
619 mystate : Integer from Standard;
623 class InteractiveContext from AIS
625 end InteractiveObject;