Integration of OCCT 6.5.0 from SVN
[occt.git] / src / AIS / AIS_ConnectedInteractive.cxx
CommitLineData
7fd59977 1// File: AIS_ConnectedInteractive.cxx
2// Created: Wed Jan 8 15:24:35 1997
3// Author: Robert COUBLANC
4// <rob@robox.paris1.matra-dtv.fr>
5
6
7#include <Standard_NotImplemented.hxx>
8
9#include <AIS_ConnectedInteractive.ixx>
10#include <SelectMgr_EntityOwner.hxx>
11#include <Select3D_SensitiveEntity.hxx>
12#include <Geom_Transformation.hxx>
13
14#include <PrsMgr_ModedPresentation.hxx>
15#include <PrsMgr_Presentation3d.hxx>
16#include <OSD_Timer.hxx>
17
18
19//=======================================================================
20//function : AIS_ConnectedInteractive
21//purpose :
22//=======================================================================
23AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
24AIS_InteractiveObject(aTypeOfPresentation3d)
25{
26 SetHilightMode(0);
27}
28
29//=======================================================================
30//function : Type
31//purpose :
32//=======================================================================
33AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const
34{return AIS_KOI_Object;}
35
36Standard_Integer AIS_ConnectedInteractive::Signature() const
37{return 0; }
38
39
40
41
42//=======================================================================
43//function : Connect
44//purpose :
45//=======================================================================
46void AIS_ConnectedInteractive::
47Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
48{
49 // Pour Avoir le temps de faire le Disconnect en dessous,
50 // on garde l'ancien un peu. SMO.
51 if(myReference==anotherIObj) return;
52 myOldReference = myReference;
53//Disconnect();
54 myReference = anotherIObj ;
55}
56
57//=======================================================================
58//function : Connect
59//purpose :
60//=======================================================================
61void AIS_ConnectedInteractive::
62Connect(const Handle(AIS_InteractiveObject)& anotherIobj,
63 const TopLoc_Location& aLocation)
64{
65 if(myLocation!=aLocation)
66 myLocation = aLocation;
67 if(myReference!=anotherIobj) {
68 myOldReference = myReference; // necessaire pour pouvoir faire le disconnect en dessous..
69// Disconnect();
70 myReference = anotherIobj;}
71
72}
73
74
75//=======================================================================
76//function : Disconnect
77//purpose :
78//=======================================================================
79
80void AIS_ConnectedInteractive::Disconnect()
81{
82 for(Standard_Integer i =1;i<=myPresentations.Length();i++)
83 {
84 Handle(PrsMgr_Presentation3d) P = Handle(PrsMgr_Presentation3d)::DownCast(myPresentations(i).Presentation());
85 if(!P.IsNull()) {
86 P->Presentation()->DisconnectAll(Graphic3d_TOC_DESCENDANT);
87 }
88 }
89}
90//=======================================================================
91//function : Compute
92//purpose :
93//=======================================================================
94
95void AIS_ConnectedInteractive::
96Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
97 const Handle(Prs3d_Presentation)& aPresentation,
98 const Standard_Integer aMode)
99{
100 static Handle(Geom_Transformation) myPrsTrans ;
101
102 if(!(HasLocation() ||HasConnection())) return;
103
104 if(HasConnection()){
105 aPresentation->Clear(Standard_False);
106 aPresentation->RemoveAll();
107 aPresentationManager->Connect( this,myReference, aMode, aMode);
108 if(aPresentationManager->Presentation(myReference,aMode)->MustBeUpdated())
109 aPresentationManager->Update(myReference,aMode);
110
111 }
112 if(HasLocation()){
113 myPrsTrans = new Geom_Transformation(myLocation.Transformation());
114 aPresentationManager->Transform(this, myPrsTrans, aMode); }
115 aPresentation->ReCompute();
116}
117
118void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
119{
120// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
121 PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation ) ;
122}
123
124void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Prs3d_Presentation& aPresentation)
125{
126// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)");
127 PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
128}
129
130void AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d, const Handle_Graphic2d_GraphicObject& aGraphicObject, const int anInteger)
131{
132// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
133 PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
134}
135
136//=======================================================================
137//function : ComputeSelection
138//purpose :
139//=======================================================================
140void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
141 const Standard_Integer aMode)
142{
143 if(!(HasLocation() ||HasConnection())) return;
144
145 aSel->Clear();
146 if(!myReference->HasSelection(aMode))
147 myReference->UpdateSelection(aMode);
148
149
150// static OSD_Timer KronSel;
151// cout<<"debut calcul connexion primitives pour le mode "<<aMode<<endl;
152// KronSel.Reset();
153// KronSel.Start();
154
155 const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode);
156 Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this);
157 Handle(Select3D_SensitiveEntity) SE3D,SNew;
158
159 if(TheRefSel->IsEmpty())
160 myReference->UpdateSelection(aMode);
161 for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next()){
162 SE3D = *((Handle(Select3D_SensitiveEntity)*) &(TheRefSel->Sensitive()));
163 if(!SE3D.IsNull()){
164 SNew = SE3D->GetConnected(myLocation);
165 if(aMode==0)
166 SNew->Set(OWN);
167 aSel->Add(SNew);
168 }
169 }
170// KronSel.Stop();
171// cout<<"fin calcul connexion primitives pour le mode "<<aMode<<endl;
172// KronSel.Show();
173}
174
175void AIS_ConnectedInteractive::UpdateLocation()
176{
177// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()");
178 SelectMgr_SelectableObject::UpdateLocation() ;
179}
180void AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)
181{
182// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)");
183 SelectMgr_SelectableObject::UpdateLocation(Sel) ;
184}
185/*void AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation& aPresentation)
186{
187// Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation&)");
188 SelectMgr_SelectableObject::UpdateLocation(aPresentation) ;
189}*/