]> SALOME platform Git repositories - modules/geom.git/blob - src/GEOM_SWIG_WITHIHM/libGEOM_Swig.cxx
Salome HOME
0021827: [CEA 650] TUI setColor on an object displayed in wireframe is ignored
[modules/geom.git] / src / GEOM_SWIG_WITHIHM / libGEOM_Swig.cxx
1 // Copyright (C) 2007-2012  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
23 // GEOM GEOMGUI : GUI for Geometry component
24 // File   : libGEOM_Swig.cxx
25 // Author : Nicolas REJNERI, Paul RASCLE
26 //
27 #include "libGEOM_Swig.h"
28
29 #include "GeometryGUI.h"
30 #include "GEOMToolsGUI.h"
31
32 #include "SUIT_Desktop.h"
33 #include "SUIT_Session.h"
34 #include "SalomeApp_Application.h"
35 #include "SalomeApp_Study.h"
36
37 #include "OB_Browser.h"
38
39 #include "OCCViewer_ViewWindow.h"
40 #include "OCCViewer_ViewManager.h"
41 #include "SOCC_ViewModel.h"
42 #include <SOCC_Prs.h>
43
44 #include "SVTK_ViewModel.h"
45 #include "SVTK_ViewWindow.h"
46 #include "SVTK_View.h"
47 #include "SVTK_Renderer.h"
48 #include <SVTK_Prs.h>
49
50 #include "GEOM_Actor.h"
51 #include "GEOM_Client.hxx"
52 #include "GEOM_AISShape.hxx"
53 #include "GEOM_InteractiveObject.hxx"
54 #include "GEOM_Displayer.h"
55 #include "GEOM_Constants.h"
56
57 #include "SALOME_Event.h"
58
59 // OCCT Includes
60 #include <TopAbs.hxx>
61 #include <TopoDS_Shape.hxx>
62 #include <AIS_ListOfInteractive.hxx>
63 #include <AIS_ListIteratorOfListOfInteractive.hxx>
64 #include <AIS_Drawer.hxx>
65 #include <Prs3d_IsoAspect.hxx>
66 #include <BRepTools.hxx>
67
68 // IDL Headers
69 #include <SALOMEconfig.h>
70 #include CORBA_SERVER_HEADER(GEOM_Gen)
71
72 #include <vtkRenderer.h>
73
74 static SHAPE_READER(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       std::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       std::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           std::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     QString 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       GEOMToolsGUI::SetColor( myEntry, QColor( myRed, myGreen, myBlue), myUpdateViewer );
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         QColor aColor (myRed, myGreen, myBlue);
475         aView->SetColor(anIO, aColor);
476         if (myUpdateViewer)
477           aView->Repaint();
478       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
479         Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
480         SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
481         if (soccViewer)
482           {
483             SALOME_Prs*   prs=      soccViewer->CreatePrs( myEntry.c_str() );
484             const SOCC_Prs* anOCCPrs = dynamic_cast<const SOCC_Prs*>( prs );
485             if ( !anOCCPrs || anOCCPrs->IsNull() )
486               return;
487
488             // get objects to be displayed
489             AIS_ListOfInteractive anAISObjects;
490             anOCCPrs->GetObjects( anAISObjects );
491             AIS_ListIteratorOfListOfInteractive ite( anAISObjects );
492             Quantity_Color CSFColor = Quantity_Color(myRed/255., myGreen/255., myBlue/255., Quantity_TOC_RGB);
493             for ( ; ite.More(); ite.Next() )
494               {
495                 if(!ic->IsDisplayed(ite.Value()))continue;  //only displayed ais 
496                 ite.Value()->SetColor(CSFColor);
497                 if (ite.Value()->IsKind(STANDARD_TYPE(GEOM_AISShape))) Handle(GEOM_AISShape)::DownCast(ite.Value())->SetShadingColor(CSFColor);
498                 ite.Value()->Redisplay(Standard_True); // as in OnColor
499               }
500             if (myUpdateViewer) occViewer->update();
501           }
502           }*/
503     }
504   };
505   ProcessVoidEvent(new TEvent(theEntry, red, green, blue, isUpdated));
506 }
507
508 void GEOM_Swig::setIsos(const char* Entry, int nbU, int nbV, bool isUpdated )
509 {
510   class TEvent: public SALOME_Event {
511     std::string myEntry;
512     int myNbU, myNbV;
513     bool myUpdateViewer;
514   public:
515     TEvent(const char* theEntry, int theNbU, int theNbV, bool theUpdated):
516       myEntry(theEntry), myNbU(theNbU), myNbV(theNbV), myUpdateViewer(theUpdated)
517     {}
518     virtual void Execute() {
519       SUIT_Application* app = SUIT_Session::session()->activeApplication();
520       if (!app) return;
521       SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
522       if (!study) return;
523
524       Handle(SALOME_InteractiveObject) anIO =
525         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
526
527       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(app)) {
528         SVTK_Viewer* aView = dynamic_cast<SVTK_Viewer*>(aViewWindow->getViewManager()->getViewModel());
529         SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( aView->CreatePrs( myEntry.c_str() ) );
530         if ( vtkPrs ) {
531           vtkActorCollection* anActors = vtkPrs->GetObjects();
532           anActors->InitTraversal();
533           GEOM_Actor* anActor = GEOM_Actor::SafeDownCast( anActors->GetNextActor() );
534           if ( anActor ) {
535             int aIsos[2]={myNbU,myNbV};
536             anActor->SetNbIsos(aIsos);
537             anActor->StoreIsoNumbers();
538             QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
539             int aMgrId = aView->getViewManager()->getGlobalId();
540             study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
541           }
542         }
543         
544         if (myUpdateViewer)
545           aView->Repaint();
546       }
547       else if (OCCViewer_Viewer* occViewer = GetOCCViewer(app)) {
548         Handle(AIS_InteractiveContext) ic = occViewer->getAISContext();
549         SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
550         if (soccViewer) {
551           int aMgrId = soccViewer->getViewManager()->getGlobalId();
552           SOCC_Prs* occPrs = dynamic_cast<SOCC_Prs*>( soccViewer->CreatePrs( myEntry.c_str() ) );
553           if ( occPrs && !occPrs->IsNull() ) {
554             AIS_ListOfInteractive shapes; occPrs->GetObjects( shapes );
555             AIS_ListIteratorOfListOfInteractive interIter( shapes );
556             for ( ; interIter.More(); interIter.Next() ) {
557               Handle(GEOM_AISShape) aSh = Handle(GEOM_AISShape)::DownCast( interIter.Value() );
558               if ( !aSh.IsNull() ) {
559                 Handle(AIS_Drawer) drawer = aSh->Attributes();
560                 QVariant v = study->getObjectProperty( aMgrId, myEntry.c_str(), EDGE_WIDTH_PROP, QVariant() );
561                 int width = v.isValid() ? v.toInt() : 1;
562                 drawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbU) );
563                 drawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, width, myNbV) );
564                 aSh->storeIsoNumbers();
565                 ic->SetLocalAttributes(aSh, drawer);
566                 ic->Redisplay(aSh);
567                 QString anIsos = QString("%1%2%3").arg(myNbU).arg(DIGIT_SEPARATOR).arg(myNbV);
568                 study->setObjectProperty(aMgrId, myEntry.c_str(), ISOS_PROP, anIsos);
569               }
570             }
571           }
572         }
573       }
574     }
575   };
576
577   ProcessVoidEvent(new TEvent (Entry, nbU, nbV, isUpdated));
578 }
579
580 void GEOM_Swig::setTransparency(const char* theEntry, float transp, bool isUpdated)
581 {
582   class TEvent: public SALOME_Event {
583     std::string myEntry;
584     float myParam;
585     bool myUpdateViewer;
586   public:
587     TEvent(const char* theEntryArg, float theParam, bool theUpdated):
588       myEntry(theEntryArg), myParam(theParam), myUpdateViewer(theUpdated)
589     {}
590     virtual void Execute() {
591       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
592       if (!anApp) return;
593
594       Handle(SALOME_InteractiveObject) anIO =
595         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
596
597       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
598         SVTK_View* aView = aViewWindow->getView();
599         aView->SetTransparency(anIO, myParam);
600         if (myUpdateViewer)
601           aView->Repaint();
602       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
603         SOCC_Viewer* soccViewer = dynamic_cast<SOCC_Viewer*>(occViewer);
604         if (soccViewer)
605           soccViewer->setTransparency(anIO, myParam, myUpdateViewer);
606       }
607     }
608   };
609
610   ProcessVoidEvent(new TEvent (theEntry, transp, isUpdated));
611 }
612
613
614 class TInitGeomGenEvent: public SALOME_Event {
615 public:
616   typedef bool TResult;
617   TResult myResult;
618   TInitGeomGenEvent() : myResult(false) {}
619   virtual void Execute() {
620     myResult = GeometryGUI::InitGeomGen();
621   }
622 };
623 bool GEOM_Swig::initGeomGen()
624 {
625   return ProcessEvent(new TInitGeomGenEvent());
626 }
627
628
629
630 void GEOM_Swig::eraseGO (const char* Entry, bool allWindows)
631 {
632   class TEvent: public SALOME_Event
633   {
634     std::string myEntry;
635     bool myFromAllWindows;
636   public:
637     TEvent(const char* theEntry, bool fromAllWindows):
638       myEntry(theEntry), myFromAllWindows(fromAllWindows)
639     {}
640     virtual void Execute()
641     {
642       SUIT_Application* app = SUIT_Session::session()->activeApplication();
643       if (!app) return;
644       SalomeApp_Study* ActiveStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
645       if (!ActiveStudy) return;
646
647       Handle (SALOME_InteractiveObject) aIO = new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
648
649       GEOM_Displayer(ActiveStudy).Erase(aIO, true);
650       /*      if (myFromAllWindows) {
651         QPtrList<SUIT_ViewWindow> aWindows = app->desktop()->windows();
652         SUIT_ViewWindow* aWin = 0;
653         for (aWin = aWindows.first(); aWin; aWin = aWindows.next()) {
654           EraseObject(aWin, aIO);
655         }
656       } else {
657         SUIT_ViewWindow* aWin = app->desktop()->activeWindow();
658         if (aWin)
659           EraseObject(aWin, aIO);
660           }*/
661     }
662
663     /*  private:
664     void EraseObject(SUIT_ViewWindow* theWin, Handle (SALOME_InteractiveObject) theIO)
665     {
666       if (theWin->getViewManager()->getType() == OCCViewer_Viewer::Type()){
667         OCCViewer_ViewWindow* vw = dynamic_cast<OCCViewer_ViewWindow*>( theWin );
668         if ( vw ) {
669           OCCViewer_ViewManager* vm = dynamic_cast<OCCViewer_ViewManager*>( vw->getViewManager() );
670           if ( vm ) {
671             SOCC_Viewer* aViewer = dynamic_cast<SOCC_Viewer*>(vm->getOCCViewer());
672             if (aViewer) {
673               SALOME_Prs* aPrs = aViewer->CreatePrs(myEntry.c_str());
674               if (aPrs) {
675                 SALOME_OCCPrs* aOccPrs =  dynamic_cast<SALOME_OCCPrs*>(aPrs);
676                 if (aOccPrs) {
677                   aViewer->Erase(aOccPrs);
678                   aViewer->Repaint();
679                 }
680               }
681             }
682           }
683         }
684       } else if (theWin->getViewManager()->getType() == SVTK_Viewer::Type()){
685         SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>( theWin );
686         if (aViewWindow) {
687           aViewWindow->Erase(theIO);
688         }
689       }
690       }*/
691
692   };
693   ProcessVoidEvent(new TEvent(Entry, allWindows));
694 }
695
696
697
698 void GEOM_Swig::setDeflection(const char* theEntry, float theDeflect)
699 {
700   class TEvent: public SALOME_Event {
701     std::string myEntry;
702     float myParam;
703   public:
704     TEvent(const char* theEntryArg, float theParam):
705       myEntry(theEntryArg), myParam(theParam)
706     {}
707     virtual void Execute() {
708       SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
709       if (!anApp) return;
710
711       Handle(SALOME_InteractiveObject) anIO =
712         new SALOME_InteractiveObject(myEntry.c_str(), "GEOM", "");
713
714       if (SVTK_ViewWindow* aViewWindow = GetSVTKViewWindow(anApp)) {
715         vtkActorCollection* aActors = aViewWindow->getRenderer()->GetActors();
716         aActors->InitTraversal();
717         while (vtkActor* aAct = aActors->GetNextActor()) {
718           if (GEOM_Actor* aGeomActor = dynamic_cast<GEOM_Actor*>(aAct)) {
719             if (aGeomActor->hasIO()) {
720               Handle(SALOME_InteractiveObject) aNextIO = aGeomActor->getIO();
721               if (aNextIO->isSame(anIO)) {
722                 aGeomActor->setDeflection(myParam);
723                 aViewWindow->Repaint();
724                 return;
725               }
726             }
727           }
728         }
729         //      aView->SetTransparency(anIO, myParam);
730         //aView->Repaint();
731       } else if (OCCViewer_Viewer* occViewer = GetOCCViewer(anApp)) {
732         Handle(AIS_InteractiveContext) aContext = occViewer->getAISContext();
733         AIS_ListOfInteractive aAISList;
734         aContext->DisplayedObjects(aAISList);
735         AIS_ListIteratorOfListOfInteractive it(aAISList);
736         for (; it.More(); it.Next()) {
737           Handle(SALOME_InteractiveObject) aObj = 
738             Handle(SALOME_InteractiveObject)::DownCast(it.Value()->GetOwner());
739           if ((!aObj.IsNull()) && aObj->hasEntry() && aObj->isSame(anIO)) {
740             Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(it.Value());
741             if (!aShape.IsNull()) {
742               TopoDS_Shape aSh = aShape->Shape();
743               if (!aSh.IsNull())
744                 BRepTools::Clean(aSh);
745
746               aShape->SetOwnDeviationCoefficient( myParam );
747               aShape->SetOwnHLRDeviationAngle( 1.57 );
748               aContext->Redisplay(aShape);
749               return;
750             }
751           }
752         }
753       }
754     }
755   };
756
757   ProcessVoidEvent(new TEvent (theEntry, theDeflect));
758 }
759