42cf5bc1 |
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 |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
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. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _AIS_InteractiveObject_HeaderFile |
18 | #define _AIS_InteractiveObject_HeaderFile |
19 | |
42cf5bc1 |
20 | #include <AIS_KindOfInteractive.hxx> |
630ab538 |
21 | #include <AIS_DragAction.hxx> |
2ec85268 |
22 | #include <SelectMgr_SelectableObject.hxx> |
2ec85268 |
23 | |
42cf5bc1 |
24 | class AIS_InteractiveContext; |
42cf5bc1 |
25 | class Graphic3d_MaterialAspect; |
42cf5bc1 |
26 | class Prs3d_BasicAspect; |
27 | class Bnd_Box; |
630ab538 |
28 | class V3d_View; |
42cf5bc1 |
29 | |
42cf5bc1 |
30 | //! Defines a class of objects with display and selection services. |
2b886265 |
31 | //! Entities which are visualized and selected are Interactive Objects. |
32 | //! Specific attributes of entities such as arrow aspect for dimensions must be loaded in a Prs3d_Drawer. |
33 | //! |
34 | //! You can make use of classes of standard Interactive Objects for which all necessary methods have already been programmed, |
35 | //! or you can implement your own classes of Interactive Objects. |
36 | //! Key interface methods to be implemented by every Interactive Object: |
37 | //! * Presentable Object (PrsMgr_PresentableObject) |
38 | //! Consider defining an enumeration of supported Display Mode indexes for particular Interactive Object or class of Interactive Objects. |
39 | //! - AcceptDisplayMode() accepting display modes implemented by this object; |
40 | //! - Compute() computing presentation for the given display mode index; |
41 | //! * Selectable Object (SelectMgr_SelectableObject) |
42 | //! Consider defining an enumeration of supported Selection Mode indexes for particular Interactive Object or class of Interactive Objects. |
43 | //! - ComputeSelection() computing selectable entities for the given selection mode index. |
42cf5bc1 |
44 | class AIS_InteractiveObject : public SelectMgr_SelectableObject |
45 | { |
2ec85268 |
46 | friend class AIS_InteractiveContext; |
47 | DEFINE_STANDARD_RTTIEXT(AIS_InteractiveObject, SelectMgr_SelectableObject) |
42cf5bc1 |
48 | public: |
49 | |
2b886265 |
50 | //! Returns the kind of Interactive Object; AIS_KOI_None by default. |
51 | virtual AIS_KindOfInteractive Type() const { return AIS_KOI_None; } |
87432b82 |
52 | |
2b886265 |
53 | //! Specifies additional characteristics of Interactive Object of Type(); -1 by default. |
54 | //! Among the datums, this signature is attributed to the shape. |
55 | //! The remaining datums have the following default signatures: |
56 | //! - Point signature 1 |
57 | //! - Axis signature 2 |
58 | //! - Trihedron signature 3 |
59 | //! - PlaneTrihedron signature 4 |
60 | //! - Line signature 5 |
61 | //! - Circle signature 6 |
62 | //! - Plane signature 7. |
63 | virtual Standard_Integer Signature() const { return -1; } |
42cf5bc1 |
64 | |
65 | //! Updates the active presentation; if <AllModes> = Standard_True |
66 | //! all the presentations inside are recomputed. |
67 | //! IMPORTANT: It is preferable to call Redisplay method of |
68 | //! corresponding AIS_InteractiveContext instance for cases when it |
69 | //! is accessible. This method just redirects call to myCTXPtr, |
70 | //! so this class field must be up to date for proper result. |
71 | Standard_EXPORT void Redisplay (const Standard_Boolean AllModes = Standard_False); |
2ec85268 |
72 | |
73 | //! Indicates whether the Interactive Object has a pointer to an interactive context. |
74 | Standard_Boolean HasInteractiveContext() const { return myCTXPtr != NULL; } |
75 | |
42cf5bc1 |
76 | //! Returns the context pointer to the interactive context. |
2b886265 |
77 | AIS_InteractiveContext* InteractiveContext() const { return myCTXPtr; } |
42cf5bc1 |
78 | |
79 | //! Sets the interactive context aCtx and provides a link |
80 | //! to the default drawing tool or "Drawer" if there is none. |
81 | Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& aCtx); |
82 | |
83 | //! Returns true if the object has an owner attributed to it. |
2b886265 |
84 | //! The owner can be a shape for a set of sub-shapes or a sub-shape for sub-shapes which it is composed of, and takes the form of a transient. |
85 | Standard_Boolean HasOwner() const { return !myOwner.IsNull(); } |
42cf5bc1 |
86 | |
87 | //! Returns the owner of the Interactive Object. |
88 | //! The owner can be a shape for a set of sub-shapes or |
89 | //! a sub-shape for sub-shapes which it is composed of, |
90 | //! and takes the form of a transient. |
91 | //! There are two types of owners: |
92 | //! - Direct owners, decomposition shapes such as |
93 | //! edges, wires, and faces. |
94 | //! - Users, presentable objects connecting to sensitive |
95 | //! primitives, or a shape which has been decomposed. |
2ec85268 |
96 | const Handle(Standard_Transient)& GetOwner() const { return myOwner; } |
97 | |
98 | //! Allows you to attribute the owner theApplicativeEntity to |
42cf5bc1 |
99 | //! an Interactive Object. This can be a shape for a set of |
100 | //! sub-shapes or a sub-shape for sub-shapes which it |
101 | //! is composed of. The owner takes the form of a transient. |
2ec85268 |
102 | void SetOwner (const Handle(Standard_Transient)& theApplicativeEntity) { myOwner = theApplicativeEntity; } |
103 | |
2b886265 |
104 | //! Each Interactive Object has methods which allow us to attribute an Owner to it in the form of a Transient. |
42cf5bc1 |
105 | //! This method removes the owner from the graphic entity. |
2b886265 |
106 | void ClearOwner() { myOwner.Nullify(); } |
f838dac4 |
107 | |
630ab538 |
108 | //! Drag object in the viewer. |
109 | //! @param theCtx [in] interactive context |
110 | //! @param theView [in] active View |
111 | //! @param theOwner [in] the owner of detected entity |
112 | //! @param theDragFrom [in] drag start point |
113 | //! @param theDragTo [in] drag end point |
114 | //! @param theAction [in] drag action |
115 | //! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start) |
116 | Standard_EXPORT virtual Standard_Boolean ProcessDragging (const Handle(AIS_InteractiveContext)& theCtx, |
117 | const Handle(V3d_View)& theView, |
118 | const Handle(SelectMgr_EntityOwner)& theOwner, |
119 | const Graphic3d_Vec2i& theDragFrom, |
120 | const Graphic3d_Vec2i& theDragTo, |
121 | const AIS_DragAction theAction); |
122 | |
2b886265 |
123 | public: |
2ec85268 |
124 | |
2b886265 |
125 | //! Returns the context pointer to the interactive context. |
126 | Standard_EXPORT Handle(AIS_InteractiveContext) GetContext() const; |
2ec85268 |
127 | |
2b886265 |
128 | //! Returns TRUE when this object has a presentation in the current DisplayMode() |
42cf5bc1 |
129 | Standard_EXPORT Standard_Boolean HasPresentation() const; |
2b886265 |
130 | |
131 | //! Returns the current presentation of this object according to the current DisplayMode() |
42cf5bc1 |
132 | Standard_EXPORT Handle(Prs3d_Presentation) Presentation() const; |
2831708b |
133 | |
42cf5bc1 |
134 | //! Sets the graphic basic aspect to the current presentation. |
2b886265 |
135 | Standard_DEPRECATED("Deprecated method, results might be undefined") |
2831708b |
136 | Standard_EXPORT void SetAspect (const Handle(Prs3d_BasicAspect)& anAspect); |
fb66bb28 |
137 | |
0904aa63 |
138 | //! Dumps the content of me into the stream |
bc73b006 |
139 | Standard_EXPORT virtual void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const Standard_OVERRIDE; |
bf5f0ca2 |
140 | protected: |
141 | |
42cf5bc1 |
142 | //! The TypeOfPresention3d means that the interactive object |
c3282ec1 |
143 | //! may have a presentation dependant of the view of Display. |
42cf5bc1 |
144 | Standard_EXPORT AIS_InteractiveObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); |
145 | |
226fce20 |
146 | protected: |
f838dac4 |
147 | |
2b886265 |
148 | AIS_InteractiveContext* myCTXPtr; //!< pointer to Interactive Context, where object is currently displayed; @sa SetContext() |
149 | Handle(Standard_Transient) myOwner; //!< application-specific owner object |
42cf5bc1 |
150 | |
151 | }; |
152 | |
2ec85268 |
153 | DEFINE_STANDARD_HANDLE(AIS_InteractiveObject, SelectMgr_SelectableObject) |
42cf5bc1 |
154 | |
155 | #endif // _AIS_InteractiveObject_HeaderFile |