b311480e |
1 | // Created on: 1997-04-22 |
2 | // Created by: Guest Design |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
1f7f5a90 |
17 | #include <AIS_MultipleConnectedInteractive.hxx> |
7fd59977 |
18 | |
0717ddc1 |
19 | #include <AIS_ConnectedInteractive.hxx> |
20 | #include <AIS_InteractiveContext.hxx> |
42cf5bc1 |
21 | #include <AIS_InteractiveObject.hxx> |
0717ddc1 |
22 | #include <Select3D_SensitiveEntity.hxx> |
42cf5bc1 |
23 | #include <SelectMgr_EntityOwner.hxx> |
24 | #include <Standard_NotImplemented.hxx> |
0717ddc1 |
25 | #include <TopLoc_Location.hxx> |
0717ddc1 |
26 | |
92efcf78 |
27 | IMPLEMENT_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObject) |
28 | |
7fd59977 |
29 | //======================================================================= |
30 | //function : AIS_MultipleConnectedInteractive |
b5cce1ab |
31 | //purpose : |
7fd59977 |
32 | //======================================================================= |
33 | |
0717ddc1 |
34 | AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive() |
b5cce1ab |
35 | : AIS_InteractiveObject (PrsMgr_TOP_AllView) |
0717ddc1 |
36 | { |
37 | myHasOwnPresentations = Standard_False; |
7fd59977 |
38 | } |
39 | |
7fd59977 |
40 | //======================================================================= |
1f7f5a90 |
41 | //function : connect |
ba9e14df |
42 | //purpose : |
7fd59977 |
43 | //======================================================================= |
1f7f5a90 |
44 | Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj, |
7f24b768 |
45 | const Handle(TopLoc_Datum3D)& theTrsf, |
778cd667 |
46 | const Handle(Graphic3d_TransformPers)& theTrsfPers) |
7fd59977 |
47 | { |
f751596e |
48 | if (myAssemblyOwner.IsNull()) |
49 | myAssemblyOwner = new SelectMgr_EntityOwner (this); |
50 | |
0717ddc1 |
51 | Handle(AIS_InteractiveObject) anObjectToAdd; |
52 | |
53 | Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj); |
54 | if (!aMultiConnected.IsNull()) |
55 | { |
56 | Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive(); |
f751596e |
57 | aNewMultiConnected->myAssemblyOwner = myAssemblyOwner; |
1f7f5a90 |
58 | aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformationGeom()); |
0717ddc1 |
59 | |
60 | // Perform deep copy of instance tree |
61 | for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next()) |
62 | { |
63 | Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
64 | if (anInteractive.IsNull()) |
65 | { |
66 | continue; |
67 | } |
68 | |
69 | aNewMultiConnected->Connect (anInteractive); |
70 | } |
7fd59977 |
71 | |
0717ddc1 |
72 | anObjectToAdd = aNewMultiConnected; |
7fd59977 |
73 | } |
0717ddc1 |
74 | else |
75 | { |
76 | Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive(); |
1f7f5a90 |
77 | aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom()); |
0717ddc1 |
78 | |
79 | anObjectToAdd = aNewConnected; |
80 | } |
81 | |
1f7f5a90 |
82 | anObjectToAdd->SetLocalTransformation (theTrsf); |
778cd667 |
83 | if (!theTrsfPers.IsNull()) |
ba9e14df |
84 | { |
778cd667 |
85 | anObjectToAdd->SetTransformPersistence (theTrsfPers); |
ba9e14df |
86 | } |
0717ddc1 |
87 | AddChild (anObjectToAdd); |
ba9e14df |
88 | return anObjectToAdd; |
0717ddc1 |
89 | } |
90 | |
7fd59977 |
91 | //======================================================================= |
92 | //function : HasConnection |
93 | //purpose : |
94 | //======================================================================= |
95 | Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const |
96 | { |
0717ddc1 |
97 | return (Children().Size() != 0); |
7fd59977 |
98 | } |
99 | |
100 | //======================================================================= |
101 | //function : Disconnect |
102 | //purpose : |
103 | //======================================================================= |
104 | |
105 | void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj) |
106 | { |
0717ddc1 |
107 | RemoveChild (anotherIObj); |
7fd59977 |
108 | } |
109 | |
110 | //======================================================================= |
111 | //function : DisconnectAll |
112 | //purpose : |
113 | //======================================================================= |
114 | |
0717ddc1 |
115 | void AIS_MultipleConnectedInteractive::DisconnectAll() |
7fd59977 |
116 | { |
0717ddc1 |
117 | Standard_Integer aNbItemsToRemove = Children().Size(); |
118 | for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter) |
119 | { |
120 | RemoveChild (Children().First()); |
121 | } |
7fd59977 |
122 | } |
123 | |
124 | //======================================================================= |
125 | //function : Compute |
792c785c |
126 | //purpose : |
7fd59977 |
127 | //======================================================================= |
decbff0d |
128 | void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager)& , |
129 | const Handle(Prs3d_Presentation)& , |
130 | const Standard_Integer ) |
7fd59977 |
131 | { |
2ec85268 |
132 | Handle(AIS_InteractiveContext) aCtx = GetContext(); |
0717ddc1 |
133 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
792c785c |
134 | { |
0717ddc1 |
135 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
2ec85268 |
136 | if (!aChild.IsNull()) |
0717ddc1 |
137 | { |
2ec85268 |
138 | aChild->SetContext (aCtx); |
7fd59977 |
139 | } |
140 | } |
7fd59977 |
141 | } |
792c785c |
142 | |
0717ddc1 |
143 | //======================================================================= |
144 | //function : AcceptShapeDecomposition |
145 | //purpose : |
146 | //======================================================================= |
147 | Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() const |
148 | { |
149 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
150 | { |
151 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
152 | if (aChild.IsNull()) |
153 | { |
154 | continue; |
155 | } |
156 | |
157 | if (aChild->AcceptShapeDecomposition()) |
158 | { |
159 | return Standard_True; |
160 | } |
161 | } |
162 | return Standard_False; |
7fd59977 |
163 | } |
164 | |
165 | //======================================================================= |
166 | //function : ComputeSelection |
167 | //purpose : |
168 | //======================================================================= |
f751596e |
169 | void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/, |
0717ddc1 |
170 | const Standard_Integer theMode) |
7fd59977 |
171 | { |
b5cce1ab |
172 | if (theMode == 0) |
0717ddc1 |
173 | { |
b5cce1ab |
174 | return; |
0717ddc1 |
175 | } |
7411850a |
176 | |
7411850a |
177 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
178 | { |
179 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
180 | if (aChild.IsNull()) |
b5cce1ab |
181 | { |
7411850a |
182 | continue; |
b5cce1ab |
183 | } |
7411850a |
184 | |
185 | if (!aChild->HasSelection (theMode)) |
b5cce1ab |
186 | { |
187 | aChild->RecomputePrimitives (theMode); |
188 | } |
7411850a |
189 | |
b5cce1ab |
190 | Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode); |
191 | aChild->ComputeSelection (aSelection, theMode); |
192 | } |
7411850a |
193 | } |
2ec85268 |
194 | |
195 | //======================================================================= |
196 | //function : SetContext |
197 | //purpose : |
198 | //======================================================================= |
199 | void AIS_MultipleConnectedInteractive::SetContext (const Handle(AIS_InteractiveContext)& theCtx) |
200 | { |
201 | AIS_InteractiveObject::SetContext (theCtx); |
202 | for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next()) |
203 | { |
204 | Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value()); |
205 | if (!aChild.IsNull()) |
206 | { |
207 | aChild->SetContext (theCtx); |
208 | } |
209 | } |
210 | } |