Salome HOME
0020328: EDF 1017 GEOM : Translation with distance GUI Exception, correct in TUI
[modules/geom.git] / src / GEOMGUI / GeometryGUI_Swig.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File   : GeometryGUI_Swig.cxx
24 // Author : Nicolas REJNERI, Paul RASCLE
25 //
26 #include "GeometryGUI_Swig.hxx"
27
28 #include "GeometryGUI.h"
29
30 #include "SUIT_Desktop.h"
31 #include "SUIT_Session.h"
32 #include "SalomeApp_Application.h"
33 #include "SalomeApp_Study.h"
34
35 #include "OB_Browser.h"
36
37 #include "OCCViewer_ViewWindow.h"
38 #include "OCCViewer_ViewManager.h"
39 #include "SOCC_ViewModel.h"
40
41 #include "SVTK_ViewModel.h"
42 #include "SVTK_ViewWindow.h"
43 #include "SVTK_View.h"
44 #include "SVTK_Renderer.h"
45
46 #include "GEOM_Actor.h"
47 #include "GEOM_Client.hxx"
48 #include "GEOM_AISShape.hxx"
49 #include "GEOM_InteractiveObject.hxx"
50 #include "GEOM_Displayer.h"
51
52 #include "SALOME_Event.h"
53
54 // OCCT Includes
55 #include <TopAbs.hxx>
56 #include <TopoDS_Shape.hxx>
57 #include <AIS_ListOfInteractive.hxx>
58 #include <AIS_ListIteratorOfListOfInteractive.hxx>
59 #include <AIS_Drawer.hxx>
60 #include <BRepTools.hxx>
61
62 // IDL Headers
63 #include <SALOMEconfig.h>
64 #include CORBA_SERVER_HEADER(GEOM_Gen)
65
66 #include <vtkRenderer.h>
67
68 using namespace std;
69
70
71 static GEOM_Client ShapeReader;
72
73 inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){
74   SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
75   if(window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()){
76     OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( window );
77     if ( vw ) {
78       OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
79       if ( vm )
80         return vm->getOCCViewer();
81     }
82   }
83
84   return 0;
85 }
86
87 inline SVTK_ViewWindow* GetSVTKViewWindow(SUIT_Application* theApp){
88   SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
89   if(window && window->getViewManager()->getType() == SVTK_Viewer::Type())
90     return dynamic_cast<SVTK_ViewWindow*>( window );
91
92   return 0;
93 }
94
95 GEOM_Swig::GEOM_Swig()
96 {
97   // MESSAGE("Constructeur");
98 }
99
100 GEOM_Swig::~GEOM_Swig()
101 {
102   // MESSAGE("Destructeur");
103 }
104
105 void GEOM_Swig::createAndDisplayGO (const char* Entry, bool isUpdated)
106 {
107   class TEvent: public SALOME_Event
108   {
109     std::string myEntry;
110     bool        myUpdateViewer;
111   public:
112     TEvent(const char* theEntry, bool toUpdateViewer):
113       myEntry(theEntry),
114       myUpdateViewer(toUpdateViewer)
115     {}
116     virtual void Execute()
117     {
118       SUIT_Application* app = SUIT_Session::session()->activeApplication();
119       if (!app) return;
120
121       SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
122       if (!ActiveStudy) return;
123
124       _PTR(Study) aStudy(ActiveStudy->studyDS());
125       _PTR(StudyBuilder) aStudyBuilder = aStudy->NewBuilder();
126
127       GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
128       if (CORBA::is_nil(Geom)) {
129         GeometryGUI::InitGeomGen();
130         Geom = GeometryGUI::GetGeomGen();
131       }
132       if (CORBA::is_nil(Geom))
133         return;
134
135       string aFatherIOR;
136       _PTR(SComponent) father = aStudy->FindComponent("GEOM");
137       if (!father)
138         return;
139       if (!father->ComponentIOR(aFatherIOR)) {
140         CORBA::String_var objStr = SalomeApp_Application::orb()->object_to_string(Geom);
141         aStudyBuilder->LoadWith(father, objStr.in());
142         father->ComponentIOR(aFatherIOR);
143       }
144
145       _PTR(SObject) obj = aStudy->FindObjectID(myEntry);
146       if (!obj)
147         return;
148
149       // Create new actor
150       _PTR(GenericAttribute) anAttr;
151       if (!obj->FindAttribute(anAttr, "AttributeIOR"))
152         return;
153       _PTR(AttributeIOR) anIOR(anAttr);
154       string anIORValue = anIOR->Value();
155
156       GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(anIORValue.c_str());
157       TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
158       if (!Shape.IsNull()) {
159         if (obj->FindAttribute(anAttr, "AttributeName")) {
160           _PTR(AttributeName) aName (anAttr);
161           string aNameValue = aName->Value();
162           // open transaction
163           /*SUIT_Operation* op = new SalomeApp_ImportOperation (app);
164           op->start();
165
166           _PTR(SObject) newObj1 = aStudyBuilder->NewObject(father);
167           aStudyBuilder->Addreference(newObj1, obj);
168           // commit transaction
169           op->commit();*/
170           Handle(GEOM_InteractiveObject) anIO =
171             new GEOM_InteractiveObject (const_cast<char*>(anIORValue.c_str()),
172                                         const_cast<char*>(aFatherIOR.c_str()),
173                                         "GEOM",
174                                         const_cast<char*>( obj->GetID().c_str()));
175
176           GEOM_Displayer(ActiveStudy).Display(anIO, myUpdateViewer);
177           /*if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
178             SVTK_View* aView = aViewWindow->getView();
179             int aMode = aView->GetDisplayMode();
180
181             vtkActorCollection* theActors =
182               GEOM_AssemblyBuilder::BuildActors(Shape,0,aMode,true);
183             theActors->InitTraversal();
184             while (vtkActor* anActor = theActors->GetNextActor()) {
185               GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
186               GActor->setName(const_cast<char*>(aNameValue.c_str()));
187               GActor->setIO(anIO);
188               aView->Display(GActor);
189             }
190             aView->Repaint();
191           } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
192             Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
193             Handle(GEOM_AISShape) aSh =
194               new GEOM_AISShape (Shape,const_cast<char*>(aNameValue.c_str()));
195             aSh->setName(const_cast<char*>(aNameValue.c_str()));
196             aSh->setIO(anIO);
197             ic->Display(aSh);
198             ic->AddOrRemoveCurrentObject(aSh,true);
199             }*/
200           // update object browser
201           SalomeApp_Application* app = NULL; //dynamic_cast<SalomeApp_Application*>(app);
202           if (app) {
203             CAM_Module* module = app->module("Geometry");
204             SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module);
205             if (appMod)
206               appMod->updateObjBrowser(true);
207           }
208         }
209       }
210     }
211   };
212
213   // MESSAGE("createAndDisplayGO");
214   ProcessVoidEvent(new TEvent (Entry, isUpdated));
215
216   class TEventUpdateBrowser: public SALOME_Event
217     {
218       public:
219         TEventUpdateBrowser() {}
220         virtual void Execute() {
221           SalomeApp_Application* app =
222             dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
223           if (app) {
224             CAM_Module* module = app->module("Geometry");
225             SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module);
226             if (appMod) appMod->updateObjBrowser(true);
227           }
228         }
229     };
230
231   if (isUpdated)
232     ProcessVoidEvent(new TEventUpdateBrowser ());
233 }
234
235 void GEOM_Swig::createAndDisplayFitAllGO (const char* Entry)
236 {
237   class TEventFitAll: public SALOME_Event
238   {
239     public:
240       TEventFitAll() {}
241       virtual void Execute() {
242         SUIT_Application* app = SUIT_Session::session()->activeApplication();
243         if (!app) return;
244         
245         if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app))
246           {
247             SVTK_View* aView = aViewWindow->getView();
248             aView->GetRenderer()->OnFitAll();
249           }
250         else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app))
251           {  
252             Handle(V3d_Viewer) aViewer3d = occViewer->getViewer3d();
253             aViewer3d->InitActiveViews();
254             
255             if (aViewer3d->MoreActiveViews())
256               aViewer3d->ActiveView()->FitAll();
257           }
258       }
259   };
260
261   createAndDisplayGO(Entry);
262   ProcessVoidEvent(new TEventFitAll());
263 }
264
265 void GEOM_Swig::UpdateViewer()
266 {
267   class TEventUpdateViewer: public SALOME_Event
268   {
269     public:
270       TEventUpdateViewer() {}
271       virtual void Execute() {
272         SUIT_Application* app = SUIT_Session::session()->activeApplication();
273         if (!app) return;
274         SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
275         if (!ActiveStudy) return;
276         
277         GEOM_Displayer(ActiveStudy).UpdateViewer();
278       }
279   };
280   
281   ProcessVoidEvent(new TEventUpdateViewer());
282 }
283
284 int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR)
285 {
286   GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
287   if (CORBA::is_nil(aGeomGen))
288     return -1;
289
290   GEOM::GEOM_Object_var aMainShape = aGeomGen->GetIORFromString(IOR);
291   GEOM::GEOM_Object_var aSubShape  = aGeomGen->GetIORFromString(SubIOR);
292   if (CORBA::is_nil(aMainShape) || CORBA::is_nil(aSubShape))
293     return -1;
294
295   GEOM::GEOM_IShapesOperations_var anIShapesOperations =
296     aGeomGen->GetIShapesOperations(aMainShape->GetStudyID());
297   if (CORBA::is_nil(anIShapesOperations))
298     return -1;
299
300   return anIShapesOperations->GetTopologyIndex(aMainShape, aSubShape);
301 }
302
303 const char* GEOM_Swig::getShapeTypeString(const char* IOR)
304 {
305   TCollection_AsciiString aTypeName ("Shape of unknown type");
306
307   GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
308   if (!CORBA::is_nil(aGeomGen))
309   {
310     GEOM::GEOM_Object_var aShape = aGeomGen->GetIORFromString(IOR);
311     if (!CORBA::is_nil(aShape))
312     {
313       GEOM::GEOM_IShapesOperations_var anIShapesOperations =
314         aGeomGen->GetIShapesOperations(aShape->GetStudyID());
315       if (!CORBA::is_nil(anIShapesOperations))
316       {
317         aTypeName = anIShapesOperations->GetShapeTypeString(aShape);
318       }
319     }
320   }
321
322   return CORBA::string_dup(aTypeName.ToCString());
323 }
324
325
326 const char* GEOM_Swig::getShapeTypeIcon(const char* IOR)
327 {
328   GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen();
329   if ( CORBA::is_nil( Geom ) )
330     return "None";
331
332   GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR);
333   TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape);
334
335   if( shape.IsNull() ) {
336     return "None" ;
337   }
338
339   switch (shape.ShapeType() )
340     {
341     case TopAbs_COMPOUND:
342       { return "ICON_OBJBROWSER_COMPOUND" ;}
343     case  TopAbs_COMPSOLID:
344       { return "ICON_OBJBROWSER_COMPSOLID" ;}
345     case TopAbs_SOLID:
346       { return "ICON_OBJBROWSER_SOLID" ;}
347     case TopAbs_SHELL:
348       { return "ICON_OBJBROWSER_SHELL" ;}
349     case TopAbs_FACE:
350       { return "ICON_OBJBROWSER_FACE" ;}
351     case TopAbs_WIRE:
352       { return "ICON_OBJBROWSER_WIRE" ;}
353     case TopAbs_EDGE:
354       { return "ICON_OBJBROWSER_EDGE" ;}
355     case TopAbs_VERTEX:
356       { return "ICON_OBJBROWSER_VERTEX" ;}
357     }
358
359   return "None";
360 }
361
362 void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode, bool isUpdated)
363 {
364   class TEvent: public SALOME_Event {
365     std::string myEntry;
366     int myMode;
367     bool myUpdateViewer;
368   public:
369     TEvent(const char* theEntryArg, int theModeArg, bool theUpdated):
370       myEntry(theEntryArg), myMode(theModeArg), myUpdateViewer(theUpdated)
371     {}
372     virtual void Execute() {
373       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
374       if (!anApp) return;
375
376       Handle(SALOME_InteractiveObject) anIO =
377         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
378
379       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
380         SVTK_View* aView = aViewWindow->getView();
381         aView->SetDisplayMode(anIO, myMode);
382         if (myUpdateViewer)
383           aView->Repaint();
384       }
385       else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
386         SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
387         if (soccViewer)
388           soccViewer->switchRepresentation(anIO, myMode, myUpdateViewer);
389       }
390     }
391   };
392
393   ProcessVoidEvent(new TEvent (theEntry, theMode, isUpdated));
394 }
395
396 void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated)
397 {
398   class TEvent: public SALOME_Event {
399     std::string myEntry;
400     int myRed;
401     int myGreen;
402     int myBlue;
403     bool myUpdateViewer;
404   public:
405     TEvent(const char* theEntryArg, int theR, int theG, int theB, bool theUpdated):
406       myEntry(theEntryArg), myRed(theR), myGreen(theG), myBlue(theB), myUpdateViewer(theUpdated)
407     {}
408     virtual void Execute() {
409       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
410       if (!anApp) return;
411
412       Handle(SALOME_InteractiveObject) anIO =
413         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
414
415       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)){
416         SVTK_View* aView = aViewWindow->getView();
417         QColor aColor (myRed, myGreen, myBlue);
418         aView->SetColor(anIO, aColor);
419         if (myUpdateViewer)
420           aView->Repaint();
421       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
422         Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
423         AIS_ListOfInteractive List;
424         ic->DisplayedObjects(List);
425         AIS_ListIteratorOfListOfInteractive ite (List);
426         for (; ite.More(); ite.Next()) {
427           Handle(SALOME_InteractiveObject) anObj =
428             Handle(SALOME_InteractiveObject)::DownCast(ite.Value()->GetOwner());
429           if (!anObj.IsNull() && anObj->hasEntry() && anObj->isSame(anIO)) {
430             Quantity_Color CSFColor =
431               Quantity_Color(myRed/255., myGreen/255., myBlue/255., Quantity_TOC_RGB);
432             ite.Value()->SetColor(CSFColor);
433             if (ite.Value()->IsKind(STANDARD_TYPE(GEOM_AISShape)))
434               Handle(GEOM_AISShape)::DownCast(ite.Value())->SetShadingColor(CSFColor);
435             ic->Redisplay(ite.Value(), true, true);
436             if (myUpdateViewer)
437               occViewer->update();
438             break;
439           }
440         }
441       }
442     }
443   };
444   ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
445 }
446
447 void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated)
448 {
449   class TEvent: public SALOME_Event {
450     std::string myEntry;
451     float myParam;
452     bool myUpdateViewer;
453   public:
454     TEvent(const char* theEntryArg, float theParam, bool theUpdated):
455       myEntry(theEntryArg), myParam(theParam), myUpdateViewer(theUpdated)
456     {}
457     virtual void Execute() {
458       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
459       if (!anApp) return;
460
461       Handle(SALOME_InteractiveObject) anIO =
462         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
463
464       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
465         SVTK_View* aView = aViewWindow->getView();
466         aView->SetTransparency(anIO, myParam);
467         if (myUpdateViewer)
468           aView->Repaint();
469       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
470         SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
471         if (soccViewer)
472           soccViewer->setTransparency(anIO, myParam, myUpdateViewer);
473       }
474     }
475   };
476
477   ProcessVoidEvent(new TEvent (theEntry, transp, isUpdated));
478 }
479
480
481 class TInitGeomGenEvent: public SALOME_Event {
482 public:
483   typedef bool TResult;
484   TResult myResult;
485   TInitGeomGenEvent() : myResult(false) {}
486   virtual void Execute() {
487     myResult = GeometryGUI::InitGeomGen();
488   }
489 };
490 bool GEOM_Swig::initGeomGen()
491 {
492   return ProcessEvent(new TInitGeomGenEvent());
493 }
494
495
496
497 void GEOM_Swig::eraseGO (const char* Entry, bool allWindows)
498 {
499   class TEvent: public SALOME_Event
500   {
501     std::string myEntry;
502     bool myFromAllWindows;
503   public:
504     TEvent(const char* theEntry, bool fromAllWindows):
505       myEntry(theEntry), myFromAllWindows(fromAllWindows)
506     {}
507     virtual void Execute()
508     {
509       SUIT_Application* app = SUIT_Session::session()->activeApplication();
510       if (!app) return;
511       SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
512       if (!ActiveStudy) return;
513
514       Handle (SALOME_InteractiveObject) aIO = new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
515
516       GEOM_Displayer(ActiveStudy).Erase(aIO, true);
517       /*      if (myFromAllWindows) {
518         QPtrList<SUIT_ViewWindow> aWindows = app->desktop()->windows();
519         SUIT_ViewWindow* aWin = 0;
520         for (aWin = aWindows.first(); aWin; aWin = aWindows.next()) {
521           EraseObject(aWin, aIO);
522         }
523       } else {
524         SUIT_ViewWindow* aWin = app->desktop()->activeWindow();
525         if (aWin)
526           EraseObject(aWin, aIO);
527           }*/
528     }
529
530     /*  private:
531     void EraseObject(SUIT_ViewWindow* theWin, Handle (SALOME_InteractiveObject) theIO)
532     {
533       if (theWin->getViewManager()->getType() == OCCViewer_Viewer::Type()){
534         OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( theWin );
535         if ( vw ) {
536           OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
537           if ( vm ) {
538             SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>(vm->getOCCViewer());
539             if (aViewer) {
540               SALOME_Prs* aPrs = aViewer->CreatePrs(myEntry.c_str());
541               if (aPrs) {
542                 SALOME_OCCPrs* aOccPrs =  dynamic_cast<SALOME_OCCPrs*>(aPrs);
543                 if (aOccPrs) {
544                   aViewer->Erase(aOccPrs);
545                   aViewer->Repaint();
546                 }
547               }
548             }
549           }
550         }
551       } else if (theWin->getViewManager()->getType() == SVTK_Viewer::Type()){
552         SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( theWin );
553         if (aViewWindow) {
554           aViewWindow->Erase(theIO);
555         }
556       }
557       }*/
558
559   };
560   ProcessVoidEvent(new TEvent(Entry, allWindows));
561 }
562
563
564
565 void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect)
566 {
567   class TEvent: public SALOME_Event {
568     std::string myEntry;
569     float myParam;
570   public:
571     TEvent(const char* theEntryArg, float theParam):
572       myEntry(theEntryArg), myParam(theParam)
573     {}
574     virtual void Execute() {
575       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
576       if (!anApp) return;
577
578       Handle(SALOME_InteractiveObject) anIO =
579         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
580
581       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
582         vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors();
583         aActors->InitTraversal();
584         while (vtkActor* aAct = aActors->GetNextActor()) {
585           if (GEOM_Actor* aGeomActor = dynamic_cast<GEOM_Actor*>(aAct)) {
586             if (aGeomActor->hasIO()) {
587               Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO();
588               if (aNextIO->isSame(anIO)) {
589                 aGeomActor->setDeflection(myParam);
590                 aViewWindow->Repaint();
591                 return;
592               }
593             }
594           }
595         }
596         //      aView->SetTransparency(anIO, myParam);
597         //aView->Repaint();
598       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
599         Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext();
600         AIS_ListOfInteractive aAISList;
601         aContext->DisplayedObjects(aAISList);
602         AIS_ListIteratorOfListOfInteractive it(aAISList);
603         for (; it.More(); it.Next()) {
604           Handle(SALOME_InteractiveObject) aObj = 
605             Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner());
606           if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) {
607             Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value());
608             if (!aShape.IsNull()) {
609               TopoDS_Shape aSh = aShape->Shape();
610               if (!aSh.IsNull())
611                 BRepTools::Clean(aSh);
612
613               aShape->SetOwnDeviationCoefficient( myParam );
614               aShape->SetOwnHLRDeviationAngle( 1.57 );
615               aContext->Redisplay(aShape);
616               return;
617             }
618           }
619         }
620       }
621     }
622   };
623
624   ProcessVoidEvent(new TEvent (theEntry, theDeflect));
625 }
626