Salome HOME
Merging with WPdev
[modules/geom.git] / src / GEOMToolsGUI / GEOMToolsGUI.cxx
1 //  GEOM GEOMGUI : GUI for Geometry component
2 //
3 //  Copyright (C) 2003  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 //
24 //  File   : GEOMBase_Tools.cxx
25 //  Author : Damien COQUERET
26 //  Module : GEOM
27 //  $Header$
28
29 #include "GEOMToolsGUI.h"
30
31 #include "GeometryGUI.h"
32 #include "GEOM_Actor.h"
33 #include "GEOMBase.h"
34 #include "GEOM_Operation.h"
35 #include "GEOM_Displayer.h"
36
37 #include <SUIT_Session.h>
38 #include <SUIT_Application.h>
39 #include <SUIT_OverrideCursor.h>
40 #include <SUIT_MessageBox.h>
41 #include <SUIT_Tools.h>
42 #include <SUIT_FileDlg.h>
43 #include <SUIT_Desktop.h>
44 #include <SUIT_ViewModel.h>
45
46 #include <SalomeApp_Application.h>
47 #include <SalomeApp_Study.h>
48 #include <LightApp_SelectionMgr.h>
49
50 #include <SALOME_ListIteratorOfListIO.hxx>
51 #include <SALOME_Prs.h>
52
53 #include "utilities.h"
54
55 // QT Includes
56 #include <qapplication.h>
57 #include <qmap.h>
58
59 // OCCT Includes
60 #include <TCollection_AsciiString.hxx>
61
62 using namespace std;
63
64 typedef QMap<QString, QString> FilterMap;
65
66 //=======================================================================
67 // function : getFileName
68 // purpose  : Selection of a file name for Import/Export. Returns also
69 //            the selected file type code through <filter> argument.
70 //=======================================================================
71 static QString getFileName( QWidget*           parent,
72                             const QString&     initial,
73                             const FilterMap&   filterMap,
74                             const QString&     caption,
75                             bool               open,
76                             QString&           format )
77 {
78   static QString lastUsedFilter;
79   QStringList filters;
80   for ( FilterMap::const_iterator it = filterMap.begin(); it != filterMap.end(); ++it )
81     filters.push_back( it.key() );
82
83   SUIT_FileDlg* fd = new SUIT_FileDlg( parent, open, true, true );
84   if ( !caption.isEmpty() )
85     fd->setCaption( caption );
86
87   if ( !initial.isEmpty() )
88     fd->setSelection( initial );
89
90   if ( !lastUsedFilter.isEmpty() && filterMap.contains( lastUsedFilter ) )
91     fd->setSelectedFilter( lastUsedFilter );
92
93   fd->setFilters( filters );
94
95   fd->exec();
96   QString filename = fd->selectedFile();
97   format = filterMap[fd->selectedFilter()];
98   lastUsedFilter = fd->selectedFilter();
99   delete fd;
100   qApp->processEvents();
101   return filename;
102 }
103
104 //=======================================================================
105 // function : GEOMToolsGUI()
106 // purpose  : Constructor
107 //=======================================================================
108 GEOMToolsGUI::GEOMToolsGUI( GeometryGUI* parent )
109 : GEOMGUI( parent )
110 {
111 }
112
113
114 //=======================================================================
115 // function : ~GEOMToolsGUI()
116 // purpose  : Destructor
117 //=======================================================================
118 GEOMToolsGUI::~GEOMToolsGUI()
119 {
120 }
121
122
123 //=======================================================================
124 // function : OnGUIEvent()
125 // purpose  :
126 //=======================================================================
127 bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
128 {
129   getGeometryGUI()->EmitSignalDeactivateDialog();
130
131   switch (theCommandID)
132     {
133     case 31: // COPY
134       {
135         OnEditCopy();
136         break;
137       }
138     case 33: // DELETE
139       {
140         OnEditDelete();
141         break;
142       }
143     case 111: // IMPORT BREP
144     case 112: // IMPORT IGES
145     case 113: // IMPORT STEP
146       {
147         Import();
148         break;
149       }
150     case 121: // EXPORT BREP
151     case 122: // EXPORT IGES
152     case 123: // EXPORT STEP
153       {
154         Export();
155         break;
156       }
157     case 411: // SETTINGS - ADD IN STUDY
158       {
159         // SAN -- TO BE REMOVED !!!
160         break;
161       }
162     case 412: // SETTINGS - SHADING COLOR
163       {
164         OnSettingsColor();
165         break;
166       }
167     case 413: // SETTINGS - ISOS
168       {
169         OnSettingsIsos();
170         break;
171       }
172     case 414: // SETTINGS : STEP VALUE FOR SPIN BOXES
173       {
174         OnSettingsStep();
175         break;
176       }
177     case 804: // ADD IN STUDY - POPUP VIEWER
178       {
179         // SAN -- TO BE REMOVED !!!!
180         break;
181       }
182     case 901: // RENAME
183       {
184         OnRename();
185         break;
186       }
187     case 5103: // CHECK GEOMETRY
188       {
189         OnCheckGeometry();
190         break;
191       }
192     case 8032: // COLOR - POPUP VIEWER
193       {
194         OnColor();
195         break;
196       }
197     case 8033: // TRANSPARENCY - POPUP VIEWER
198       {
199         OnTransparency();
200         break;
201       }
202     case 8034: // ISOS - POPUP VIEWER
203       {
204         OnNbIsos();
205         break;
206       }
207     case 9024 : // OPEN - OBJBROSER POPUP
208       {
209         OnOpen();
210         break;
211       }
212     default:
213       {
214         SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
215         break;
216       }
217     }
218   return true;
219 }
220
221
222
223 //===============================================================================
224 // function : OnEditDelete()
225 // purpose  :
226 //===============================================================================
227 void GEOMToolsGUI::OnEditDelete()
228 {
229   SALOME_ListIO selected;
230   SalomeApp_Application* app =
231     dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
232   if ( app ) {
233     LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
234     SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
235     if ( aSelMgr && appStudy ) {
236       aSelMgr->selectedObjects( selected, QString::null, false );
237       if ( !selected.IsEmpty() ) {
238         _PTR(Study) aStudy = appStudy->studyDS();
239
240         bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
241         if ( aLocked ) {
242           SUIT_MessageBox::warn1 ( app->desktop(),
243                                    QObject::tr("WRN_WARNING"),
244                                    QObject::tr("WRN_STUDY_LOCKED"),
245                                    QObject::tr("BUT_OK") );
246           return;
247         }
248
249         // VSR 17/11/04: check if all objects selected belong to GEOM component --> start
250         // modifications of ASV 01.06.05
251         QString parentComp = getParentComponent( aStudy, selected );
252   CORBA::String_var geomIOR = app->orb()->object_to_string( GeometryGUI::GetGeomGen() );
253         QString geomComp = getParentComponent( aStudy->FindObjectIOR( geomIOR.in() ) );
254
255         if ( parentComp != geomComp )  {
256           SUIT_MessageBox::warn1 ( app->desktop(),
257                                   QObject::tr("ERR_ERROR"),
258                                   QObject::tr("NON_GEOM_OBJECTS_SELECTED").arg( getGeometryGUI()->moduleName() ),
259                                   QObject::tr("BUT_OK") );
260           return;
261         }
262         // VSR 17/11/04: check if all objects selected belong to GEOM component <-- finish
263
264         if ( SUIT_MessageBox::warn2( app->desktop(),
265                                      QObject::tr( "GEOM_WRN_WARNING" ),
266                                      QObject::tr( "GEOM_REALLY_DELETE" ),
267                                      QObject::tr( "GEOM_BUT_YES" ),
268                                      QObject::tr( "GEOM_BUT_NO" ), 1, 0, 0 ) != 1 )
269           return;
270
271         //      QAD_Operation* op = new SALOMEGUI_ImportOperation(.....);
272         //      op->start();
273
274         // prepare list of SALOME_Views
275         QPtrList<SALOME_View> views;
276         SALOME_View* view;
277         // fill the list
278         ViewManagerList vmans = app->viewManagers();
279         SUIT_ViewManager* vman;
280         for ( vman = vmans.first(); vman; vman = vmans.next() ) {
281           SUIT_ViewModel* vmod = vman->getViewModel();
282           view = dynamic_cast<SALOME_View*> ( vmod ); // must work for OCC and VTK views
283           if ( view )
284             views.append( view );
285         }
286
287         _PTR(StudyBuilder) aStudyBuilder (aStudy->NewBuilder());
288         _PTR(GenericAttribute) anAttr;
289         GEOM_Displayer* disp = new GEOM_Displayer( appStudy );
290
291         _PTR(SComponent) aGeom ( aStudy->FindComponent("GEOM") );
292           if ( !aGeom )
293             return;     
294
295         // MAIN LOOP OF SELECTED OBJECTS
296         for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
297
298           Handle(SALOME_InteractiveObject) io = It.Value();
299           if ( !io->hasEntry() )
300             continue;
301
302           _PTR(SObject) obj ( aStudy->FindObjectID( io->getEntry() ) );
303
304           // disable removal of "Geometry" component object
305           if ( !strcmp( obj->GetIOR().c_str(), geomIOR ) )
306             continue;
307
308           //If the object has been used to create another one,then it can't be deleted 
309           _PTR(ChildIterator) it (aStudy->NewChildIterator(aGeom));
310           for ( it->InitEx( true ); it->More(); it->Next() ) {
311              _PTR(SObject) chobj (it->Value());
312              if(CheckSubObjectInUse(chobj, obj, aStudy)) return;
313              //check subobjects
314              for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
315                _PTR(SObject) child (it->Value());
316                if(CheckSubObjectInUse( chobj, child, aStudy)) return;
317              }
318            }
319
320           RemoveObjectWithChildren(obj, aStudy, views, disp);
321
322           // Remove objects from Study
323           aStudyBuilder->RemoveObject( obj );
324
325           //deleted = true;
326         } // MAIN LOOP of selected
327
328         selected.Clear();
329         aSelMgr->setSelectedObjects( selected );
330         getGeometryGUI()->updateObjBrowser();
331       } // if ( selected not empty )
332     } // if ( selMgr && appStudy )
333
334     app->updateActions(); //SRN: To update a Save button in the toolbar
335
336   } // if ( app )
337
338
339   //  if ( deleted )
340   //    op->finish();
341   //  else
342   //    op->abort();
343 }
344
345
346 //==============================================================================
347 // function : OnEditCopy()
348 // purpose  :
349 //==============================================================================
350 void GEOMToolsGUI::OnEditCopy()
351 {
352 /*
353  SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection() );
354   GEOM::string_array_var listIOR = new GEOM::string_array;
355
356   const SALOME_ListIO& List = Sel->StoredIObjects();
357
358   myGeomBase->ConvertListOfIOInListOfIOR(List, listIOR);
359
360   Sel->ClearIObjects();
361
362   SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
363   int aStudyID = aStudy->StudyId();
364
365   for (unsigned int ind = 0; ind < listIOR->length();ind++) {
366     GEOM::GEOM_Object_var aShapeInit = myGeom->GetIORFromString(listIOR[ind]);
367     try {
368       GEOM::GEOM_IInsertOperations_var IOp =  myGeom->GetIInsertOperations(aStudyID);
369       GEOM::GEOM_Object_var result = IOp->MakeCopy(aShapeInit);
370       myGeomBase->Display(result);
371     }
372     catch  (const SALOME::SALOME_Exception& S_ex) {
373       QtCatchCorbaException(S_ex);
374     }
375   }
376
377   QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_READY"));
378 */
379 }
380
381
382 //=====================================================================================
383 // function : Import
384 // purpose  : BRep, Iges, Step
385 //=====================================================================================
386 bool GEOMToolsGUI::Import()
387 {
388   SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( getGeometryGUI()->getApp() );
389   //SUIT_Application* app = getGeometryGUI()->getApp();
390   if (! app) return false;
391
392   SalomeApp_Study* stud = dynamic_cast<SalomeApp_Study*> ( app->activeStudy() );
393   if ( !stud ) {
394     cout << "FAILED to cast active study to SalomeApp_Study" << endl;
395     return false;
396   }
397   _PTR(Study) aStudy = stud->studyDS();
398
399   bool aLocked = (_PTR(AttributeStudyProperties)(aStudy->GetProperties()))->IsLocked();
400   if ( aLocked ) {
401     SUIT_MessageBox::warn1 ( app->desktop(),
402                             QObject::tr("WRN_WARNING"),
403                             QObject::tr("WRN_STUDY_LOCKED"),
404                             QObject::tr("BUT_OK") );
405     return false;
406   }
407
408   GEOM::GEOM_Gen_var eng = GeometryGUI::GetGeomGen();
409   if ( CORBA::is_nil( eng ) ) {
410     SUIT_MessageBox::error1( app->desktop(),
411                             QObject::tr("WRN_WARNING"),
412                             QObject::tr( "GEOM Engine is not started" ),
413                             QObject::tr("BUT_OK") );
414       return false;
415     }
416
417   GEOM::GEOM_IInsertOperations_var aInsOp = eng->GetIInsertOperations( aStudy->StudyId() );
418   if ( aInsOp->_is_nil() )
419     return false;
420
421   GEOM::GEOM_Object_var anObj;
422
423   // Obtain a list of available import formats
424   FilterMap aMap;
425   GEOM::string_array_var aFormats, aPatterns;
426   aInsOp->ImportTranslators( aFormats, aPatterns );
427
428   for ( int i = 0, n = aFormats->length(); i < n; i++ )
429     aMap.insert( (char*)aPatterns[i], (char*)aFormats[i] );
430
431   QString fileType;
432
433   QString fileName = getFileName(app->desktop(), "", aMap,
434                                  tr("GEOM_MEN_IMPORT"), true, fileType);
435
436   if (fileType.isEmpty() )
437     {
438       // Trying to detect file type
439       QFileInfo aFileInfo( fileName );
440       QString aPossibleType = (aFileInfo.extension(false)).upper() ;
441
442       if ( (aMap.values()).contains(aPossibleType) )
443         fileType = aPossibleType;
444     }
445
446   if (fileName.isEmpty() || fileType.isEmpty())
447     return false;
448
449   GEOM_Operation* anOp = new GEOM_Operation (app, aInsOp.in());
450   try {
451     SUIT_OverrideCursor wc;
452
453     app->putInfo(tr("GEOM_PRP_LOADING").arg(SUIT_Tools::file(fileName, /*withExten=*/true)));
454
455     anOp->start();
456
457     CORBA::String_var fileN = fileName.latin1();
458     CORBA::String_var fileT = fileType.latin1();
459     anObj = aInsOp->Import(fileN, fileT);
460
461     if ( !anObj->_is_nil() && aInsOp->IsDone() ) {
462       anObj->SetName(GEOMBase::GetDefaultName(QObject::tr("GEOM_IMPORT")).latin1());
463       QString aPublishObjName =
464         GEOMBase::GetDefaultName(SUIT_Tools::file(fileName, /*withExten=*/true));
465
466       SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy(aStudy);
467       GeometryGUI::GetGeomGen()->PublishInStudy(aDSStudy,
468                                                 SALOMEDS::SObject::_nil(),
469                                                 anObj,
470                                                 aPublishObjName);
471
472       GEOM_Displayer( stud ).Display( anObj.in() );
473
474       // update data model and object browser
475       getGeometryGUI()->updateObjBrowser( true );
476
477       anOp->commit();
478     }
479     else {
480       anOp->abort();
481       wc.suspend();
482       SUIT_MessageBox::error1( app->desktop(),
483                               QObject::tr( "GEOM_ERROR" ),
484                               QObject::tr("GEOM_PRP_ABORT") + "\n" + QString( aInsOp->GetErrorCode() ),
485                               QObject::tr("BUT_OK") );
486     }
487   }
488   catch( const SALOME::SALOME_Exception& S_ex ) {
489     //QtCatchCorbaException(S_ex);
490     anOp->abort();
491     return false;
492   }
493
494   app->updateActions(); //SRN: To update a Save button in the toolbar
495
496   return true;
497 }
498
499
500 //=====================================================================================
501 // function : Export
502 // purpose  : BRep, Iges, Step
503 //=====================================================================================
504 bool GEOMToolsGUI::Export()
505 {
506   SalomeApp_Application* app = getGeometryGUI()->getApp();
507   if (!app) return false;
508
509   SalomeApp_Study* stud = dynamic_cast<SalomeApp_Study*> ( app->activeStudy() );
510   if ( !stud ) {
511     cout << "FAILED to cast active study to SalomeApp_Study" << endl;
512     return false;
513   }
514   _PTR(Study) aStudy = stud->studyDS();
515
516   GEOM::GEOM_Gen_var eng = GeometryGUI::GetGeomGen();
517   if ( CORBA::is_nil( eng ) ) {
518     SUIT_MessageBox::error1( app->desktop(),
519                              QObject::tr("WRN_WARNING"),
520                              QObject::tr( "GEOM Engine is not started" ),
521                              QObject::tr("BUT_OK") );
522     return false;
523   }
524
525   GEOM::GEOM_IInsertOperations_var aInsOp = eng->GetIInsertOperations( aStudy->StudyId() );
526   if ( aInsOp->_is_nil() )
527     return false;
528
529   // Obtain a list of available export formats
530   FilterMap aMap;
531   GEOM::string_array_var aFormats, aPatterns;
532   aInsOp->ExportTranslators( aFormats, aPatterns );
533   for ( int i = 0, n = aFormats->length(); i < n; i++ )
534     aMap.insert( (char*)aPatterns[i], (char*)aFormats[i] );
535
536   // Get selected objects
537   LightApp_SelectionMgr* sm = app->selectionMgr();
538   if ( !sm )
539     return false;
540
541   SALOME_ListIO selectedObjects;
542   sm->selectedObjects( selectedObjects );
543
544   SALOME_ListIteratorOfListIO It( selectedObjects );
545   for(;It.More();It.Next()) {
546     Handle(SALOME_InteractiveObject) IObject = It.Value();
547     Standard_Boolean found;
548     GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject(IObject, found);
549
550     if ( !found || anObj->_is_nil() )
551       continue;
552
553     QString fileType;
554     QString file = getFileName(app->desktop(), QString( IObject->getName() ), aMap,
555                                tr("GEOM_MEN_EXPORT"), false, fileType);
556
557     // User has pressed "Cancel" --> stop the operation
558     if ( file.isEmpty() || fileType.isEmpty() )
559       return false;
560
561     GEOM_Operation* anOp = new GEOM_Operation( app, aInsOp.in() );
562     try {
563       SUIT_OverrideCursor wc;
564
565       app->putInfo( tr("GEOM_PRP_EXPORT").arg(SUIT_Tools::file( file, /*withExten=*/true )) );
566
567       anOp->start();
568
569
570       aInsOp->Export( anObj, file, fileType.latin1() );
571
572       if ( aInsOp->IsDone() )
573         anOp->commit();
574       else
575         {
576           anOp->abort();
577           wc.suspend();
578           SUIT_MessageBox::error1( app->desktop(),
579                                    QObject::tr( "GEOM_ERROR" ),
580                                    QObject::tr("GEOM_PRP_ABORT") + "\n" + QString( aInsOp->GetErrorCode() ),
581                                    QObject::tr("BUT_OK") );
582           return false;
583         }
584     }
585     catch (const SALOME::SALOME_Exception& S_ex) {
586       //QtCatchCorbaException(S_ex);
587       anOp->abort();
588       return false;
589     }
590   }
591
592   return true;
593 }
594
595
596 QString GEOMToolsGUI::getParentComponent( _PTR( Study ) study, const SALOME_ListIO& iobjs )
597 {
598   QString parentComp;
599
600   for ( SALOME_ListIteratorOfListIO it( iobjs ); it.More(); it.Next() ) {
601
602     Handle(SALOME_InteractiveObject) io = it.Value();
603     if ( !io->hasEntry() )
604       continue;
605
606     QString compName = getParentComponent( study->FindObjectID( io->getEntry() ) );
607
608     if ( parentComp.isNull() )
609       parentComp = compName;
610     else if ( parentComp.compare( compName) != 0 ) { // objects belonging to different components are selected
611       parentComp = QString::null;
612       break;
613     }
614   }
615
616   return parentComp;
617 }
618
619 QString GEOMToolsGUI::getParentComponent( _PTR( SObject ) obj )
620 {
621   if ( obj ) {
622     _PTR(SComponent) comp = obj->GetFatherComponent();
623     if ( comp ) {
624       _PTR(GenericAttribute) anAttr;
625       if ( comp->FindAttribute( anAttr, "AttributeName") ) {
626         _PTR(AttributeName) aName( anAttr );
627         return QString( aName->Value().c_str() );
628       }
629     }
630   }
631   return QString();
632 }
633
634 //=====================================================================================
635 // function : RemoveObjectWithChildren
636 // purpose  : to be used by OnEditDelete() method
637 //=====================================================================================
638 void GEOMToolsGUI::RemoveObjectWithChildren(_PTR(SObject) obj,
639                                             _PTR(Study) aStudy,
640                                             QPtrList<SALOME_View> views,
641                                             GEOM_Displayer* disp)
642 {
643   // iterate through all children of obj
644   for (_PTR(ChildIterator) it (aStudy->NewChildIterator(obj)); it->More(); it->Next()) {
645     _PTR(SObject) child (it->Value());
646     RemoveObjectWithChildren(child, aStudy, views, disp);
647   }
648
649   // erase object and remove it from engine
650   _PTR(GenericAttribute) anAttr;
651   if (obj->FindAttribute(anAttr, "AttributeIOR")) {
652     _PTR(AttributeIOR) anIOR (anAttr);
653
654     // Delete shape in Client
655     const TCollection_AsciiString ASCIor ((char*)anIOR->Value().c_str());
656     getGeometryGUI()->GetShapeReader().RemoveShapeFromBuffer(ASCIor);
657
658     CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(obj);
659     GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
660     if (!CORBA::is_nil(geomObj)) {
661       // Erase graphical object
662       SALOME_View* view = views.first();
663       for (; view; view = views.next()) {
664         disp->Erase(geomObj, true, view);
665       }
666
667       // Remove object from Engine
668       GeometryGUI::GetGeomGen()->RemoveObject( geomObj );
669     }
670   }
671 }
672
673 //=====================================================================================
674 // function : CheckSubObjectInUse
675 // purpose  : to be used by OnEditDelete() method
676 //=====================================================================================
677 bool GEOMToolsGUI::CheckSubObjectInUse(_PTR(SObject) checkobj,
678                                        _PTR(SObject) remobj,
679                                        _PTR(Study) aStudy)
680 {
681   CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject(checkobj);
682   GEOM::GEOM_Object_var geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
683   if( CORBA::is_nil(geomObj) ) 
684     return false;
685
686   GEOM::ListOfGO_var list = geomObj->GetDependency();
687   if( list->length() > 1 )
688     for(int i = 0; i < list->length(); i++ ){
689       CORBA::Object_var corbaObj_rem = GeometryGUI::ClientSObjectToObject(remobj);
690       GEOM::GEOM_Object_var geomObj_rem = GEOM::GEOM_Object::_narrow( corbaObj_rem );
691       if( list[i]->_is_equivalent( geomObj_rem ) ){
692         SalomeApp_Application* app =
693           dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
694
695         SUIT_MessageBox::warn1 ( app->desktop(),
696                                  QObject::tr("WRN_WARNING"),
697                                  QObject::tr("DEP_OBJECT"),
698                                  QObject::tr("BUT_OK") );
699         return true;
700       }
701     }
702
703   return false;
704 }
705
706 //=====================================================================================
707 // EXPORTED METHODS
708 //=====================================================================================
709 extern "C"
710 {
711 GEOMTOOLSGUI_EXPORT
712   GEOMGUI* GetLibGUI( GeometryGUI* parent )
713   {
714     return new GEOMToolsGUI( parent );
715   }
716 }