b311480e |
1 | // Created on: 1997-01-17 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
d94bed0e |
17 | #include <AIS_InteractiveContext.hxx> |
2ec85268 |
18 | |
42cf5bc1 |
19 | #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx> |
d94bed0e |
20 | #include <AIS_ConnectedInteractive.hxx> |
7fd59977 |
21 | #include <AIS_GlobalStatus.hxx> |
42cf5bc1 |
22 | #include <AIS_InteractiveObject.hxx> |
23 | #include <AIS_ListIteratorOfListOfInteractive.hxx> |
7fd59977 |
24 | #include <AIS_MapIteratorOfMapOfInteractive.hxx> |
42cf5bc1 |
25 | #include <AIS_MultipleConnectedInteractive.hxx> |
7fd59977 |
26 | #include <AIS_Shape.hxx> |
42cf5bc1 |
27 | #include <AIS_Trihedron.hxx> |
28 | #include <Geom_Axis2Placement.hxx> |
7fd59977 |
29 | #include <Graphic3d_AspectFillArea3d.hxx> |
30 | #include <HLRBRep.hxx> |
42cf5bc1 |
31 | #include <OSD_Environment.hxx> |
32 | #include <Precision.hxx> |
33 | #include <Prs3d_BasicAspect.hxx> |
7fd59977 |
34 | #include <Prs3d_DatumAspect.hxx> |
42cf5bc1 |
35 | #include <Prs3d_IsoAspect.hxx> |
36 | #include <Prs3d_LineAspect.hxx> |
7fd59977 |
37 | #include <Prs3d_PlaneAspect.hxx> |
f838dac4 |
38 | #include <Prs3d_PointAspect.hxx> |
42cf5bc1 |
39 | #include <Prs3d_ShadingAspect.hxx> |
40 | #include <PrsMgr_ModedPresentation.hxx> |
7fd59977 |
41 | #include <PrsMgr_PresentableObject.hxx> |
42cf5bc1 |
42 | #include <Quantity_Color.hxx> |
43 | #include <SelectMgr_EntityOwner.hxx> |
44 | #include <SelectMgr_Filter.hxx> |
45 | #include <SelectMgr_OrFilter.hxx> |
46 | #include <SelectMgr_SelectionManager.hxx> |
e33e7e78 |
47 | #include <Standard_Atomic.hxx> |
42cf5bc1 |
48 | #include <Standard_Transient.hxx> |
49 | #include <Standard_Type.hxx> |
f751596e |
50 | #include <StdSelect_ViewerSelector3d.hxx> |
42cf5bc1 |
51 | #include <TCollection_AsciiString.hxx> |
52 | #include <TCollection_ExtendedString.hxx> |
53 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
54 | #include <TColStd_MapIteratorOfMapOfTransient.hxx> |
55 | #include <TopLoc_Location.hxx> |
56 | #include <TopoDS_Shape.hxx> |
7fd59977 |
57 | #include <UnitsAPI.hxx> |
42cf5bc1 |
58 | #include <V3d_View.hxx> |
59 | #include <V3d_Viewer.hxx> |
7fd59977 |
60 | |
2ec85268 |
61 | IMPLEMENT_STANDARD_RTTIEXT(AIS_InteractiveContext, Standard_Transient) |
92efcf78 |
62 | |
e33e7e78 |
63 | namespace |
7fd59977 |
64 | { |
b586500b |
65 | typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)> AIS_MapOfObjectOwners; |
66 | typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject), Handle(SelectMgr_IndexedMapOfOwner)>::Iterator AIS_MapIteratorOfMapOfObjectOwners; |
f838dac4 |
67 | |
68 | //! Initialize default highlighting attributes. |
69 | static void initDefaultHilightAttributes (const Handle(Prs3d_Drawer)& theDrawer) |
70 | { |
71 | theDrawer->SetMethod (Aspect_TOHM_COLOR); |
72 | theDrawer->SetDisplayMode (0); |
73 | |
74 | theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0)); |
75 | *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect(); |
76 | theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
77 | *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect(); |
78 | theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
79 | *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect(); |
80 | theDrawer->SetPlaneAspect (new Prs3d_PlaneAspect()); |
81 | *theDrawer->PlaneAspect()->EdgesAspect() = *theDrawer->Link()->PlaneAspect()->EdgesAspect(); |
82 | theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
83 | *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect(); |
84 | theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0)); |
85 | *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect(); |
86 | |
87 | theDrawer->WireAspect()->SetWidth (2.0); |
88 | theDrawer->LineAspect()->SetWidth (2.0); |
89 | theDrawer->PlaneAspect()->EdgesAspect()->SetWidth (2.0); |
90 | theDrawer->FreeBoundaryAspect() ->SetWidth (2.0); |
91 | theDrawer->UnFreeBoundaryAspect()->SetWidth (2.0); |
92 | theDrawer->PointAspect()->SetTypeOfMarker (Aspect_TOM_O_POINT); |
93 | theDrawer->PointAspect()->SetScale (2.0); |
94 | |
95 | // the triangulation should be computed using main presentation attributes, |
96 | // and should not be overridden by highlighting |
97 | theDrawer->SetAutoTriangulation (Standard_False); |
98 | } |
2195ab96 |
99 | } |
7fd59977 |
100 | |
101 | //======================================================================= |
102 | //function : AIS_InteractiveContext |
103 | //purpose : |
104 | //======================================================================= |
105 | |
106 | AIS_InteractiveContext::AIS_InteractiveContext(const Handle(V3d_Viewer)& MainViewer): |
c357e426 |
107 | myMainPM(new PrsMgr_PresentationManager3d(MainViewer->StructureManager())), |
7fd59977 |
108 | myMainVwr(MainViewer), |
109 | myMainSel(new StdSelect_ViewerSelector3d()), |
cbff1e55 |
110 | myWasLastMain(Standard_False), |
cbff1e55 |
111 | myToHilightSelected(Standard_True), |
f838dac4 |
112 | mySelection(new AIS_Selection()), |
7fd59977 |
113 | myFilters(new SelectMgr_OrFilter()), |
114 | myDefaultDrawer(new Prs3d_Drawer()), |
f0cddd16 |
115 | myCurDetected(0), |
116 | myCurHighlighted(0), |
14c4193d |
117 | myPickingStrategy (SelectMgr_PickingStrategy_FirstAcceptable), |
68dcee02 |
118 | myAutoHilight(Standard_True), |
016e5959 |
119 | myIsAutoActivateSelMode(Standard_True) |
f838dac4 |
120 | { |
68dcee02 |
121 | mgrSelector = new SelectMgr_SelectionManager (myMainSel); |
122 | |
f838dac4 |
123 | myStyles[Prs3d_TypeOfHighlight_None] = myDefaultDrawer; |
124 | myStyles[Prs3d_TypeOfHighlight_Selected] = new Prs3d_Drawer(); |
125 | myStyles[Prs3d_TypeOfHighlight_Dynamic] = new Prs3d_Drawer(); |
126 | myStyles[Prs3d_TypeOfHighlight_LocalSelected] = new Prs3d_Drawer(); |
127 | myStyles[Prs3d_TypeOfHighlight_LocalDynamic] = new Prs3d_Drawer(); |
128 | myStyles[Prs3d_TypeOfHighlight_SubIntensity] = new Prs3d_Drawer(); |
129 | |
130 | myDefaultDrawer->SetZLayer(Graphic3d_ZLayerId_Default); |
131 | myDefaultDrawer->SetDisplayMode(0); |
132 | { |
133 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Dynamic]; |
134 | aStyle->Link (myDefaultDrawer); |
135 | initDefaultHilightAttributes (aStyle); |
136 | aStyle->SetZLayer(Graphic3d_ZLayerId_Top); |
137 | aStyle->SetColor (Quantity_NOC_CYAN1); |
138 | } |
139 | { |
140 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalDynamic]; |
141 | aStyle->Link (myDefaultDrawer); |
142 | initDefaultHilightAttributes (aStyle); |
143 | aStyle->SetZLayer(Graphic3d_ZLayerId_Topmost); |
144 | aStyle->SetColor (Quantity_NOC_CYAN1); |
145 | } |
146 | { |
147 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_Selected]; |
148 | aStyle->Link (myDefaultDrawer); |
149 | initDefaultHilightAttributes (aStyle); |
150 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
151 | aStyle->SetColor (Quantity_NOC_GRAY80); |
152 | } |
153 | { |
154 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_LocalSelected]; |
155 | aStyle->Link (myDefaultDrawer); |
156 | initDefaultHilightAttributes (aStyle); |
157 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
158 | aStyle->SetColor (Quantity_NOC_GRAY80); |
159 | } |
160 | { |
161 | const Handle(Prs3d_Drawer)& aStyle = myStyles[Prs3d_TypeOfHighlight_SubIntensity]; |
162 | aStyle->SetZLayer(Graphic3d_ZLayerId_UNKNOWN); |
163 | aStyle->SetMethod(Aspect_TOHM_COLOR); |
164 | aStyle->SetColor (Quantity_NOC_GRAY40); |
165 | } |
166 | |
7fd59977 |
167 | InitAttributes(); |
168 | } |
169 | |
2ec85268 |
170 | //======================================================================= |
171 | //function : ~AIS_InteractiveContext |
172 | //purpose : |
173 | //======================================================================= |
174 | AIS_InteractiveContext::~AIS_InteractiveContext() |
7fd59977 |
175 | { |
016e5959 |
176 | // clear the current selection |
02974a19 |
177 | mySelection->Clear(); |
68dcee02 |
178 | mgrSelector.Nullify(); |
2195ab96 |
179 | |
da0e82aa |
180 | Handle(AIS_InteractiveContext) aNullContext; |
2195ab96 |
181 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
da0e82aa |
182 | { |
b5cce1ab |
183 | const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key(); |
2195ab96 |
184 | anObj->SetContext (aNullContext); |
b5cce1ab |
185 | for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next()) |
c3282ec1 |
186 | { |
b5cce1ab |
187 | aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Renew); |
c3282ec1 |
188 | } |
da0e82aa |
189 | } |
7fd59977 |
190 | } |
191 | |
7fd59977 |
192 | //======================================================================= |
193 | //function : UpdateCurrentViewer |
194 | //purpose : |
195 | //======================================================================= |
196 | |
197 | void AIS_InteractiveContext::UpdateCurrentViewer() |
198 | { |
199 | if (!myMainVwr.IsNull()) |
200 | myMainVwr->Update(); |
201 | } |
202 | |
7fd59977 |
203 | //======================================================================= |
204 | //function : DisplayedObjects |
2195ab96 |
205 | //purpose : |
7fd59977 |
206 | //======================================================================= |
68dcee02 |
207 | void AIS_InteractiveContext::DisplayedObjects (AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
208 | { |
2195ab96 |
209 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
210 | { |
211 | if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed) |
212 | { |
68dcee02 |
213 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
214 | } |
2195ab96 |
215 | } |
7fd59977 |
216 | } |
2195ab96 |
217 | |
7fd59977 |
218 | //======================================================================= |
219 | //function : DisplayedObjects |
2195ab96 |
220 | //purpose : |
7fd59977 |
221 | //======================================================================= |
2195ab96 |
222 | void AIS_InteractiveContext::DisplayedObjects (const AIS_KindOfInteractive theKind, |
223 | const Standard_Integer theSign, |
68dcee02 |
224 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
225 | { |
2195ab96 |
226 | ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Displayed, theListOfIO); |
7fd59977 |
227 | } |
228 | |
7fd59977 |
229 | //======================================================================= |
230 | //function : ErasedObjects |
2195ab96 |
231 | //purpose : |
7fd59977 |
232 | //======================================================================= |
2195ab96 |
233 | void AIS_InteractiveContext::ErasedObjects (AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
234 | { |
2195ab96 |
235 | ObjectsByDisplayStatus (AIS_DS_Erased, theListOfIO); |
7fd59977 |
236 | } |
237 | |
238 | //======================================================================= |
239 | //function : ErasedObjects |
2195ab96 |
240 | //purpose : |
7fd59977 |
241 | //======================================================================= |
2195ab96 |
242 | void AIS_InteractiveContext::ErasedObjects (const AIS_KindOfInteractive theKind, |
243 | const Standard_Integer theSign, |
244 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
245 | { |
2195ab96 |
246 | ObjectsByDisplayStatus (theKind, theSign, AIS_DS_Erased, theListOfIO); |
7fd59977 |
247 | } |
248 | |
249 | //======================================================================= |
250 | //function : ObjectsByDisplayStatus |
2195ab96 |
251 | //purpose : |
7fd59977 |
252 | //======================================================================= |
2195ab96 |
253 | void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_DisplayStatus theStatus, |
254 | AIS_ListOfInteractive& theListOfIO) const |
7fd59977 |
255 | { |
2195ab96 |
256 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
257 | { |
258 | if (anObjIter.Value()->GraphicStatus() == theStatus) |
259 | { |
260 | theListOfIO.Append (anObjIter.Key()); |
261 | } |
7fd59977 |
262 | } |
263 | } |
264 | |
265 | //======================================================================= |
266 | //function : ObjectsByDisplayStatus |
2195ab96 |
267 | //purpose : |
7fd59977 |
268 | //======================================================================= |
2195ab96 |
269 | void AIS_InteractiveContext::ObjectsByDisplayStatus (const AIS_KindOfInteractive theKind, |
270 | const Standard_Integer theSign, |
271 | const AIS_DisplayStatus theStatus, |
272 | AIS_ListOfInteractive& theListOfIO) const |
273 | { |
274 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
275 | { |
a1954302 |
276 | if (theStatus != AIS_DS_None |
277 | && anObjIter.Value()->GraphicStatus() != theStatus) |
278 | { |
279 | continue; |
280 | } |
281 | else if (anObjIter.Key()->Type() != theKind) |
2195ab96 |
282 | { |
283 | continue; |
284 | } |
7fd59977 |
285 | |
2195ab96 |
286 | if (theSign == -1 |
287 | || anObjIter.Key()->Signature() == theSign) |
288 | { |
289 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
290 | } |
291 | } |
292 | } |
293 | |
294 | //======================================================================= |
295 | //function : ObjectsInside |
2195ab96 |
296 | //purpose : |
7fd59977 |
297 | //======================================================================= |
2195ab96 |
298 | void AIS_InteractiveContext::ObjectsInside (AIS_ListOfInteractive& theListOfIO, |
299 | const AIS_KindOfInteractive theKind, |
300 | const Standard_Integer theSign) const |
7fd59977 |
301 | { |
2195ab96 |
302 | if (theKind == AIS_KOI_None |
303 | && theSign == -1) |
304 | { |
305 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
306 | { |
307 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
308 | } |
2195ab96 |
309 | return; |
7fd59977 |
310 | } |
2195ab96 |
311 | |
312 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
313 | { |
314 | if (anObjIter.Key()->Type() != theKind) |
315 | { |
316 | continue; |
317 | } |
318 | |
319 | if (theSign == -1 |
320 | || anObjIter.Key()->Signature() == theSign) |
321 | { |
322 | theListOfIO.Append (anObjIter.Key()); |
7fd59977 |
323 | } |
324 | } |
325 | } |
326 | |
a272ed94 |
327 | //======================================================================= |
328 | //function : ObjectsForView |
329 | //purpose : |
330 | //======================================================================= |
331 | void AIS_InteractiveContext::ObjectsForView (AIS_ListOfInteractive& theListOfIO, |
332 | const Handle(V3d_View)& theView, |
333 | const Standard_Boolean theIsVisibleInView, |
334 | const AIS_DisplayStatus theStatus) const |
335 | { |
c357e426 |
336 | Handle(Graphic3d_CView) aViewImpl = theView->View(); |
337 | const Standard_Integer aViewId = aViewImpl->Identification(); |
a272ed94 |
338 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
339 | { |
340 | if (theStatus != AIS_DS_None |
341 | && anObjIter.Value()->GraphicStatus() != theStatus) |
342 | { |
343 | theListOfIO.Append (anObjIter.Key()); |
344 | continue; |
345 | } |
346 | |
c357e426 |
347 | Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (anObjIter.Key()); |
a272ed94 |
348 | const Standard_Boolean isVisible = anAffinity->IsVisible (aViewId); |
349 | if (isVisible == theIsVisibleInView) |
350 | { |
351 | theListOfIO.Append (anObjIter.Key()); |
352 | } |
353 | } |
354 | } |
355 | |
7fd59977 |
356 | //======================================================================= |
357 | //function : Display |
2195ab96 |
358 | //purpose : |
7fd59977 |
359 | //======================================================================= |
2195ab96 |
360 | void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj, |
361 | const Standard_Boolean theToUpdateViewer) |
362 | { |
363 | if (theIObj.IsNull()) |
364 | { |
365 | return; |
366 | } |
367 | |
368 | Standard_Integer aDispMode = 0, aHiMod = -1, aSelMode = -1; |
369 | GetDefModes (theIObj, aDispMode, aHiMod, aSelMode); |
68dcee02 |
370 | Display (theIObj, aDispMode, myIsAutoActivateSelMode ? aSelMode : -1, theToUpdateViewer); |
2195ab96 |
371 | } |
7fd59977 |
372 | |
a272ed94 |
373 | //======================================================================= |
374 | //function : SetViewAffinity |
375 | //purpose : |
376 | //======================================================================= |
377 | void AIS_InteractiveContext::SetViewAffinity (const Handle(AIS_InteractiveObject)& theIObj, |
378 | const Handle(V3d_View)& theView, |
379 | const Standard_Boolean theIsVisible) |
380 | { |
381 | if (theIObj.IsNull() |
382 | || !myObjects.IsBound (theIObj)) |
383 | { |
384 | return; |
385 | } |
386 | |
c357e426 |
387 | Handle(Graphic3d_ViewAffinity) anAffinity = myMainVwr->StructureManager()->ObjectAffinity (theIObj); |
388 | Handle(Graphic3d_CView) aViewImpl = theView->View(); |
389 | anAffinity->SetVisible (aViewImpl->Identification(), theIsVisible == Standard_True); |
a272ed94 |
390 | if (theIsVisible) |
391 | { |
c04c30b3 |
392 | theView->View()->ChangeHiddenObjects()->Remove (theIObj.get()); |
a272ed94 |
393 | } |
394 | else |
395 | { |
c04c30b3 |
396 | theView->View()->ChangeHiddenObjects()->Add (theIObj.get()); |
a272ed94 |
397 | } |
398 | } |
399 | |
2195ab96 |
400 | //======================================================================= |
401 | //function : Display |
402 | //purpose : |
403 | //======================================================================= |
404 | void AIS_InteractiveContext::Display (const Handle(AIS_InteractiveObject)& theIObj, |
405 | const Standard_Integer theDispMode, |
406 | const Standard_Integer theSelectionMode, |
407 | const Standard_Boolean theToUpdateViewer, |
a1954302 |
408 | const AIS_DisplayStatus theDispStatus) |
7fd59977 |
409 | { |
2195ab96 |
410 | if (theIObj.IsNull()) |
411 | { |
412 | return; |
413 | } |
7fd59977 |
414 | |
a1954302 |
415 | if (theDispStatus == AIS_DS_Erased) |
416 | { |
417 | Erase (theIObj, theToUpdateViewer); |
68dcee02 |
418 | Load (theIObj, theSelectionMode); |
6194ee76 |
419 | if (Handle(AIS_GlobalStatus)* aStatusPtr = myObjects.ChangeSeek (theIObj)) |
420 | { |
421 | (*aStatusPtr)->SetDisplayMode (theDispMode); |
422 | } |
a1954302 |
423 | return; |
424 | } |
425 | |
2ec85268 |
426 | setContextToObject (theIObj); |
2195ab96 |
427 | if (!myObjects.IsBound (theIObj)) |
428 | { |
429 | Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Displayed, theDispMode, theSelectionMode); |
430 | myObjects.Bind (theIObj, aStatus); |
6194ee76 |
431 | myMainVwr->StructureManager()->RegisterObject (theIObj); |
2195ab96 |
432 | myMainPM->Display(theIObj, theDispMode); |
433 | if (theSelectionMode != -1) |
434 | { |
543a9964 |
435 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
436 | if (!mgrSelector->Contains (anObj)) |
2195ab96 |
437 | { |
438 | mgrSelector->Load (theIObj); |
7fd59977 |
439 | } |
68dcee02 |
440 | mgrSelector->Activate (theIObj, theSelectionMode); |
2195ab96 |
441 | } |
7fd59977 |
442 | } |
7fd59977 |
443 | else |
444 | { |
2195ab96 |
445 | Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); |
a6964ce6 |
446 | |
f2b63181 |
447 | // Mark the presentation modes hidden of interactive object different from aDispMode. |
2195ab96 |
448 | // Then make sure aDispMode is displayed and maybe highlighted. |
449 | // Finally, activate selection mode <SelMode> if not yet activated. |
3db69e41 |
450 | const Standard_Integer anOldMode = aStatus->DisplayMode(); |
451 | if (anOldMode != theDispMode) |
2195ab96 |
452 | { |
3db69e41 |
453 | if(myMainPM->IsHighlighted (theIObj, anOldMode)) |
2195ab96 |
454 | { |
f838dac4 |
455 | unhighlightGlobal (theIObj); |
2195ab96 |
456 | } |
3db69e41 |
457 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
2195ab96 |
458 | } |
7fd59977 |
459 | |
3db69e41 |
460 | aStatus->SetDisplayMode (theDispMode); |
7fd59977 |
461 | |
2195ab96 |
462 | myMainPM->Display (theIObj, theDispMode); |
a1954302 |
463 | aStatus->SetGraphicStatus (AIS_DS_Displayed); |
2195ab96 |
464 | if (aStatus->IsHilighted()) |
465 | { |
f838dac4 |
466 | highlightGlobal (theIObj, aStatus->HilightStyle(), theDispMode); |
2195ab96 |
467 | } |
468 | if (theSelectionMode != -1) |
469 | { |
543a9964 |
470 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
471 | if (!mgrSelector->Contains (anObj)) |
2195ab96 |
472 | { |
473 | mgrSelector->Load (theIObj); |
7fd59977 |
474 | } |
2195ab96 |
475 | if (!mgrSelector->IsActivated (theIObj, theSelectionMode)) |
476 | { |
0824e32e |
477 | if (!aStatus->IsSModeIn (theSelectionMode)) |
478 | aStatus->AddSelectionMode (theSelectionMode); |
68dcee02 |
479 | mgrSelector->Activate (theIObj, theSelectionMode); |
7fd59977 |
480 | } |
7fd59977 |
481 | } |
482 | } |
7fd59977 |
483 | |
2195ab96 |
484 | if (theToUpdateViewer) |
485 | { |
486 | myMainVwr->Update(); |
487 | } |
488 | } |
7fd59977 |
489 | |
490 | //======================================================================= |
491 | //function : Load |
2195ab96 |
492 | //purpose : |
7fd59977 |
493 | //======================================================================= |
2195ab96 |
494 | void AIS_InteractiveContext::Load (const Handle(AIS_InteractiveObject)& theIObj, |
68dcee02 |
495 | const Standard_Integer theSelMode) |
7fd59977 |
496 | { |
2195ab96 |
497 | if (theIObj.IsNull()) |
498 | { |
499 | return; |
500 | } |
7fd59977 |
501 | |
2ec85268 |
502 | setContextToObject (theIObj); |
6194ee76 |
503 | if (!myObjects.IsBound (theIObj)) |
2195ab96 |
504 | { |
6194ee76 |
505 | Standard_Integer aDispMode, aHiMod, aSelModeDef; |
506 | GetDefModes (theIObj, aDispMode, aHiMod, aSelModeDef); |
507 | Handle(AIS_GlobalStatus) aStatus = new AIS_GlobalStatus (AIS_DS_Erased, aDispMode, theSelMode != -1 ? theSelMode : aSelModeDef); |
508 | myObjects.Bind (theIObj, aStatus); |
509 | myMainVwr->StructureManager()->RegisterObject (theIObj); |
510 | } |
89cc29b0 |
511 | |
6194ee76 |
512 | // Register theIObj in the selection manager to prepare further activation of selection |
513 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
514 | if (!mgrSelector->Contains (anObj)) |
515 | { |
516 | mgrSelector->Load (theIObj); |
2195ab96 |
517 | } |
518 | } |
7fd59977 |
519 | |
520 | //======================================================================= |
521 | //function : Erase |
2195ab96 |
522 | //purpose : |
7fd59977 |
523 | //======================================================================= |
2195ab96 |
524 | void AIS_InteractiveContext::Erase (const Handle(AIS_InteractiveObject)& theIObj, |
525 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
526 | { |
2195ab96 |
527 | if (theIObj.IsNull()) |
528 | { |
529 | return; |
530 | } |
7fd59977 |
531 | |
2195ab96 |
532 | if (!theIObj->IsAutoHilight()) |
533 | { |
534 | theIObj->ClearSelected(); |
7fd59977 |
535 | } |
2195ab96 |
536 | |
68dcee02 |
537 | EraseGlobal (theIObj, Standard_False); |
2195ab96 |
538 | if (theToUpdateViewer) |
539 | { |
540 | myMainVwr->Update(); |
541 | } |
7fd59977 |
542 | } |
7fd59977 |
543 | |
544 | //======================================================================= |
545 | //function : EraseAll |
2195ab96 |
546 | //purpose : |
7fd59977 |
547 | //======================================================================= |
2195ab96 |
548 | void AIS_InteractiveContext::EraseAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
549 | { |
2195ab96 |
550 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
551 | { |
552 | if (anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
553 | { |
2195ab96 |
554 | Erase (anObjIter.Key(), Standard_False); |
7fd59977 |
555 | } |
556 | } |
2195ab96 |
557 | |
558 | if (theToUpdateViewer) |
559 | { |
560 | myMainVwr->Update(); |
561 | } |
7fd59977 |
562 | } |
563 | |
564 | //======================================================================= |
565 | //function : DisplayAll |
2195ab96 |
566 | //purpose : |
7fd59977 |
567 | //======================================================================= |
2195ab96 |
568 | void AIS_InteractiveContext::DisplayAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
569 | { |
2195ab96 |
570 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
571 | { |
572 | const AIS_DisplayStatus aStatus = anObjIter.Value()->GraphicStatus(); |
573 | if (aStatus == AIS_DS_Erased) |
eb4320f2 |
574 | { |
2195ab96 |
575 | Display (anObjIter.Key(), Standard_False); |
7fd59977 |
576 | } |
577 | } |
2195ab96 |
578 | |
579 | if (theToUpdateViewer) |
580 | { |
581 | myMainVwr->Update(); |
582 | } |
7fd59977 |
583 | } |
584 | |
585 | //======================================================================= |
586 | //function : DisplaySelected |
2195ab96 |
587 | //purpose : |
7fd59977 |
588 | //======================================================================= |
2195ab96 |
589 | void AIS_InteractiveContext::DisplaySelected (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
590 | { |
b5cce1ab |
591 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
2195ab96 |
592 | { |
b5cce1ab |
593 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2195ab96 |
594 | Display (anObj, Standard_False); |
2195ab96 |
595 | } |
7fd59977 |
596 | |
b5cce1ab |
597 | if (theToUpdateViewer && !mySelection->Objects().IsEmpty()) |
2195ab96 |
598 | { |
599 | myMainVwr->Update(); |
600 | } |
601 | } |
7fd59977 |
602 | |
2195ab96 |
603 | //======================================================================= |
604 | //function : EraseSelected |
605 | //purpose : |
606 | //======================================================================= |
607 | void AIS_InteractiveContext::EraseSelected (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
608 | { |
b5cce1ab |
609 | Standard_Boolean isFound = Standard_False; |
610 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Init (mySelection->Objects())) |
2195ab96 |
611 | { |
b5cce1ab |
612 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2195ab96 |
613 | Erase (anObj, Standard_False); |
614 | isFound = Standard_True; |
615 | } |
616 | |
617 | if (isFound && theToUpdateViewer) |
618 | { |
619 | myMainVwr->Update(); |
7fd59977 |
620 | } |
621 | } |
2195ab96 |
622 | |
7fd59977 |
623 | //======================================================================= |
2195ab96 |
624 | //function : DisplayStatus |
625 | //purpose : |
7fd59977 |
626 | //======================================================================= |
2195ab96 |
627 | AIS_DisplayStatus AIS_InteractiveContext::DisplayStatus (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
628 | { |
2195ab96 |
629 | if (theIObj.IsNull()) |
630 | { |
631 | return AIS_DS_None; |
632 | } |
68dcee02 |
633 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
634 | return aStatus != NULL ? (*aStatus)->GraphicStatus() : AIS_DS_None; |
7fd59977 |
635 | } |
636 | |
7fd59977 |
637 | //======================================================================= |
638 | //function : Remove |
2195ab96 |
639 | //purpose : |
7fd59977 |
640 | //======================================================================= |
2195ab96 |
641 | void AIS_InteractiveContext::Remove (const Handle(AIS_InteractiveObject)& theIObj, |
642 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
643 | { |
2195ab96 |
644 | if (theIObj.IsNull()) |
645 | { |
646 | return; |
7fd59977 |
647 | } |
2195ab96 |
648 | |
2ec85268 |
649 | if (theIObj->HasInteractiveContext()) |
650 | { |
651 | if (theIObj->myCTXPtr != this) |
652 | { |
9775fa61 |
653 | throw Standard_ProgramError("AIS_InteractiveContext - object has been displayed in another context!"); |
2ec85268 |
654 | } |
655 | theIObj->SetContext (Handle(AIS_InteractiveContext)()); |
656 | } |
2195ab96 |
657 | ClearGlobal (theIObj, theToUpdateViewer); |
7fd59977 |
658 | } |
659 | |
660 | //======================================================================= |
661 | //function : RemoveAll |
2195ab96 |
662 | //purpose : |
7fd59977 |
663 | //======================================================================= |
2195ab96 |
664 | void AIS_InteractiveContext::RemoveAll (const Standard_Boolean theToUpdateViewer) |
7fd59977 |
665 | { |
666 | AIS_ListOfInteractive aList; |
2195ab96 |
667 | ObjectsInside (aList); |
668 | for (AIS_ListIteratorOfListOfInteractive aListIterator (aList); aListIterator.More(); aListIterator.Next()) |
669 | { |
670 | Remove (aListIterator.Value(), Standard_False); |
7fd59977 |
671 | } |
7fd59977 |
672 | |
2195ab96 |
673 | if (theToUpdateViewer) |
674 | { |
675 | myMainVwr->Update(); |
7fd59977 |
676 | } |
7fd59977 |
677 | } |
678 | |
7fd59977 |
679 | //======================================================================= |
8e5fb5ea |
680 | //function : HilightWithColor |
681 | //purpose : |
7fd59977 |
682 | //======================================================================= |
8e5fb5ea |
683 | void AIS_InteractiveContext::HilightWithColor(const Handle(AIS_InteractiveObject)& theObj, |
f838dac4 |
684 | const Handle(Prs3d_Drawer)& theStyle, |
8e5fb5ea |
685 | const Standard_Boolean theIsToUpdate) |
7fd59977 |
686 | { |
8e5fb5ea |
687 | if (theObj.IsNull()) |
2195ab96 |
688 | return; |
7fd59977 |
689 | |
2ec85268 |
690 | setContextToObject (theObj); |
68dcee02 |
691 | if (!myObjects.IsBound (theObj)) |
692 | return; |
eb4320f2 |
693 | |
68dcee02 |
694 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theObj); |
695 | aStatus->SetHilightStatus (Standard_True); |
8e5fb5ea |
696 | |
68dcee02 |
697 | if (aStatus->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
698 | { |
68dcee02 |
699 | highlightGlobal (theObj, theStyle, aStatus->DisplayMode()); |
700 | aStatus->SetHilightStyle (theStyle); |
eb4320f2 |
701 | } |
702 | |
8e5fb5ea |
703 | if (theIsToUpdate) |
2195ab96 |
704 | myMainVwr->Update(); |
7fd59977 |
705 | } |
706 | |
707 | //======================================================================= |
708 | //function : Unhilight |
709 | //purpose : |
710 | //======================================================================= |
7fd59977 |
711 | void AIS_InteractiveContext::Unhilight(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer) |
712 | { |
713 | if(anIObj.IsNull()) return; |
68dcee02 |
714 | if(!myObjects.IsBound(anIObj)) return; |
7fd59977 |
715 | |
68dcee02 |
716 | const Handle(AIS_GlobalStatus)& aStatus = myObjects(anIObj); |
717 | aStatus->SetHilightStatus (Standard_False); |
718 | aStatus->SetHilightStyle (Handle(Prs3d_Drawer)()); |
eb4320f2 |
719 | |
68dcee02 |
720 | if (aStatus->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
721 | { |
68dcee02 |
722 | unhighlightGlobal (anIObj); |
eb4320f2 |
723 | } |
68dcee02 |
724 | |
7fd59977 |
725 | if(updateviewer) myMainVwr->Update(); |
726 | } |
727 | |
728 | //======================================================================= |
729 | //function : IsHilighted |
8e5fb5ea |
730 | //purpose : Returns true if the objects global status is set to highlighted. |
7fd59977 |
731 | //======================================================================= |
8e5fb5ea |
732 | Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(AIS_InteractiveObject)& theObj) const |
7fd59977 |
733 | { |
68dcee02 |
734 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
735 | return aStatus != NULL |
736 | && (*aStatus)->IsHilighted(); |
7fd59977 |
737 | } |
738 | |
c3282ec1 |
739 | //======================================================================= |
740 | //function : IsHilighted |
8e5fb5ea |
741 | //purpose : Returns true if the owner is highlighted with selection style. |
c3282ec1 |
742 | //======================================================================= |
8e5fb5ea |
743 | Standard_Boolean AIS_InteractiveContext::IsHilighted (const Handle(SelectMgr_EntityOwner)& theOwner) const |
c3282ec1 |
744 | { |
745 | if (theOwner.IsNull() || !theOwner->HasSelectable()) |
746 | return Standard_False; |
747 | |
748 | const Handle(AIS_InteractiveObject) anObj = |
749 | Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
750 | |
8e5fb5ea |
751 | if (anObj->GlobalSelOwner() == theOwner) |
752 | { |
753 | if (!myObjects.IsBound (anObj)) |
754 | return Standard_False; |
755 | |
756 | return myObjects (anObj)->IsHilighted(); |
757 | } |
758 | |
759 | return theOwner->IsSelected(); |
760 | } |
761 | |
762 | //======================================================================= |
763 | //function : HighlightStyle |
764 | //purpose : |
765 | //======================================================================= |
766 | Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(AIS_InteractiveObject)& theObj, |
f838dac4 |
767 | Handle(Prs3d_Drawer)& theStyle) const |
8e5fb5ea |
768 | { |
68dcee02 |
769 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
770 | if (aStatus != NULL |
771 | && (*aStatus)->IsHilighted()) |
8e5fb5ea |
772 | { |
68dcee02 |
773 | theStyle = (*aStatus)->HilightStyle(); |
8e5fb5ea |
774 | return Standard_True; |
775 | } |
68dcee02 |
776 | |
777 | theStyle.Nullify(); |
778 | return Standard_False; |
8e5fb5ea |
779 | } |
c3282ec1 |
780 | |
8e5fb5ea |
781 | //======================================================================= |
782 | //function : HighlightStyle |
783 | //purpose : |
784 | //======================================================================= |
785 | Standard_Boolean AIS_InteractiveContext::HighlightStyle (const Handle(SelectMgr_EntityOwner)& theOwner, |
f838dac4 |
786 | Handle(Prs3d_Drawer)& theStyle) const |
8e5fb5ea |
787 | { |
788 | if (theOwner.IsNull() || !theOwner->HasSelectable()) |
789 | return Standard_False; |
790 | |
791 | if (IsHilighted (theOwner)) |
c3282ec1 |
792 | { |
8e5fb5ea |
793 | const Handle(AIS_InteractiveObject) anObj = |
794 | Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()); |
795 | if (anObj->GlobalSelOwner() == theOwner) |
c3282ec1 |
796 | { |
8e5fb5ea |
797 | theStyle = myObjects (anObj)->HilightStyle(); |
c3282ec1 |
798 | } |
799 | else |
800 | { |
8e5fb5ea |
801 | // since part selection style is not stored in global status, |
802 | // check if the object has own selection style. If not, it can |
803 | // only be highlighted with default selection style (because |
804 | // sub-intensity does not modify any selection states) |
f838dac4 |
805 | theStyle = getSelStyle (anObj, theOwner); |
c3282ec1 |
806 | } |
c3282ec1 |
807 | return Standard_True; |
808 | } |
8e5fb5ea |
809 | else |
810 | { |
811 | theStyle.Nullify(); |
812 | return Standard_False; |
813 | } |
c3282ec1 |
814 | } |
7fd59977 |
815 | |
816 | //======================================================================= |
817 | //function : IsDisplayed |
818 | //purpose : |
819 | //======================================================================= |
820 | |
68dcee02 |
821 | Standard_Boolean AIS_InteractiveContext::IsDisplayed(const Handle(AIS_InteractiveObject)& theObj) const |
7fd59977 |
822 | { |
68dcee02 |
823 | if(theObj.IsNull()) return Standard_False; |
7fd59977 |
824 | |
68dcee02 |
825 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theObj); |
826 | return aStatus != NULL |
827 | && (*aStatus)->GraphicStatus() == AIS_DS_Displayed; |
7fd59977 |
828 | } |
7fd59977 |
829 | |
830 | //======================================================================= |
831 | //function : IsDisplayed |
2195ab96 |
832 | //purpose : |
7fd59977 |
833 | //======================================================================= |
2195ab96 |
834 | Standard_Boolean AIS_InteractiveContext::IsDisplayed (const Handle(AIS_InteractiveObject)& theIObj, |
835 | const Standard_Integer theMode) const |
7fd59977 |
836 | { |
2195ab96 |
837 | if (theIObj.IsNull()) |
838 | { |
839 | return Standard_False; |
840 | } |
841 | |
68dcee02 |
842 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
843 | return aStatus != NULL |
844 | && (*aStatus)->GraphicStatus() == AIS_DS_Displayed |
845 | && (*aStatus)->DisplayMode() == theMode; |
7fd59977 |
846 | } |
847 | |
7fd59977 |
848 | //======================================================================= |
849 | //function : DisplayPriority |
2195ab96 |
850 | //purpose : |
7fd59977 |
851 | //======================================================================= |
2195ab96 |
852 | Standard_Integer AIS_InteractiveContext::DisplayPriority (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
853 | { |
2195ab96 |
854 | if (theIObj.IsNull()) |
855 | { |
856 | return -1; |
857 | } |
eb4320f2 |
858 | |
68dcee02 |
859 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
860 | if (aStatus != NULL |
861 | && ((*aStatus)->GraphicStatus() == AIS_DS_Displayed |
862 | || (*aStatus)->GraphicStatus() == AIS_DS_Erased)) |
eb4320f2 |
863 | { |
2195ab96 |
864 | Standard_Integer aDispMode = theIObj->HasDisplayMode() |
865 | ? theIObj->DisplayMode() |
f838dac4 |
866 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
867 | ? myDefaultDrawer->DisplayMode() |
2195ab96 |
868 | : 0); |
869 | return myMainPM->DisplayPriority (theIObj, aDispMode); |
7fd59977 |
870 | } |
871 | return 0; |
872 | } |
2195ab96 |
873 | |
7fd59977 |
874 | //======================================================================= |
875 | //function : SetDisplayPriority |
2195ab96 |
876 | //purpose : |
7fd59977 |
877 | //======================================================================= |
2195ab96 |
878 | void AIS_InteractiveContext::SetDisplayPriority (const Handle(AIS_InteractiveObject)& theIObj, |
879 | const Standard_Integer thePriority) |
7fd59977 |
880 | { |
2195ab96 |
881 | if (theIObj.IsNull()) |
882 | { |
7fd59977 |
883 | return; |
2195ab96 |
884 | } |
885 | |
2ec85268 |
886 | setContextToObject (theIObj); |
68dcee02 |
887 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
888 | if (aStatus != NULL |
889 | && ((*aStatus)->GraphicStatus() == AIS_DS_Displayed |
890 | || (*aStatus)->GraphicStatus() == AIS_DS_Erased)) |
2195ab96 |
891 | { |
68dcee02 |
892 | Standard_Integer aDisplayMode = theIObj->HasDisplayMode() |
893 | ? theIObj->DisplayMode() |
894 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
895 | ? myDefaultDrawer->DisplayMode() |
896 | : 0); |
897 | myMainPM->SetDisplayPriority (theIObj, aDisplayMode, thePriority); |
eb4320f2 |
898 | } |
7fd59977 |
899 | } |
900 | |
901 | //======================================================================= |
902 | //function : Redisplay |
2195ab96 |
903 | //purpose : |
7fd59977 |
904 | //======================================================================= |
2195ab96 |
905 | void AIS_InteractiveContext::Redisplay (const Handle(AIS_InteractiveObject)& theIObj, |
906 | const Standard_Boolean theToUpdateViewer, |
907 | const Standard_Boolean theAllModes) |
7fd59977 |
908 | { |
2195ab96 |
909 | RecomputePrsOnly (theIObj, theToUpdateViewer, theAllModes); |
910 | RecomputeSelectionOnly (theIObj); |
7fd59977 |
911 | } |
912 | |
913 | //======================================================================= |
914 | //function : Redisplay |
2195ab96 |
915 | //purpose : |
7fd59977 |
916 | //======================================================================= |
2195ab96 |
917 | void AIS_InteractiveContext::Redisplay (const AIS_KindOfInteractive theKOI, |
918 | const Standard_Integer /*theSign*/, |
919 | const Standard_Boolean theToUpdateViewer) |
920 | { |
921 | Standard_Boolean isRedisplayed = Standard_False; |
922 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
923 | { |
924 | Handle(AIS_InteractiveObject) anObj = anObjIter.Key(); |
925 | if (anObj->Type() != theKOI) |
926 | { |
927 | continue; |
7fd59977 |
928 | } |
2195ab96 |
929 | |
930 | Redisplay (anObj, Standard_False); |
931 | isRedisplayed = anObjIter.Value()->GraphicStatus() == AIS_DS_Displayed |
932 | || isRedisplayed; |
7fd59977 |
933 | } |
2195ab96 |
934 | |
935 | if (theToUpdateViewer |
936 | && isRedisplayed) |
eb4320f2 |
937 | { |
938 | myMainVwr->Update(); |
7fd59977 |
939 | } |
940 | } |
941 | |
7fd59977 |
942 | //======================================================================= |
943 | //function : RecomputePrsOnly |
2195ab96 |
944 | //purpose : |
7fd59977 |
945 | //======================================================================= |
2195ab96 |
946 | void AIS_InteractiveContext::RecomputePrsOnly (const Handle(AIS_InteractiveObject)& theIObj, |
947 | const Standard_Boolean theToUpdateViewer, |
948 | const Standard_Boolean theAllModes) |
7fd59977 |
949 | { |
2195ab96 |
950 | if (theIObj.IsNull()) |
951 | { |
952 | return; |
953 | } |
eb4320f2 |
954 | |
2195ab96 |
955 | theIObj->Update (theAllModes); |
956 | if (!theToUpdateViewer) |
eb4320f2 |
957 | { |
958 | return; |
959 | } |
960 | |
68dcee02 |
961 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
962 | if (aStatus != NULL |
963 | && (*aStatus)->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
964 | { |
965 | myMainVwr->Update(); |
7fd59977 |
966 | } |
967 | } |
968 | //======================================================================= |
969 | //function : RecomputeSelectionOnly |
970 | //purpose : |
971 | //======================================================================= |
bc677575 |
972 | void AIS_InteractiveContext::RecomputeSelectionOnly (const Handle(AIS_InteractiveObject)& theIO) |
7fd59977 |
973 | { |
bc677575 |
974 | if (theIO.IsNull()) |
975 | { |
976 | return; |
977 | } |
7fd59977 |
978 | |
bc677575 |
979 | mgrSelector->RecomputeSelection (theIO); |
0d969553 |
980 | |
68dcee02 |
981 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIO); |
982 | if (aStatus == NULL |
983 | || (*aStatus)->GraphicStatus() != AIS_DS_Displayed) |
bc677575 |
984 | { |
985 | return; |
986 | } |
987 | |
988 | TColStd_ListOfInteger aModes; |
989 | ActivatedModes (theIO, aModes); |
990 | TColStd_ListIteratorOfListOfInteger aModesIter (aModes); |
991 | for (; aModesIter.More(); aModesIter.Next()) |
992 | { |
68dcee02 |
993 | mgrSelector->Activate (theIO, aModesIter.Value()); |
7fd59977 |
994 | } |
995 | } |
996 | |
997 | //======================================================================= |
998 | //function : Update |
2195ab96 |
999 | //purpose : |
7fd59977 |
1000 | //======================================================================= |
f3889691 |
1001 | void AIS_InteractiveContext::Update (const Handle(AIS_InteractiveObject)& theIObj, |
2195ab96 |
1002 | const Standard_Boolean theUpdateViewer) |
7fd59977 |
1003 | { |
f3889691 |
1004 | if (theIObj.IsNull()) |
1005 | { |
1006 | return; |
1007 | } |
7fd59977 |
1008 | |
2195ab96 |
1009 | TColStd_ListOfInteger aPrsModes; |
1010 | theIObj->ToBeUpdated (aPrsModes); |
1011 | for (TColStd_ListIteratorOfListOfInteger aPrsModesIt (aPrsModes); aPrsModesIt.More(); aPrsModesIt.Next()) |
f3889691 |
1012 | { |
1013 | theIObj->Update (aPrsModesIt.Value(), Standard_False); |
7fd59977 |
1014 | } |
f3889691 |
1015 | |
1016 | mgrSelector->Update(theIObj); |
1017 | |
1018 | if (theUpdateViewer) |
1019 | { |
68dcee02 |
1020 | const Handle(AIS_GlobalStatus)* aStatus = myObjects.Seek (theIObj); |
1021 | if (aStatus != NULL |
1022 | && (*aStatus)->GraphicStatus() == AIS_DS_Displayed) |
f3889691 |
1023 | { |
68dcee02 |
1024 | myMainVwr->Update(); |
7fd59977 |
1025 | } |
1026 | } |
1027 | } |
1028 | |
7fd59977 |
1029 | //======================================================================= |
1030 | //function : SetLocation |
2195ab96 |
1031 | //purpose : |
7fd59977 |
1032 | //======================================================================= |
2195ab96 |
1033 | void AIS_InteractiveContext::SetLocation (const Handle(AIS_InteractiveObject)& theIObj, |
1034 | const TopLoc_Location& theLoc) |
7fd59977 |
1035 | { |
2195ab96 |
1036 | if (theIObj.IsNull()) |
1037 | { |
1038 | return; |
1039 | } |
7fd59977 |
1040 | |
2195ab96 |
1041 | if (theIObj->HasTransformation() |
1042 | && theLoc.IsIdentity()) |
1043 | { |
1044 | theIObj->ResetTransformation(); |
1045 | mgrSelector->Update (theIObj, Standard_False); |
1046 | return; |
1047 | } |
1048 | else if (theLoc.IsIdentity()) |
1049 | { |
7fd59977 |
1050 | return; |
1051 | } |
7fd59977 |
1052 | |
0d969553 |
1053 | // first reset the previous location to properly clean everything... |
2195ab96 |
1054 | if (theIObj->HasTransformation()) |
1055 | { |
1056 | theIObj->ResetTransformation(); |
1057 | } |
7fd59977 |
1058 | |
2195ab96 |
1059 | theIObj->SetLocalTransformation (theLoc.Transformation()); |
7fd59977 |
1060 | |
68dcee02 |
1061 | mgrSelector->Update (theIObj, Standard_False); |
5396886c |
1062 | |
1063 | // if the object or its part is highlighted dynamically, it is necessary to apply location transformation |
1064 | // to its highlight structure immediately |
8e5fb5ea |
1065 | if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (theIObj)) |
5396886c |
1066 | { |
7bbccb5f |
1067 | const Standard_Integer aHiMod = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
5396886c |
1068 | myLastPicked->UpdateHighlightTrsf (myMainVwr, |
1069 | myMainPM, |
7bbccb5f |
1070 | aHiMod); |
5396886c |
1071 | } |
7fd59977 |
1072 | } |
2195ab96 |
1073 | |
7fd59977 |
1074 | //======================================================================= |
1075 | //function : ResetLocation |
2195ab96 |
1076 | //purpose : |
7fd59977 |
1077 | //======================================================================= |
2195ab96 |
1078 | void AIS_InteractiveContext::ResetLocation (const Handle(AIS_InteractiveObject)& theIObj) |
7fd59977 |
1079 | { |
2195ab96 |
1080 | if (theIObj.IsNull()) |
1081 | { |
1082 | return; |
1083 | } |
7fd59977 |
1084 | |
2195ab96 |
1085 | theIObj->ResetTransformation(); |
1086 | mgrSelector->Update (theIObj, Standard_False); |
7fd59977 |
1087 | } |
1088 | |
1089 | //======================================================================= |
1090 | //function : HasLocation |
2195ab96 |
1091 | //purpose : |
7fd59977 |
1092 | //======================================================================= |
2195ab96 |
1093 | Standard_Boolean AIS_InteractiveContext::HasLocation (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1094 | { |
2195ab96 |
1095 | return !theIObj.IsNull() |
1096 | && theIObj->HasTransformation(); |
7fd59977 |
1097 | } |
1098 | |
2195ab96 |
1099 | //======================================================================= |
1100 | //function : Location |
1101 | //purpose : |
1102 | //======================================================================= |
1103 | TopLoc_Location AIS_InteractiveContext::Location (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1104 | { |
2195ab96 |
1105 | return theIObj->Transformation(); |
7fd59977 |
1106 | } |
1107 | |
1108 | //======================================================================= |
1109 | //function : SetDeviationCoefficient |
2195ab96 |
1110 | //purpose : |
7fd59977 |
1111 | //======================================================================= |
2195ab96 |
1112 | void AIS_InteractiveContext::SetDeviationCoefficient (const Standard_Real theCoefficient) |
7fd59977 |
1113 | { |
2195ab96 |
1114 | myDefaultDrawer->SetDeviationCoefficient (theCoefficient); |
7fd59977 |
1115 | } |
2195ab96 |
1116 | |
7fd59977 |
1117 | //======================================================================= |
1118 | //function : SetDeviationAngle |
2195ab96 |
1119 | //purpose : |
7fd59977 |
1120 | //======================================================================= |
2195ab96 |
1121 | void AIS_InteractiveContext::SetDeviationAngle (const Standard_Real theAngle) |
7fd59977 |
1122 | { |
e19792fa |
1123 | myDefaultDrawer->SetDeviationAngle (theAngle); |
7fd59977 |
1124 | } |
1125 | |
1126 | //======================================================================= |
1127 | //function : DeviationAngle |
1128 | //purpose : Gets deviationAngle |
1129 | //======================================================================= |
7fd59977 |
1130 | Standard_Real AIS_InteractiveContext::DeviationAngle() const |
1131 | { |
2195ab96 |
1132 | return myDefaultDrawer->DeviationAngle(); |
7fd59977 |
1133 | } |
1134 | |
1135 | //======================================================================= |
1136 | //function : DeviationCoefficient |
2195ab96 |
1137 | //purpose : |
7fd59977 |
1138 | //======================================================================= |
2195ab96 |
1139 | Standard_Real AIS_InteractiveContext::DeviationCoefficient() const |
7fd59977 |
1140 | { |
1141 | return myDefaultDrawer->DeviationCoefficient(); |
1142 | } |
2195ab96 |
1143 | |
7fd59977 |
1144 | //======================================================================= |
1145 | //function : SetHLRDeviationCoefficient |
2195ab96 |
1146 | //purpose : |
7fd59977 |
1147 | //======================================================================= |
2195ab96 |
1148 | void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Standard_Real theCoefficient) |
7fd59977 |
1149 | { |
2195ab96 |
1150 | myDefaultDrawer->SetHLRDeviationCoefficient (theCoefficient); |
7fd59977 |
1151 | } |
1152 | |
1153 | //======================================================================= |
1154 | //function : HLRDeviationCoefficient |
2195ab96 |
1155 | //purpose : |
7fd59977 |
1156 | //======================================================================= |
2195ab96 |
1157 | Standard_Real AIS_InteractiveContext::HLRDeviationCoefficient() const |
7fd59977 |
1158 | { |
1159 | return myDefaultDrawer->HLRDeviationCoefficient(); |
1160 | } |
1161 | |
1162 | //======================================================================= |
1163 | //function : SetHLRAngle |
2195ab96 |
1164 | //purpose : |
7fd59977 |
1165 | //======================================================================= |
2195ab96 |
1166 | void AIS_InteractiveContext::SetHLRAngle (const Standard_Real theAngle) |
7fd59977 |
1167 | { |
2195ab96 |
1168 | myDefaultDrawer->SetHLRAngle (theAngle); |
7fd59977 |
1169 | } |
1170 | |
1171 | //======================================================================= |
1172 | //function : SetHLRAngleAndDeviation |
1173 | //purpose : compute with anangle a HLRAngle and a HLRDeviationCoefficient |
1174 | // and set them in myHLRAngle and in myHLRDeviationCoefficient |
1175 | // of myDefaultDrawer |
1176 | //======================================================================= |
2195ab96 |
1177 | void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Standard_Real theAngle) |
7fd59977 |
1178 | { |
2195ab96 |
1179 | Standard_Real anOutAngl, anOutDefl; |
1180 | HLRBRep::PolyHLRAngleAndDeflection (theAngle, anOutAngl, anOutDefl); |
7fd59977 |
1181 | |
2195ab96 |
1182 | myDefaultDrawer->SetHLRAngle (anOutAngl); |
1183 | myDefaultDrawer->SetHLRDeviationCoefficient (anOutDefl); |
7fd59977 |
1184 | } |
1185 | |
1186 | //======================================================================= |
1187 | //function : HLRAngle |
2195ab96 |
1188 | //purpose : |
7fd59977 |
1189 | //======================================================================= |
7fd59977 |
1190 | Standard_Real AIS_InteractiveContext::HLRAngle() const |
1191 | { |
1192 | return myDefaultDrawer->HLRAngle(); |
1193 | } |
1194 | |
1195 | //======================================================================= |
1196 | //function : SetDisplayMode |
2195ab96 |
1197 | //purpose : |
7fd59977 |
1198 | //======================================================================= |
e5d7e249 |
1199 | void AIS_InteractiveContext::SetDisplayMode(const Standard_Integer theMode, |
1200 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1201 | { |
f838dac4 |
1202 | if (theMode == myDefaultDrawer->DisplayMode()) |
2195ab96 |
1203 | { |
1204 | return; |
1205 | } |
7fd59977 |
1206 | |
2195ab96 |
1207 | for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next()) |
1208 | { |
1209 | Handle(AIS_InteractiveObject) anObj = anObjIter.Key(); |
1210 | Standard_Boolean toProcess = anObj->IsKind (STANDARD_TYPE(AIS_Shape)) |
1211 | || anObj->IsKind (STANDARD_TYPE(AIS_ConnectedInteractive)) |
1212 | || anObj->IsKind (STANDARD_TYPE(AIS_MultipleConnectedInteractive)); |
7fd59977 |
1213 | |
2195ab96 |
1214 | if (!toProcess |
1215 | || anObj->HasDisplayMode() |
1216 | || !anObj->AcceptDisplayMode (theMode)) |
1217 | { |
1218 | continue; |
1219 | } |
1220 | |
1221 | Handle(AIS_GlobalStatus) aStatus = anObjIter.Value(); |
3db69e41 |
1222 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1223 | |
2195ab96 |
1224 | if (aStatus->GraphicStatus() == AIS_DS_Displayed) |
1225 | { |
2195ab96 |
1226 | myMainPM->Display (anObj, theMode); |
8e5fb5ea |
1227 | if (!myLastPicked.IsNull() && myLastPicked->IsSameSelectable (anObj)) |
c3282ec1 |
1228 | { |
1229 | myMainPM->BeginImmediateDraw(); |
f838dac4 |
1230 | unhighlightGlobal (anObj); |
c3282ec1 |
1231 | myMainPM->EndImmediateDraw (myMainVwr); |
1232 | } |
2195ab96 |
1233 | if (aStatus->IsSubIntensityOn()) |
7fd59977 |
1234 | { |
8e5fb5ea |
1235 | highlightWithSubintensity (anObj, theMode); |
7fd59977 |
1236 | } |
f838dac4 |
1237 | myMainPM->SetVisibility (anObj, myDefaultDrawer->DisplayMode(), Standard_False); |
2195ab96 |
1238 | } |
1239 | } |
1240 | |
f838dac4 |
1241 | myDefaultDrawer->SetDisplayMode (theMode); |
2195ab96 |
1242 | if (theToUpdateViewer) |
1243 | { |
1244 | myMainVwr->Update(); |
1245 | } |
7fd59977 |
1246 | } |
1247 | |
1248 | //======================================================================= |
1249 | //function : SetDisplayMode |
2195ab96 |
1250 | //purpose : |
7fd59977 |
1251 | //======================================================================= |
2195ab96 |
1252 | void AIS_InteractiveContext::SetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, |
1253 | const Standard_Integer theMode, |
1254 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1255 | { |
2ec85268 |
1256 | setContextToObject (theIObj); |
2195ab96 |
1257 | if (!myObjects.IsBound (theIObj)) |
1258 | { |
1259 | theIObj->SetDisplayMode (theMode); |
1260 | return; |
1261 | } |
1262 | else if (!theIObj->AcceptDisplayMode (theMode)) |
1263 | { |
1264 | return; |
1265 | } |
eb4320f2 |
1266 | |
2195ab96 |
1267 | Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); |
1268 | if (aStatus->GraphicStatus() != AIS_DS_Displayed) |
1269 | { |
b2bafb33 |
1270 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1271 | theIObj->SetDisplayMode (theMode); |
1272 | return; |
1273 | } |
a6964ce6 |
1274 | |
2195ab96 |
1275 | // erase presentations for all display modes different from <aMode> |
3db69e41 |
1276 | const Standard_Integer anOldMode = aStatus->DisplayMode(); |
1277 | if (anOldMode != theMode) |
2195ab96 |
1278 | { |
3db69e41 |
1279 | if (myMainPM->IsHighlighted (theIObj, anOldMode)) |
2195ab96 |
1280 | { |
f838dac4 |
1281 | unhighlightGlobal (theIObj); |
7fd59977 |
1282 | } |
3db69e41 |
1283 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
7fd59977 |
1284 | } |
2195ab96 |
1285 | |
3db69e41 |
1286 | aStatus->SetDisplayMode (theMode); |
2195ab96 |
1287 | |
1288 | myMainPM->Display (theIObj, theMode); |
2195ab96 |
1289 | if (aStatus->IsHilighted()) |
1290 | { |
f838dac4 |
1291 | highlightGlobal (theIObj, getSelStyle (theIObj, theIObj->GlobalSelOwner()), theMode); |
2195ab96 |
1292 | } |
1293 | if (aStatus->IsSubIntensityOn()) |
1294 | { |
8e5fb5ea |
1295 | highlightWithSubintensity (theIObj, theMode); |
2195ab96 |
1296 | } |
1297 | |
1298 | if (theToUpdateViewer) |
1299 | { |
1300 | myMainVwr->Update(); |
1301 | } |
1302 | theIObj->SetDisplayMode (theMode); |
7fd59977 |
1303 | } |
1304 | |
1305 | //======================================================================= |
1306 | //function : UnsetDisplayMode |
2195ab96 |
1307 | //purpose : |
7fd59977 |
1308 | //======================================================================= |
2195ab96 |
1309 | void AIS_InteractiveContext::UnsetDisplayMode (const Handle(AIS_InteractiveObject)& theIObj, |
1310 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1311 | { |
2195ab96 |
1312 | if (theIObj.IsNull() |
1313 | || !theIObj->HasDisplayMode()) |
1314 | { |
1315 | return; |
1316 | } |
1317 | |
1318 | if (!myObjects.IsBound (theIObj)) |
1319 | { |
1320 | theIObj->UnsetDisplayMode(); |
1321 | return; |
1322 | } |
1323 | |
1324 | const Standard_Integer anOldMode = theIObj->DisplayMode(); |
f838dac4 |
1325 | if (myDefaultDrawer->DisplayMode() == anOldMode) |
2195ab96 |
1326 | { |
1327 | return; |
1328 | } |
1329 | |
1330 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); |
f838dac4 |
1331 | aStatus->SetDisplayMode (myDefaultDrawer->DisplayMode()); |
2195ab96 |
1332 | |
1333 | if (aStatus->GraphicStatus() == AIS_DS_Displayed) |
1334 | { |
1335 | if (myMainPM->IsHighlighted (theIObj, anOldMode)) |
7fd59977 |
1336 | { |
f838dac4 |
1337 | unhighlightGlobal (theIObj); |
2195ab96 |
1338 | } |
1339 | myMainPM->SetVisibility (theIObj, anOldMode, Standard_False); |
f838dac4 |
1340 | myMainPM->Display (theIObj, myDefaultDrawer->DisplayMode()); |
2195ab96 |
1341 | if (aStatus->IsHilighted()) |
1342 | { |
8e5fb5ea |
1343 | highlightSelected (theIObj->GlobalSelOwner()); |
2195ab96 |
1344 | } |
1345 | if (aStatus->IsSubIntensityOn()) |
1346 | { |
f838dac4 |
1347 | highlightWithSubintensity (theIObj, myDefaultDrawer->DisplayMode()); |
7fd59977 |
1348 | } |
2195ab96 |
1349 | |
1350 | if (theToUpdateViewer) |
1351 | { |
1352 | myMainVwr->Update(); |
1353 | } |
1354 | } |
1355 | |
1356 | theIObj->UnsetDisplayMode(); |
7fd59977 |
1357 | } |
1358 | |
1359 | //======================================================================= |
1360 | //function : SetCurrentFacingModel |
2195ab96 |
1361 | //purpose : |
7fd59977 |
1362 | //======================================================================= |
2195ab96 |
1363 | void AIS_InteractiveContext::SetCurrentFacingModel (const Handle(AIS_InteractiveObject)& theIObj, |
1364 | const Aspect_TypeOfFacingModel theModel) |
b8ddfc2f |
1365 | { |
2195ab96 |
1366 | if (!theIObj.IsNull()) |
1367 | { |
1368 | theIObj->SetCurrentFacingModel (theModel); |
1369 | } |
7fd59977 |
1370 | } |
7fd59977 |
1371 | |
1372 | //======================================================================= |
2195ab96 |
1373 | //function : redisplayPrsRecModes |
1374 | //purpose : |
7fd59977 |
1375 | //======================================================================= |
2195ab96 |
1376 | void AIS_InteractiveContext::redisplayPrsRecModes (const Handle(AIS_InteractiveObject)& theIObj, |
1377 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1378 | { |
2195ab96 |
1379 | if (theIObj->RecomputeEveryPrs()) |
1380 | { |
36132a2e |
1381 | theIObj->Update (Standard_True); |
1382 | theIObj->UpdateSelection(); |
2195ab96 |
1383 | } |
1384 | else |
1385 | { |
1386 | for (TColStd_ListIteratorOfListOfInteger aModes (theIObj->ListOfRecomputeModes()); aModes.More(); aModes.Next()) |
1387 | { |
1388 | theIObj->Update (aModes.Value(), Standard_False); |
1389 | } |
28ee613b |
1390 | theIObj->UpdateSelection(); |
2195ab96 |
1391 | theIObj->SetRecomputeOk(); |
1392 | } |
1393 | |
1394 | if (theToUpdateViewer) |
1395 | { |
1396 | UpdateCurrentViewer(); |
1397 | } |
7fd59977 |
1398 | } |
1399 | |
2195ab96 |
1400 | //======================================================================= |
1401 | //function : redisplayPrsModes |
1402 | //purpose : |
1403 | //======================================================================= |
1404 | void AIS_InteractiveContext::redisplayPrsModes (const Handle(AIS_InteractiveObject)& theIObj, |
1405 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1406 | { |
2195ab96 |
1407 | if (theIObj->RecomputeEveryPrs()) |
1408 | { |
36132a2e |
1409 | theIObj->Update (Standard_True); |
1410 | theIObj->UpdateSelection(); |
2195ab96 |
1411 | } |
7fd59977 |
1412 | else |
2195ab96 |
1413 | { |
1414 | TColStd_ListOfInteger aModes; |
1415 | theIObj->ToBeUpdated (aModes); |
1416 | for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next()) |
7fd59977 |
1417 | { |
2195ab96 |
1418 | theIObj->Update (aModeIter.Value(), Standard_False); |
7fd59977 |
1419 | } |
2195ab96 |
1420 | theIObj->SetRecomputeOk(); |
1421 | } |
7fd59977 |
1422 | |
2195ab96 |
1423 | if (theToUpdateViewer) |
1424 | { |
1425 | UpdateCurrentViewer(); |
1426 | } |
7fd59977 |
1427 | } |
1428 | |
2195ab96 |
1429 | //======================================================================= |
1430 | //function : SetColor |
1431 | //purpose : |
1432 | //======================================================================= |
1433 | void AIS_InteractiveContext::SetColor (const Handle(AIS_InteractiveObject)& theIObj, |
1434 | const Quantity_Color& theColor, |
1435 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1436 | { |
2195ab96 |
1437 | if (theIObj.IsNull()) |
1438 | { |
1439 | return; |
1440 | } |
7fd59977 |
1441 | |
2ec85268 |
1442 | setContextToObject (theIObj); |
2195ab96 |
1443 | theIObj->SetColor (theColor); |
1444 | redisplayPrsRecModes (theIObj, theToUpdateViewer); |
1445 | } |
7fd59977 |
1446 | |
5ad8c033 |
1447 | //======================================================================= |
1448 | //function : SetIsoOnTriangulation |
1449 | //purpose : |
1450 | //======================================================================= |
1451 | void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theIsEnabled, |
1452 | const Handle(AIS_InteractiveObject)& theObject) |
1453 | { |
1454 | if (theObject.IsNull()) |
1455 | { |
1456 | return; |
1457 | } |
1458 | |
1459 | theObject->SetIsoOnTriangulation (theIsEnabled); |
1460 | } |
1461 | |
2195ab96 |
1462 | //======================================================================= |
1463 | //function : SetDeviationCoefficient |
1464 | //purpose : |
1465 | //======================================================================= |
1466 | void AIS_InteractiveContext::SetDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj, |
1467 | const Standard_Real theCoefficient, |
1468 | const Standard_Boolean theToUpdateViewer) |
1469 | { |
1470 | if (theIObj.IsNull()) |
1471 | { |
1472 | return; |
1473 | } |
7fd59977 |
1474 | |
2195ab96 |
1475 | // to be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1476 | setContextToObject (theIObj); |
2195ab96 |
1477 | if (theIObj->Type() != AIS_KOI_Object |
1478 | && theIObj->Type() != AIS_KOI_Shape) |
1479 | { |
1480 | return; |
1481 | } |
1482 | else if (theIObj->Signature() != 0) |
1483 | { |
1484 | return; |
1485 | } |
1486 | |
1487 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1488 | aShape->SetOwnDeviationCoefficient (theCoefficient); |
1489 | redisplayPrsModes (theIObj, theToUpdateViewer); |
7fd59977 |
1490 | } |
1491 | |
1492 | //======================================================================= |
1493 | //function : SetHLRDeviationCoefficient |
2195ab96 |
1494 | //purpose : |
7fd59977 |
1495 | //======================================================================= |
2195ab96 |
1496 | void AIS_InteractiveContext::SetHLRDeviationCoefficient (const Handle(AIS_InteractiveObject)& theIObj, |
1497 | const Standard_Real theCoefficient, |
1498 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1499 | { |
2195ab96 |
1500 | if (theIObj.IsNull()) |
1501 | { |
1502 | return; |
1503 | } |
1504 | |
81bba717 |
1505 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1506 | setContextToObject (theIObj); |
2195ab96 |
1507 | if (theIObj->Type() != AIS_KOI_Object |
1508 | && theIObj->Type() != AIS_KOI_Shape) |
1509 | { |
1510 | return; |
1511 | } |
1512 | else if (theIObj->Signature() != 0) |
1513 | { |
1514 | return; |
1515 | } |
7fd59977 |
1516 | |
2195ab96 |
1517 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1518 | aShape->SetOwnHLRDeviationCoefficient (theCoefficient); |
1519 | redisplayPrsModes (theIObj, theToUpdateViewer); |
7fd59977 |
1520 | } |
1521 | |
7fd59977 |
1522 | //======================================================================= |
1523 | //function : SetDeviationAngle |
2195ab96 |
1524 | //purpose : |
7fd59977 |
1525 | //======================================================================= |
2195ab96 |
1526 | void AIS_InteractiveContext::SetDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj, |
1527 | const Standard_Real theAngle, |
1528 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1529 | { |
2195ab96 |
1530 | if (theIObj.IsNull()) |
1531 | { |
1532 | return; |
1533 | } |
1534 | |
e33e7e78 |
1535 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1536 | setContextToObject (theIObj); |
2195ab96 |
1537 | if (theIObj->Type() != AIS_KOI_Shape) |
1538 | { |
1539 | return; |
1540 | } |
1541 | else if (theIObj->Signature() != 0) |
1542 | { |
1543 | return; |
1544 | } |
7fd59977 |
1545 | |
2195ab96 |
1546 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1547 | aShape->SetOwnDeviationAngle (theAngle); |
1548 | redisplayPrsModes (theIObj, theToUpdateViewer); |
7fd59977 |
1549 | } |
2195ab96 |
1550 | |
7fd59977 |
1551 | //======================================================================= |
2195ab96 |
1552 | //function : SetAngleAndDeviation |
1553 | //purpose : |
7fd59977 |
1554 | //======================================================================= |
2195ab96 |
1555 | void AIS_InteractiveContext::SetAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj, |
1556 | const Standard_Real theAngle, |
1557 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1558 | { |
2195ab96 |
1559 | if (theIObj.IsNull()) |
1560 | { |
1561 | return; |
1562 | } |
1563 | |
e33e7e78 |
1564 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1565 | setContextToObject (theIObj); |
2195ab96 |
1566 | if (theIObj->Type() != AIS_KOI_Shape) |
1567 | { |
1568 | return; |
1569 | } |
1570 | if (theIObj->Signature() != 0) |
1571 | { |
1572 | return; |
1573 | } |
7fd59977 |
1574 | |
2195ab96 |
1575 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1576 | aShape->SetAngleAndDeviation (theAngle); |
7fd59977 |
1577 | |
2195ab96 |
1578 | if (theIObj->RecomputeEveryPrs()) |
1579 | { |
36132a2e |
1580 | theIObj->Update (Standard_True); |
1581 | theIObj->UpdateSelection(); |
2195ab96 |
1582 | } |
7fd59977 |
1583 | else |
2195ab96 |
1584 | { |
1585 | Update (theIObj, theToUpdateViewer); |
1586 | } |
7fd59977 |
1587 | } |
1588 | |
1589 | //======================================================================= |
2195ab96 |
1590 | //function : SetHLRAngleAndDeviation |
1591 | //purpose : |
7fd59977 |
1592 | //======================================================================= |
2195ab96 |
1593 | void AIS_InteractiveContext::SetHLRAngleAndDeviation (const Handle(AIS_InteractiveObject)& theIObj, |
1594 | const Standard_Real theAngle, |
1595 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1596 | { |
2195ab96 |
1597 | if (theIObj.IsNull()) |
1598 | { |
1599 | return; |
1600 | } |
7fd59977 |
1601 | |
e33e7e78 |
1602 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1603 | setContextToObject (theIObj); |
2195ab96 |
1604 | if (theIObj->Type() != AIS_KOI_Shape) |
1605 | { |
1606 | return; |
1607 | } |
1608 | if (theIObj->Signature() != 0) |
1609 | { |
1610 | return; |
1611 | } |
1612 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1613 | aShape->SetHLRAngleAndDeviation (theAngle); |
1614 | redisplayPrsModes (theIObj, theToUpdateViewer); |
7fd59977 |
1615 | } |
1616 | |
1617 | //======================================================================= |
1618 | //function : SetHLRDeviationAngle |
2195ab96 |
1619 | //purpose : |
7fd59977 |
1620 | //======================================================================= |
2195ab96 |
1621 | void AIS_InteractiveContext::SetHLRDeviationAngle (const Handle(AIS_InteractiveObject)& theIObj, |
1622 | const Standard_Real theAngle, |
1623 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1624 | { |
2195ab96 |
1625 | if (theIObj.IsNull()) |
1626 | { |
1627 | return; |
1628 | } |
7fd59977 |
1629 | |
2195ab96 |
1630 | // To be modified after the related methods of AIS_Shape are passed to InteractiveObject |
2ec85268 |
1631 | setContextToObject (theIObj); |
2195ab96 |
1632 | if (theIObj->Type() != AIS_KOI_Shape) |
1633 | { |
1634 | return; |
1635 | } |
1636 | if (theIObj->Signature() != 0) |
1637 | { |
1638 | return; |
1639 | } |
1640 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (theIObj); |
1641 | aShape->SetOwnHLRDeviationAngle (theAngle); |
1642 | redisplayPrsModes (theIObj, theToUpdateViewer); |
7fd59977 |
1643 | } |
1644 | |
1645 | //======================================================================= |
1646 | //function : UnsetColor |
2195ab96 |
1647 | //purpose : |
7fd59977 |
1648 | //======================================================================= |
2195ab96 |
1649 | void AIS_InteractiveContext::UnsetColor (const Handle(AIS_InteractiveObject)& theIObj, |
1650 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1651 | { |
2195ab96 |
1652 | if (theIObj.IsNull()) |
1653 | { |
1654 | return; |
1655 | } |
1656 | |
1657 | theIObj->UnsetColor(); |
1658 | redisplayPrsRecModes (theIObj, theToUpdateViewer); |
7fd59977 |
1659 | } |
1660 | |
1661 | //======================================================================= |
1662 | //function : HasColor |
2195ab96 |
1663 | //purpose : |
7fd59977 |
1664 | //======================================================================= |
2195ab96 |
1665 | Standard_Boolean AIS_InteractiveContext::HasColor (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1666 | { |
2195ab96 |
1667 | return theIObj->HasColor(); |
7fd59977 |
1668 | } |
1669 | |
2195ab96 |
1670 | //======================================================================= |
1671 | //function : Color |
1672 | //purpose : |
1673 | //======================================================================= |
1674 | void AIS_InteractiveContext::Color (const Handle(AIS_InteractiveObject)& theIObj, |
1675 | Quantity_Color& theColor) const |
7fd59977 |
1676 | { |
2195ab96 |
1677 | theIObj->Color (theColor); |
7fd59977 |
1678 | } |
7fd59977 |
1679 | |
1680 | //======================================================================= |
1681 | //function : Width |
2195ab96 |
1682 | //purpose : |
7fd59977 |
1683 | //======================================================================= |
2195ab96 |
1684 | Standard_Real AIS_InteractiveContext::Width (const Handle(AIS_InteractiveObject)& theIObj) const |
7fd59977 |
1685 | { |
2195ab96 |
1686 | return theIObj->Width(); |
7fd59977 |
1687 | } |
1688 | |
1689 | //======================================================================= |
1690 | //function : SetWidth |
2195ab96 |
1691 | //purpose : |
7fd59977 |
1692 | //======================================================================= |
2195ab96 |
1693 | void AIS_InteractiveContext::SetWidth (const Handle(AIS_InteractiveObject)& theIObj, |
1694 | const Standard_Real theWidth, |
1695 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1696 | { |
2195ab96 |
1697 | if (theIObj.IsNull()) |
1698 | { |
1699 | return; |
1700 | } |
1701 | |
2ec85268 |
1702 | setContextToObject (theIObj); |
2195ab96 |
1703 | theIObj->SetWidth (theWidth); |
1704 | redisplayPrsRecModes (theIObj, theToUpdateViewer); |
8e5fb5ea |
1705 | if (!myLastinMain.IsNull() && myLastinMain->IsSameSelectable (theIObj)) |
c3282ec1 |
1706 | { |
1707 | if (myLastinMain->IsAutoHilight()) |
1708 | { |
f838dac4 |
1709 | const Standard_Integer aHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
8e5fb5ea |
1710 | myLastinMain->HilightWithColor (myMainPM, |
f838dac4 |
1711 | myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain), |
8e5fb5ea |
1712 | aHiMode); |
c3282ec1 |
1713 | } |
1714 | else |
1715 | { |
8e5fb5ea |
1716 | theIObj->HilightOwnerWithColor (myMainPM, |
f838dac4 |
1717 | myLastinMain->IsSelected() ? getSelStyle (theIObj, myLastinMain) : getHiStyle (theIObj, myLastinMain), |
8e5fb5ea |
1718 | myLastinMain); |
c3282ec1 |
1719 | } |
1720 | } |
7fd59977 |
1721 | } |
1722 | |
1723 | //======================================================================= |
1724 | //function : UnsetWidth |
2195ab96 |
1725 | //purpose : |
7fd59977 |
1726 | //======================================================================= |
2195ab96 |
1727 | void AIS_InteractiveContext::UnsetWidth (const Handle(AIS_InteractiveObject)& theIObj, |
1728 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1729 | { |
2195ab96 |
1730 | if (theIObj.IsNull()) |
1731 | { |
1732 | return; |
1733 | } |
1734 | |
1735 | theIObj->UnsetWidth(); |
1736 | redisplayPrsRecModes (theIObj, theToUpdateViewer); |
7fd59977 |
1737 | } |
1738 | |
1739 | //======================================================================= |
1740 | //function : SetMaterial |
2195ab96 |
1741 | //purpose : |
7fd59977 |
1742 | //======================================================================= |
2195ab96 |
1743 | void AIS_InteractiveContext::SetMaterial (const Handle(AIS_InteractiveObject)& theIObj, |
87432b82 |
1744 | const Graphic3d_MaterialAspect& theMaterial, |
2195ab96 |
1745 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1746 | { |
2195ab96 |
1747 | if (theIObj.IsNull()) |
1748 | { |
1749 | return; |
1750 | } |
1751 | |
2ec85268 |
1752 | setContextToObject (theIObj); |
87432b82 |
1753 | theIObj->SetMaterial (theMaterial); |
2195ab96 |
1754 | redisplayPrsRecModes (theIObj, theToUpdateViewer); |
7fd59977 |
1755 | } |
1756 | |
1757 | //======================================================================= |
1758 | //function : UnsetMaterial |
2195ab96 |
1759 | //purpose : |
7fd59977 |
1760 | //======================================================================= |
2195ab96 |
1761 | void AIS_InteractiveContext::UnsetMaterial (const Handle(AIS_InteractiveObject)& theIObj, |
1762 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1763 | { |
2195ab96 |
1764 | if (theIObj.IsNull()) |
1765 | { |
1766 | return; |
1767 | } |
1768 | theIObj->UnsetMaterial(); |
1769 | redisplayPrsRecModes (theIObj, theToUpdateViewer); |
7fd59977 |
1770 | } |
1771 | |
1772 | //======================================================================= |
1773 | //function : SetTransparency |
2195ab96 |
1774 | //purpose : |
7fd59977 |
1775 | //======================================================================= |
2195ab96 |
1776 | void AIS_InteractiveContext::SetTransparency (const Handle(AIS_InteractiveObject)& theIObj, |
1777 | const Standard_Real theValue, |
1778 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1779 | { |
2195ab96 |
1780 | if (theIObj.IsNull()) |
1781 | { |
1782 | return; |
1783 | } |
1784 | |
2ec85268 |
1785 | setContextToObject (theIObj); |
2195ab96 |
1786 | if (!theIObj->IsTransparent() |
f838dac4 |
1787 | && theValue <= 0.005) |
a6964ce6 |
1788 | { |
1789 | return; |
1790 | } |
1791 | |
f838dac4 |
1792 | if (theValue <= 0.005) |
2195ab96 |
1793 | { |
1794 | UnsetTransparency (theIObj, theToUpdateViewer); |
7fd59977 |
1795 | return; |
1796 | } |
a6964ce6 |
1797 | |
2195ab96 |
1798 | theIObj->SetTransparency (theValue); |
1799 | redisplayPrsRecModes (theIObj, theToUpdateViewer); |
7fd59977 |
1800 | } |
1801 | |
1802 | //======================================================================= |
1803 | //function : UnsetTransparency |
2195ab96 |
1804 | //purpose : |
7fd59977 |
1805 | //======================================================================= |
2195ab96 |
1806 | void AIS_InteractiveContext::UnsetTransparency (const Handle(AIS_InteractiveObject)& theIObj, |
1807 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1808 | { |
2195ab96 |
1809 | if (theIObj.IsNull()) |
1810 | { |
1811 | return; |
1812 | } |
7fd59977 |
1813 | |
2195ab96 |
1814 | theIObj->UnsetTransparency(); |
1815 | redisplayPrsRecModes (theIObj, theToUpdateViewer); |
7fd59977 |
1816 | } |
1817 | |
2195ab96 |
1818 | //======================================================================= |
1819 | //function : SetSelectedAspect |
1820 | //purpose : |
1821 | //======================================================================= |
1822 | void AIS_InteractiveContext::SetSelectedAspect (const Handle(Prs3d_BasicAspect)& theAspect, |
2195ab96 |
1823 | const Standard_Boolean theToUpdateViewer) |
1824 | { |
2195ab96 |
1825 | Standard_Boolean isFound = Standard_False; |
02974a19 |
1826 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
2195ab96 |
1827 | { |
1828 | isFound = Standard_True; |
02974a19 |
1829 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable()); |
2831708b |
1830 | anObj->SetAspect (theAspect); |
2195ab96 |
1831 | } |
1832 | |
016e5959 |
1833 | if (isFound && theToUpdateViewer) |
2195ab96 |
1834 | { |
1835 | myMainVwr->Update(); |
7fd59977 |
1836 | } |
1837 | } |
7fd59977 |
1838 | |
1839 | //======================================================================= |
1840 | //function : SetLocalAttributes |
2195ab96 |
1841 | //purpose : |
7fd59977 |
1842 | //======================================================================= |
2195ab96 |
1843 | void AIS_InteractiveContext::SetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
6262338c |
1844 | const Handle(Prs3d_Drawer)& theDrawer, |
2195ab96 |
1845 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1846 | { |
2195ab96 |
1847 | if (theIObj.IsNull()) |
1848 | { |
1849 | return; |
1850 | } |
1851 | |
2ec85268 |
1852 | setContextToObject (theIObj); |
2195ab96 |
1853 | theIObj->SetAttributes (theDrawer); |
1854 | Update (theIObj, theToUpdateViewer); |
7fd59977 |
1855 | } |
1856 | |
1857 | //======================================================================= |
1858 | //function : UnsetLocalAttributes |
2195ab96 |
1859 | //purpose : |
7fd59977 |
1860 | //======================================================================= |
2195ab96 |
1861 | void AIS_InteractiveContext::UnsetLocalAttributes (const Handle(AIS_InteractiveObject)& theIObj, |
1862 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
1863 | { |
2195ab96 |
1864 | if (theIObj.IsNull()) |
1865 | { |
1866 | return; |
1867 | } |
7fd59977 |
1868 | |
2ec85268 |
1869 | setContextToObject (theIObj); |
2195ab96 |
1870 | theIObj->UnsetAttributes(); |
1871 | Update (theIObj, theToUpdateViewer); |
1872 | } |
7fd59977 |
1873 | |
1874 | //======================================================================= |
1875 | //function : Status |
2195ab96 |
1876 | //purpose : |
7fd59977 |
1877 | //======================================================================= |
2195ab96 |
1878 | void AIS_InteractiveContext::Status (const Handle(AIS_InteractiveObject)& theIObj, |
1879 | TCollection_ExtendedString& theStatus) const |
7fd59977 |
1880 | { |
2195ab96 |
1881 | theStatus = ""; |
1882 | if (theIObj.IsNull() |
1883 | || !myObjects.IsBound (theIObj)) |
1884 | { |
1885 | return; |
1886 | } |
7fd59977 |
1887 | |
2195ab96 |
1888 | theStatus += "\t ____________________________________________"; |
1889 | theStatus += "\t| Known at Neutral Point:\n\tDisplayStatus:"; |
1890 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); |
1891 | switch (aStatus->GraphicStatus()) |
1892 | { |
7fd59977 |
1893 | case AIS_DS_Displayed: |
2195ab96 |
1894 | { |
1895 | theStatus += "\t| -->Displayed\n"; |
7fd59977 |
1896 | break; |
1897 | } |
2195ab96 |
1898 | case AIS_DS_Erased: |
1899 | { |
1900 | theStatus += "\t| -->Erased\n"; |
1901 | break; |
7fd59977 |
1902 | } |
2195ab96 |
1903 | default: |
1904 | break; |
1905 | } |
1906 | |
1907 | theStatus += "\t| Active Display Modes in the MainViewer :\n"; |
3db69e41 |
1908 | theStatus += "\t|\t Mode "; |
1909 | theStatus += TCollection_AsciiString (aStatus->DisplayMode()); |
1910 | theStatus += "\n"; |
1911 | |
2195ab96 |
1912 | if (IsSelected(theIObj)) theStatus +="\t| Selected\n"; |
7fd59977 |
1913 | |
2195ab96 |
1914 | theStatus += "\t| Active Selection Modes in the MainViewer :\n"; |
1915 | for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next()) |
1916 | { |
1917 | theStatus += "\t\t Mode "; |
1918 | theStatus += TCollection_AsciiString (aSelModeIter.Value()); |
1919 | theStatus += "\n"; |
1920 | } |
1921 | theStatus += "\t ____________________________________________"; |
1922 | } |
7fd59977 |
1923 | |
1924 | //======================================================================= |
1925 | //function : GetDefModes |
2195ab96 |
1926 | //purpose : |
7fd59977 |
1927 | //======================================================================= |
2195ab96 |
1928 | void AIS_InteractiveContext::GetDefModes (const Handle(AIS_InteractiveObject)& theIObj, |
1929 | Standard_Integer& theDispMode, |
1930 | Standard_Integer& theHiMode, |
1931 | Standard_Integer& theSelMode) const |
7fd59977 |
1932 | { |
2195ab96 |
1933 | if (theIObj.IsNull()) |
1934 | { |
1935 | return; |
1936 | } |
7fd59977 |
1937 | |
2195ab96 |
1938 | theDispMode = theIObj->HasDisplayMode() |
1939 | ? theIObj->DisplayMode() |
f838dac4 |
1940 | : (theIObj->AcceptDisplayMode (myDefaultDrawer->DisplayMode()) |
1941 | ? myDefaultDrawer->DisplayMode() |
2195ab96 |
1942 | : 0); |
1943 | theHiMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : theDispMode; |
c3282ec1 |
1944 | theSelMode = theIObj->GlobalSelectionMode(); |
2195ab96 |
1945 | } |
7fd59977 |
1946 | |
1947 | //======================================================================= |
1948 | //function : EraseGlobal |
2195ab96 |
1949 | //purpose : |
7fd59977 |
1950 | //======================================================================= |
2195ab96 |
1951 | void AIS_InteractiveContext::EraseGlobal (const Handle(AIS_InteractiveObject)& theIObj, |
1952 | const Standard_Boolean theToUpdateviewer) |
7fd59977 |
1953 | { |
2195ab96 |
1954 | if (theIObj.IsNull() |
1955 | || !myObjects.IsBound (theIObj)) |
1956 | { |
1957 | return; |
1958 | } |
7fd59977 |
1959 | |
2195ab96 |
1960 | Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); |
1961 | |
a1954302 |
1962 | const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
68dcee02 |
1963 | if (aStatus->GraphicStatus() == AIS_DS_Erased) |
2195ab96 |
1964 | { |
a1954302 |
1965 | return; |
1966 | } |
2195ab96 |
1967 | |
3db69e41 |
1968 | if (aStatus->IsHilighted()) |
a1954302 |
1969 | { |
404c8936 |
1970 | Standard_DISABLE_DEPRECATION_WARNINGS |
3db69e41 |
1971 | if (IsCurrent (theIObj)) |
2195ab96 |
1972 | { |
3db69e41 |
1973 | AddOrRemoveCurrentObject (theIObj, Standard_False); |
1974 | } |
1975 | else if (myMainPM->IsHighlighted (theIObj, aStatus->DisplayMode())) |
1976 | { |
f838dac4 |
1977 | unhighlightGlobal (theIObj); |
2195ab96 |
1978 | } |
404c8936 |
1979 | Standard_ENABLE_DEPRECATION_WARNINGS |
a1954302 |
1980 | } |
2195ab96 |
1981 | |
3db69e41 |
1982 | myMainPM->SetVisibility (theIObj, aStatus->DisplayMode(), Standard_False); |
1983 | |
4f51d9d7 |
1984 | if (aStatus->IsHilighted() |
1985 | && theIObj->HasHilightMode()) |
1986 | { |
f838dac4 |
1987 | unhighlightGlobal (theIObj); |
4f51d9d7 |
1988 | } |
1989 | |
1990 | if (!myLastPicked.IsNull() |
8e5fb5ea |
1991 | && myLastPicked->IsSameSelectable (theIObj)) |
4f51d9d7 |
1992 | { |
731c9b5b |
1993 | clearDynamicHighlight(); |
4f51d9d7 |
1994 | } |
1995 | |
905b0e31 |
1996 | // make sure highlighting presentations are properly erased |
1997 | theIObj->ErasePresentations (false); |
1998 | |
c3282ec1 |
1999 | if (IsSelected (theIObj) |
3db69e41 |
2000 | && aStatus->DisplayMode() != aDispMode) |
a1954302 |
2001 | { |
2002 | myMainPM->SetVisibility (theIObj, aDispMode, Standard_False); |
2003 | } |
2004 | |
2005 | for (TColStd_ListIteratorOfListOfInteger aSelModeIter (aStatus->SelectionModes()); aSelModeIter.More(); aSelModeIter.Next()) |
2006 | { |
68dcee02 |
2007 | mgrSelector->Deactivate (theIObj, aSelModeIter.Value()); |
7fd59977 |
2008 | } |
c3282ec1 |
2009 | aStatus->ClearSelectionModes(); |
2195ab96 |
2010 | aStatus->SetGraphicStatus (AIS_DS_Erased); |
a1954302 |
2011 | |
2012 | if (theToUpdateviewer) |
2013 | { |
2014 | myMainVwr->Update(); |
2015 | } |
7fd59977 |
2016 | } |
2017 | |
c3282ec1 |
2018 | //======================================================================= |
2019 | //function : unhighlightOwners |
2020 | //purpose : |
2021 | //======================================================================= |
2022 | void AIS_InteractiveContext::unhighlightOwners (const Handle(AIS_InteractiveObject)& theObject) |
2023 | { |
02974a19 |
2024 | SelectMgr_SequenceOfOwner aSeq; |
2025 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
c3282ec1 |
2026 | { |
a3d4053c |
2027 | if (aSelIter.Value()->IsSameSelectable (theObject)) |
c3282ec1 |
2028 | { |
02974a19 |
2029 | aSeq.Append (aSelIter.Value()); |
c3282ec1 |
2030 | } |
02974a19 |
2031 | } |
2032 | for (SelectMgr_SequenceOfOwner::Iterator aDelIter (aSeq); aDelIter.More(); aDelIter.Next()) |
2033 | { |
2034 | AddOrRemoveSelected (aDelIter.Value(), Standard_False); |
c3282ec1 |
2035 | } |
2036 | } |
2037 | |
7fd59977 |
2038 | //======================================================================= |
2039 | //function : ClearGlobal |
2195ab96 |
2040 | //purpose : |
7fd59977 |
2041 | //======================================================================= |
2195ab96 |
2042 | void AIS_InteractiveContext::ClearGlobal (const Handle(AIS_InteractiveObject)& theIObj, |
2043 | const Standard_Boolean theToUpdateviewer) |
7fd59977 |
2044 | { |
2195ab96 |
2045 | if (theIObj.IsNull() |
2046 | || !myObjects.IsBound (theIObj)) |
2047 | { |
f751596e |
2048 | // for cases when reference shape of connected interactives was not displayed |
2049 | // but its selection primitives were calculated |
543a9964 |
2050 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
2051 | mgrSelector->Remove (anObj); |
2195ab96 |
2052 | return; |
2053 | } |
2054 | |
2055 | Handle(AIS_GlobalStatus) aStatus = myObjects (theIObj); |
c3282ec1 |
2056 | unhighlightOwners (theIObj); |
7fd59977 |
2057 | |
e2d7642f |
2058 | myMainPM->Erase (theIObj, -1); |
905b0e31 |
2059 | theIObj->ErasePresentations (true); // make sure highlighting presentations are properly erased |
4f51d9d7 |
2060 | |
2195ab96 |
2061 | // Object removes from Detected sequence |
404c8936 |
2062 | Standard_DISABLE_DEPRECATION_WARNINGS |
f2a88e54 |
2063 | for (Standard_Integer aDetIter = myDetectedSeq.Lower(); aDetIter <= myDetectedSeq.Upper();) |
7fd59977 |
2064 | { |
f2a88e54 |
2065 | Handle(SelectMgr_EntityOwner) aPicked = myMainSel->Picked (myDetectedSeq (aDetIter)); |
2066 | Handle(AIS_InteractiveObject) anObj; |
2067 | if (!aPicked.IsNull()) |
2068 | { |
2069 | anObj = Handle(AIS_InteractiveObject)::DownCast (aPicked->Selectable()); |
2070 | } |
2071 | |
2195ab96 |
2072 | if (!anObj.IsNull() |
f2a88e54 |
2073 | && anObj == theIObj) |
2195ab96 |
2074 | { |
f0cddd16 |
2075 | myDetectedSeq.Remove (aDetIter); |
f2a88e54 |
2076 | if (myCurDetected == aDetIter) |
2077 | { |
2078 | myCurDetected = Min (myDetectedSeq.Upper(), aDetIter); |
2079 | } |
2080 | if (myCurHighlighted == aDetIter) |
2081 | { |
2082 | myCurHighlighted = 0; |
2083 | } |
2084 | } |
2085 | else |
2086 | { |
2087 | aDetIter++; |
2195ab96 |
2088 | } |
7fd59977 |
2089 | } |
404c8936 |
2090 | Standard_ENABLE_DEPRECATION_WARNINGS |
7fd59977 |
2091 | |
2195ab96 |
2092 | // remove IO from the selection manager to avoid memory leaks |
543a9964 |
2093 | const Handle(SelectMgr_SelectableObject)& anObj = theIObj; // to avoid ambiguity |
2094 | mgrSelector->Remove (anObj); |
7fd59977 |
2095 | |
2195ab96 |
2096 | myObjects.UnBind (theIObj); |
c357e426 |
2097 | myMainVwr->StructureManager()->UnregisterObject (theIObj); |
6a24c6de |
2098 | |
2099 | for (V3d_ListOfViewIterator aDefViewIter (myMainVwr->DefinedViewIterator()); aDefViewIter.More(); aDefViewIter.Next()) |
a272ed94 |
2100 | { |
6a24c6de |
2101 | aDefViewIter.Value()->View()->ChangeHiddenObjects()->Remove (theIObj.get()); |
a272ed94 |
2102 | } |
7fd59977 |
2103 | |
1beb58d7 |
2104 | if (!myLastinMain.IsNull()) |
2105 | { |
2106 | if (myLastinMain->IsSameSelectable (theIObj) |
2107 | || myLastPicked->IsSameSelectable(theIObj)) |
2108 | { |
731c9b5b |
2109 | clearDynamicHighlight(); |
1beb58d7 |
2110 | myLastinMain.Nullify(); |
f2a88e54 |
2111 | myLastPicked.Nullify(); |
1beb58d7 |
2112 | } |
2113 | } |
c3282ec1 |
2114 | |
2115 | if (theToUpdateviewer && aStatus->GraphicStatus() == AIS_DS_Displayed) |
eb4320f2 |
2116 | { |
2117 | myMainVwr->Update(); |
2118 | } |
7fd59977 |
2119 | } |
2120 | |
2121 | //======================================================================= |
2122 | //function : ClearGlobalPrs |
2195ab96 |
2123 | //purpose : |
7fd59977 |
2124 | //======================================================================= |
2195ab96 |
2125 | void AIS_InteractiveContext::ClearGlobalPrs (const Handle(AIS_InteractiveObject)& theIObj, |
2126 | const Standard_Integer theMode, |
2127 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
2128 | { |
2195ab96 |
2129 | if (theIObj.IsNull() |
2130 | || !myObjects.IsBound (theIObj)) |
2131 | { |
2132 | return; |
2133 | } |
2134 | |
2135 | const Handle(AIS_GlobalStatus)& aStatus = myObjects (theIObj); |
3db69e41 |
2136 | if (aStatus->DisplayMode() == theMode) |
2195ab96 |
2137 | { |
2138 | const Standard_Integer aDispMode = theIObj->HasHilightMode() ? theIObj->HilightMode() : 0; |
2139 | if (aDispMode == theMode |
2140 | && myMainPM->IsHighlighted (theIObj, theMode)) |
2141 | { |
f838dac4 |
2142 | unhighlightGlobal (theIObj); |
2195ab96 |
2143 | } |
2144 | |
2145 | myMainPM->Erase (theIObj, theMode); |
7fd59977 |
2146 | } |
eb4320f2 |
2147 | |
2195ab96 |
2148 | if (aStatus->GraphicStatus() == AIS_DS_Displayed |
2149 | && theToUpdateViewer) |
2150 | { |
7fd59977 |
2151 | myMainVwr->Update(); |
2195ab96 |
2152 | } |
7fd59977 |
2153 | } |
2154 | |
8a590580 |
2155 | //======================================================================= |
2156 | //function : ClearDetected |
2157 | //purpose : |
2158 | //======================================================================= |
2159 | Standard_Boolean AIS_InteractiveContext::ClearDetected (Standard_Boolean theToRedrawImmediate) |
2160 | { |
2161 | myCurDetected = 0; |
2162 | myCurHighlighted = 0; |
2163 | myDetectedSeq.Clear(); |
2164 | myLastPicked = myLastinMain; |
2165 | myWasLastMain = Standard_True; |
2166 | Standard_Boolean toUpdate = Standard_False; |
2167 | if (!myLastPicked.IsNull() && myLastPicked->HasSelectable()) |
2168 | { |
2169 | toUpdate = Standard_True; |
2170 | clearDynamicHighlight(); |
2171 | } |
2172 | myLastinMain.Nullify(); |
2173 | myLastPicked.Nullify(); |
2174 | myMainSel->ClearPicked(); |
2175 | if (toUpdate && theToRedrawImmediate) |
2176 | { |
2177 | myMainVwr->RedrawImmediate(); |
2178 | } |
2179 | return toUpdate; |
2180 | } |
2181 | |
7fd59977 |
2182 | //======================================================================= |
2183 | //function : DrawHiddenLine |
2195ab96 |
2184 | //purpose : |
7fd59977 |
2185 | //======================================================================= |
2195ab96 |
2186 | Standard_Boolean AIS_InteractiveContext::DrawHiddenLine() const |
2187 | { |
7fd59977 |
2188 | return myDefaultDrawer->DrawHiddenLine(); |
2189 | } |
2190 | |
2191 | //======================================================================= |
2192 | //function : EnableDrawHiddenLine |
2195ab96 |
2193 | //purpose : |
7fd59977 |
2194 | //======================================================================= |
2195ab96 |
2195 | void AIS_InteractiveContext::EnableDrawHiddenLine() const |
2196 | { |
7fd59977 |
2197 | myDefaultDrawer->EnableDrawHiddenLine(); |
2198 | } |
2199 | |
2200 | //======================================================================= |
2201 | //function : DisableDrawHiddenLine |
2195ab96 |
2202 | //purpose : |
7fd59977 |
2203 | //======================================================================= |
2195ab96 |
2204 | void AIS_InteractiveContext::DisableDrawHiddenLine() const |
2205 | { |
7fd59977 |
2206 | myDefaultDrawer->DisableDrawHiddenLine(); |
2207 | } |
2208 | |
2209 | //======================================================================= |
2210 | //function : HiddenLineAspect |
2195ab96 |
2211 | //purpose : |
7fd59977 |
2212 | //======================================================================= |
2195ab96 |
2213 | Handle (Prs3d_LineAspect) AIS_InteractiveContext::HiddenLineAspect() const |
2214 | { |
7fd59977 |
2215 | return myDefaultDrawer->HiddenLineAspect(); |
2216 | } |
2217 | |
2218 | //======================================================================= |
2219 | //function : SetHiddenLineAspect |
2195ab96 |
2220 | //purpose : |
7fd59977 |
2221 | //======================================================================= |
2195ab96 |
2222 | void AIS_InteractiveContext::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect) const |
2223 | { |
2224 | myDefaultDrawer->SetHiddenLineAspect (theAspect); |
7fd59977 |
2225 | } |
2226 | |
2227 | //======================================================================= |
2228 | //function : SetIsoNumber |
2195ab96 |
2229 | //purpose : |
7fd59977 |
2230 | //======================================================================= |
2195ab96 |
2231 | void AIS_InteractiveContext::SetIsoNumber (const Standard_Integer theNb, |
2232 | const AIS_TypeOfIso theType) |
7fd59977 |
2233 | { |
2195ab96 |
2234 | switch (theType) |
2235 | { |
2236 | case AIS_TOI_IsoU: |
2237 | myDefaultDrawer->UIsoAspect()->SetNumber (theNb); |
2238 | break; |
2239 | case AIS_TOI_IsoV: |
2240 | myDefaultDrawer->VIsoAspect()->SetNumber (theNb); |
2241 | break; |
2242 | case AIS_TOI_Both: |
2243 | myDefaultDrawer->UIsoAspect()->SetNumber (theNb); |
2244 | myDefaultDrawer->VIsoAspect()->SetNumber (theNb); |
2245 | break; |
7fd59977 |
2246 | } |
2247 | } |
2195ab96 |
2248 | |
7fd59977 |
2249 | //======================================================================= |
2250 | //function : IsoNumber |
2195ab96 |
2251 | //purpose : |
7fd59977 |
2252 | //======================================================================= |
2195ab96 |
2253 | Standard_Integer AIS_InteractiveContext::IsoNumber (const AIS_TypeOfIso theType) |
7fd59977 |
2254 | { |
2195ab96 |
2255 | switch (theType) |
2256 | { |
2257 | case AIS_TOI_IsoU: return myDefaultDrawer->UIsoAspect()->Number(); |
2258 | case AIS_TOI_IsoV: return myDefaultDrawer->VIsoAspect()->Number(); |
2259 | case AIS_TOI_Both: return myDefaultDrawer->UIsoAspect()->Number() == myDefaultDrawer->VIsoAspect()->Number() |
2260 | ? myDefaultDrawer->UIsoAspect()->Number() |
2261 | : -1; |
7fd59977 |
2262 | } |
2263 | return 0; |
2264 | } |
2265 | |
2266 | //======================================================================= |
2267 | //function : IsoOnPlane |
2195ab96 |
2268 | //purpose : |
7fd59977 |
2269 | //======================================================================= |
2195ab96 |
2270 | void AIS_InteractiveContext::IsoOnPlane (const Standard_Boolean theToSwitchOn) |
7fd59977 |
2271 | { |
2195ab96 |
2272 | myDefaultDrawer->SetIsoOnPlane (theToSwitchOn); |
7fd59977 |
2273 | } |
2274 | |
2275 | //======================================================================= |
2276 | //function : IsoOnPlane |
2195ab96 |
2277 | //purpose : |
7fd59977 |
2278 | //======================================================================= |
2195ab96 |
2279 | Standard_Boolean AIS_InteractiveContext::IsoOnPlane() const |
7fd59977 |
2280 | { |
2281 | return myDefaultDrawer->IsoOnPlane(); |
2282 | } |
2283 | |
3c982548 |
2284 | //======================================================================= |
5ad8c033 |
2285 | //function : IsoOnTriangulation |
2286 | //purpose : |
2287 | //======================================================================= |
2288 | void AIS_InteractiveContext::IsoOnTriangulation (const Standard_Boolean theToSwitchOn) |
2289 | { |
2290 | myDefaultDrawer->SetIsoOnTriangulation (theToSwitchOn); |
2291 | } |
2292 | |
2293 | //======================================================================= |
2294 | //function : IsoOnTriangulation |
2295 | //purpose : |
2296 | //======================================================================= |
2297 | Standard_Boolean AIS_InteractiveContext::IsoOnTriangulation() const |
2298 | { |
2299 | return myDefaultDrawer->IsoOnTriangulation(); |
2300 | } |
2301 | |
51004f1c |
2302 | //======================================================================= |
3c982548 |
2303 | //function : SetPixelTolerance |
51004f1c |
2304 | //purpose : |
3c982548 |
2305 | //======================================================================= |
3bf9a45f |
2306 | void AIS_InteractiveContext::SetPixelTolerance (const Standard_Integer thePrecision) |
2195ab96 |
2307 | { |
68dcee02 |
2308 | myMainSel->SetPixelTolerance (thePrecision); |
7fd59977 |
2309 | } |
3c982548 |
2310 | |
2311 | //======================================================================= |
2312 | //function : PixelTolerance |
2195ab96 |
2313 | //purpose : |
3c982548 |
2314 | //======================================================================= |
3bf9a45f |
2315 | Standard_Integer AIS_InteractiveContext::PixelTolerance() const |
2195ab96 |
2316 | { |
68dcee02 |
2317 | return myMainSel->PixelTolerance(); |
3c982548 |
2318 | } |
7fd59977 |
2319 | |
8a1170ad |
2320 | //======================================================================= |
2321 | //function : SetSelectionSensitivity |
2322 | //purpose : Allows to manage sensitivity of a particular selection of interactive object theObject |
2323 | //======================================================================= |
2324 | void AIS_InteractiveContext::SetSelectionSensitivity (const Handle(AIS_InteractiveObject)& theObject, |
2325 | const Standard_Integer theMode, |
2326 | const Standard_Integer theNewSensitivity) |
2327 | { |
8a1170ad |
2328 | mgrSelector->SetSelectionSensitivity (theObject, theMode, theNewSensitivity); |
2329 | } |
2330 | |
7fd59977 |
2331 | //======================================================================= |
2332 | //function : InitAttributes |
2195ab96 |
2333 | //purpose : |
7fd59977 |
2334 | //======================================================================= |
7fd59977 |
2335 | void AIS_InteractiveContext::InitAttributes() |
2336 | { |
2195ab96 |
2337 | Graphic3d_MaterialAspect aMat (Graphic3d_NOM_BRASS); |
2338 | myDefaultDrawer->ShadingAspect()->SetMaterial (aMat); |
7fd59977 |
2339 | |
2340 | // myDefaultDrawer->ShadingAspect()->SetColor(Quantity_NOC_GRAY70); |
2195ab96 |
2341 | Handle(Prs3d_LineAspect) aLineAspect = myDefaultDrawer->HiddenLineAspect(); |
2342 | aLineAspect->SetColor (Quantity_NOC_GRAY20); |
2343 | aLineAspect->SetWidth (1.0); |
2344 | aLineAspect->SetTypeOfLine (Aspect_TOL_DASH); |
7fd59977 |
2345 | |
28ee613b |
2346 | // tolerance to 2 pixels... |
3bf9a45f |
2347 | SetPixelTolerance (2); |
7fd59977 |
2348 | |
2349 | // Customizing the drawer for trihedrons and planes... |
2195ab96 |
2350 | Handle(Prs3d_DatumAspect) aTrihAspect = myDefaultDrawer->DatumAspect(); |
2351 | const Standard_Real aLength = 100.0; |
2352 | aTrihAspect->SetAxisLength (aLength, aLength, aLength); |
87432b82 |
2353 | const Quantity_Color aColor = Quantity_NOC_LIGHTSTEELBLUE4; |
bc001a40 |
2354 | aTrihAspect->LineAspect(Prs3d_DP_XAxis)->SetColor (aColor); |
2355 | aTrihAspect->LineAspect(Prs3d_DP_YAxis)->SetColor (aColor); |
2356 | aTrihAspect->LineAspect(Prs3d_DP_ZAxis)->SetColor (aColor); |
7fd59977 |
2357 | |
2195ab96 |
2358 | Handle(Prs3d_PlaneAspect) aPlaneAspect = myDefaultDrawer->PlaneAspect(); |
2359 | const Standard_Real aPlaneLength = 200.0; |
2360 | aPlaneAspect->SetPlaneLength (aPlaneLength, aPlaneLength); |
2361 | aPlaneAspect->EdgesAspect()->SetColor (Quantity_NOC_SKYBLUE); |
7fd59977 |
2362 | } |
2363 | |
7fd59977 |
2364 | //======================================================================= |
2365 | //function : TrihedronSize |
2195ab96 |
2366 | //purpose : |
7fd59977 |
2367 | //======================================================================= |
2368 | Standard_Real AIS_InteractiveContext::TrihedronSize() const |
2369 | { |
bc001a40 |
2370 | return myDefaultDrawer->DatumAspect()->AxisLength(Prs3d_DP_XAxis); |
7fd59977 |
2371 | } |
2195ab96 |
2372 | |
7fd59977 |
2373 | //======================================================================= |
2374 | //function : SetTrihedronSize |
2195ab96 |
2375 | //purpose : |
7fd59977 |
2376 | //======================================================================= |
2195ab96 |
2377 | void AIS_InteractiveContext::SetTrihedronSize (const Standard_Real theVal, |
2378 | const Standard_Boolean /*updateviewer*/) |
7fd59977 |
2379 | { |
2195ab96 |
2380 | myDefaultDrawer->DatumAspect()->SetAxisLength (theVal, theVal, theVal); |
2381 | Redisplay (AIS_KOI_Datum, 3, Standard_False); |
2382 | Redisplay (AIS_KOI_Datum, 4, Standard_True); |
7fd59977 |
2383 | } |
2384 | |
7fd59977 |
2385 | //======================================================================= |
2386 | //function : SetPlaneSize |
2195ab96 |
2387 | //purpose : |
7fd59977 |
2388 | //======================================================================= |
2195ab96 |
2389 | void AIS_InteractiveContext::SetPlaneSize(const Standard_Real theValX, |
2390 | const Standard_Real theValY, |
0577ae8c |
2391 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
2392 | { |
2195ab96 |
2393 | myDefaultDrawer->PlaneAspect()->SetPlaneLength (theValX, theValY); |
0577ae8c |
2394 | Redisplay (AIS_KOI_Datum, 7, theToUpdateViewer); |
7fd59977 |
2395 | } |
2396 | |
2397 | //======================================================================= |
2398 | //function : SetPlaneSize |
2195ab96 |
2399 | //purpose : |
7fd59977 |
2400 | //======================================================================= |
2195ab96 |
2401 | void AIS_InteractiveContext::SetPlaneSize (const Standard_Real theVal, |
2402 | const Standard_Boolean theToUpdateViewer) |
7fd59977 |
2403 | { |
2195ab96 |
2404 | SetPlaneSize (theVal, theVal, theToUpdateViewer); |
7fd59977 |
2405 | } |
2406 | |
2407 | //======================================================================= |
2408 | //function : PlaneSize |
2195ab96 |
2409 | //purpose : |
7fd59977 |
2410 | //======================================================================= |
2195ab96 |
2411 | Standard_Boolean AIS_InteractiveContext::PlaneSize (Standard_Real& theX, |
2412 | Standard_Real& theY) const |
7fd59977 |
2413 | { |
2195ab96 |
2414 | theX = myDefaultDrawer->PlaneAspect()->PlaneXLength(); |
2415 | theY = myDefaultDrawer->PlaneAspect()->PlaneYLength(); |
2416 | return (Abs (theX - theY) <= Precision::Confusion()); |
7fd59977 |
2417 | } |
2418 | |
59f45b7c |
2419 | //======================================================================= |
2420 | //function : SetZLayer |
2195ab96 |
2421 | //purpose : |
59f45b7c |
2422 | //======================================================================= |
59f45b7c |
2423 | void AIS_InteractiveContext::SetZLayer (const Handle(AIS_InteractiveObject)& theIObj, |
8f138407 |
2424 | const Graphic3d_ZLayerId theLayerId) |
59f45b7c |
2425 | { |
2195ab96 |
2426 | if (theIObj.IsNull()) |
59f45b7c |
2427 | return; |
2428 | |
a1954302 |
2429 | theIObj->SetZLayer (theLayerId); |
59f45b7c |
2430 | } |
2431 | |
2432 | //======================================================================= |
2433 | //function : GetZLayer |
2195ab96 |
2434 | //purpose : |
59f45b7c |
2435 | //======================================================================= |
8f138407 |
2436 | Graphic3d_ZLayerId AIS_InteractiveContext::GetZLayer (const Handle(AIS_InteractiveObject)& theIObj) const |
59f45b7c |
2437 | { |
a1954302 |
2438 | return !theIObj.IsNull() |
2439 | ? theIObj->ZLayer() |
2440 | : Graphic3d_ZLayerId_UNKNOWN; |
59f45b7c |
2441 | } |
f751596e |
2442 | |
2443 | //======================================================================= |
2444 | //function : RebuildSelectionStructs |
2445 | //purpose : Rebuilds 1st level of BVH selection forcibly |
2446 | //======================================================================= |
2447 | void AIS_InteractiveContext::RebuildSelectionStructs() |
2448 | { |
2449 | myMainSel->RebuildObjectsTree (Standard_True); |
2450 | } |
2451 | |
2452 | //======================================================================= |
2453 | //function : Disconnect |
2454 | //purpose : Disconnects selectable object from an assembly and updates selection structures |
2455 | //======================================================================= |
2456 | void AIS_InteractiveContext::Disconnect (const Handle(AIS_InteractiveObject)& theAssembly, |
2457 | const Handle(AIS_InteractiveObject)& theObjToDisconnect) |
2458 | { |
2459 | if (theAssembly->IsInstance ("AIS_MultipleConnectedInteractive")) |
2460 | { |
c5f3a425 |
2461 | Handle(AIS_MultipleConnectedInteractive) theObj (Handle(AIS_MultipleConnectedInteractive)::DownCast (theAssembly)); |
f751596e |
2462 | theObj->Disconnect (theObjToDisconnect); |
543a9964 |
2463 | const Handle(SelectMgr_SelectableObject)& anObj = theObjToDisconnect; // to avoid ambiguity |
2464 | mgrSelector->Remove (anObj); |
f751596e |
2465 | } |
c04c30b3 |
2466 | else if (theAssembly->IsInstance ("AIS_ConnectedInteractive") && theObjToDisconnect.IsNull()) |
f751596e |
2467 | { |
c5f3a425 |
2468 | Handle(AIS_ConnectedInteractive) theObj (Handle(AIS_ConnectedInteractive)::DownCast (theAssembly)); |
f751596e |
2469 | theObj->Disconnect(); |
543a9964 |
2470 | const Handle(SelectMgr_SelectableObject)& anObj = theObj; // to avoid ambiguity |
2471 | mgrSelector->Remove (anObj); |
f751596e |
2472 | } |
2473 | else |
2474 | return; |
2475 | } |
b586500b |
2476 | |
0577ae8c |
2477 | //======================================================================= |
2478 | //function : FitSelected |
2479 | //purpose : Fits the view corresponding to the bounds of selected objects |
2480 | //======================================================================= |
2481 | void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView) |
2482 | { |
2483 | FitSelected (theView, 0.01, Standard_True); |
2484 | } |
2485 | |
b586500b |
2486 | //======================================================================= |
2487 | //function : FitSelected |
2488 | //purpose : Fits the view corresponding to the bounds of selected objects |
2489 | //======================================================================= |
2490 | void AIS_InteractiveContext::FitSelected (const Handle(V3d_View)& theView, |
2491 | const Standard_Real theMargin, |
2492 | const Standard_Boolean theToUpdate) |
2493 | { |
b586500b |
2494 | Bnd_Box aBndSelected; |
b586500b |
2495 | AIS_MapOfObjectOwners anObjectOwnerMap; |
68dcee02 |
2496 | for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next()) |
b586500b |
2497 | { |
b5cce1ab |
2498 | const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value(); |
02974a19 |
2499 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); |
2500 | if (anObj->IsInfinite()) |
b586500b |
2501 | { |
02974a19 |
2502 | continue; |
2503 | } |
b586500b |
2504 | |
02974a19 |
2505 | if (anOwner == anObj->GlobalSelOwner()) |
2506 | { |
b586500b |
2507 | Bnd_Box aTmpBnd; |
2508 | anObj->BoundingBox (aTmpBnd); |
2509 | aBndSelected.Add (aTmpBnd); |
2510 | } |
2511 | else |
2512 | { |
b586500b |
2513 | Handle(SelectMgr_IndexedMapOfOwner) anOwnerMap; |
2514 | if (!anObjectOwnerMap.Find (anOwner->Selectable(), anOwnerMap)) |
2515 | { |
2516 | anOwnerMap = new SelectMgr_IndexedMapOfOwner(); |
2517 | anObjectOwnerMap.Bind (anOwner->Selectable(), anOwnerMap); |
2518 | } |
2519 | |
2520 | anOwnerMap->Add (anOwner); |
2521 | } |
2522 | } |
2523 | |
2524 | for (AIS_MapIteratorOfMapOfObjectOwners anIter (anObjectOwnerMap); anIter.More(); anIter.Next()) |
2525 | { |
2526 | const Handle(SelectMgr_SelectableObject) anObject = anIter.Key(); |
2527 | Bnd_Box aTmpBox = anObject->BndBoxOfSelected (anIter.ChangeValue()); |
2528 | aBndSelected.Add (aTmpBox); |
2529 | } |
2530 | |
2531 | anObjectOwnerMap.Clear(); |
2532 | |
2533 | if (aBndSelected.IsVoid()) |
2534 | return; |
2535 | |
2536 | theView->FitAll (aBndSelected, theMargin, theToUpdate); |
2537 | } |
1d92133e |
2538 | |
2539 | //======================================================================= |
2540 | //function : SetTransformPersistence |
2541 | //purpose : |
2542 | //======================================================================= |
2543 | void AIS_InteractiveContext::SetTransformPersistence (const Handle(AIS_InteractiveObject)& theObject, |
778cd667 |
2544 | const Handle(Graphic3d_TransformPers)& theTrsfPers) |
1d92133e |
2545 | { |
778cd667 |
2546 | theObject->SetTransformPersistence (theTrsfPers); |
1d92133e |
2547 | if (!myObjects.IsBound (theObject)) |
2548 | { |
2549 | return; |
2550 | } |
2551 | |
2552 | mgrSelector->UpdateSelection (theObject); |
2553 | |
2554 | const Standard_Integer aLayerId = myObjects.Find (theObject)->GetLayerIndex(); |
2555 | const Handle(V3d_Viewer)& aCurViewer = CurrentViewer(); |
6a24c6de |
2556 | for (V3d_ListOfViewIterator anActiveViewIter (aCurViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next()) |
1d92133e |
2557 | { |
6a24c6de |
2558 | anActiveViewIter.Value()->View()->InvalidateBVHData (aLayerId); |
2559 | anActiveViewIter.Value()->View()->InvalidateZLayerBoundingBox (aLayerId); |
1d92133e |
2560 | } |
2561 | } |