Commit | Line | Data |
---|---|---|
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 | //======================================================================= | |
23 | AIS_ConnectedInteractive::AIS_ConnectedInteractive(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d): | |
24 | AIS_InteractiveObject(aTypeOfPresentation3d) | |
25 | { | |
26 | SetHilightMode(0); | |
27 | } | |
28 | ||
29 | //======================================================================= | |
30 | //function : Type | |
31 | //purpose : | |
32 | //======================================================================= | |
33 | AIS_KindOfInteractive AIS_ConnectedInteractive::Type() const | |
34 | {return AIS_KOI_Object;} | |
35 | ||
36 | Standard_Integer AIS_ConnectedInteractive::Signature() const | |
37 | {return 0; } | |
38 | ||
39 | ||
40 | ||
41 | ||
42 | //======================================================================= | |
43 | //function : Connect | |
44 | //purpose : | |
45 | //======================================================================= | |
46 | void AIS_ConnectedInteractive:: | |
47 | Connect(const Handle(AIS_InteractiveObject)& anotherIObj) | |
48 | { | |
81bba717 | 49 | // To have the time to Disconnect below, |
50 | // the old is kept for a while. | |
7fd59977 | 51 | if(myReference==anotherIObj) return; |
52 | myOldReference = myReference; | |
53 | //Disconnect(); | |
54 | myReference = anotherIObj ; | |
55 | } | |
56 | ||
57 | //======================================================================= | |
58 | //function : Connect | |
59 | //purpose : | |
60 | //======================================================================= | |
61 | void AIS_ConnectedInteractive:: | |
62 | Connect(const Handle(AIS_InteractiveObject)& anotherIobj, | |
63 | const TopLoc_Location& aLocation) | |
64 | { | |
65 | if(myLocation!=aLocation) | |
66 | myLocation = aLocation; | |
67 | if(myReference!=anotherIobj) { | |
81bba717 | 68 | myOldReference = myReference; // necessary to disconnect below.. |
7fd59977 | 69 | // Disconnect(); |
70 | myReference = anotherIobj;} | |
71 | ||
72 | } | |
73 | ||
74 | ||
75 | //======================================================================= | |
76 | //function : Disconnect | |
77 | //purpose : | |
78 | //======================================================================= | |
79 | ||
80 | void 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 | ||
95 | void AIS_ConnectedInteractive:: | |
96 | Compute(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 | ||
118 | void 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 | ||
124 | void 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 | ||
130 | void 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 | //======================================================================= | |
ac04d101 SA |
140 | |
141 | void AIS_ConnectedInteractive::ComputeSelection(const Handle(SelectMgr_Selection)& aSel, | |
142 | const Standard_Integer aMode) | |
7fd59977 | 143 | { |
144 | if(!(HasLocation() ||HasConnection())) return; | |
145 | ||
146 | aSel->Clear(); | |
147 | if(!myReference->HasSelection(aMode)) | |
148 | myReference->UpdateSelection(aMode); | |
ac04d101 | 149 | |
7fd59977 | 150 | const Handle(SelectMgr_Selection)& TheRefSel = myReference->Selection(aMode); |
151 | Handle(SelectMgr_EntityOwner) OWN = new SelectMgr_EntityOwner(this); | |
ac04d101 | 152 | Handle(Select3D_SensitiveEntity) SE3D, SNew; |
7fd59977 | 153 | |
154 | if(TheRefSel->IsEmpty()) | |
155 | myReference->UpdateSelection(aMode); | |
ac04d101 SA |
156 | for(TheRefSel->Init();TheRefSel->More();TheRefSel->Next()) |
157 | { | |
158 | SE3D = Handle(Select3D_SensitiveEntity)::DownCast(TheRefSel->Sensitive()); | |
159 | if(!SE3D.IsNull()) | |
160 | { | |
161 | // Get the copy of SE3D | |
7fd59977 | 162 | SNew = SE3D->GetConnected(myLocation); |
163 | if(aMode==0) | |
ac04d101 SA |
164 | { |
165 | SNew->Set(OWN); | |
166 | // In case if SE3D caches some location-dependent data | |
167 | // that must be updated after setting OWN | |
168 | SNew->SetLocation(myLocation); | |
169 | } | |
7fd59977 | 170 | aSel->Add(SNew); |
171 | } | |
172 | } | |
7fd59977 | 173 | } |
174 | ||
175 | void AIS_ConnectedInteractive::UpdateLocation() | |
176 | { | |
177 | // Standard_NotImplemented::Raise("AIS_ConnectedInteractive::UpdateLocation()"); | |
178 | SelectMgr_SelectableObject::UpdateLocation() ; | |
179 | } | |
180 | void 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 | }*/ |