Salome HOME
Typo-fix by Kunda
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI.cxx
1 // Copyright (C) 2007-2016  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, or (at your option) any later version.
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   : GEOMBase_Tools.cxx
25 // Author : Damien COQUERET, Open CASCADE S.A.S.
26
27 #include "GEOMToolsGUI.h"
28 #include "GEOMToolsGUI_DeleteDlg.h"
29
30 #include <GeometryGUI.h>
31 #include "GeometryGUI_Operations.h"
32 #include <GEOMBase.h>
33 #include <GEOM_Operation.h>
34 #include <GEOM_Displayer.h>
35
36 #include <SUIT_Session.h>
37 #include <SUIT_OverrideCursor.h>
38 #include <SUIT_MessageBox.h>
39 #include <SUIT_Tools.h>
40 #include <SUIT_FileDlg.h>
41 #include <SUIT_Desktop.h>
42 #include <SUIT_ViewModel.h>
43 #include <SUIT_ViewManager.h>
44
45 #include <SalomeApp_Application.h>
46 #include <SalomeApp_Study.h>
47 #include <LightApp_SelectionMgr.h>
48 #include <GEOMImpl_Types.hxx>
49
50 #include <SALOME_ListIO.hxx>
51 #include <SALOME_Prs.h>
52
53 // QT Includes
54 #include <QApplication>
55 #include <QMap>
56 #include <QRegExp>
57
58 // OCCT Includes
59 #include <TCollection_AsciiString.hxx>
60
61 typedef QMap<QString, QString> FilterMap;
62 static QString lastUsedFilter;
63
64 //=======================================================================
65 // function : getParentComponent
66 // purpose  : Get object's parent component entry
67 //=======================================================================
68 static QString getParentComponent( _PTR( SObject ) obj )
69 {
70   if ( obj ) {
71     _PTR(SComponent) comp = obj->GetFatherComponent();
72     if ( comp )
73       return QString( comp->GetID().c_str() );
74   }
75   return QString();
76 }
77
78 //=====================================================================================
79 // function : inUse
80 // purpose  : check if the object(s) passed as the second arguments are used
81 //            by the other objects in the study
82 //=====================================================================================
83 static bool inUse( _PTR(Study) study, const QString& component, const QMap<QString,QString>& objects )
84 {
85   _PTR(SObject) comp = study->FindObjectID( component.toLatin1().data() );
86   if ( !comp )
87     return false;
88
89   // collect all GEOM objects being deleted
90   QMap<QString, GEOM::GEOM_BaseObject_var> gobjects;
91   QMap<QString, QString>::ConstIterator oit;
92   std::list<_PTR(SObject)> aSelectedSO;
93   for ( oit = objects.begin(); oit != objects.end(); ++oit )
94   {
95     _PTR(SObject) so = study->FindObjectID( oit.key().toLatin1().data() );
96     if ( !so )
97       continue;
98     aSelectedSO.push_back(so);
99     CORBA::Object_var        corbaObj_rem = GeometryGUI::ClientSObjectToObject( so );
100     GEOM::GEOM_BaseObject_var geomObj_rem = GEOM::GEOM_BaseObject::_narrow( corbaObj_rem );
101     if ( ! CORBA::is_nil( geomObj_rem ))
102       gobjects.insert( oit.key(), geomObj_rem );
103   }
104
105   // Search References with other Modules
106   std::list< _PTR(SObject) >::iterator itSO = aSelectedSO.begin();
107   for ( ; itSO != aSelectedSO.end(); ++itSO )
108   {
109     std::vector<_PTR(SObject)> aReferences = study->FindDependances( *itSO  );
110     int aRefLength = aReferences.size();
111     for ( int i = 0; i < aRefLength; i++ )
112     {
113       _PTR(SObject) firstSO( aReferences[i] );
114       _PTR(SComponent) aComponent = firstSO->GetFatherComponent();
115       QString type = aComponent->ComponentDataType().c_str();
116       if ( type == "SMESH" )
117         return true;
118     }
119   }
120
121   // browse through all GEOM data tree to find an object with is not deleted and depends
122   // on a deleted object
123   _PTR(ChildIterator) it ( study->NewChildIterator( comp ) );
124   for ( it->InitEx( true ); it->More(); it->Next() )
125   {
126     _PTR(SObject) child   = it->Value();
127     QString       childID = child->GetID().c_str();
128     bool deleted = objects.contains( childID );
129     if ( deleted )
130       continue; // deleted object
131
132     CORBA::Object_var    corbaObj = GeometryGUI::ClientSObjectToObject( child );
133     GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
134     if ( CORBA::is_nil( geomObj ) )
135       continue;
136
137     GEOM::ListOfGBO_var dep = geomObj->GetDependency(); // child depends on dep
138     for( CORBA::ULong i = 0; i < dep->length(); i++ )
139     {
140       CORBA::String_var id = dep[i]->GetStudyEntry();
141       bool depends = objects.contains( id.in() ); // depends on deleted
142
143       QMap<QString, GEOM::GEOM_BaseObject_var>::Iterator git;
144       for ( git = gobjects.begin(); git != gobjects.end() && ( !depends || !deleted ); ++git )
145       {
146         depends = depends || dep[i]->_is_equivalent( *git );
147         deleted = deleted || git.key() == childID ;//geomObj->_is_equivalent( *git )
148       }
149       if ( depends && !deleted )
150         return true;
151     }
152   }
153   return false;
154 }
155
156 //=======================================================================
157 // function : getGeomChildrenAndFolders
158 // purpose  : Get direct (1-level) GEOM objects under each folder, sub-folder, etc. and these folders itself
159 //=======================================================================
160 static void getGeomChildrenAndFolders( _PTR(SObject) theSO,
161                                        QMap<QString,QString>& geomObjList,
162                                        QMap<QString,QString>& folderList ) {
163   if ( !theSO ) return;
164   _PTR(Study) aStudy = theSO->GetStudy();
165   if ( !aStudy ) return;
166   _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
167
168   bool isFolder = false;
169   _PTR(GenericAttribute) anAttr;
170   if ( theSO->FindAttribute(anAttr, "AttributeLocalID") ) {
171     _PTR(AttributeLocalID) aLocalID( anAttr );
172     isFolder = aLocalID->Value() == 999;
173   }
174   QString anEntry = theSO->GetID().c_str();
175   QString aName = theSO->GetName().c_str();
176   if ( isFolder ) {
177     folderList.insert( anEntry, aName );
178     _PTR(UseCaseIterator) ucit ( aUseCaseBuilder->GetUseCaseIterator( theSO ) );
179     for ( ucit->Init( false ); ucit->More(); ucit->Next() ) {
180       getGeomChildrenAndFolders( ucit->Value(), geomObjList, folderList );
181     }
182   } else {
183     geomObjList.insert( anEntry, aName );
184   }
185 }
186
187 //=======================================================================
188 // function : GEOMToolsGUI()
189 // purpose  : Constructor
190 //=======================================================================
191 GEOMToolsGUI::GEOMToolsGUI( GeometryGUI* parent )
192   : GEOMGUI( parent )
193 {
194 }
195
196 //=======================================================================
197 // function : ~GEOMToolsGUI()
198 // purpose  : Destructor
199 //=======================================================================
200 GEOMToolsGUI::~GEOMToolsGUI()
201 {
202 }
203
204 //=======================================================================
205 // function : OnGUIEvent()
206 // purpose  :
207 //=======================================================================
208 bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
209 {
210   getGeometryGUI()->EmitSignalDeactivateDialog();
211
212   switch ( theCommandID ) {
213   case GEOMOp::OpDelete:         // EDIT - DELETE
214     OnEditDelete();
215     break;
216 #ifndef DISABLE_PYCONSOLE
217   case GEOMOp::OpCheckGeom:      // TOOLS - CHECK GEOMETRY
218     OnCheckGeometry();
219     break;
220 #endif
221   case GEOMOp::OpSelectVertex:   // POPUP - SELECT ONLY - VERTEX
222     OnSelectOnly( GEOM_POINT );
223     break;
224   case GEOMOp::OpSelectEdge:     // POPUP - SELECT ONLY - EDGE
225     OnSelectOnly( GEOM_EDGE );
226     break;
227   case GEOMOp::OpSelectWire:     // POPUP - SELECT ONLY - WIRE
228     OnSelectOnly( GEOM_WIRE );
229     break;
230   case GEOMOp::OpSelectFace:     // POPUP - SELECT ONLY - FACE
231     OnSelectOnly( GEOM_FACE );
232     break;
233   case GEOMOp::OpSelectShell:    // POPUP - SELECT ONLY - SHELL
234     OnSelectOnly( GEOM_SHELL );
235     break;
236   case GEOMOp::OpSelectSolid:    // POPUP - SELECT ONLY - SOLID
237     OnSelectOnly( GEOM_SOLID );
238     break;
239   case GEOMOp::OpSelectCompound: // POPUP - SELECT ONLY - COMPOUND
240     OnSelectOnly( GEOM_COMPOUND );
241     break;
242   case GEOMOp::OpSelectAll:      // POPUP - SELECT ONLY - SELECT ALL
243     OnSelectOnly( GEOM_ALLOBJECTS );
244     break;
245   case GEOMOp::OpDeflection:     // POPUP - DEFLECTION ANGLE
246     OnDeflection();
247     break;
248   case GEOMOp::OpColor:          // POPUP - COLOR
249     OnColor();
250     break;
251   case GEOMOp::OpSetTexture:     // POPUP - TEXTURE
252     OnTexture();
253     break;
254   case GEOMOp::OpTransparency:   // POPUP - TRANSPARENCY
255     OnTransparency();
256     break;
257   case GEOMOp::OpIncrTransparency: // SHORTCUT   - INCREASE TRANSPARENCY
258     OnChangeTransparency( true );
259     break;
260   case GEOMOp::OpDecrTransparency: // SHORTCUT   - DECREASE TRANSPARENCY
261     OnChangeTransparency( false );
262     break;
263   case GEOMOp::OpIsos:           // POPUP - ISOS
264     OnNbIsos();
265     break;
266   case GEOMOp::OpIncrNbIsos:     // SHORTCUT   - INCREASE NB ISOLINES
267     OnNbIsos( INCR );
268     break;
269   case GEOMOp::OpDecrNbIsos:     // SHORTCUT   - DECREASE NB ISOLINES
270     OnNbIsos( DECR );
271     break;
272   case GEOMOp::OpMaterialProperties: // POPUP - MATERIAL PROPERTIES
273     OnMaterialProperties();
274     break;
275   case GEOMOp::OpPredefMaterCustom:  // POPUP  - MATERIAL PROPERTIES - CUSTOM...
276     OnMaterialProperties();
277     break;
278   case GEOMOp::OpMaterialsLibrary:    // POPUP MENU - MATERIAL PROPERTIES
279     OnMaterialsLibrary();
280     break;
281   case GEOMOp::OpAutoColor:      // POPUP - AUTO COLOR
282     OnAutoColor();
283     break;
284   case GEOMOp::OpNoAutoColor:    // POPUP - DISABLE AUTO COLOR
285     OnDisableAutoColor();
286     break;
287   case GEOMOp::OpDiscloseChildren:   // POPUP - SHOW CHILDREN
288   case GEOMOp::OpConcealChildren:   // POPUP - HIDE CHILDREN
289     OnDiscloseConcealChildren( theCommandID == GEOMOp::OpDiscloseChildren );
290     break;
291   case GEOMOp::OpPointMarker:    // POPUP - POINT MARKER
292     OnPointMarker();
293     break;
294   case GEOMOp::OpUnpublishObject:// POPUP - UNPUBLISH
295     OnUnpublishObject();
296     break;
297   case GEOMOp::OpPublishObject:// GEOM ROOT OBJECT - POPUP - PUBLISH
298     OnPublishObject();
299     break;
300   case GEOMOp::OpEdgeWidth:
301     OnEdgeWidth();
302     break;
303   case GEOMOp::OpIsosWidth:
304     OnIsosWidth();
305     break;
306   case GEOMOp::OpBringToFront:
307     OnBringToFront();
308     break;
309   case GEOMOp::OpClsBringToFront:
310     OnClsBringToFront();
311      break;
312   case GEOMOp::OpCreateFolder:
313     OnCreateFolder();
314      break;
315   case GEOMOp::OpSortChildren:
316     OnSortChildren();
317     break;
318 #ifndef DISABLE_GRAPHICSVIEW
319   case GEOMOp::OpShowDependencyTree:
320     OnShowDependencyTree();
321      break;
322 #endif
323   case GEOMOp::OpReduceStudy:
324     OnReduceStudy();
325     break;
326   default:
327     SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
328     break;
329   }
330   return true;
331 }
332
333 //=======================================================================
334 // function : OnGUIEvent()
335 // purpose  :
336 //=======================================================================
337 bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent, const QVariant& theParam )
338 {
339   getGeometryGUI()->EmitSignalDeactivateDialog();
340
341   switch ( theCommandID ) {
342   case GEOMOp::OpPredefMaterial:         // POPUP MENU - MATERIAL PROPERTIES - <SOME MATERIAL>
343     OnSetMaterial( theParam );
344     break;
345   default:
346     SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
347     break;
348   }
349   return true;
350 }
351
352 //===============================================================================
353 // function : OnEditDelete()
354 // purpose  :
355 //===============================================================================
356 void GEOMToolsGUI::OnEditDelete()
357 {
358   SALOME_ListIO selected;
359   SalomeApp_Application* app =
360     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
361   if ( !app )
362     return;
363
364   LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
365   SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
366   if ( !aSelMgr || !appStudy )
367     return;
368
369   // get selection
370   aSelMgr->selectedObjects( selected, "ObjectBrowser", false );
371   if ( selected.IsEmpty() )
372     return;
373
374   _PTR(Study) aStudy = appStudy->studyDS();
375   _PTR(UseCaseBuilder) aUseCaseBuilder = aStudy->GetUseCaseBuilder();
376
377   // check if study is locked
378   if ( _PTR(AttributeStudyProperties)( aStudy->GetProperties() )->IsLocked() ) {
379     SUIT_MessageBox::warning( app->desktop(),
380                               tr("WRN_WARNING"),
381                               tr("WRN_STUDY_LOCKED") );
382     return; // study is locked
383   }
384
385   // get GEOM component
386   CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
387   QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR.in() ) );
388
389   // check each selected object: if belongs to GEOM, if not reference...
390   QMap<QString,QString> toBeDeleted;
391   QMap<QString,QString> allDeleted;
392   QMap<QString,QString> toBeDelFolders;
393   bool isComponentSelected = false;
394
395   for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
396     Handle(SALOME_InteractiveObject) anIObject = It.Value();
397     if ( !anIObject->hasEntry() )
398       continue; // invalid object
399     // ...
400     QString entry = anIObject->getEntry();
401     _PTR(SObject) obj = aStudy->FindObjectID( entry.toLatin1().data() );
402     // check parent component
403     QString parentComp = getParentComponent( obj );
404     if ( parentComp != geomComp )  {
405       SUIT_MessageBox::warning( app->desktop(),
406                                 QObject::tr("ERR_ERROR"),
407                                 QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg( getGeometryGUI()->moduleName() ) );
408       return; // not GEOM object selected
409     }
410
411     ///////////////////////////////////////////////////////
412     // if GEOM component is selected, so skip other checks
413     if ( isComponentSelected ) continue;
414     ///////////////////////////////////////////////////////
415
416     // check if object is reference
417     _PTR(SObject) refobj;
418     if ( obj && obj->ReferencedObject( refobj ) ) {
419       // get the main object by reference IPAL 21354
420       obj = refobj;
421       entry = obj->GetID().c_str();
422     }
423     // ...
424     QString aName = obj->GetName().c_str();
425     if ( entry == geomComp ) {
426       // GEOM component is selected, skip other checks
427       isComponentSelected = true;
428       continue;
429     }
430     // all sub-objects of folder have to be deleted
431     getGeomChildrenAndFolders( obj, toBeDeleted, toBeDelFolders );
432     allDeleted.insert( entry, aName ); // skip GEOM component
433     // browse through all children recursively
434     _PTR(UseCaseIterator) it ( aUseCaseBuilder->GetUseCaseIterator( obj ) );
435     for ( it->Init( true ); it->More(); it->Next() ) {
436       _PTR(SObject) child( it->Value() );
437       if ( child && child->ReferencedObject( refobj ) )
438         continue; // skip references
439       aName = child->GetName().c_str();
440       if ( !aName.isEmpty() )
441         allDeleted.insert( child->GetID().c_str(), aName );
442     }
443   }
444
445   // is there is anything to delete?
446   if ( !isComponentSelected && allDeleted.count() <= 0 )
447     return; // nothing to delete
448
449   // show confirmation dialog box
450   GEOMToolsGUI_DeleteDlg dlg( app->desktop(), allDeleted, isComponentSelected );
451   if ( !dlg.exec() )
452     return; // operation is cancelled by user
453
454   SUIT_OverrideCursor wc;
455
456   // get currently opened views
457   QList<SALOME_View*> views;
458   SALOME_View* view;
459   ViewManagerList vmans = app->viewManagers();
460   SUIT_ViewManager* vman;
461   foreach ( vman, vmans ) {
462     SUIT_ViewModel* vmod = vman->getViewModel();
463     view = dynamic_cast<SALOME_View*> ( vmod ); // must work for OCC and VTK views
464     if ( view )
465       views.append( view );
466   }
467
468   _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
469   GEOM_Displayer disp( appStudy );
470   bool toUpdateColorScale = disp.SetUpdateColorScale( false ); // IPAL54049
471
472   if ( isComponentSelected ) {
473     // GEOM component is selected: delete all objects recursively
474     _PTR(SObject) comp = aStudy->FindObjectID( geomComp.toLatin1().data() );
475     if ( !comp )
476       return;
477     _PTR(ChildIterator) it ( aStudy->NewChildIterator( comp ) );
478     // remove top-level objects only
479     for ( it->InitEx( false ); it->More(); it->Next() ) {
480       _PTR(SObject) child( it->Value() );
481       // remove object from GEOM engine
482       removeObjectWithChildren( child, aStudy, views, &disp );
483       // remove object from study
484       aStudyBuilder->RemoveObjectWithChildren( child );
485       // remove object from use case tree
486       aUseCaseBuilder->Remove( child );
487     }
488   }
489   else {
490     // GEOM component is not selected: check if selected objects are in use
491     if ( inUse( aStudy, geomComp, allDeleted ) && 
492          SUIT_MessageBox::question( app->desktop(),
493                                     QObject::tr("WRN_WARNING"),
494                                     QObject::tr("DEP_OBJECT"),
495                                     SUIT_MessageBox::Yes | SUIT_MessageBox::No,
496                                     SUIT_MessageBox::No ) != SUIT_MessageBox::Yes ) {
497       return; // object(s) in use
498     }
499     // ... and then delete all objects
500     QMap<QString, QString>::Iterator it;
501     for ( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) {
502       _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
503       // remove object from GEOM engine
504       removeObjectWithChildren( obj, aStudy, views, &disp );
505       // remove objects from study
506       aStudyBuilder->RemoveObjectWithChildren( obj );
507       // remove object from use case tree
508       aUseCaseBuilder->Remove( obj );
509     }
510     // ... and then delete all folders
511     for ( it = toBeDelFolders.begin(); it != toBeDelFolders.end(); ++it ) {
512       _PTR(SObject) obj ( aStudy->FindObjectID( it.key().toLatin1().data() ) );
513       // remove object from GEOM engine
514       removeObjectWithChildren( obj, aStudy, views, &disp );
515       // remove objects from study
516       aStudyBuilder->RemoveObjectWithChildren( obj );
517       // remove object from use case tree
518       aUseCaseBuilder->Remove( obj );
519     }
520   }
521
522   disp.SetUpdateColorScale( toUpdateColorScale ); // IPAL54049
523   selected.Clear();
524   aSelMgr->setSelectedObjects( selected );
525   getGeometryGUI()->updateObjBrowser();
526   app->updateActions(); //SRN: To update a Save button in the toolbar
527 }
528
529 //=====================================================================================
530 // function : RemoveObjectWithChildren
531 // purpose  : used by OnEditDelete() method
532 //=====================================================================================
533 void GEOMToolsGUI::removeObjectWithChildren(_PTR(SObject) obj,
534                                             _PTR(Study) aStudy,
535                                             QList<SALOME_View*> views,
536                                             GEOM_Displayer* disp)
537 {
538   // iterate through all children of obj
539   for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
540   // for (_PTR(UseCaseIterator) it (aStudy->GetUseCaseBuilder()->GetUseCaseIterator(obj)); it->More(); it->Next()) {
541     _PTR(SObject) child (it->Value());
542     removeObjectWithChildren(child, aStudy, views, disp);
543   }
544
545   // erase object and remove it from engine
546   _PTR(GenericAttribute) anAttr;
547   if (obj->FindAttribute(anAttr, "AttributeIOR")) {
548     _PTR(AttributeIOR) anIOR (anAttr);
549
550     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
551
552     // Delete shape in Client
553     const TCollection_AsciiString ASCIor ((char*)anIOR->Value().c_str());
554     getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer(ASCIor);
555
556     CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(obj);
557     GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
558     if (!CORBA::is_nil(geomObj)) {
559
560       //Remove visual properties of the object
561       appStudy->removeObjectProperties(obj->GetID().c_str());
562
563       // Erase graphical object
564       QListIterator<SALOME_View*> it( views );
565       while ( it.hasNext() )
566         if ( SALOME_View* view = it.next() )
567           disp->Erase(geomObj, true, true, view);
568
569       // Remove object from Engine
570       // We can't directly remove object from engine. All we can do is to unpublish the object
571       // from the study. Another client could be using the object.
572       // Unpublishing is done just after in aStudyBuilder->RemoveObjectWithChildren( child );
573       //GeometryGUI::GetGeomGen()->RemoveObject( geomObj );
574     }
575   }
576 }
577
578 //=================================================================================
579 // function : deactivate()
580 // purpose  : Called when GEOM component is deactivated
581 //=================================================================================
582 void GEOMToolsGUI::deactivate()
583 {
584   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
585   if ( app ) {
586     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
587     GEOM_Displayer aDisp (appStudy);
588     aDisp.GlobalSelection();
589     getGeometryGUI()->setLocalSelectionMode(GEOM_ALLOBJECTS);
590   }
591 }
592
593 //=====================================================================================
594 // EXPORTED METHODS
595 //=====================================================================================
596 extern "C"
597 {
598 #ifdef WIN32
599   __declspec( dllexport )
600 #endif
601   GEOMGUI* GetLibGUI( GeometryGUI* parent )
602   {
603     return new GEOMToolsGUI( parent );
604   }
605 }