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