Salome HOME
Feature #170: HYDRO Toolbar and HYDRO main menu:
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Operations.cxx
1 // Copyright (C) 2007-2013  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 #include "HYDROGUI_Operations.h"
24
25 #include "HYDROGUI_CopyPasteOp.h"
26 #include "HYDROGUI_CalculationOp.h"
27 #include "HYDROGUI_ChannelOp.h"
28 #include "HYDROGUI_DataModel.h"
29 #include "HYDROGUI_DeleteOp.h"
30 #include "HYDROGUI_ExportImageOp.h"
31 #include "HYDROGUI_ImportImageOp.h"
32 #include "HYDROGUI_ImportBathymetryOp.h"
33 #include "HYDROGUI_ImmersibleZoneOp.h"
34 #include "HYDROGUI_Module.h"
35 #include "HYDROGUI_ObserveImageOp.h"
36 #include "HYDROGUI_PolylineOp.h"
37 #include "HYDROGUI_Poly3DOp.h"
38 #include "HYDROGUI_ProfileOp.h"
39 #include "HYDROGUI_RemoveImageRefsOp.h"
40 #include "HYDROGUI_ShowHideOp.h"
41 #include "HYDROGUI_StreamOp.h"
42 #include "HYDROGUI_TwoImagesOp.h"
43 #include "HYDROGUI_UpdateFlags.h"
44 #include "HYDROGUI_UpdateObjectOp.h"
45 #include "HYDROGUI_VisualStateOp.h"
46 #include "HYDROGUI_ImmersibleZoneOp.h"
47 #include "HYDROGUI_ImportGeomObjectOp.h"
48 #include "HYDROGUI_ImportObstacleFromFileOp.h"
49 #include "HYDROGUI_ExportCalculationOp.h"
50 #include "HYDROGUI_ImportProfilesOp.h"
51 #include "HYDROGUI_GeoreferencementOp.h"
52 #include "HYDROGUI_SetColorOp.h"
53 #include "HYDROGUI_Tool.h"
54
55 #include <HYDROData_Document.h>
56 #include <HYDROData_Obstacle.h>
57 #include <HYDROData_SplitToZonesTool.h>
58
59 #include <GeometryGUI.h>
60 #include <GeometryGUI_Operations.h>
61 #include <GEOMBase.h>
62
63 #include <SalomeApp_Study.h>
64
65 #include <LightApp_Application.h>
66
67 #include <CAM_Application.h>
68
69 #include <QtxListAction.h>
70 #include <QtxActionToolMgr.h>
71
72 #include <SUIT_Desktop.h>
73 #include <SUIT_ResourceMgr.h>
74 #include <SUIT_Session.h>
75 #include <SUIT_MessageBox.h>
76
77 #include <QAction>
78 #include <QApplication>
79
80 QAction* HYDROGUI_Module::createAction( const int theId, const QString& theSuffix, const QString& theImg,
81                                         const int theKey, const bool isToggle, const QString& theSlot )
82 {
83   QString aSlot = theSlot;
84   if( aSlot.isEmpty() )
85     aSlot = SLOT( onOperation() );
86   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
87   std::string anImg = theImg.toStdString();
88   QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aResMgr->loadPixmap( "HYDRO", tr( anImg.c_str() ) );
89   std::string aMenu    = ( "MEN_" + theSuffix ).toStdString();
90   std::string aDesktop = ( "DSK_" + theSuffix ).toStdString();
91   std::string aToolbar = ( "STB_" + theSuffix ).toStdString();
92   std::string aSlotStr = aSlot.toStdString();
93   return LightApp_Module::createAction( theId, tr( aDesktop.c_str() ), aPixmap,
94     tr( aMenu.c_str() ), tr( aToolbar.c_str() ),
95                 theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() );
96 }
97
98 void HYDROGUI_Module::createActions()
99 {
100   createAction( SaveVisualStateId, "SAVE_VISUAL_STATE" );
101   createAction( LoadVisualStateId, "LOAD_VISUAL_STATE" );
102
103   createAction( CopyId, "COPY", "", Qt::CTRL + Qt::Key_C );
104   createAction( PasteId, "PASTE", "", Qt::CTRL + Qt::Key_V );
105
106   createAction( UpdateObjectId, "UPDATE_OBJECT" );
107
108   createAction( ImportImageId, "IMPORT_IMAGE", "IMPORT_IMAGE_ICO", Qt::CTRL + Qt::Key_I );
109   createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE", "EDIT_IMPORTED_IMAGE_ICO" );
110   createAction( ObserveImageId, "OBSERVE_IMAGE", "OBSERVE_IMAGE_ICO" );
111   createAction( ExportImageId, "EXPORT_IMAGE", "EXPORT_IMAGE_ICO" );
112   createAction( RemoveImageRefsId, "REMOVE_IMAGE_REFERENCE", "REMOVE_IMAGE_REFERENCE_ICO" );
113
114   createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" );
115   createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" ); 
116
117   createAction( CreatePolyline3DId, "CREATE_POLYLINE_3D", "CREATE_POLYLINE_3D_ICO" );
118   createAction( EditPolyline3DId, "EDIT_POLYLINE_3D", "EDIT_POLYLINE_3D_ICO" ); 
119
120   createAction( CreateProfileId, "CREATE_PROFILE", "CREATE_PROFILE_ICO" );
121   createAction( ImportProfilesId, "IMPORT_PROFILES", "IMPORT_PROFILES_ICO" );
122   createAction( EditProfileId, "EDIT_PROFILE", "EDIT_PROFILE_ICO" ); 
123   createAction( AllGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" ); 
124   createAction( SelectedGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" ); 
125   
126   createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "IMPORT_BATHYMETRY_ICO", Qt::CTRL + Qt::Key_B );
127   createAction( EditImportedBathymetryId, "EDIT_IMPORTED_BATHYMETRY", "EDIT_IMPORTED_BATHYMETRY_ICO" );
128
129   createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE", "CREATE_IMMERSIBLE_ZONE_ICO" );
130   createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE", "EDIT_IMMERSIBLE_ZONE_ICO" );
131
132   createAction( CreateStreamId, "CREATE_STREAM", "CREATE_STREAM_ICO" );
133   createAction( EditStreamId, "EDIT_STREAM", "EDIT_STREAM_ICO" );
134
135   createAction( CreateChannelId, "CREATE_CHANNEL", "CREATE_CHANNEL_ICO" );
136   createAction( EditChannelId, "EDIT_CHANNEL", "EDIT_CHANNEL_ICO" );
137
138   createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" );
139   createAction( ImportGeomObjectId, "IMPORT_GEOM_OBJECT", "IMPORT_GEOM_OBJECT_ICO" );
140   createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" );
141   createAction( CreateCylinderId, "CREATE_CYLINDER", "CREATE_CYLINDER_ICO" );
142
143   createAction( CreateCalculationId, "CREATE_CALCULATION", "CREATE_CALCULATION_ICO" );
144   createAction( EditCalculationId, "EDIT_CALCULATION", "EDIT_CALCULATION_ICO" );
145   createAction( ExportCalculationId, "EXPORT_CALCULATION", "EXPORT_CALCULATION_ICO" );
146
147   createAction( FuseImagesId, "FUSE_IMAGES", "FUSE_IMAGES_ICO" );
148   createAction( EditFusedImageId, "EDIT_FUSED_IMAGE", "EDIT_FUSED_IMAGE_ICO" );
149
150   createAction( CutImagesId, "CUT_IMAGES", "CUT_IMAGES_ICO" );
151   createAction( EditCutImageId, "EDIT_CUT_IMAGE", "EDIT_CUT_IMAGE_ICO" );
152
153   createAction( SplitImageId, "SPLIT_IMAGE", "SPLIT_IMAGE_ICO" );
154   createAction( EditSplittedImageId, "EDIT_SPLITTED_IMAGE", "EDIT_SPLITTED_IMAGE_ICO" );
155
156   createAction( DeleteId, "DELETE", "", Qt::Key_Delete, false,
157                 SLOT( onDelete() ) );
158
159   createAction( SetColorId, "COLOR" );
160
161   createAction( ShowId, "SHOW" );
162   createAction( ShowOnlyId, "SHOW_ONLY" );
163   createAction( ShowAllId, "SHOW_ALL" );
164   createAction( HideId, "HIDE" );
165   createAction( HideAllId, "HIDE_ALL" );
166 }
167
168 void HYDROGUI_Module::createMenus()
169 {
170   int aFileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 );
171   int aCustomPos = 5; // to insert custom actions after "Save as" and before "Preferences"
172   createMenu( SaveVisualStateId, aFileMenu, aCustomPos );
173   createMenu( separator(), aFileMenu, -1, aCustomPos );
174
175   int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
176   createMenu( UndoId, anEditMenu );
177   createMenu( RedoId, anEditMenu );
178   createMenu( separator(), anEditMenu );
179   createMenu( CopyId, anEditMenu );
180   createMenu( PasteId, anEditMenu );
181
182   int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
183   int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
184   createMenu( ImportImageId, aHydroId, -1, -1 );
185   createMenu( ImportBathymetryId, aHydroId, -1, -1 );
186   createMenu( CreatePolylineId, aHydroId, -1, -1 );
187   createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
188
189   int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
190   createMenu( CreateProfileId, aNewProfileId, -1, -1 );
191   createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
192   createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
193
194   int anArtificialMenuId = createMenu( tr( "MEN_DESK_ARTIFICIAL" ), aHydroId, -1 );
195   createMenu( CreateChannelId, anArtificialMenuId, -1, -1 );
196
197   int aNaturalMenuId = createMenu( tr( "MEN_DESK_NATURAL" ), aHydroId, -1 );
198   createMenu( CreateImmersibleZoneId, aNaturalMenuId, -1, -1 );
199   createMenu( CreateStreamId, aNaturalMenuId, -1, -1 );
200
201   int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 );
202   createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 );
203   createMenu( CreateBoxId, anObstacleMenuId, -1, -1 );
204   createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 );
205
206   createMenu( CreateCalculationId, aHydroId, -1, -1 );
207   createMenu( separator(), aHydroId );
208   createMenu( FuseImagesId, aHydroId, -1, -1 );
209   createMenu( CutImagesId, aHydroId, -1, -1 );
210   createMenu( SplitImageId, aHydroId, -1, -1 );
211   createMenu( separator(), aHydroId );
212 }
213
214 void HYDROGUI_Module::createPopups()
215 {
216 }
217
218 void HYDROGUI_Module::createToolbars()
219 {
220   int aToolBar = createTool( tr( "MEN_DESK_HYDRO" ) );
221   createTool( UndoId, aToolBar );
222   createTool( RedoId, aToolBar );
223
224   createTool( separator(), aToolBar );
225   createTool( ImportImageId, aToolBar );
226   createTool( ImportBathymetryId, aToolBar );
227   createTool( CreatePolylineId, aToolBar );
228   createTool( CreatePolyline3DId, aToolBar );
229
230   createTool( separator(), aToolBar );
231   createTool( CreateProfileId, aToolBar );
232   createTool( ImportProfilesId, aToolBar );
233   createTool( AllGeoreferencementId, aToolBar );
234
235   createTool( separator(), aToolBar );
236   createTool( CreateChannelId, aToolBar );
237
238   createTool( separator(), aToolBar );
239   createTool( CreateImmersibleZoneId, aToolBar );
240   createTool( CreateStreamId, aToolBar );
241
242   createTool( separator(), aToolBar );
243   createTool( ImportObstacleFromFileId, aToolBar );
244   createTool( CreateBoxId, aToolBar );
245   createTool( CreateCylinderId, aToolBar );
246
247   createTool( separator(), aToolBar );
248   createTool( CreateCalculationId, aToolBar );
249
250   createTool( separator(), aToolBar );
251   createTool( FuseImagesId, aToolBar );
252   createTool( CutImagesId, aToolBar );
253   createTool( SplitImageId, aToolBar );
254 }
255
256 void HYDROGUI_Module::createUndoRedoActions()
257 {
258   SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
259
260   QtxListAction* anEditUndo = new QtxListAction( tr( "MEN_UNDO" ),
261     aResMgr->loadPixmap( "HYDRO", tr( "UNDO_ICO" ) ), tr( "DSK_UNDO" ),
262     Qt::CTRL + Qt::Key_Z, application()->desktop() );
263     
264   QtxListAction* anEditRedo = new QtxListAction( tr( "MEN_REDO" ),
265     aResMgr->loadPixmap( "HYDRO", tr( "REDO_ICO" ) ), tr( "DSK_REDO" ),
266     Qt::CTRL + Qt::Key_Y, application()->desktop() );
267   
268   registerAction( UndoId, anEditUndo );
269   registerAction( RedoId, anEditRedo );
270
271   anEditUndo->setComment( tr( "STB_UNDO" ) );
272   anEditRedo->setComment( tr( "STB_REDO" ) );
273
274   connect( anEditUndo, SIGNAL( triggered( int ) ), this, SLOT( onUndo( int ) ) );
275   connect( anEditRedo, SIGNAL( triggered( int ) ), this, SLOT( onRedo( int ) ) );
276 }
277
278 void HYDROGUI_Module::updateUndoRedoControls()
279 {
280   HYDROGUI_DataModel* aModel = getDataModel();
281
282   QtxListAction* aUndoAction = (QtxListAction*)action( UndoId );
283   QtxListAction* aRedoAction = (QtxListAction*)action( RedoId );
284
285   bool aCanUndo = aModel->canUndo();
286   bool aCanRedo = aModel->canRedo();
287
288   if( aCanUndo )
289     aUndoAction->addNames( aModel->undoNames() );
290   aUndoAction->setEnabled( aCanUndo );
291
292   if( aCanRedo )
293     aRedoAction->addNames( aModel->redoNames() );
294   aRedoAction->setEnabled( aCanRedo );
295 }
296
297 void HYDROGUI_Module::onOperation()
298 {
299   const QAction* anAction = dynamic_cast<const QAction*>( sender() );
300   int anId = actionId( anAction );
301   if( anId >= 0 )
302     startOperation( anId );
303 }
304
305 void HYDROGUI_Module::onDelete()
306 {
307   SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
308   HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
309   if ( aPolylineOp && aPolylineOp->deleteEnabled() )
310     aPolylineOp->deleteSelected();
311   else
312     startOperation( DeleteId );
313 }
314
315 bool HYDROGUI_Module::onUndo( int theNumActions )
316 {
317   QApplication::setOverrideCursor( Qt::WaitCursor );
318   bool anIsOk = true;
319   HYDROGUI_DataModel* aModel = getDataModel();
320   if( aModel )
321   {
322     while( theNumActions > 0 )
323     {
324       if( !aModel->undo() )
325       {
326         anIsOk = false;
327         break;
328       }
329       theNumActions--;
330     }
331     update( UF_All );
332   }
333   QApplication::restoreOverrideCursor();
334   return anIsOk;
335 }
336
337 bool HYDROGUI_Module::onRedo( int theNumActions )
338 {
339   QApplication::setOverrideCursor( Qt::WaitCursor );
340   bool anIsOk = true;
341   HYDROGUI_DataModel* aModel = getDataModel();
342   if( aModel )
343   {
344     while( theNumActions > 0 )
345     {
346       if( !aModel->redo() )
347       {
348         anIsOk = false;
349         break;
350       }
351       theNumActions--;
352     }
353     update( UF_All );
354   }
355   QApplication::restoreOverrideCursor();
356   return anIsOk;
357 }
358
359 LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
360 {
361   LightApp_Operation* anOp = 0;
362   HYDROGUI_Module* aModule = const_cast<HYDROGUI_Module*>( this );
363   switch( theId )
364   {
365   case SaveVisualStateId:
366   case LoadVisualStateId:
367     anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
368     break;
369   case CopyId:
370   case PasteId:
371     anOp = new HYDROGUI_CopyPasteOp( aModule, theId == PasteId );
372     break;
373   case ImportImageId:
374   case EditImportedImageId:
375     anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImportedImageId );
376     break;
377   case ObserveImageId:
378     anOp = new HYDROGUI_ObserveImageOp( aModule );
379     break;
380   case ExportImageId:
381     anOp = new HYDROGUI_ExportImageOp( aModule );
382     break;
383   case UpdateObjectId:
384     anOp = new HYDROGUI_UpdateObjectOp( aModule );
385     break;
386   case RemoveImageRefsId:
387     anOp = new HYDROGUI_RemoveImageRefsOp( aModule );
388     break;
389   case CreatePolyline3DId:
390   case EditPolyline3DId:
391     anOp = new HYDROGUI_Poly3DOp( aModule, theId == EditPolyline3DId );
392     break;
393   case CreatePolylineId:
394   case EditPolylineId:
395     anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
396     break;
397   case CreateProfileId:
398   case EditProfileId:
399     anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId );
400     break;
401   case ImportProfilesId:
402     anOp = new HYDROGUI_ImportProfilesOp( aModule ) ;
403     break;
404   case AllGeoreferencementId:
405     anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::All ) ;
406     break;
407   case SelectedGeoreferencementId:
408     anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::Selected ) ;
409     break;
410   case ImportBathymetryId:
411   case EditImportedBathymetryId:
412     anOp = new HYDROGUI_ImportBathymetryOp( aModule, theId == EditImportedBathymetryId  );
413     break;
414   case CreateImmersibleZoneId:
415   case EditImmersibleZoneId:
416     anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
417     break;
418   case CreateStreamId:
419   case EditStreamId:
420     anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId );
421     break;
422   case CreateChannelId:
423   case EditChannelId:
424     anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId );
425     break;
426   case CreateCalculationId:
427   case EditCalculationId:
428     anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
429     break;
430   case ExportCalculationId:
431     anOp = new HYDROGUI_ExportCalculationOp( aModule );
432     break;
433   case FuseImagesId:
434   case EditFusedImageId:
435     anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId );
436     break;
437   case CutImagesId:
438   case EditCutImageId:
439     anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut, theId == EditCutImageId );
440     break;
441   case SplitImageId:
442   case EditSplittedImageId:
443     anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Split, theId == EditSplittedImageId );
444     break;
445   case ImportObstacleFromFileId:
446     anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
447     break;
448   case ImportCreatedPrimitiveId:
449     anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportCreated );
450     break;
451   case ImportGeomObjectId:
452     anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelected );
453     break;
454   case CreateBoxId:
455     application()->activateOperation( "Geometry", GEOMOp::OpBox );
456     break;
457   case CreateCylinderId:
458     application()->activateOperation( "Geometry", GEOMOp::OpCylinder );
459     break;
460   case DeleteId:
461     anOp = new HYDROGUI_DeleteOp( aModule );
462     break;
463   case SetColorId:
464     anOp = new HYDROGUI_SetColorOp( aModule );
465     break;
466   case ShowId:
467   case ShowOnlyId:
468   case ShowAllId:
469   case HideId:
470   case HideAllId:
471     anOp = new HYDROGUI_ShowHideOp( aModule, theId );
472     break;
473   }
474
475   if( !anOp )
476     anOp = LightApp_Module::createOperation( theId );
477
478   return anOp;
479 }
480
481 bool HYDROGUI_Module::reusableOperation( const int id )
482 {
483   if ( id == ImportGeomObjectId ) {
484     return false;
485   }
486
487   return LightApp_Module::reusableOperation( id );
488 }
489
490 /**
491  * Called when the operation perfomed by another module is finished.
492  * \param theModuleName the name of the module which perfomed the operation
493  * \param theOperationName the operation name
494  * \param theEntryList the list of the created objects entries
495  */
496 void HYDROGUI_Module::onExternalOperationFinished( const QString& theModuleName,
497                                                    const QString& theOperationName,
498                                                    const QStringList& theEntryList )
499 {
500   // Process "Geometry" module operations with non-empty list of created objects only
501   if ( theModuleName != "Geometry" || theEntryList.isEmpty() ) {
502     return;
503   }
504   
505   // Start import GEOM object operation
506   myGeomObjectsToImport = theEntryList;
507   startOperation( ImportCreatedPrimitiveId );
508   myGeomObjectsToImport.clear();
509 }
510
511 /**
512  * Returns the list of entries of GEOM objects to be imported.
513  */
514 QStringList HYDROGUI_Module::GetGeomObjectsToImport()
515 {
516   return myGeomObjectsToImport;
517 }
518
519 /**
520  * Returns true if the object with the given entry can be renamed.
521  * @param theEntry the object entry
522  */
523 bool HYDROGUI_Module::renameAllowed( const QString& theEntry ) const
524 {
525   // Allow to rename all HYDRO objects
526   Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
527   return !anEntity.IsNull();
528 }
529 /**
530  * Returns true if the object with the given entry is renamed.
531  * @param theEntry the object entry
532  * @param theName the new name
533  */
534 bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theName )
535 {
536   Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
537   bool aRes = !anEntity.IsNull();
538   if ( aRes )
539   {
540     HYDROGUI_DataModel* aModel = getDataModel();
541     if( aModel )
542     {
543       if( anEntity->GetName() != theName )
544       {
545         // check that there are no other objects with the same name in the document
546         Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( this, theName );
547         aRes = anObject.IsNull();
548         if ( aRes )
549         {
550           aRes = aModel->rename( anEntity, theName );
551         }
552         else
553         {
554           // Inform the user that the name is already used
555           QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
556           QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
557           SUIT_MessageBox::critical( getApp()->desktop(), aTitle, aMessage );
558         }
559       }
560     }
561   }
562   return aRes;
563 }