42cf5bc1 |
1 | // Created on: 1997-01-08 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1997-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_ConnectedInteractive_HeaderFile |
18 | #define _AIS_ConnectedInteractive_HeaderFile |
19 | |
42cf5bc1 |
20 | #include <AIS_InteractiveObject.hxx> |
42cf5bc1 |
21 | #include <AIS_KindOfInteractive.hxx> |
1f7f5a90 |
22 | #include <TopoDS_Shape.hxx> |
42cf5bc1 |
23 | |
24 | //! Creates an arbitrary located instance of another Interactive Object, |
25 | //! which serves as a reference. |
26 | //! This allows you to use the Connected Interactive |
27 | //! Object without having to recalculate presentation, |
28 | //! selection or graphic structure. These are deduced |
29 | //! from your reference object. |
30 | //! The relation between the connected interactive object |
31 | //! and its source is generally one of geometric transformation. |
32 | //! AIS_ConnectedInteractive class supports selection mode 0 for any InteractiveObject and |
33 | //! all standard modes if its reference based on AIS_Shape. |
34 | //! Descendants may redefine ComputeSelection() though. |
35 | //! Also ConnectedInteractive will handle HLR if its reference based on AIS_Shape. |
36 | class AIS_ConnectedInteractive : public AIS_InteractiveObject |
37 | { |
1f7f5a90 |
38 | DEFINE_STANDARD_RTTIEXT(AIS_ConnectedInteractive, AIS_InteractiveObject) |
42cf5bc1 |
39 | public: |
40 | |
42cf5bc1 |
41 | //! Disconnects the previous view and sets highlight |
42 | //! mode to 0. This highlights the wireframe presentation |
43 | //! aTypeOfPresentation3d. |
44 | //! Top_AllView deactivates hidden line removal. |
45 | Standard_EXPORT AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView); |
46 | |
47 | //! Returns KOI_Object |
60adbe67 |
48 | virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KOI_Object; } |
49 | |
50 | //! Returns 0 |
51 | virtual Standard_Integer Signature() const Standard_OVERRIDE { return 0; } |
42cf5bc1 |
52 | |
53 | //! Establishes the connection between the Connected |
54 | //! Interactive Object, anotherIobj, and its reference. |
0f57ab75 |
55 | void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj) { connect (theAnotherObj, Handle(Geom_Transformation)()); } |
60adbe67 |
56 | |
42cf5bc1 |
57 | //! Establishes the connection between the Connected |
58 | //! Interactive Object, anotherIobj, and its reference. |
59 | //! Locates instance in aLocation. |
0f57ab75 |
60 | void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj, |
1f7f5a90 |
61 | const gp_Trsf& theLocation) { connect (theAnotherObj, new Geom_Transformation (theLocation)); } |
62 | |
63 | //! Establishes the connection between the Connected |
64 | //! Interactive Object, anotherIobj, and its reference. |
65 | //! Locates instance in aLocation. |
0f57ab75 |
66 | void Connect (const Handle(AIS_InteractiveObject)& theAnotherObj, |
67 | const Handle(Geom_Transformation)& theLocation) { connect (theAnotherObj, theLocation); } |
42cf5bc1 |
68 | |
69 | //! Returns true if there is a connection established |
70 | //! between the presentation and its source reference. |
60adbe67 |
71 | Standard_Boolean HasConnection() const { return !myReference.IsNull(); } |
42cf5bc1 |
72 | |
73 | //! Returns the connection with the reference Interactive Object. |
60adbe67 |
74 | const Handle(AIS_InteractiveObject)& ConnectedTo() const { return myReference; } |
75 | |
42cf5bc1 |
76 | //! Clears the connection with a source reference. The |
77 | //! presentation will no longer be displayed. |
78 | //! Warning Must be done before deleting the presentation. |
79 | Standard_EXPORT void Disconnect(); |
60adbe67 |
80 | |
42cf5bc1 |
81 | //! Informs the graphic context that the interactive Object |
82 | //! may be decomposed into sub-shapes for dynamic selection. |
60adbe67 |
83 | virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE |
84 | { |
85 | return !myReference.IsNull() && myReference->AcceptShapeDecomposition(); |
86 | } |
87 | |
88 | //! Return true if reference presentation accepts specified display mode. |
89 | virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE |
90 | { |
91 | return myReference.IsNull() |
92 | || myReference->AcceptDisplayMode (theMode); |
93 | } |
42cf5bc1 |
94 | |
42cf5bc1 |
95 | protected: |
96 | |
42cf5bc1 |
97 | //! Calculates the view aPresentation and its updates. |
98 | //! The latter are managed by aPresentationManager. |
99 | //! The display mode aMode is 0 by default. |
100 | //! this method is redefined virtual; |
101 | //! when the instance is connected to another |
102 | //! InteractiveObject,this method doesn't |
103 | //! compute anything, but just uses the |
104 | //! presentation of this last object, with |
105 | //! a transformation if there's one stored. |
60adbe67 |
106 | Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode) Standard_OVERRIDE; |
107 | |
42cf5bc1 |
108 | //! Computes the presentation according to a point of view |
109 | //! given by <aProjector>. |
110 | //! To be Used when the associated degenerated Presentations |
111 | //! have been transformed by <aTrsf> which is not a Pure |
112 | //! Translation. The HLR Prs can't be deducted automatically |
113 | //! WARNING :<aTrsf> must be applied |
114 | //! to the object to display before computation !!! |
115 | Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Geom_Transformation)& aTrsf, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; |
60adbe67 |
116 | |
42cf5bc1 |
117 | //! Computes the presentation according to a point of view |
118 | //! given by <aProjector>. |
119 | Standard_EXPORT virtual void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation) Standard_OVERRIDE; |
60adbe67 |
120 | |
42cf5bc1 |
121 | //! Generates sensitive entities by copying |
122 | //! them from myReference selection, creates and sets an entity |
123 | //! owner for this entities and adds them to theSelection |
124 | Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode) Standard_OVERRIDE; |
60adbe67 |
125 | |
42cf5bc1 |
126 | //! Generates sensitive entities by copying |
127 | //! them from myReference sub shapes selection, creates and sets an entity |
128 | //! owner for this entities and adds them to theSelection |
129 | Standard_EXPORT void computeSubShapeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer theMode); |
60adbe67 |
130 | |
42cf5bc1 |
131 | Standard_EXPORT void updateShape (const Standard_Boolean WithLocation = Standard_True); |
60adbe67 |
132 | |
42cf5bc1 |
133 | //! Computes the presentation according to a point of view |
134 | //! given by <aProjector>. |
135 | Standard_EXPORT void Compute (const Handle(Prs3d_Projector)& aProjector, const Handle(Prs3d_Presentation)& aPresentation, const TopoDS_Shape& aShape); |
136 | |
1f7f5a90 |
137 | Standard_EXPORT void connect (const Handle(AIS_InteractiveObject)& theAnotherObj, |
138 | const Handle(Geom_Transformation)& theLocation); |
139 | |
60adbe67 |
140 | protected: |
42cf5bc1 |
141 | |
60adbe67 |
142 | Handle(AIS_InteractiveObject) myReference; |
143 | TopoDS_Shape myShape; |
42cf5bc1 |
144 | |
145 | }; |
146 | |
1f7f5a90 |
147 | DEFINE_STANDARD_HANDLE(AIS_ConnectedInteractive, AIS_InteractiveObject) |
148 | |
42cf5bc1 |
149 | #endif // _AIS_ConnectedInteractive_HeaderFile |