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