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