Salome HOME
Use the prefix std:: instead of the directive using namespace std;
[modules/geom.git] / src / GEOMGUI / GeometryGUI_Swig.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3
4 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 //
7 //  This library is free software; you can redistribute it and/or
8 //  modify it under the terms of the GNU Lesser General Public
9 //  License as published by the Free Software Foundation; either
10 //  version 2.1 of the License.
11 //
12 //  This library is distributed in the hope that it will be useful,
13 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 //  Lesser General Public License for more details.
16 //
17 //  You should have received a copy of the GNU Lesser General Public
18 //  License along with this library; if not, write to the Free Software
19 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 //
21 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 //
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : GeometryGUI_Swig.cxx
25 // Author : Nicolas REJNERI, Paul RASCLE
26 //
27 #include "GeometryGUI_Swig.hxx"
28
29 #include "GeometryGUI.h"
30
31 #include "SUIT_Desktop.h"
32 #include "SUIT_Session.h"
33 #include "SalomeApp_Application.h"
34 #include "SalomeApp_Study.h"
35
36 #include "OB_Browser.h"
37
38 #include "OCCViewer_ViewWindow.h"
39 #include "OCCViewer_ViewManager.h"
40 #include "SOCC_ViewModel.h"
41 #include <SOCC_Prs.h>
42
43 #include "SVTK_ViewModel.h"
44 #include "SVTK_ViewWindow.h"
45 #include "SVTK_View.h"
46 #include "SVTK_Renderer.h"
47 #include <SVTK_Prs.h>
48
49 #include "GEOM_Actor.h"
50 #include "GEOM_Client.hxx"
51 #include "GEOM_AISShape.hxx"
52 #include "GEOM_InteractiveObject.hxx"
53 #include "GEOM_Displayer.h"
54
55 #include "SALOME_Event.h"
56
57 // OCCT Includes
58 #include <TopAbs.hxx>
59 #include <TopoDS_Shape.hxx>
60 #include <AIS_ListOfInteractive.hxx>
61 #include <AIS_ListIteratorOfListOfInteractive.hxx>
62 #include <AIS_Drawer.hxx>
63 #include <BRepTools.hxx>
64
65 // IDL Headers
66 #include <SALOMEconfig.h>
67 #include CORBA_SERVER_HEADER(GEOM_Gen)
68
69 #include <vtkRenderer.h>
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       std::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       std::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           std::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::setVectorsMode(const char* theEntry, bool isOn, bool isUpdated)
397 {
398   class TEvent: public SALOME_Event {
399     std::string myEntry;
400     bool myOn;
401     bool myUpdateViewer;
402   public:
403     TEvent(const char* theEntryArg, bool theOn, bool theUpdated):
404       myEntry(theEntryArg), myOn(theOn), myUpdateViewer(theUpdated)
405     {}
406     virtual void Execute() {
407       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
408       if (!anApp) return;
409
410       Handle(SALOME_InteractiveObject) anIO =
411         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
412
413       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
414         SVTK_View* aView = aViewWindow->getView();
415         SVTK_Viewer* stvkViewer = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
416         SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( stvkViewer->CreatePrs( myEntry.c_str()  ) );
417         vtkActorCollection* anActors = vtkPrs->GetObjects();
418         anActors->InitTraversal();
419         while (vtkActor* anAct = anActors->GetNextActor()) {
420           GEOM_Actor* aGeomActor = GEOM_Actor::SafeDownCast(anAct);
421           aGeomActor->SetVectorMode(!aGeomActor->GetVectorMode());
422         }
423         if (myUpdateViewer)
424           aView->Repaint();
425       }
426       else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
427         Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
428         SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
429         if (soccViewer) {
430           SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
431           if ( occPrs && !occPrs->IsNull() ) {
432             AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
433             AIS_ListIteratorOfListOfInteractive interIter( shapes );
434             for ( ; interIter.More(); interIter.Next() ) {
435               Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
436               aSh->SetDisplayVectors(myOn);
437               ic->RecomputePrsOnly(interIter.Value());
438             }
439           }
440         }
441       }
442     }
443   };
444
445   ProcessVoidEvent(new TEvent (theEntry, isOn, isUpdated));
446 }
447
448 void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue, bool isUpdated)
449 {
450   class TEvent: public SALOME_Event {
451     std::string myEntry;
452     int myRed;
453     int myGreen;
454     int myBlue;
455     bool myUpdateViewer;
456   public:
457     TEvent(const char* theEntryArg, int theR, int theG, int theB, bool theUpdated):
458       myEntry(theEntryArg), myRed(theR), myGreen(theG), myBlue(theB), myUpdateViewer(theUpdated)
459     {}
460     virtual void Execute() {
461       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
462       if (!anApp) return;
463
464       Handle(SALOME_InteractiveObject) anIO =
465         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
466
467       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)){
468         SVTK_View* aView = aViewWindow->getView();
469         QColor aColor (myRed, myGreen, myBlue);
470         aView->SetColor(anIO, aColor);
471         if (myUpdateViewer)
472           aView->Repaint();
473       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
474         Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
475         AIS_ListOfInteractive List;
476         ic->DisplayedObjects(List);
477         AIS_ListIteratorOfListOfInteractive ite (List);
478         for (; ite.More(); ite.Next()) {
479           Handle(SALOME_InteractiveObject) anObj =
480             Handle(SALOME_InteractiveObject)::DownCast(ite.Value()->GetOwner());
481           if (!anObj.IsNull() && anObj->hasEntry() && anObj->isSame(anIO)) {
482             Quantity_Color CSFColor =
483               Quantity_Color(myRed/255., myGreen/255., myBlue/255., Quantity_TOC_RGB);
484             ite.Value()->SetColor(CSFColor);
485             if (ite.Value()->IsKind(STANDARD_TYPE(GEOM_AISShape)))
486               Handle(GEOM_AISShape)::DownCast(ite.Value())->SetShadingColor(CSFColor);
487             ic->Redisplay(ite.Value(), true, true);
488             if (myUpdateViewer)
489               occViewer->update();
490             break;
491           }
492         }
493       }
494     }
495   };
496   ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
497 }
498
499 void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated)
500 {
501   class TEvent: public SALOME_Event {
502     std::string myEntry;
503     float myParam;
504     bool myUpdateViewer;
505   public:
506     TEvent(const char* theEntryArg, float theParam, bool theUpdated):
507       myEntry(theEntryArg), myParam(theParam), myUpdateViewer(theUpdated)
508     {}
509     virtual void Execute() {
510       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
511       if (!anApp) return;
512
513       Handle(SALOME_InteractiveObject) anIO =
514         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
515
516       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
517         SVTK_View* aView = aViewWindow->getView();
518         aView->SetTransparency(anIO, myParam);
519         if (myUpdateViewer)
520           aView->Repaint();
521       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
522         SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
523         if (soccViewer)
524           soccViewer->setTransparency(anIO, myParam, myUpdateViewer);
525       }
526     }
527   };
528
529   ProcessVoidEvent(new TEvent (theEntry, transp, isUpdated));
530 }
531
532
533 class TInitGeomGenEvent: public SALOME_Event {
534 public:
535   typedef bool TResult;
536   TResult myResult;
537   TInitGeomGenEvent() : myResult(false) {}
538   virtual void Execute() {
539     myResult = GeometryGUI::InitGeomGen();
540   }
541 };
542 bool GEOM_Swig::initGeomGen()
543 {
544   return ProcessEvent(new TInitGeomGenEvent());
545 }
546
547
548
549 void GEOM_Swig::eraseGO (const char* Entry, bool allWindows)
550 {
551   class TEvent: public SALOME_Event
552   {
553     std::string myEntry;
554     bool myFromAllWindows;
555   public:
556     TEvent(const char* theEntry, bool fromAllWindows):
557       myEntry(theEntry), myFromAllWindows(fromAllWindows)
558     {}
559     virtual void Execute()
560     {
561       SUIT_Application* app = SUIT_Session::session()->activeApplication();
562       if (!app) return;
563       SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
564       if (!ActiveStudy) return;
565
566       Handle (SALOME_InteractiveObject) aIO = new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
567
568       GEOM_Displayer(ActiveStudy).Erase(aIO, true);
569       /*      if (myFromAllWindows) {
570         QPtrList<SUIT_ViewWindow> aWindows = app->desktop()->windows();
571         SUIT_ViewWindow* aWin = 0;
572         for (aWin = aWindows.first(); aWin; aWin = aWindows.next()) {
573           EraseObject(aWin, aIO);
574         }
575       } else {
576         SUIT_ViewWindow* aWin = app->desktop()->activeWindow();
577         if (aWin)
578           EraseObject(aWin, aIO);
579           }*/
580     }
581
582     /*  private:
583     void EraseObject(SUIT_ViewWindow* theWin, Handle (SALOME_InteractiveObject) theIO)
584     {
585       if (theWin->getViewManager()->getType() == OCCViewer_Viewer::Type()){
586         OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( theWin );
587         if ( vw ) {
588           OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
589           if ( vm ) {
590             SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>(vm->getOCCViewer());
591             if (aViewer) {
592               SALOME_Prs* aPrs = aViewer->CreatePrs(myEntry.c_str());
593               if (aPrs) {
594                 SALOME_OCCPrs* aOccPrs =  dynamic_cast<SALOME_OCCPrs*>(aPrs);
595                 if (aOccPrs) {
596                   aViewer->Erase(aOccPrs);
597                   aViewer->Repaint();
598                 }
599               }
600             }
601           }
602         }
603       } else if (theWin->getViewManager()->getType() == SVTK_Viewer::Type()){
604         SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( theWin );
605         if (aViewWindow) {
606           aViewWindow->Erase(theIO);
607         }
608       }
609       }*/
610
611   };
612   ProcessVoidEvent(new TEvent(Entry, allWindows));
613 }
614
615
616
617 void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect)
618 {
619   class TEvent: public SALOME_Event {
620     std::string myEntry;
621     float myParam;
622   public:
623     TEvent(const char* theEntryArg, float theParam):
624       myEntry(theEntryArg), myParam(theParam)
625     {}
626     virtual void Execute() {
627       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
628       if (!anApp) return;
629
630       Handle(SALOME_InteractiveObject) anIO =
631         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
632
633       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
634         vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors();
635         aActors->InitTraversal();
636         while (vtkActor* aAct = aActors->GetNextActor()) {
637           if (GEOM_Actor* aGeomActor = dynamic_cast<GEOM_Actor*>(aAct)) {
638             if (aGeomActor->hasIO()) {
639               Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO();
640               if (aNextIO->isSame(anIO)) {
641                 aGeomActor->setDeflection(myParam);
642                 aViewWindow->Repaint();
643                 return;
644               }
645             }
646           }
647         }
648         //      aView->SetTransparency(anIO, myParam);
649         //aView->Repaint();
650       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
651         Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext();
652         AIS_ListOfInteractive aAISList;
653         aContext->DisplayedObjects(aAISList);
654         AIS_ListIteratorOfListOfInteractive it(aAISList);
655         for (; it.More(); it.Next()) {
656           Handle(SALOME_InteractiveObject) aObj = 
657             Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner());
658           if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) {
659             Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value());
660             if (!aShape.IsNull()) {
661               TopoDS_Shape aSh = aShape->Shape();
662               if (!aSh.IsNull())
663                 BRepTools::Clean(aSh);
664
665               aShape->SetOwnDeviationCoefficient( myParam );
666               aShape->SetOwnHLRDeviationAngle( 1.57 );
667               aContext->Redisplay(aShape);
668               return;
669             }
670           }
671         }
672       }
673     }
674   };
675
676   ProcessVoidEvent(new TEvent (theEntry, theDeflect));
677 }
678