1 // Created on: 1997-01-08
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <Standard_NotImplemented.hxx>
25 #include <AIS_ConnectedInteractive.ixx>
26 #include <SelectMgr_EntityOwner.hxx>
27 #include <Select3D_SensitiveEntity.hxx>
28 #include <Geom_Transformation.hxx>
30 #include <PrsMgr_ModedPresentation.hxx>
31 #include <PrsMgr_Presentation3d.hxx>
32 #include <OSD_Timer.hxx>
35 //=======================================================================
36 //function : AIS_ConnectedInteractive
38 //=======================================================================
39 AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
40 AIS_InteractiveObject(aTypeOfPresentation3d)
45 //=======================================================================
48 //=======================================================================
49 AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const
50 {return AIS_KOI_Object;}
52 Standard_Integer AIS_ConnectedInteractive::Signature() const
58 //=======================================================================
61 //=======================================================================
62 void AIS_ConnectedInteractive::
63 Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
65 // To have the time to Disconnect below,
66 // the old is kept for a while.
67 if(myReference==anotherIObj) return;
68 myOldReference = myReference;
70 myReference = anotherIObj ;
73 //=======================================================================
76 //=======================================================================
77 void AIS_ConnectedInteractive::
78 Connect(const Handle(AIS_InteractiveObject)& anotherIobj,
79 const TopLoc_Location& aLocation)
81 if(myLocation!=aLocation)
82 myLocation = aLocation;
83 if(myReference!=anotherIobj) {
84 myOldReference = myReference; // necessary to disconnect below..
86 myReference = anotherIobj;}
91 //=======================================================================
92 //function : Disconnect
94 //=======================================================================
96 void AIS_ConnectedInteractive::Disconnect()
98 for(Standard_Integer i =1;i<=myPresentations.Length();i++)
100 Handle(PrsMgr_Presentation3d) P = Handle(PrsMgr_Presentation3d)::DownCast(myPresentations(i).Presentation());
102 P->Presentation()->DisconnectAll(Graphic3d_TOC_DESCENDANT);
106 //=======================================================================
109 //=======================================================================
110 void AIS_ConnectedInteractive::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
111 const Handle(Prs3d_Presentation)& thePrs,
112 const Standard_Integer theMode)
114 if (!(HasLocation() || HasConnection()))
121 thePrs->Clear (Standard_False);
124 if (!myReference->HasInteractiveContext())
126 myReference->SetContext (GetContext());
128 thePrsMgr->Connect (this, myReference, theMode, theMode);
129 if (thePrsMgr->Presentation (myReference, theMode)->MustBeUpdated())
131 thePrsMgr->Update (myReference, theMode);
137 Handle(Geom_Transformation) aPrsTrans = new Geom_Transformation (myLocation.Transformation());
138 thePrsMgr->Transform (this, aPrsTrans, theMode);
143 void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
145 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
146 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
149 void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Prs3d_Presentation& aPresentation)
151 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)");
152 PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
155 //=======================================================================
156 //function : ComputeSelection
158 //=======================================================================
160 void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
161 const Standard_Integer aMode)
163 if(!(HasLocation() ||HasConnection())) return;
166 if(!myReference->HasSelection(aMode))
167 myReference->UpdateSelection(aMode);
169 const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode);
170 Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this);
171 Handle(Select3D_SensitiveEntity) SE3D, SNew;
173 if(TheRefSel->IsEmpty())
174 myReference->UpdateSelection(aMode);
175 for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next())
177 SE3D = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive());
180 // Get the copy of SE3D
181 SNew = SE3D->GetConnected(myLocation);
185 // In case if SE3D caches some location-dependent data
186 // that must be updated after setting OWN
187 SNew->SetLocation(myLocation);
194 void AIS_ConnectedInteractive::UpdateLocation()
196 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()");
197 SelectMgr_SelectableObject::UpdateLocation() ;
199 void AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)
201 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)");
202 SelectMgr_SelectableObject::UpdateLocation(Sel) ;
204 /*void AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation& aPresentation)
206 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation&)");
207 SelectMgr_SelectableObject::UpdateLocation(aPresentation) ;