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>
7 #include <Standard_NotImplemented.hxx>
9 #include <AIS_ConnectedInteractive.ixx>
10 #include <SelectMgr_EntityOwner.hxx>
11 #include <Select3D_SensitiveEntity.hxx>
12 #include <Geom_Transformation.hxx>
14 #include <PrsMgr_ModedPresentation.hxx>
15 #include <PrsMgr_Presentation3d.hxx>
16 #include <OSD_Timer.hxx>
19 //=======================================================================
20 //function : AIS_ConnectedInteractive
22 //=======================================================================
23 AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d):
24 AIS_InteractiveObject(aTypeOfPresentation3d)
29 //=======================================================================
32 //=======================================================================
33 AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const
34 {return AIS_KOI_Object;}
36 Standard_Integer AIS_ConnectedInteractive::Signature() const
42 //=======================================================================
45 //=======================================================================
46 void AIS_ConnectedInteractive::
47 Connect(const Handle(AIS_InteractiveObject)& anotherIObj)
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;
54 myReference = anotherIObj ;
57 //=======================================================================
60 //=======================================================================
61 void AIS_ConnectedInteractive::
62 Connect(const Handle(AIS_InteractiveObject)& anotherIobj,
63 const TopLoc_Location& aLocation)
65 if(myLocation!=aLocation)
66 myLocation = aLocation;
67 if(myReference!=anotherIobj) {
68 myOldReference = myReference; // necessaire pour pouvoir faire le disconnect en dessous..
70 myReference = anotherIobj;}
75 //=======================================================================
76 //function : Disconnect
78 //=======================================================================
80 void AIS_ConnectedInteractive::Disconnect()
82 for(Standard_Integer i =1;i<=myPresentations.Length();i++)
84 Handle(PrsMgr_Presentation3d) P = Handle(PrsMgr_Presentation3d)::DownCast(myPresentations(i).Presentation());
86 P->Presentation()->DisconnectAll(Graphic3d_TOC_DESCENDANT);
90 //=======================================================================
93 //=======================================================================
95 void AIS_ConnectedInteractive::
96 Compute(const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
97 const Handle(Prs3d_Presentation)& aPresentation,
98 const Standard_Integer aMode)
100 static Handle(Geom_Transformation) myPrsTrans ;
102 if(!(HasLocation() ||HasConnection())) return;
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);
113 myPrsTrans = new Geom_Transformation(myLocation.Transformation());
114 aPresentationManager->Transform(this, myPrsTrans, aMode); }
115 aPresentation->ReCompute();
118 void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation)
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 ) ;
124 void AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Prs3d_Presentation& aPresentation)
126 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_Prs3d_Projector&, const Handle_Prs3d_Presentation&)");
127 PrsMgr_PresentableObject::Compute( aProjector , aPresentation ) ;
130 void AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d& aPresentationManager2d, const Handle_Graphic2d_GraphicObject& aGraphicObject, const int anInteger)
132 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::Compute(const Handle_PrsMgr_PresentationManager2d&, const Handle_Graphic2d_GraphicObject&, const int)");
133 PrsMgr_PresentableObject::Compute( aPresentationManager2d ,aGraphicObject,anInteger) ;
136 //=======================================================================
137 //function : ComputeSelection
139 //=======================================================================
140 void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel,
141 const Standard_Integer aMode)
143 if(!(HasLocation() ||HasConnection())) return;
146 if(!myReference->HasSelection(aMode))
147 myReference->UpdateSelection(aMode);
150 // static OSD_Timer KronSel;
151 // cout<<"debut calcul connexion primitives pour le mode "<<aMode<<endl;
155 const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode);
156 Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this);
157 Handle(Select3D_SensitiveEntity) SE3D,SNew;
159 if(TheRefSel->IsEmpty())
160 myReference->UpdateSelection(aMode);
161 for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next()){
162 SE3D = *((Handle(Select3D_SensitiveEntity)*) &(TheRefSel->Sensitive()));
164 SNew = SE3D->GetConnected(myLocation);
171 // cout<<"fin calcul connexion primitives pour le mode "<<aMode<<endl;
175 void AIS_ConnectedInteractive::UpdateLocation()
177 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()");
178 SelectMgr_SelectableObject::UpdateLocation() ;
180 void AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)
182 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle(SelectMgr_Selection)& Sel)");
183 SelectMgr_SelectableObject::UpdateLocation(Sel) ;
185 /*void AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation& aPresentation)
187 // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation(const Handle_Prs3d_Presentation&)");
188 SelectMgr_SelectableObject::UpdateLocation(aPresentation) ;