1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_Operations.h"
21 #include "HYDROGUI_CopyPasteOp.h"
22 #include "HYDROGUI_CalculationOp.h"
23 #include "HYDROGUI_ChannelOp.h"
24 #include "HYDROGUI_DataModel.h"
25 #include "HYDROGUI_CopyPastePositionOp.h"
26 #include "HYDROGUI_DeleteOp.h"
27 #include "HYDROGUI_DigueOp.h"
28 #include "HYDROGUI_ExportImageOp.h"
29 #include "HYDROGUI_ExportFileOp.h"
30 #include "HYDROGUI_ImportImageOp.h"
31 #include "HYDROGUI_ImportPolylineOp.h"
32 #include "HYDROGUI_ImportSinusXOp.h"
33 #include "HYDROGUI_ImportBathymetryOp.h"
34 #include "HYDROGUI_ImmersibleZoneOp.h"
35 #include "HYDROGUI_Module.h"
36 #include "HYDROGUI_ObserveImageOp.h"
37 #include "HYDROGUI_PolylineOp.h"
38 #include "HYDROGUI_Poly3DOp.h"
39 #include "HYDROGUI_ProfileOp.h"
40 #include "HYDROGUI_RemoveImageRefsOp.h"
41 #include "HYDROGUI_ShowHideOp.h"
42 #include "HYDROGUI_StreamOp.h"
43 #include "HYDROGUI_TwoImagesOp.h"
44 #include "HYDROGUI_UpdateFlags.h"
45 #include "HYDROGUI_UpdateObjectOp.h"
46 #include "HYDROGUI_VisualStateOp.h"
47 #include "HYDROGUI_ImmersibleZoneOp.h"
48 #include "HYDROGUI_ImportGeomObjectOp.h"
49 #include "HYDROGUI_ImportObstacleFromFileOp.h"
50 #include "HYDROGUI_TranslateObstacleOp.h"
51 #include "HYDROGUI_ExportCalculationOp.h"
52 #include "HYDROGUI_ImportProfilesOp.h"
53 #include "HYDROGUI_GeoreferencementOp.h"
54 #include "HYDROGUI_SetColorOp.h"
55 #include "HYDROGUI_BathymetryBoundsOp.h"
56 #include "HYDROGUI_Tool2.h"
57 #include "HYDROGUI_ZLevelsOp.h"
58 #include "HYDROGUI_LocalCSOp.h"
59 #include "HYDROGUI_RiverBottomOp.h"
60 #include "HYDROGUI_ProfileInterpolateOp.h"
61 #include "HYDROGUI_RecognizeContoursOp.h"
62 #include "HYDROGUI_SubmersibleOp.h"
63 #include "HYDROGUI_StricklerTableOp.h"
64 #include "HYDROGUI_DuplicateOp.h"
65 #include "HYDROGUI_LandCoverMapOp.h"
66 #include "HYDROGUI_PolylineExtractionOp.h"
67 #include "HYDROGUI_ExportSinusXOp.h"
68 #include "HYDROGUI_MergePolylinesOp.h"
69 #include "HYDROGUI_SplitPolylinesOp.h"
70 #include "HYDROGUI_LandCoverColoringOp.h"
71 #include "HYDROGUI_SetTransparencyOp.h"
72 #include "HYDROGUI_ImportLandCoverMapOp.h"
73 #include "HYDROGUI_BathymetrySelectionOp.h"
74 #include "HYDROGUI_BathymetryOp.h"
76 #include <HYDROData_Document.h>
77 #include <HYDROData_Obstacle.h>
78 #include <HYDROData_SplitToZonesTool.h>
79 #include <HYDROData_Iterator.h>
81 #include <GeometryGUI.h>
82 #include <GeometryGUI_Operations.h>
85 #include <SalomeApp_Study.h>
87 #include <LightApp_Application.h>
89 #include <CAM_Application.h>
91 #include <QtxListAction.h>
92 #include <QtxActionToolMgr.h>
94 #include <SUIT_Desktop.h>
95 #include <SUIT_ResourceMgr.h>
96 #include <SUIT_Session.h>
97 #include <SUIT_MessageBox.h>
100 #include <QApplication>
102 QAction* HYDROGUI_Module::createAction( const int theId, const QString& theSuffix, const QString& theImg,
103 const int theKey, const bool isToggle, const QString& theSlot )
105 QString aSlot = theSlot;
106 if( aSlot.isEmpty() )
107 aSlot = SLOT( onOperation() );
108 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
109 std::string anImg = theImg.toStdString();
110 QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aResMgr->loadPixmap( "HYDRO", tr( anImg.c_str() ) );
111 std::string aMenu = ( "MEN_" + theSuffix ).toStdString();
112 std::string aDesktop = ( "DSK_" + theSuffix ).toStdString();
113 std::string aToolbar = ( "STB_" + theSuffix ).toStdString();
114 std::string aSlotStr = aSlot.toStdString();
115 return LightApp_Module::createAction( theId, tr( aDesktop.c_str() ), aPixmap,
116 tr( aMenu.c_str() ), tr( aToolbar.c_str() ),
117 theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() );
120 void HYDROGUI_Module::createActions()
122 createAction( SaveVisualStateId, "SAVE_VISUAL_STATE" );
123 createAction( LoadVisualStateId, "LOAD_VISUAL_STATE" );
125 createAction( CopyId, "COPY", "", Qt::CTRL + Qt::Key_C );
126 createAction( PasteId, "PASTE", "", Qt::CTRL + Qt::Key_V );
128 createAction( UpdateObjectId, "UPDATE_OBJECT" );
129 createAction( ForcedUpdateObjectId, "FORCED_UPDATE_OBJECT" );
131 createAction( ImportImageId, "IMPORT_IMAGE", "IMPORT_IMAGE_ICO", Qt::CTRL + Qt::Key_I );
132 createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE", "EDIT_IMPORTED_IMAGE_ICO" );
133 createAction( ObserveImageId, "OBSERVE_IMAGE", "OBSERVE_IMAGE_ICO" );
134 createAction( ExportImageId, "EXPORT_IMAGE", "EXPORT_IMAGE_ICO" );
135 createAction( RemoveImageRefsId, "REMOVE_IMAGE_REFERENCE", "REMOVE_IMAGE_REFERENCE_ICO" );
137 createAction( ImportPolylineId, "IMPORT_POLYLINE", "IMPORT_POLYLINE_ICO" );
138 createAction( ImportSinusXId, "IMPORT_SINUSX", "IMPORT_SINUSX_ICO" );
139 createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" );
140 createAction( ImportLandCoverMapId, "IMPORT_LANDCOVER_MAP", "IMPORT_LANDCOVER_MAP_ICO" );
142 createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" );
143 createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" );
145 createAction( CreatePolyline3DId, "CREATE_POLYLINE_3D", "CREATE_POLYLINE_3D_ICO" );
146 createAction( EditPolyline3DId, "EDIT_POLYLINE_3D", "EDIT_POLYLINE_3D_ICO" );
148 createAction( CreateProfileId, "CREATE_PROFILE", "CREATE_PROFILE_ICO" );
149 createAction( ImportProfilesId, "IMPORT_PROFILES", "IMPORT_PROFILES_ICO" );
150 createAction( EditProfileId, "EDIT_PROFILE", "EDIT_PROFILE_ICO" );
151 createAction( AllGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" );
152 createAction( SelectedGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" );
154 createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "IMPORT_BATHYMETRY_ICO", Qt::CTRL + Qt::Key_B );
155 createAction( EditImportedBathymetryId, "EDIT_IMPORTED_BATHYMETRY", "EDIT_IMPORTED_BATHYMETRY_ICO" );
156 createAction( BathymetryBoundsId, "BATHYMETRY_BOUNDS", "BATHYMETRY_BOUNDS_ICO" );
157 createAction( BathymetrySelectionId, "BATHYMETRY_SELECTION", "BATHYMETRY_SELECTION_ICO",
158 0, true, SLOT( onBathymetrySelection() ) );
160 createAction( BathymetryTextId, "BATHYMETRY_TEXT", "BATHYMETRY_TEXT_ICO",
161 0, true, SLOT( onBathymetryText() ) );
163 createAction( BathymetryRescaleSelectionId, "BATHYMETRY_RESCALE_SELECTION", "BATHYMETRY_RESCALE_SELECTION_ICO" );
164 createAction( BathymetryRescaleVisibleId, "BATHYMETRY_RESCALE_VISIBLE", "BATHYMETRY_RESCALE_VISIBLE_ICO" );
165 createAction( BathymetryRescaleUserId, "BATHYMETRY_RESCALE_USER", "BATHYMETRY_RESCALE_USER_ICO" );
166 createAction( BathymetryRescaleDefaultId, "BATHYMETRY_RESCALE_DEFAULT", "BATHYMETRY_RESCALE_DEFAULT_ICO" );
168 createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE", "CREATE_IMMERSIBLE_ZONE_ICO" );
169 createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE", "EDIT_IMMERSIBLE_ZONE_ICO" );
171 createAction( CreateStreamId, "CREATE_STREAM", "CREATE_STREAM_ICO" );
172 createAction( EditStreamId, "EDIT_STREAM", "EDIT_STREAM_ICO" );
174 createAction( CreateChannelId, "CREATE_CHANNEL", "CREATE_CHANNEL_ICO" );
175 createAction( EditChannelId, "EDIT_CHANNEL", "EDIT_CHANNEL_ICO" );
177 createAction( CreateDigueId, "CREATE_DIGUE", "CREATE_DIGUE_ICO" );
178 createAction( EditDigueId, "EDIT_DIGUE", "EDIT_DIGUE_ICO" );
180 createAction( ImportStricklerTableFromFileId, "IMPORT_STRICKLER_TABLE", "IMPORT_STRICKLER_TABLE_ICO" );
181 createAction( ExportStricklerTableFromFileId, "EXPORT_STRICKLER_TABLE", "EXPORT_STRICKLER_TABLE_ICO" );
182 createAction( EditStricklerTableId, "EDIT_STRICKLER_TABLE", "EDIT_STRICKLER_TABLE_ICO" );
183 createAction( DuplicateStricklerTableId, "DUPLICATE_STRICKLER_TABLE", "DUPLICATE_STRICKLER_TABLE_ICO" );
185 createAction( CreateLandCoverMapId, "CREATE_LAND_COVER_MAP", "CREATE_LAND_COVER_MAP_ICO" );
187 createAction( AddLandCoverId, "ADD_LAND_COVER", "ADD_LAND_COVER_ICO" );
188 createAction( RemoveLandCoverId, "REMOVE_LAND_COVER", "REMOVE_LAND_COVER_ICO" );
189 createAction( SplitLandCoverId, "SPLIT_LAND_COVER", "SPLIT_LAND_COVER_ICO" );
190 createAction( MergeLandCoverId, "MERGE_LAND_COVER", "MERGE_LAND_COVER_ICO" );
191 createAction( ChangeLandCoverTypeId, "CHANGE_LAND_COVER_TYPE", "CHANGE_LAND_COVER_TYPE_ICO" );
193 createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" );
194 createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" );
195 createAction( ImportGeomObjectAsPolylineId, "IMPORT_GEOM_OBJECT_AS_POLYLINE", "IMPORT_GEOM_OBJECT_ICO" );
196 createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" );
197 createAction( CreateCylinderId, "CREATE_CYLINDER", "CREATE_CYLINDER_ICO" );
198 createAction( TranslateObstacleId, "TRANSLATE_OBSTACLE" );
200 createAction( CreateCalculationId, "CREATE_CALCULATION", "CREATE_CALCULATION_ICO" );
201 createAction( EditCalculationId, "EDIT_CALCULATION", "EDIT_CALCULATION_ICO" );
202 createAction( ExportCalculationId, "EXPORT_CALCULATION", "EXPORT_CALCULATION_ICO" );
204 createAction( FuseImagesId, "FUSE_IMAGES", "FUSE_IMAGES_ICO" );
205 createAction( EditFusedImageId, "EDIT_FUSED_IMAGE", "EDIT_FUSED_IMAGE_ICO" );
207 createAction( CutImagesId, "CUT_IMAGES", "CUT_IMAGES_ICO" );
208 createAction( EditCutImageId, "EDIT_CUT_IMAGE", "EDIT_CUT_IMAGE_ICO" );
210 createAction( SplitImageId, "SPLIT_IMAGE", "SPLIT_IMAGE_ICO" );
211 createAction( EditSplitImageId, "EDIT_SPLIT_IMAGE", "EDIT_SPLIT_IMAGE_ICO" );
213 createAction( RecognizeContoursId, "RECOGNIZE_CONTOURS", "RECOGNIZE_CONTOURS_ICO" );
215 createAction( CopyViewerPositionId, "COPY_VIEWER_POSITION", "" );
217 createAction( DeleteId, "DELETE", "", Qt::Key_Delete, false,
218 SLOT( onDelete() ) );
220 createAction( SetColorId, "COLOR" );
221 createAction( SetTransparencyId, "TRANSPARENCY" );
222 createAction( SetZLevelId, "ZLEVEL" );
223 createAction( EditLocalCSId, "EDIT_LOCAL_CS" );
225 createAction( ShowId, "SHOW" );
226 createAction( ShowOnlyId, "SHOW_ONLY" );
227 createAction( ShowAllId, "SHOW_ALL" );
228 createAction( HideId, "HIDE" );
229 createAction( HideAllId, "HIDE_ALL" );
231 createAction( RiverBottomId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
232 createAction( RiverBottomContextId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
233 createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" );
235 createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
236 createAction( ExportToShapeFileID, "EXPORT_TO_SHAPE_FILE", "EXPORT_TO_SHAPE_FILE_ICO" );
238 createAction( PolylineExtractionId, "POLYLINE_EXTRACTION" );
239 createAction( SplitPolylinesId, "SPLIT_POLYLINES", "SPLIT_POLYLINES_ICO" );
240 createAction( MergePolylinesId, "MERGE_POLYLINES", "MERGE_POLYLINES_ICO" );
242 createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
243 createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
246 void HYDROGUI_Module::createMenus()
248 int aFileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 );
249 int aCustomPos = 5; // to insert custom actions after "Save as" and before "Preferences"
250 createMenu( SaveVisualStateId, aFileMenu, aCustomPos );
251 createMenu( separator(), aFileMenu, -1, aCustomPos );
253 int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
254 createMenu( UndoId, anEditMenu );
255 createMenu( RedoId, anEditMenu );
256 createMenu( separator(), anEditMenu );
257 createMenu( CopyId, anEditMenu );
258 createMenu( PasteId, anEditMenu );
260 int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
261 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
262 createMenu( ImportSinusXId, aHydroId, -1, -1 );
263 createMenu( ExportSinusXId, aHydroId, -1, -1 );
265 createMenu( ImportBathymetryId, aHydroId, -1, -1 );
266 createMenu( ImportStricklerTableFromFileId, aHydroId, -1, -1 );
267 createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
268 createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
269 createMenu( CreateChannelId, aHydroId, -1, -1 );
270 createMenu( CreateDigueId, aHydroId, -1, -1 );
272 int aNewImageId = createMenu( tr( "MEN_DESK_IMAGE" ), aHydroId, -1 );
273 createMenu( ImportImageId, aNewImageId, -1, -1 );
274 createMenu( separator(), aNewImageId );
275 createMenu( FuseImagesId, aNewImageId, -1, -1 );
276 createMenu( CutImagesId, aNewImageId, -1, -1 );
277 createMenu( SplitImageId, aNewImageId, -1, -1 );
279 int aNewPolylineId = createMenu( tr( "MEN_DESK_POLYLINE" ), aHydroId, -1 );
280 createMenu( ImportPolylineId, aNewPolylineId, -1, -1 );
281 createMenu( CreatePolylineId, aNewPolylineId, -1, -1 );
282 createMenu( separator(), aNewPolylineId );
283 createMenu( SplitPolylinesId, aNewPolylineId, -1, -1 );
284 createMenu( MergePolylinesId, aNewPolylineId, -1, -1 );
286 int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
287 createMenu( CreateProfileId, aNewProfileId, -1, -1 );
288 createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
289 createMenu( separator(), aNewProfileId );
290 createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
292 int aStreamMenuId = createMenu( tr( "MEN_DESK_STREAM" ), aHydroId, -1 );
293 createMenu( CreateStreamId, aStreamMenuId, -1, -1 );
294 createMenu( separator(), aStreamMenuId );
295 createMenu( RiverBottomId, aStreamMenuId, -1, -1 );
296 createMenu( ProfileInterpolateId, aStreamMenuId, -1, -1 );
298 int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 );
299 createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 );
300 createMenu( separator(), anObstacleMenuId );
301 createMenu( CreateBoxId, anObstacleMenuId, -1, -1 );
302 createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 );
304 int aLandCoverMapMenuId = createMenu( tr( "MEN_DESK_LAND_COVER_MAP" ), aHydroId, -1 );
305 createMenu( ImportLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
306 createMenu( CreateLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
307 createMenu( separator(), aLandCoverMapMenuId );
308 createMenu( AddLandCoverId, aLandCoverMapMenuId, -1, -1 );
309 createMenu( RemoveLandCoverId, aLandCoverMapMenuId, -1, -1 );
310 createMenu( separator(), aLandCoverMapMenuId );
311 createMenu( SplitLandCoverId, aLandCoverMapMenuId, -1, -1 );
312 createMenu( MergeLandCoverId, aLandCoverMapMenuId, -1, -1 );
313 createMenu( ChangeLandCoverTypeId, aLandCoverMapMenuId, -1, -1 );
315 createMenu( CreateCalculationId, aHydroId, -1, -1 );
316 createMenu( separator(), aHydroId );
317 createMenu( EditLocalCSId, aHydroId, -1, -1 );
318 createMenu( separator(), aHydroId );
321 void HYDROGUI_Module::createPopups()
325 void HYDROGUI_Module::createToolbars()
327 int aToolBar = createTool( tr( "MEN_DESK_HYDRO" ) );
328 createTool( UndoId, aToolBar );
329 createTool( RedoId, aToolBar );
331 createTool( separator(), aToolBar );
332 createTool( ImportImageId, aToolBar );
333 createTool( ImportPolylineId, aToolBar );
334 createTool( ImportSinusXId, aToolBar );
335 createTool( ExportSinusXId, aToolBar );
336 createTool( ImportLandCoverMapId, aToolBar );
338 createTool( ImportBathymetryId, aToolBar );
339 createTool( CreatePolylineId, aToolBar );
340 createTool( CreatePolyline3DId, aToolBar );
342 createTool( separator(), aToolBar );
343 createTool( CreateProfileId, aToolBar );
344 createTool( ImportProfilesId, aToolBar );
345 createTool( AllGeoreferencementId, aToolBar );
347 createTool( separator(), aToolBar );
348 createTool( CreateChannelId, aToolBar );
349 createTool( CreateDigueId, aToolBar );
351 createTool( separator(), aToolBar );
352 createTool( CreateImmersibleZoneId, aToolBar );
353 createTool( CreateStreamId, aToolBar );
355 createTool( separator(), aToolBar );
356 createTool( ImportObstacleFromFileId, aToolBar );
357 createTool( CreateBoxId, aToolBar );
358 createTool( CreateCylinderId, aToolBar );
360 createTool( separator(), aToolBar );
361 createTool( ImportStricklerTableFromFileId, aToolBar );
363 createTool( separator(), aToolBar );
364 createTool( CreateLandCoverMapId, aToolBar );
365 createTool( AddLandCoverId, aToolBar );
366 createTool( RemoveLandCoverId, aToolBar );
367 createTool( SplitLandCoverId, aToolBar );
368 createTool( MergeLandCoverId, aToolBar );
369 createTool( ChangeLandCoverTypeId, aToolBar );
372 createTool( separator(), aToolBar );
373 createTool( CreateCalculationId, aToolBar );
375 createTool( separator(), aToolBar );
376 createTool( FuseImagesId, aToolBar );
377 createTool( CutImagesId, aToolBar );
378 createTool( SplitImageId, aToolBar );
380 createTool( separator(), aToolBar );
381 createTool( BathymetrySelectionId, aToolBar );
382 createTool( BathymetryTextId, aToolBar );
383 createTool( BathymetryRescaleSelectionId, aToolBar );
384 createTool( BathymetryRescaleVisibleId, aToolBar );
385 createTool( BathymetryRescaleUserId, aToolBar );
386 createTool( BathymetryRescaleDefaultId, aToolBar );
389 void HYDROGUI_Module::createUndoRedoActions()
391 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
393 QtxListAction* anEditUndo = new QtxListAction( tr( "MEN_UNDO" ),
394 aResMgr->loadPixmap( "HYDRO", tr( "UNDO_ICO" ) ), tr( "DSK_UNDO" ),
395 Qt::CTRL + Qt::Key_Z, application()->desktop() );
397 QtxListAction* anEditRedo = new QtxListAction( tr( "MEN_REDO" ),
398 aResMgr->loadPixmap( "HYDRO", tr( "REDO_ICO" ) ), tr( "DSK_REDO" ),
399 Qt::CTRL + Qt::Key_Y, application()->desktop() );
401 registerAction( UndoId, anEditUndo );
402 registerAction( RedoId, anEditRedo );
404 anEditUndo->setComment( tr( "STB_UNDO" ) );
405 anEditRedo->setComment( tr( "STB_REDO" ) );
407 connect( anEditUndo, SIGNAL( triggered( int ) ), this, SLOT( onUndo( int ) ) );
408 connect( anEditRedo, SIGNAL( triggered( int ) ), this, SLOT( onRedo( int ) ) );
411 void HYDROGUI_Module::updateUndoRedoControls()
413 HYDROGUI_DataModel* aModel = getDataModel();
415 QtxListAction* aUndoAction = (QtxListAction*)action( UndoId );
416 QtxListAction* aRedoAction = (QtxListAction*)action( RedoId );
418 bool aCanUndo = aModel->canUndo();
419 bool aCanRedo = aModel->canRedo();
422 aUndoAction->addNames( aModel->undoNames() );
423 aUndoAction->setEnabled( aCanUndo );
426 aRedoAction->addNames( aModel->redoNames() );
427 aRedoAction->setEnabled( aCanRedo );
430 void HYDROGUI_Module::enableLCMActions()
432 HYDROData_Iterator anIt( HYDROData_Document::Document( getStudyId() ), KIND_LAND_COVER_MAP );
433 bool anEnableTools = anIt.More();
435 QtxListAction* anAction;
436 anAction = (QtxListAction*)action( AddLandCoverId );
437 if ( anAction ) anAction->setEnabled( anEnableTools );
438 anAction = (QtxListAction*)action( RemoveLandCoverId );
439 if ( anAction ) anAction->setEnabled( anEnableTools );
440 anAction = (QtxListAction*)action( SplitLandCoverId );
441 if ( anAction ) anAction->setEnabled( anEnableTools );
442 anAction = (QtxListAction*)action( MergeLandCoverId );
443 if ( anAction ) anAction->setEnabled( anEnableTools );
444 anAction = (QtxListAction*)action( ChangeLandCoverTypeId );
445 if ( anAction ) anAction->setEnabled( anEnableTools );
448 void HYDROGUI_Module::onOperation()
450 const QAction* anAction = dynamic_cast<const QAction*>( sender() );
451 int anId = actionId( anAction );
453 startOperation( anId );
456 void HYDROGUI_Module::onDelete()
458 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
459 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
460 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
461 aPolylineOp->deleteSelected();
463 startOperation( DeleteId );
466 bool HYDROGUI_Module::onUndo( int theNumActions )
468 QApplication::setOverrideCursor( Qt::WaitCursor );
470 HYDROGUI_DataModel* aModel = getDataModel();
473 while( theNumActions > 0 )
475 if( !aModel->undo() )
484 QApplication::restoreOverrideCursor();
488 bool HYDROGUI_Module::onRedo( int theNumActions )
490 QApplication::setOverrideCursor( Qt::WaitCursor );
492 HYDROGUI_DataModel* aModel = getDataModel();
495 while( theNumActions > 0 )
497 if( !aModel->redo() )
506 QApplication::restoreOverrideCursor();
510 LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
512 LightApp_Operation* anOp = 0;
513 HYDROGUI_Module* aModule = const_cast<HYDROGUI_Module*>( this );
516 case SaveVisualStateId:
517 case LoadVisualStateId:
518 anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
522 anOp = new HYDROGUI_CopyPasteOp( aModule, theId == PasteId );
525 case EditImportedImageId:
526 anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImportedImageId );
528 case ImportPolylineId:
529 anOp = new HYDROGUI_ImportPolylineOp( aModule/*, theId == EditImportedPolylineId*/ );
532 anOp = new HYDROGUI_ImportSinusXOp( aModule );
535 anOp = new HYDROGUI_ExportSinusXOp( aModule );
538 anOp = new HYDROGUI_ObserveImageOp( aModule );
541 anOp = new HYDROGUI_ExportImageOp( aModule );
544 case ForcedUpdateObjectId:
545 anOp = new HYDROGUI_UpdateObjectOp( aModule, theId == ForcedUpdateObjectId );
547 case ExportToShapeFileID:
548 anOp = new HYDROGUI_ExportFileOp( aModule );
550 case ImportLandCoverMapId:
551 anOp = new HYDROGUI_ImportLandCoverMapOp( aModule );
553 case RemoveImageRefsId:
554 anOp = new HYDROGUI_RemoveImageRefsOp( aModule );
556 case CreatePolyline3DId:
557 case EditPolyline3DId:
558 anOp = new HYDROGUI_Poly3DOp( aModule, theId == EditPolyline3DId );
560 case CreatePolylineId:
562 anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
564 case CreateProfileId:
566 anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId );
568 case ProfileInterpolateId:
569 anOp = new HYDROGUI_ProfileInterpolateOp( aModule );
571 case ImportProfilesId:
572 anOp = new HYDROGUI_ImportProfilesOp( aModule ) ;
574 case AllGeoreferencementId:
575 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::All ) ;
577 case SelectedGeoreferencementId:
578 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::Selected ) ;
580 case ImportBathymetryId:
581 case EditImportedBathymetryId:
582 anOp = new HYDROGUI_ImportBathymetryOp( aModule, theId == EditImportedBathymetryId );
584 case BathymetryBoundsId:
585 anOp = new HYDROGUI_BathymetryBoundsOp( aModule );
587 case BathymetrySelectionId:
588 anOp = new HYDROGUI_BathymetrySelectionOp( aModule );
590 case BathymetryTextId:
591 case BathymetryRescaleSelectionId:
592 case BathymetryRescaleVisibleId:
593 case BathymetryRescaleUserId:
594 case BathymetryRescaleDefaultId:
595 anOp = new HYDROGUI_BathymetryOp( aModule, theId );
598 case CreateImmersibleZoneId:
599 case EditImmersibleZoneId:
600 anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
604 anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId );
606 case CreateChannelId:
608 anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId );
612 anOp = new HYDROGUI_DigueOp( aModule, theId == EditDigueId );
614 case ImportStricklerTableFromFileId:
615 case ExportStricklerTableFromFileId:
616 case EditStricklerTableId:
617 anOp = new HYDROGUI_StricklerTableOp( aModule, theId );
619 case CreateLandCoverMapId:
621 case RemoveLandCoverId:
622 case SplitLandCoverId:
623 case MergeLandCoverId:
624 case ChangeLandCoverTypeId:
625 anOp = new HYDROGUI_LandCoverMapOp( aModule, theId );
627 case DuplicateStricklerTableId:
628 anOp = new HYDROGUI_DuplicateOp( aModule );
630 case CreateCalculationId:
631 case EditCalculationId:
632 anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
634 case ExportCalculationId:
635 anOp = new HYDROGUI_ExportCalculationOp( aModule );
638 case EditFusedImageId:
639 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId );
643 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut, theId == EditCutImageId );
646 case EditSplitImageId:
647 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Split, theId == EditSplitImageId );
649 case ImportObstacleFromFileId:
650 anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
652 case ImportGeomObjectAsObstacleId:
653 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsObstacle );
655 case ImportGeomObjectAsPolylineId:
656 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsPolyline );
659 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
660 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpBox );
662 case CreateCylinderId:
663 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
664 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpCylinder );
666 case TranslateObstacleId:
667 anOp = new HYDROGUI_TranslateObstacleOp( aModule );
669 case CopyViewerPositionId:
670 anOp = new HYDROGUI_CopyPastePositionOp( aModule, false );
673 anOp = new HYDROGUI_DeleteOp( aModule );
676 anOp = new HYDROGUI_SetColorOp( aModule );
678 case SetTransparencyId:
679 anOp = new HYDROGUI_SetTransparencyOp( aModule );
682 anOp = new HYDROGUI_ZLevelsOp( aModule );
685 anOp = new HYDROGUI_LocalCSOp( aModule );
688 case RiverBottomContextId:
689 anOp = new HYDROGUI_RiverBottomOp( aModule );
691 case RecognizeContoursId:
692 anOp = new HYDROGUI_RecognizeContoursOp( aModule );
699 anOp = new HYDROGUI_ShowHideOp( aModule, theId );
702 anOp = new HYDROGUI_SubmersibleOp( aModule );
704 case PolylineExtractionId:
705 anOp = new HYDROGUI_PolylineExtractionOp( aModule );
707 case SplitPolylinesId:
708 anOp = new HYDROGUI_SplitPolylinesOp( aModule );
710 case MergePolylinesId:
711 anOp = new HYDROGUI_MergePolylinesOp( aModule );
713 case LandCoverScalarMapModeOnId:
714 case LandCoverScalarMapModeOffId:
715 anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
720 anOp = LightApp_Module::createOperation( theId );
725 bool HYDROGUI_Module::reusableOperation( const int id )
727 if ( id == ImportGeomObjectAsObstacleId ||
728 id == ImportGeomObjectAsPolylineId ) {
732 return LightApp_Module::reusableOperation( id );
736 * Returns true if the object with the given entry can be renamed.
737 * @param theEntry the object entry
739 bool HYDROGUI_Module::renameAllowed( const QString& theEntry ) const
741 // Allow to rename all HYDRO objects
742 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
743 return !anEntity.IsNull();
746 * Returns true if the object with the given entry is renamed.
747 * @param theEntry the object entry
748 * @param theName the new name
750 bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theName )
752 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
754 if ( !anEntity.IsNull() )
756 HYDROGUI_DataModel* aModel = getDataModel();
759 if( anEntity->GetName() != theName )
761 // check that there are no other objects with the same name in the document
762 Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( this, theName );
763 if ( anObject.IsNull() )
765 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
766 if ( anOp && anOp->inherits( "HYDROGUI_CalculationOp" ) )
768 anEntity->SetName( theName );
773 aRes = aModel->rename( anEntity, theName );
778 // Inform the user that the name is already used
779 QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
780 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
781 SUIT_MessageBox::critical( getApp()->desktop(), aTitle, aMessage );
789 void HYDROGUI_Module::onBathymetrySelection()
791 QAction* a = qobject_cast<QAction*>( sender() );
795 bool isChecked = a->isChecked();
797 startOperation( BathymetrySelectionId );
800 LightApp_Operation* op = operation( BathymetryTextId );
804 op = operation( BathymetrySelectionId );
810 void HYDROGUI_Module::onBathymetryText()
812 QAction* a = qobject_cast<QAction*>( sender() );
816 bool isChecked = a->isChecked();
818 startOperation( BathymetryTextId );
820 operation( BathymetryTextId )->abort();