1 // Created on: 1997-04-22
2 // Created by: Guest Design
3 // Copyright (c) 1997-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 #include <AIS_MultipleConnectedInteractive.hxx>
19 #include <AIS_ConnectedInteractive.hxx>
20 #include <AIS_InteractiveContext.hxx>
21 #include <AIS_InteractiveObject.hxx>
22 #include <Prs3d_Projector.hxx>
23 #include <PrsMgr_ModedPresentation.hxx>
24 #include <Select3D_SensitiveEntity.hxx>
25 #include <SelectMgr_EntityOwner.hxx>
26 #include <Standard_NotImplemented.hxx>
27 #include <TopLoc_Location.hxx>
29 IMPLEMENT_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObject)
31 //=======================================================================
32 //function : AIS_MultipleConnectedInteractive
34 //=======================================================================
36 AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive()
37 : AIS_InteractiveObject (PrsMgr_TOP_AllView)
39 myHasOwnPresentations = Standard_False;
40 myAssemblyOwner = NULL;
43 //=======================================================================
46 //=======================================================================
47 AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const
49 return AIS_KOI_Object;
52 //=======================================================================
53 //function : Signature
55 //=======================================================================
56 Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
61 //=======================================================================
64 //=======================================================================
65 Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
66 const Handle(Geom_Transformation)& theTrsf,
67 const Handle(Graphic3d_TransformPers)& theTrsfPers)
69 if (myAssemblyOwner.IsNull())
70 myAssemblyOwner = new SelectMgr_EntityOwner (this);
72 Handle(AIS_InteractiveObject) anObjectToAdd;
74 Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj);
75 if (!aMultiConnected.IsNull())
77 Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive();
78 aNewMultiConnected->myAssemblyOwner = myAssemblyOwner;
79 aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformationGeom());
81 // Perform deep copy of instance tree
82 for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next())
84 Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
85 if (anInteractive.IsNull())
90 aNewMultiConnected->Connect (anInteractive);
93 anObjectToAdd = aNewMultiConnected;
97 Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive();
98 aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom());
100 anObjectToAdd = aNewConnected;
103 anObjectToAdd->SetLocalTransformation (theTrsf);
104 if (!theTrsfPers.IsNull())
106 anObjectToAdd->SetTransformPersistence (theTrsfPers);
108 AddChild (anObjectToAdd);
109 return anObjectToAdd;
112 //=======================================================================
113 //function : HasConnection
115 //=======================================================================
116 Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
118 return (Children().Size() != 0);
121 //=======================================================================
122 //function : Disconnect
124 //=======================================================================
126 void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
128 RemoveChild (anotherIObj);
131 //=======================================================================
132 //function : DisconnectAll
134 //=======================================================================
136 void AIS_MultipleConnectedInteractive::DisconnectAll()
138 Standard_Integer aNbItemsToRemove = Children().Size();
139 for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter)
141 RemoveChild (Children().First());
145 //=======================================================================
148 //=======================================================================
149 void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/,
150 const Handle(Prs3d_Presentation)& /*thePrs*/,
151 const Standard_Integer /*theMode*/)
153 Handle(AIS_InteractiveContext) aCtx = GetContext();
154 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
156 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
157 if (!aChild.IsNull())
159 aChild->SetContext (aCtx);
164 //=======================================================================
167 //=======================================================================
169 void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector,
170 const Handle(Prs3d_Presentation)& aPresentation)
172 PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
175 //=======================================================================
178 //=======================================================================
180 void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector,
181 const Handle(Geom_Transformation)& aTransformation,
182 const Handle(Prs3d_Presentation)& aPresentation)
184 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
187 //=======================================================================
188 //function : AcceptShapeDecomposition
190 //=======================================================================
191 Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() const
193 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
195 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
201 if (aChild->AcceptShapeDecomposition())
203 return Standard_True;
206 return Standard_False;
209 //=======================================================================
210 //function : ComputeSelection
212 //=======================================================================
213 void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
214 const Standard_Integer theMode)
218 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
220 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
226 if (!aChild->HasSelection (theMode))
228 aChild->RecomputePrimitives (theMode);
231 Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode);
232 aChild->ComputeSelection (aSelection, theMode);
237 //=======================================================================
238 //function : GlobalSelOwner
240 //=======================================================================
241 Handle(SelectMgr_EntityOwner) AIS_MultipleConnectedInteractive::GlobalSelOwner() const
243 return myAssemblyOwner;
246 //=======================================================================
247 //function : HasSelection
249 //=======================================================================
250 Standard_Boolean AIS_MultipleConnectedInteractive::HasSelection (const Standard_Integer theMode) const
252 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
254 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
258 if (!aChild->HasSelection (theMode))
259 return Standard_False;
262 return Standard_True;
265 //=======================================================================
266 //function : SetContext
268 //=======================================================================
269 void AIS_MultipleConnectedInteractive::SetContext (const Handle(AIS_InteractiveContext)& theCtx)
271 AIS_InteractiveObject::SetContext (theCtx);
272 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
274 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
275 if (!aChild.IsNull())
277 aChild->SetContext (theCtx);