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 <Select3D_SensitiveEntity.hxx>
24 #include <SelectMgr_EntityOwner.hxx>
25 #include <Standard_NotImplemented.hxx>
26 #include <TopLoc_Location.hxx>
28 IMPLEMENT_STANDARD_RTTIEXT(AIS_MultipleConnectedInteractive,AIS_InteractiveObject)
30 //=======================================================================
31 //function : AIS_MultipleConnectedInteractive
33 //=======================================================================
35 AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive()
36 : AIS_InteractiveObject (PrsMgr_TOP_AllView)
38 myHasOwnPresentations = Standard_False;
41 //=======================================================================
44 //=======================================================================
45 AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const
47 return AIS_KOI_Object;
50 //=======================================================================
51 //function : Signature
53 //=======================================================================
54 Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
59 //=======================================================================
62 //=======================================================================
63 Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
64 const Handle(Geom_Transformation)& theTrsf,
65 const Handle(Graphic3d_TransformPers)& theTrsfPers)
67 if (myAssemblyOwner.IsNull())
68 myAssemblyOwner = new SelectMgr_EntityOwner (this);
70 Handle(AIS_InteractiveObject) anObjectToAdd;
72 Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj);
73 if (!aMultiConnected.IsNull())
75 Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive();
76 aNewMultiConnected->myAssemblyOwner = myAssemblyOwner;
77 aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformationGeom());
79 // Perform deep copy of instance tree
80 for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next())
82 Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
83 if (anInteractive.IsNull())
88 aNewMultiConnected->Connect (anInteractive);
91 anObjectToAdd = aNewMultiConnected;
95 Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive();
96 aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom());
98 anObjectToAdd = aNewConnected;
101 anObjectToAdd->SetLocalTransformation (theTrsf);
102 if (!theTrsfPers.IsNull())
104 anObjectToAdd->SetTransformPersistence (theTrsfPers);
106 AddChild (anObjectToAdd);
107 return anObjectToAdd;
110 //=======================================================================
111 //function : HasConnection
113 //=======================================================================
114 Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
116 return (Children().Size() != 0);
119 //=======================================================================
120 //function : Disconnect
122 //=======================================================================
124 void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
126 RemoveChild (anotherIObj);
129 //=======================================================================
130 //function : DisconnectAll
132 //=======================================================================
134 void AIS_MultipleConnectedInteractive::DisconnectAll()
136 Standard_Integer aNbItemsToRemove = Children().Size();
137 for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter)
139 RemoveChild (Children().First());
143 //=======================================================================
146 //=======================================================================
147 void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/,
148 const Handle(Prs3d_Presentation)& /*thePrs*/,
149 const Standard_Integer /*theMode*/)
151 Handle(AIS_InteractiveContext) aCtx = GetContext();
152 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
154 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
155 if (!aChild.IsNull())
157 aChild->SetContext (aCtx);
162 //=======================================================================
165 //=======================================================================
167 void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector,
168 const Handle(Prs3d_Presentation)& aPresentation)
170 PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
173 //=======================================================================
176 //=======================================================================
178 void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector,
179 const Handle(Geom_Transformation)& aTransformation,
180 const Handle(Prs3d_Presentation)& aPresentation)
182 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
185 //=======================================================================
186 //function : AcceptShapeDecomposition
188 //=======================================================================
189 Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() const
191 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
193 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
199 if (aChild->AcceptShapeDecomposition())
201 return Standard_True;
204 return Standard_False;
207 //=======================================================================
208 //function : ComputeSelection
210 //=======================================================================
211 void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
212 const Standard_Integer theMode)
219 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
221 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
227 if (!aChild->HasSelection (theMode))
229 aChild->RecomputePrimitives (theMode);
232 Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode);
233 aChild->ComputeSelection (aSelection, theMode);
237 //=======================================================================
238 //function : SetContext
240 //=======================================================================
241 void AIS_MultipleConnectedInteractive::SetContext (const Handle(AIS_InteractiveContext)& theCtx)
243 AIS_InteractiveObject::SetContext (theCtx);
244 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
246 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
247 if (!aChild.IsNull())
249 aChild->SetContext (theCtx);