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,
57 TypeOfPresentation3d from PrsMgr,
58 InteractiveContext from AIS,
59 KindOfInteractive from AIS,
60 TypeOfFacingModel from Aspect,
61 Transformation from Geom,
62 Presentation from Prs3d,
63 BasicAspect from Prs3d,
64 -- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
65 PresentationManager from PrsMgr,
66 Presentation from PrsMgr
67 -- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
70 Initialize (aTypeOfPresentation3d: TypeOfPresentation3d from PrsMgr = PrsMgr_TOP_AllView) ;
71 ---Purpose: The TypeOfPresention3d means that the interactive object
72 -- may have a presentation dependant of the view of Display
76 ---Category: Virtual methods to be redefined...
78 Type (me) returns KindOfInteractive from AIS is virtual;
80 -- Returns the kind of Interactive Object:
85 -- By default, the interactive object has a None type.
86 -- Because specific shapes entail different behavior
87 -- according to their sub-shapes, you may need to
88 -- create a Local Context. This will allow you to
89 -- specify the additional characteristics which you
90 -- need to handle these shapes.
92 Signature(me) returns Integer from Standard is virtual;
93 ---Purpose: Specifies additional characteristics of Interactive
94 -- Objects. A signature is, in fact, an index with integer
95 -- values assigned different properties.
96 -- This method is frequently used in conjuction with
97 -- Type to give a particular type and signature to an
98 -- Interactive Object. By default, the Interactive Object
99 -- has a None type and a signature of 0. Among the
100 -- datums, this signature is attributed to the shape
101 -- The remaining datums have the following default signatures:
102 -- - Point signature 1
103 -- - Axis signature 2
104 -- - Trihedron signature 3
105 -- - PlaneTrihedron signature 4
106 -- - Line signature 5
107 -- - Circle signature 6
108 -- - Plane signature 7.
111 AcceptShapeDecomposition(me) returns Boolean from Standard is virtual;
113 ---Purpose: Informs the graphic context that the interactive Object
114 -- may be decomposed into sub-shapes for dynamic selection.
115 -- The most used Interactive Object is AIS_Shape.
116 -- Activation methods for standard selection modes are
117 -- proposed in the Interactive Context. These include
118 -- selection by vertex or by edges. For datums with the
119 -- same behavior as AIS_Shape, such as vetices and
120 -- edges, we must redefine the virtual method so that
121 -- AcceptShapeDecomposition returns false.
122 -- Rule for selection :
123 -- Mode 0 : Selection of the interactive Object itself
124 -- Mode 1 : Selection of vertices
125 -- Mode 2 : Selection Of Edges
126 -- Mode 3 : Selection Of Wires
127 -- Mode 4 : Selection Of Faces ...
130 SetCurrentFacingModel(me: mutable;
131 aModel: TypeOfFacingModel from Aspect = Aspect_TOFM_BOTH_SIDE);
132 ---Purpose: change the current facing model apply on polygons for
133 -- SetColor(), SetTransparency(), SetMaterial() methods
134 -- default facing model is Aspect_TOFM_TWO_SIDE. This mean that attributes is
135 -- applying both on the front and back face.
137 CurrentFacingModel(me) returns TypeOfFacingModel from Aspect;
138 ---Purpose: Returns the current facing model which is in effect.
140 SetColor(me:mutable;aColor:Color from Quantity) is virtual;
142 SetColor(me:mutable;aColor:NameOfColor from Quantity) is virtual;
143 ---Purpose: only the interactive obj knowns which Drawer attribute
144 -- is affected by the color (ex: for a wire, it's the
145 -- wireaspect field of the drawer, but for a vertex, only
146 -- the point aspect field is affected by the color)
147 -- WARNING : Do not forget to set the corresponding fields
148 -- here (hasOwnColor and myOwnColor)
150 UnsetColor(me:mutable) is virtual;
151 ---Purpose: Removes color settings. Only the Interactive Object
152 -- knows which Drawer attribute is affected by the color
153 -- setting. For a wire, for example, wire aspect is the
154 -- attribute affected. For a vertex, however, only point
155 -- aspect is affected by the color setting.
157 SetWidth(me:mutable; aValue:Real from Standard) is virtual;
158 ---Purpose: Allows you to provide the setting aValue for width.
159 -- Only the Interactive Object knows which Drawer
160 -- attribute is affected by the width setting.
162 UnsetWidth(me:mutable) is virtual;
164 AcceptDisplayMode(me;aMode:Integer from Standard) returns Boolean from Standard is virtual;
165 ---Purpose: Returns true if the class of objects accepts the display mode aMode.
166 -- The interactive context can have a default mode of
167 -- representation for the set of Interactive Objects. This
168 -- mode may not be accepted by a given class of
169 -- objects. Consequently, this virtual method allowing us
170 -- to get information about the class in question must be implemented.
171 DefaultDisplayMode(me) returns Integer from Standard is virtual;
172 ---Purpose: Returns the default display mode. This method is to
173 -- be implemented when the main mode is not mode 0.
176 Redisplay (me:mutable; AllModes:Boolean from Standard =Standard_False);
177 ---Purpose: Updates the active presentation; if <AllModes> = Standard_True
178 -- all the presentations inside are recomputed.
179 -- IMPORTANT: It is preferable to call Redisplay method of
180 -- corresponding AIS_InteractiveContext instance for cases when it
181 -- is accessible. This method just redirects call to myCTXPtr,
182 -- so this class field must be up to date for proper result.
185 SetInfiniteState(me:mutable;aFlag:Boolean from Standard = Standard_True);
186 ---Purpose: Sets the infinite state flag aFlage.
187 -- if <aFlag> = True , the interactiveObject is
188 -- considered as infinite, i.e. its graphic presentations
189 -- are not taken in account for View FitAll...
191 IsInfinite(me) returns Boolean from Standard;
194 -- Returns true if the interactive object is infinite. In this
195 -- case, its graphic presentations are not taken into
196 -- account in the fit-all view.
199 ---Category: Link To InteractiveContext
201 HasInteractiveContext(me) returns Boolean from Standard;
202 ---Purpose: Indicates whether the Interactive Object has a pointer
203 -- to an interactive context.
205 GetContext(me) returns InteractiveContext from AIS;
206 ---Purpose: Returns the context pointer to the interactive context.
208 SetContext(me:mutable; aCtx : InteractiveContext from AIS) is virtual;
209 ---Purpose: Sets the interactive context aCtx and provides a link
210 -- to the default drawing tool or "Drawer" if there is none.
212 HasOwner (me) returns Boolean from Standard;
213 ---Purpose: Returns true if the object has an owner attributed to it.
214 -- The owner can be a shape for a set of sub-shapes or
215 -- a sub-shape for sub-shapes which it is composed of,
216 -- and takes the form of a transient.
218 GetOwner (me) returns any Transient from Standard;
219 ---Purpose: Returns the owner of the Interactive Object.
220 -- The owner can be a shape for a set of sub-shapes or
221 -- a sub-shape for sub-shapes which it is composed of,
222 -- and takes the form of a transient.
223 -- There are two types of owners:
224 -- - Direct owners, decomposition shapes such as
225 -- edges, wires, and faces.
226 -- - Users, presentable objects connecting to sensitive
227 -- primitives, or a shape which has been decomposed.
229 ---C++: return const&
233 SetOwner (me : mutable;
234 ApplicativeEntity : Transient from Standard);
235 ---Purpose: Allows you to attribute the owner ApplicativeEntity to
236 -- an Interactive Object. This can be a shape for a set of
237 -- sub-shapes or a sub-shape for sub-shapes which it
238 -- is composed of. The owner takes the form of a transient.
241 ClearOwner(me:mutable);
242 ---Purpose: Each Interactive Object has methods which allow us
243 -- to attribute an Owner to it in the form of a Transient.
244 -- This method removes the owner from the graphic entity.
247 HasUsers(me) returns Boolean from Standard;
249 Users(me) returns ListOfTransient from TColStd;
251 ---C++: return const&
254 AddUser(me:mutable; aUser : Transient from Standard);
256 ClearUsers(me:mutable);
260 ---Category: "STANDARD" LOCAL ATTRIBUTES :
262 -- -Local DisplayMode
264 -- -width of lines or points
265 -- -typeOfLine or Marker Aspect
266 -- -material name (if needed)
267 -- -transparency (if needed)
269 -- Specific attributes of entities (such as
270 -- arrow aspect for dimensions) must be
271 -- loaded in a Drawer; this drawer is then
272 -- applied to InteractiveObject WARNING :
273 -- Here the Methods for standard attributes
274 -- are virtual and do nothing they must be
275 -- redefined by the inheriting classes
276 -- (setcolor for a point and setcolor for a plane
277 -- don't affect the same attributes in the Drawer)
281 returns Boolean from Standard;
283 -- Returns true if the Interactive Object has a display
284 -- mode setting. Otherwise, it is displayed in Neutral Point.
287 SetDisplayMode(me : mutable; aMode : Integer from Standard);
288 ---Purpose: Sets the display mode aMode for the interactive object.
289 -- An object can have its own temporary display mode,
290 -- which is different from that proposed by the interactive context.
291 -- The range of possibilities currently proposed is the following:
294 -- This range can, however, be extended through the creation of new display modes.
296 UnsetDisplayMode(me : mutable);
297 ---Purpose: Removes display mode settings from the interactive object.
303 ---Purpose: Returns the display mode setting of the Interactive Object.
304 -- The range of possibilities is the following:
307 -- This range can, however, be extended through the
308 -- creation of new display modes.
311 HasSelectionMode(me) returns Boolean from Standard;
312 ---Purpose: Allows you to change the selection mode of an
313 -- Interactive Object.
314 -- The default selection mode setting is 0.
315 -- For shapes, for example, the selection modes are as follows:
316 -- - mode 0 - selection of the shape itself
317 -- - mode 1 - selection of vertices
318 -- - mode 2 - selection of edges
319 -- - mode 3 - selection of wires
320 -- - mode 4 - selection of faces
321 -- - mode 5 - selection of shells
322 -- - mode 6 - selection of solids
323 -- - mode 7 - selection of compounds
324 -- For trihedra, on the other hand, the selection modes are the following four:
325 -- - mode 0 - selection of a trihedron
326 -- - mode 1 - selection of its origin
327 -- - mode 2 - selection of its axes
328 -- - mode 3 - selection of its planes
330 SelectionMode(me) returns Integer from Standard;
331 ---Purpose: Returns the selection mode of the interactive object.
333 SetSelectionMode(me:mutable; aMode: Integer from Standard);
334 ---Purpose: You can change the default selection mode index
335 -- aMode of an Interactive Object.
336 -- This is only of interest if you decide that mode 0
337 -- adopted by convention will not do.
339 UnsetSelectionMode(me:mutable);
340 ---Purpose: You can change the default selection mode index of
341 -- an Interactive Object.
342 -- This is only of interest if you decide that the 0 mode
343 -- adopted by convention will not do.
347 SelectionPriority(me) returns Integer from Standard;
349 ---Purpose: Returns the selection priority setting. -1 indicates that there is none.
350 -- You can modify the selection priority of an owner to
351 -- make one entity more selectionable than another one.
352 -- The default selection priority for an owner is 5, for
353 -- example. To increase selection priority, choose a
354 -- setting between 5 and 10. An entity with priority 7 will
355 -- take priority over one with a setting of 6 if both
356 -- objects are selected at the same time.
357 -- You could give vertices priority 8, edges priority 7,
358 -- faces priority 6, and shapes priority 5. If a vertex, an
359 -- edge and a face are simultaneously detected during
360 -- selection, only the vertex will then be highlighted.
361 -- For trihedra, for example, the default priorities are the following four:
362 -- - priority 1 - a trihedron
363 -- - priority 5 - its origin
364 -- - priority 3 - its axes
365 -- - priority 2 - its planes
367 SetSelectionPriority(me:mutable; aPriority : Integer from Standard);
369 ---Purpose: Allows you to provide a setting aPriority for selection priority.
370 -- You can modify selection priority of an owner to make
371 -- one entity more selectionable than another one. The
372 -- default selection priority for an owner is 5, for
373 -- example. To increase selection priority, choose a
374 -- setting between 5 and 10. An entity with priority 7 will
375 -- take priority over one with a setting of 6.
377 UnsetSelectionPriority(me:mutable);
379 ---Purpose: Removes the setting for selection priority. SelectionPriority then returns -1.
381 HasSelectionPriority(me) returns Boolean from Standard;
383 ---Purpose: Returns true if there is a setting for selection priority.
384 -- You can modify selection priority of an owner to make
385 -- one entity more selectionable than another one. The
386 -- default selection priority for an owner is 5, for
387 -- example. To increase selection priority, choose a
388 -- setting between 5 and 10. An entity with priority 7 will
389 -- take priority over one with a setting of 6.
391 HasHilightMode(me) returns Boolean from Standard;
393 ---Purpose: Returns true if the Interactive Object is in highlight mode.
395 HilightMode(me) returns Integer from Standard ;
397 ---Purpose: Returns the setting for highlight mode.
398 -- At dynamic detection, the presentation echoed by the
399 -- Interactive Context, is by default the presentation
400 -- already on the screen. You can specify a Highlight
401 -- presentation mode which is valid no matter what the
402 -- active representation of the object. It makes no
403 -- difference whether this choice is temporary or
404 -- definitive. To do this, we use the following functions:
406 -- - UnSetHilightMode
407 -- In the case of a shape, whether it is visualized in
408 -- wireframe presentation or with shading, we want to
409 -- systematically highlight the wireframe presentation.
410 -- Consequently, we set the highlight mode to 0.
412 SetHilightMode(me:mutable;anIndex : Integer from Standard);
414 ---Purpose: Sets the highlight mode anIndex for the interactive object.
415 -- If, for example, you want to systematically highlight
416 -- the wireframe presentation of a shape - whether
417 -- visualized in wireframe presentation or with shading -
418 -- you set the highlight mode to 0.
420 UnsetHilightMode(me:mutable);
422 ---Purpose: Allows the user to take a given Prs for hilight
423 -- ex : for a shape which would be displayed in shading mode
424 -- the hilight Prs is the wireframe mode.
425 -- if No specific hilight mode is defined, the displayed Prs
426 -- will be the hilighted one.
428 HasColor (me) returns Boolean from Standard;
430 ---Purpose: Returns true if the Interactive Object has color.
432 Color(me) returns NameOfColor from Quantity is virtual;
434 ---Purpose: Returns the color setting of the Interactive Object.
436 Color(me; aColor: out Color from Quantity) is virtual;
439 HasWidth(me) returns Boolean from Standard;
441 ---Purpose: Returns true if the Interactive Object has width.
443 Width(me) returns Real from Standard ;
444 --- Purpose: Returns the width setting of the Interactive Object.
446 HasMaterial(me) returns Boolean from Standard ;
447 ---Purpose: Returns true if the Interactive Object has a setting for material.
448 Material(me) returns NameOfMaterial from Graphic3d is virtual;
449 ---Purpose: Returns the current material setting.
450 -- This will be on of the following materials:
458 SetMaterial(me:mutable;aName:NameOfMaterial from Graphic3d) is virtual;
459 ---Purpose: Sets the name aName for material defining this
460 -- display attribute for the interactive object.
461 -- Material aspect determines shading aspect, color and
462 -- transparency of visible entities.
465 SetMaterial(me:mutable;aName:MaterialAspect from Graphic3d) is virtual;
466 --- Purpose: Sets the material aMat defining this display attribute
467 -- for the interactive object.
468 -- Material aspect determines shading aspect, color and
469 -- transparency of visible entities.
471 UnsetMaterial(me:mutable) is virtual;
472 ---Purpose: Removes the setting for material.
474 SetTransparency(me:mutable;aValue : Real from Standard=0.6) is virtual;
475 ---Purpose: Attributes a setting aValue for transparency.
476 -- The transparency value should be between 0.0 and 1.0.
477 -- At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
478 -- Warning At a value of 1.0, there may be nothing visible.
480 IsTransparent(me) returns Boolean from Standard;
482 ---Purpose: Returns true if there is a transparency setting.
484 Transparency(me) returns Real from Standard is virtual;
485 ---Purpose: Returns the transparency setting.
486 -- This will be between 0.0 and 1.0.
487 -- At 0.0 an object will be totally opaque, and at 1.0, fully transparent.
489 UnsetTransparency(me:mutable) is virtual;
490 ---Purpose: Removes the transparency setting. The object is opaque by default.
492 UnsetAttributes(me:mutable) is redefined virtual;
493 ---Purpose: Clears settings provided by the drawing tool aDrawer.
495 ---Category: information about Prs to be recomputed
496 -- after local attributes change... to be removed...
498 RecomputeEveryPrs(me) returns Boolean is virtual private;
500 MustRecomputePrs(me;aMode : Integer from Standard) is private;
502 ListOfRecomputeModes(me)returns ListOfInteger from TColStd is private;
503 ---C++: return const&
504 SetRecomputeOk(me:mutable) is private;
506 State(me:mutable;theState: Integer from Standard) ;
508 State(me) returns Integer from Standard ;
511 HasPresentation ( me ) returns Boolean from Standard
514 ---Purpose: Returns TRUE when this object has a presentation
515 -- in the current DisplayMode()
516 ---Category: Inquire transformation method
518 Presentation ( me ) returns Presentation from Prs3d
521 ---Purpose: Returns the current presentation of this object
522 -- according to the current DisplayMode()
523 ---Category: Inquire transformation method
525 SetAspect ( me : mutable; anAspect: any BasicAspect from Prs3d;
526 globalChange: Boolean from Standard = Standard_True)
529 ---Purpose: Sets the graphic basic aspect to the current presentation.
530 -- When <globalChange> is TRUE , the full object presentation
532 -- When <globalChange> is FALSE , only the current group
533 -- of the object presentation is changed.
534 ---Category: Graphic attributes management
536 -- 22-03-04 OCC4895 SAN High-level interface for controlling polygon offsets
537 SetPolygonOffsets ( me : mutable;
538 aMode : Integer from Standard;
539 aFactor : ShortReal from Standard = 1.0;
540 aUnits : ShortReal from Standard = 0.0 ) is virtual;
542 ---Purpose: Sets up polygon offsets for this object.
543 -- It modifies all existing presentations of <anObj> (if any),
544 -- so it is reasonable to call this method after <anObj> has been displayed.
545 -- Otherwise, Compute() method should pass Graphic3d_AspectFillArea3d
546 -- aspect from <myDrawer> to Graphic3d_Group to make polygon offsets work.
548 -- <aMode> parameter can contain various combinations of
549 -- Aspect_PolygonOffsetMode enumeration elements (Aspect_POM_None means
550 -- that polygon offsets are not changed).
551 -- If <aMode> is different from Aspect_POM_Off and Aspect_POM_None, then <aFactor> and <aUnits>
552 -- arguments are used by graphic renderer to calculate a depth offset value:
554 -- offset = <aFactor> * m + <aUnits> * r, where
555 -- m - maximum depth slope for the polygon currently being displayed,
556 -- r - minimum window coordinates depth resolution (implementation-specific).
558 -- Deafult settings for OCC 3D viewer: mode = Aspect_POM_Fill, factor = 1., units = 0.
560 -- Negative offset values move polygons closer to the viewport,
561 -- while positive values shift polygons away.
562 -- Consult OpenGL reference for details (glPolygonOffset function description).
564 -- NOTE: This method has a side effect - it creates own shading aspect
565 -- if not yet created, so it is better to set up object material,
566 -- color, etc. first.
567 ---Category: Graphic attributes management
569 HasPolygonOffsets ( me )
570 returns Boolean from Standard
573 ---Purpose: Returns Standard_True if <myDrawer> has non-null shading aspect
574 ---Category: Inquire methods
577 aMode : out Integer from Standard;
578 aFactor : out ShortReal from Standard;
579 aUnits : out ShortReal from Standard ) is virtual;
581 ---Purpose: Retrieves current polygon offsets settings from <myDrawer>.
582 ---Category: Inquire methods
586 myCTXPtr : PToContext from AIS;
588 -- The reference to applicative World...
590 myOwner : Transient from Standard;
591 myUsers : ListOfTransient from TColStd;
593 -- The Information Fields
595 myTransparency : Real from Standard is protected;
596 myOwnColor : Color from Quantity is protected;
597 myOwnMaterial : NameOfMaterial from Graphic3d is protected;
598 ---myOwnMaterial : NameOfPhysicalMaterial from Graphic3d is protected;
599 mySelPriority : Integer from Standard;
600 myDisplayMode : Integer from Standard ;
601 mySelectionMode : Integer from Standard;
602 myHilightMode : Integer from Standard is protected;
603 myOwnWidth : Real from Standard is protected;
604 myInfiniteState : Boolean from Standard is protected;
605 hasOwnColor : Boolean from Standard is protected;
606 hasOwnMaterial : Boolean from Standard is protected ;
607 myCurrentFacingModel: TypeOfFacingModel from Aspect is protected;
609 -- the management field (to be removed)...
610 myRecomputeEveryPrs : Boolean from Standard is protected;
612 myToRecomputeModes : ListOfInteger from TColStd is protected;
613 mystate : Integer from Standard;
617 class InteractiveContext from AIS
619 end InteractiveObject;