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