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;
42 //=======================================================================
45 //=======================================================================
46 AIS_KindOfInteractive AIS_MultipleConnectedInteractive::Type() const
48 return AIS_KOI_Object;
51 //=======================================================================
52 //function : Signature
54 //=======================================================================
55 Standard_Integer AIS_MultipleConnectedInteractive::Signature() const
60 //=======================================================================
63 //=======================================================================
64 Handle(AIS_InteractiveObject) AIS_MultipleConnectedInteractive::connect (const Handle(AIS_InteractiveObject)& theAnotherObj,
65 const Handle(Geom_Transformation)& theTrsf,
66 const Handle(Graphic3d_TransformPers)& theTrsfPers)
68 if (myAssemblyOwner.IsNull())
69 myAssemblyOwner = new SelectMgr_EntityOwner (this);
71 Handle(AIS_InteractiveObject) anObjectToAdd;
73 Handle(AIS_MultipleConnectedInteractive) aMultiConnected = Handle(AIS_MultipleConnectedInteractive)::DownCast (theAnotherObj);
74 if (!aMultiConnected.IsNull())
76 Handle(AIS_MultipleConnectedInteractive) aNewMultiConnected = new AIS_MultipleConnectedInteractive();
77 aNewMultiConnected->myAssemblyOwner = myAssemblyOwner;
78 aNewMultiConnected->SetLocalTransformation (aMultiConnected->LocalTransformationGeom());
80 // Perform deep copy of instance tree
81 for (PrsMgr_ListOfPresentableObjectsIter anIter (aMultiConnected->Children()); anIter.More(); anIter.Next())
83 Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
84 if (anInteractive.IsNull())
89 aNewMultiConnected->Connect (anInteractive);
92 anObjectToAdd = aNewMultiConnected;
96 Handle(AIS_ConnectedInteractive) aNewConnected = new AIS_ConnectedInteractive();
97 aNewConnected->Connect (theAnotherObj, theAnotherObj->LocalTransformationGeom());
99 anObjectToAdd = aNewConnected;
102 anObjectToAdd->SetLocalTransformation (theTrsf);
103 if (!theTrsfPers.IsNull())
105 anObjectToAdd->SetTransformPersistence (theTrsfPers);
107 AddChild (anObjectToAdd);
108 return anObjectToAdd;
111 //=======================================================================
112 //function : HasConnection
114 //=======================================================================
115 Standard_Boolean AIS_MultipleConnectedInteractive::HasConnection() const
117 return (Children().Size() != 0);
120 //=======================================================================
121 //function : Disconnect
123 //=======================================================================
125 void AIS_MultipleConnectedInteractive::Disconnect(const Handle(AIS_InteractiveObject)& anotherIObj)
127 RemoveChild (anotherIObj);
130 //=======================================================================
131 //function : DisconnectAll
133 //=======================================================================
135 void AIS_MultipleConnectedInteractive::DisconnectAll()
137 Standard_Integer aNbItemsToRemove = Children().Size();
138 for (Standard_Integer anIter = 0; anIter < aNbItemsToRemove; ++anIter)
140 RemoveChild (Children().First());
144 //=======================================================================
147 //=======================================================================
148 void AIS_MultipleConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& /*thePrsMgr*/,
149 const Handle(Prs3d_Presentation)& /*thePrs*/,
150 const Standard_Integer /*theMode*/)
152 Handle(AIS_InteractiveContext) aCtx = GetContext();
153 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
155 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
156 if (!aChild.IsNull())
158 aChild->SetContext (aCtx);
163 //=======================================================================
166 //=======================================================================
168 void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector,
169 const Handle(Prs3d_Presentation)& aPresentation)
171 PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
174 //=======================================================================
177 //=======================================================================
179 void AIS_MultipleConnectedInteractive::Compute(const Handle(Prs3d_Projector)& aProjector,
180 const Handle(Geom_Transformation)& aTransformation,
181 const Handle(Prs3d_Presentation)& aPresentation)
183 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
186 //=======================================================================
187 //function : AcceptShapeDecomposition
189 //=======================================================================
190 Standard_Boolean AIS_MultipleConnectedInteractive::AcceptShapeDecomposition() const
192 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
194 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
200 if (aChild->AcceptShapeDecomposition())
202 return Standard_True;
205 return Standard_False;
208 //=======================================================================
209 //function : ComputeSelection
211 //=======================================================================
212 void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
213 const Standard_Integer theMode)
220 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
222 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
228 if (!aChild->HasSelection (theMode))
230 aChild->RecomputePrimitives (theMode);
233 Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode);
234 aChild->ComputeSelection (aSelection, theMode);
238 //=======================================================================
239 //function : SetContext
241 //=======================================================================
242 void AIS_MultipleConnectedInteractive::SetContext (const Handle(AIS_InteractiveContext)& theCtx)
244 AIS_InteractiveObject::SetContext (theCtx);
245 for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
247 Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
248 if (!aChild.IsNull())
250 aChild->SetContext (theCtx);