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_MeasurementToolOp.h"
49 #include "HYDROGUI_ImportGeomObjectOp.h"
50 #include "HYDROGUI_ImportObstacleFromFileOp.h"
51 #include "HYDROGUI_TranslateObstacleOp.h"
52 #include "HYDROGUI_ExportCalculationOp.h"
53 #include "HYDROGUI_ImportProfilesOp.h"
54 #include "HYDROGUI_GeoreferencementOp.h"
55 #include "HYDROGUI_SetColorOp.h"
56 #include "HYDROGUI_BathymetryBoundsOp.h"
57 #include "HYDROGUI_Tool2.h"
58 #include "HYDROGUI_ZLevelsOp.h"
59 #include "HYDROGUI_LocalCSOp.h"
60 #include "HYDROGUI_RiverBottomOp.h"
61 #include "HYDROGUI_ProfileInterpolateOp.h"
62 #include "HYDROGUI_RecognizeContoursOp.h"
63 #include <HYDROGUI_ImportBCPolygonOp.h>
64 #include "HYDROGUI_SubmersibleOp.h"
65 #include "HYDROGUI_StricklerTableOp.h"
66 #include "HYDROGUI_DuplicateOp.h"
67 #include "HYDROGUI_LandCoverMapOp.h"
68 #include "HYDROGUI_PolylineExtractionOp.h"
69 #include "HYDROGUI_ExportSinusXOp.h"
70 #include "HYDROGUI_MergePolylinesOp.h"
71 #include "HYDROGUI_SplitPolylinesOp.h"
72 #include "HYDROGUI_LandCoverColoringOp.h"
73 #include "HYDROGUI_SetTransparencyOp.h"
74 #include "HYDROGUI_ImportLandCoverMapOp.h"
75 #include "HYDROGUI_BathymetrySelectionOp.h"
76 #include "HYDROGUI_BathymetryOp.h"
77 #include "HYDROGUI_RegenerateRegionColorsOp.h"
78 #include "HYDROGUI_PolylineStyleOp.h"
79 #include "HYDROGUI_ZoneSetColorOp.h"
80 #include <HYDROGUI_ShowAttrPolyOp.h>
81 #include <HYDROGUI_SetBoundaryTypePolygonOp.h>
82 #include <HYDROData_Document.h>
83 #include <HYDROData_Obstacle.h>
84 #include <HYDROData_SplitToZonesTool.h>
85 #include <HYDROData_Iterator.h>
87 #include <GeometryGUI.h>
88 #include <GeometryGUI_Operations.h>
91 #include <SalomeApp_Study.h>
93 #include <LightApp_Application.h>
95 #include <OCCViewer_ViewModel.h>
96 #include <OCCViewer_ViewManager.h>
97 #include <OCCViewer_ViewWindow.h>
98 #include <OCCViewer_ViewFrame.h>
100 #include <QtxListAction.h>
101 #include <QtxActionToolMgr.h>
103 #include <SUIT_Desktop.h>
104 #include <SUIT_ResourceMgr.h>
105 #include <SUIT_Session.h>
106 #include <SUIT_MessageBox.h>
109 #include <QApplication>
111 QAction* HYDROGUI_Module::createAction( const int theId, const QString& theSuffix, const QString& theImg,
112 const int theKey, const bool isToggle, const QString& theSlot )
114 QString aSlot = theSlot;
115 if( aSlot.isEmpty() )
116 aSlot = SLOT( onOperation() );
117 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
118 std::string anImg = theImg.toStdString();
119 QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aResMgr->loadPixmap( "HYDRO", tr( anImg.c_str() ) );
120 std::string aMenu = ( "MEN_" + theSuffix ).toStdString();
121 std::string aDesktop = ( "DSK_" + theSuffix ).toStdString();
122 std::string aToolbar = ( "STB_" + theSuffix ).toStdString();
123 std::string aSlotStr = aSlot.toStdString();
124 return LightApp_Module::createAction( theId, tr( aDesktop.c_str() ), aPixmap,
125 tr( aMenu.c_str() ), tr( aToolbar.c_str() ),
126 theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() );
129 void HYDROGUI_Module::createActions()
131 createAction( SaveVisualStateId, "SAVE_VISUAL_STATE" );
132 createAction( LoadVisualStateId, "LOAD_VISUAL_STATE" );
134 createAction( CopyId, "COPY", "", Qt::CTRL + Qt::Key_C );
135 createAction( PasteId, "PASTE", "", Qt::CTRL + Qt::Key_V );
137 createAction( UpdateObjectId, "UPDATE_OBJECT" );
138 createAction( ForcedUpdateObjectId, "FORCED_UPDATE_OBJECT" );
140 createAction( ImportImageId, "IMPORT_IMAGE", "IMPORT_IMAGE_ICO", Qt::CTRL + Qt::Key_I );
141 createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE", "EDIT_IMPORTED_IMAGE_ICO" );
142 createAction( ObserveImageId, "OBSERVE_IMAGE", "OBSERVE_IMAGE_ICO" );
143 createAction( ExportImageId, "EXPORT_IMAGE", "EXPORT_IMAGE_ICO" );
144 createAction( RemoveImageRefsId, "REMOVE_IMAGE_REFERENCE", "REMOVE_IMAGE_REFERENCE_ICO" );
146 createAction( ImportPolylineId, "IMPORT_POLYLINE", "IMPORT_POLYLINE_ICO" );
147 createAction( ImportSinusXId, "IMPORT_SINUSX", "IMPORT_SINUSX_ICO" );
148 createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" );
149 createAction( ImportLandCoverMapId, "IMPORT_LANDCOVER_MAP", "IMPORT_LANDCOVER_MAP_ICO" );
151 createAction( MeasurementToolId, "MEASUREMENT_TOOL", "MEASUREMENT_TOOL_ICO" );
153 createAction( ImportBCPolygonId, "IMPORT_BC_POLYGON", "IMPORT_BC_POLYGON_ICO" );
155 createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" );
156 createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" );
158 createAction( CreatePolyline3DId, "CREATE_POLYLINE_3D", "CREATE_POLYLINE_3D_ICO" );
159 createAction( EditPolyline3DId, "EDIT_POLYLINE_3D", "EDIT_POLYLINE_3D_ICO" );
161 createAction( CreateProfileId, "CREATE_PROFILE", "CREATE_PROFILE_ICO" );
162 createAction( ImportProfilesId, "IMPORT_PROFILES", "IMPORT_PROFILES_ICO" );
163 createAction( EditProfileId, "EDIT_PROFILE", "EDIT_PROFILE_ICO" );
164 createAction( AllGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" );
165 createAction( SelectedGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" );
167 createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "IMPORT_BATHYMETRY_ICO", Qt::CTRL + Qt::Key_B );
168 createAction( EditImportedBathymetryId, "EDIT_IMPORTED_BATHYMETRY", "EDIT_IMPORTED_BATHYMETRY_ICO" );
169 createAction( BathymetryBoundsId, "BATHYMETRY_BOUNDS", "BATHYMETRY_BOUNDS_ICO" );
170 createAction( BathymetrySelectionId, "BATHYMETRY_SELECTION", "BATHYMETRY_SELECTION_ICO",
171 0, true, SLOT( onBathymetrySelection() ) );
173 createAction( BathymetryTextId, "BATHYMETRY_TEXT", "BATHYMETRY_TEXT_ICO",
174 0, true, SLOT( onBathymetryText() ) );
176 createAction( BathymetryRescaleSelectionId, "BATHYMETRY_RESCALE_SELECTION", "BATHYMETRY_RESCALE_SELECTION_ICO" );
177 createAction( BathymetryRescaleVisibleId, "BATHYMETRY_RESCALE_VISIBLE", "BATHYMETRY_RESCALE_VISIBLE_ICO" );
178 createAction( BathymetryRescaleUserId, "BATHYMETRY_RESCALE_USER", "BATHYMETRY_RESCALE_USER_ICO" );
179 createAction( BathymetryRescaleDefaultId, "BATHYMETRY_RESCALE_DEFAULT", "BATHYMETRY_RESCALE_DEFAULT_ICO" );
181 createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE", "CREATE_IMMERSIBLE_ZONE_ICO" );
182 createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE", "EDIT_IMMERSIBLE_ZONE_ICO" );
184 createAction( CreateStreamId, "CREATE_STREAM", "CREATE_STREAM_ICO" );
185 createAction( EditStreamId, "EDIT_STREAM", "EDIT_STREAM_ICO" );
187 createAction( CreateChannelId, "CREATE_CHANNEL", "CREATE_CHANNEL_ICO" );
188 createAction( EditChannelId, "EDIT_CHANNEL", "EDIT_CHANNEL_ICO" );
190 createAction( CreateDigueId, "CREATE_DIGUE", "CREATE_DIGUE_ICO" );
191 createAction( EditDigueId, "EDIT_DIGUE", "EDIT_DIGUE_ICO" );
193 createAction( ImportStricklerTableFromFileId, "IMPORT_STRICKLER_TABLE", "IMPORT_STRICKLER_TABLE_ICO" );
194 createAction( ExportStricklerTableFromFileId, "EXPORT_STRICKLER_TABLE", "EXPORT_STRICKLER_TABLE_ICO" );
195 createAction( EditStricklerTableId, "EDIT_STRICKLER_TABLE", "EDIT_STRICKLER_TABLE_ICO" );
196 createAction( DuplicateStricklerTableId, "DUPLICATE_STRICKLER_TABLE", "DUPLICATE_STRICKLER_TABLE_ICO" );
198 createAction( CreateLandCoverMapId, "CREATE_LAND_COVER_MAP", "CREATE_LAND_COVER_MAP_ICO" );
200 createAction( AddLandCoverId, "ADD_LAND_COVER", "ADD_LAND_COVER_ICO" );
201 createAction( RemoveLandCoverId, "REMOVE_LAND_COVER", "REMOVE_LAND_COVER_ICO" );
202 createAction( SplitLandCoverId, "SPLIT_LAND_COVER", "SPLIT_LAND_COVER_ICO" );
203 createAction( MergeLandCoverId, "MERGE_LAND_COVER", "MERGE_LAND_COVER_ICO" );
204 createAction( ChangeLandCoverTypeId, "CHANGE_LAND_COVER_TYPE", "CHANGE_LAND_COVER_TYPE_ICO" );
206 createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" );
207 createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" );
208 createAction( ImportGeomObjectAsPolylineId, "IMPORT_GEOM_OBJECT_AS_POLYLINE", "IMPORT_GEOM_OBJECT_ICO" );
209 createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" );
210 createAction( CreateCylinderId, "CREATE_CYLINDER", "CREATE_CYLINDER_ICO" );
211 createAction( TranslateObstacleId, "TRANSLATE_OBSTACLE" );
213 createAction( CreateCalculationId, "CREATE_CALCULATION", "CREATE_CALCULATION_ICO" );
214 createAction( EditCalculationId, "EDIT_CALCULATION", "EDIT_CALCULATION_ICO" );
215 createAction( ExportCalculationId, "EXPORT_CALCULATION", "EXPORT_CALCULATION_ICO" );
217 createAction( CompleteCalculationId, "COMPLETE_CALCULATION", "COMPLETE_CALCULATION_ICO" );
219 createAction( FuseImagesId, "FUSE_IMAGES", "FUSE_IMAGES_ICO" );
220 createAction( EditFusedImageId, "EDIT_FUSED_IMAGE", "EDIT_FUSED_IMAGE_ICO" );
222 createAction( CutImagesId, "CUT_IMAGES", "CUT_IMAGES_ICO" );
223 createAction( EditCutImageId, "EDIT_CUT_IMAGE", "EDIT_CUT_IMAGE_ICO" );
225 createAction( SplitImageId, "SPLIT_IMAGE", "SPLIT_IMAGE_ICO" );
226 createAction( EditSplitImageId, "EDIT_SPLIT_IMAGE", "EDIT_SPLIT_IMAGE_ICO" );
228 createAction( RecognizeContoursId, "RECOGNIZE_CONTOURS", "RECOGNIZE_CONTOURS_ICO" );
230 createAction( CopyViewerPositionId, "COPY_VIEWER_POSITION", "" );
232 createAction( DeleteId, "DELETE", "", Qt::Key_Delete, false,
233 SLOT( onDelete() ) );
235 createAction( SetColorId, "COLOR" );
236 createAction( SetTransparencyId, "TRANSPARENCY" );
237 createAction( SetZLevelId, "ZLEVEL" );
238 createAction( EditLocalCSId, "EDIT_LOCAL_CS" );
240 createAction( ShowId, "SHOW" );
241 createAction( ShowOnlyId, "SHOW_ONLY" );
242 createAction( ShowAllId, "SHOW_ALL" );
243 createAction( HideId, "HIDE" );
244 createAction( HideAllId, "HIDE_ALL" );
246 createAction( RiverBottomId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
247 createAction( RiverBottomContextId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
248 createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" );
250 createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
251 createAction( UnSubmersibleId, "UNSUBMERSIBLE", "HYDRO_UNSUBMERSIBLE16_ICO" );
252 createAction( ExportToShapeFileID, "EXPORT_TO_SHAPE_FILE", "EXPORT_TO_SHAPE_FILE_ICO" );
254 createAction( PolylineExtractionId, "POLYLINE_EXTRACTION" );
255 createAction( SplitPolylinesId, "SPLIT_POLYLINES", "SPLIT_POLYLINES_ICO" );
256 createAction( MergePolylinesId, "MERGE_POLYLINES", "MERGE_POLYLINES_ICO" );
258 createAction( ShowAttrPolylinesId, "SHOWATTR_POLYLINES");
260 createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
261 createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
263 createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" );
264 createAction( ZoneSetColorId, "ZONE_SET_COLOR" );
265 createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" );
266 createAction( SetBoundaryTypePolygonId, "SET_BOUNDARY_TYPE_POLYGON" );
269 void HYDROGUI_Module::createMenus()
271 int aFileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 );
272 int aCustomPos = 5; // to insert custom actions after "Save as" and before "Preferences"
273 createMenu( SaveVisualStateId, aFileMenu, aCustomPos );
274 createMenu( separator(), aFileMenu, -1, aCustomPos );
276 int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
277 createMenu( UndoId, anEditMenu );
278 createMenu( RedoId, anEditMenu );
279 createMenu( separator(), anEditMenu );
280 createMenu( CopyId, anEditMenu );
281 createMenu( PasteId, anEditMenu );
283 int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
284 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
285 createMenu( ImportSinusXId, aHydroId, -1, -1 );
286 createMenu( ExportSinusXId, aHydroId, -1, -1 );
288 createMenu( ImportBathymetryId, aHydroId, -1, -1 );
289 createMenu( ImportStricklerTableFromFileId, aHydroId, -1, -1 );
290 createMenu( ImportBCPolygonId, aHydroId, -1, -1 );
291 createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
292 createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
293 createMenu( CreateChannelId, aHydroId, -1, -1 );
294 createMenu( CreateDigueId, aHydroId, -1, -1 );
296 createMenu( MeasurementToolId, aHydroId, -1, -1 );
298 int aNewImageId = createMenu( tr( "MEN_DESK_IMAGE" ), aHydroId, -1 );
299 createMenu( ImportImageId, aNewImageId, -1, -1 );
300 createMenu( separator(), aNewImageId );
301 createMenu( FuseImagesId, aNewImageId, -1, -1 );
302 createMenu( CutImagesId, aNewImageId, -1, -1 );
303 createMenu( SplitImageId, aNewImageId, -1, -1 );
305 int aNewPolylineId = createMenu( tr( "MEN_DESK_POLYLINE" ), aHydroId, -1 );
306 createMenu( ImportPolylineId, aNewPolylineId, -1, -1 );
307 createMenu( CreatePolylineId, aNewPolylineId, -1, -1 );
308 createMenu( separator(), aNewPolylineId );
309 createMenu( SplitPolylinesId, aNewPolylineId, -1, -1 );
310 createMenu( MergePolylinesId, aNewPolylineId, -1, -1 );
312 int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
313 createMenu( CreateProfileId, aNewProfileId, -1, -1 );
314 createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
315 createMenu( separator(), aNewProfileId );
316 createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
318 int aStreamMenuId = createMenu( tr( "MEN_DESK_STREAM" ), aHydroId, -1 );
319 createMenu( CreateStreamId, aStreamMenuId, -1, -1 );
320 createMenu( separator(), aStreamMenuId );
321 createMenu( RiverBottomId, aStreamMenuId, -1, -1 );
322 createMenu( ProfileInterpolateId, aStreamMenuId, -1, -1 );
324 int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 );
325 createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 );
326 createMenu( separator(), anObstacleMenuId );
327 createMenu( CreateBoxId, anObstacleMenuId, -1, -1 );
328 createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 );
330 int aLandCoverMapMenuId = createMenu( tr( "MEN_DESK_LAND_COVER_MAP" ), aHydroId, -1 );
331 createMenu( ImportLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
332 createMenu( CreateLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
333 createMenu( separator(), aLandCoverMapMenuId );
334 createMenu( AddLandCoverId, aLandCoverMapMenuId, -1, -1 );
335 createMenu( RemoveLandCoverId, aLandCoverMapMenuId, -1, -1 );
336 createMenu( separator(), aLandCoverMapMenuId );
337 createMenu( SplitLandCoverId, aLandCoverMapMenuId, -1, -1 );
338 createMenu( MergeLandCoverId, aLandCoverMapMenuId, -1, -1 );
339 createMenu( ChangeLandCoverTypeId, aLandCoverMapMenuId, -1, -1 );
341 createMenu( CreateCalculationId, aHydroId, -1, -1 );
342 createMenu( separator(), aHydroId );
343 createMenu( EditLocalCSId, aHydroId, -1, -1 );
344 createMenu( separator(), aHydroId );
347 void HYDROGUI_Module::createPopups()
351 void HYDROGUI_Module::createToolbars()
353 int aToolBar = createTool( tr( "MEN_DESK_HYDRO" ) );
354 createTool( UndoId, aToolBar );
355 createTool( RedoId, aToolBar );
357 createTool( separator(), aToolBar );
358 createTool( ImportImageId, aToolBar );
359 createTool( ImportPolylineId, aToolBar );
360 createTool( ImportSinusXId, aToolBar );
361 createTool( ExportSinusXId, aToolBar );
362 createTool( ImportLandCoverMapId, aToolBar );
364 createTool( ImportBCPolygonId, aToolBar );
365 createTool( MeasurementToolId, aToolBar );
367 createTool( ImportBathymetryId, aToolBar );
368 createTool( CreatePolylineId, aToolBar );
369 createTool( CreatePolyline3DId, aToolBar );
371 createTool( separator(), aToolBar );
372 createTool( CreateProfileId, aToolBar );
373 createTool( ImportProfilesId, aToolBar );
374 createTool( AllGeoreferencementId, aToolBar );
376 createTool( separator(), aToolBar );
377 createTool( CreateChannelId, aToolBar );
378 createTool( CreateDigueId, aToolBar );
380 createTool( separator(), aToolBar );
381 createTool( CreateImmersibleZoneId, aToolBar );
382 createTool( CreateStreamId, aToolBar );
384 createTool( separator(), aToolBar );
385 createTool( ImportObstacleFromFileId, aToolBar );
386 createTool( CreateBoxId, aToolBar );
387 createTool( CreateCylinderId, aToolBar );
389 createTool( separator(), aToolBar );
390 createTool( ImportStricklerTableFromFileId, aToolBar );
392 createTool( separator(), aToolBar );
393 createTool( CreateLandCoverMapId, aToolBar );
394 createTool( AddLandCoverId, aToolBar );
395 createTool( RemoveLandCoverId, aToolBar );
396 createTool( SplitLandCoverId, aToolBar );
397 createTool( MergeLandCoverId, aToolBar );
398 createTool( ChangeLandCoverTypeId, aToolBar );
401 createTool( separator(), aToolBar );
402 createTool( CreateCalculationId, aToolBar );
404 createTool( separator(), aToolBar );
405 createTool( FuseImagesId, aToolBar );
406 createTool( CutImagesId, aToolBar );
407 createTool( SplitImageId, aToolBar );
409 createTool( separator(), aToolBar );
410 createTool( BathymetrySelectionId, aToolBar );
411 createTool( BathymetryTextId, aToolBar );
412 createTool( BathymetryRescaleSelectionId, aToolBar );
413 createTool( BathymetryRescaleVisibleId, aToolBar );
414 createTool( BathymetryRescaleUserId, aToolBar );
415 createTool( BathymetryRescaleDefaultId, aToolBar );
418 void HYDROGUI_Module::createUndoRedoActions()
420 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
422 QtxListAction* anEditUndo = new QtxListAction( tr( "MEN_UNDO" ),
423 aResMgr->loadPixmap( "HYDRO", tr( "UNDO_ICO" ) ), tr( "DSK_UNDO" ),
424 Qt::CTRL + Qt::Key_Z, application()->desktop() );
426 QtxListAction* anEditRedo = new QtxListAction( tr( "MEN_REDO" ),
427 aResMgr->loadPixmap( "HYDRO", tr( "REDO_ICO" ) ), tr( "DSK_REDO" ),
428 Qt::CTRL + Qt::Key_Y, application()->desktop() );
430 registerAction( UndoId, anEditUndo );
431 registerAction( RedoId, anEditRedo );
433 anEditUndo->setComment( tr( "STB_UNDO" ) );
434 anEditRedo->setComment( tr( "STB_REDO" ) );
436 connect( anEditUndo, SIGNAL( triggered( int ) ), this, SLOT( onUndo( int ) ) );
437 connect( anEditRedo, SIGNAL( triggered( int ) ), this, SLOT( onRedo( int ) ) );
440 void HYDROGUI_Module::updateUndoRedoControls()
442 HYDROGUI_DataModel* aModel = getDataModel();
444 QtxListAction* aUndoAction = (QtxListAction*)action( UndoId );
445 QtxListAction* aRedoAction = (QtxListAction*)action( RedoId );
447 bool aCanUndo = aModel->canUndo();
448 bool aCanRedo = aModel->canRedo();
451 aUndoAction->addNames( aModel->undoNames() );
452 aUndoAction->setEnabled( aCanUndo );
455 aRedoAction->addNames( aModel->redoNames() );
456 aRedoAction->setEnabled( aCanRedo );
459 void HYDROGUI_Module::enableLCMActions()
461 HYDROData_Iterator anIt( HYDROData_Document::Document( getStudyId() ), KIND_LAND_COVER_MAP );
462 bool anEnableTools = anIt.More();
464 QtxListAction* anAction;
465 anAction = (QtxListAction*)action( AddLandCoverId );
466 if ( anAction ) anAction->setEnabled( anEnableTools );
467 anAction = (QtxListAction*)action( RemoveLandCoverId );
468 if ( anAction ) anAction->setEnabled( anEnableTools );
469 anAction = (QtxListAction*)action( SplitLandCoverId );
470 if ( anAction ) anAction->setEnabled( anEnableTools );
471 anAction = (QtxListAction*)action( MergeLandCoverId );
472 if ( anAction ) anAction->setEnabled( anEnableTools );
473 anAction = (QtxListAction*)action( ChangeLandCoverTypeId );
474 if ( anAction ) anAction->setEnabled( anEnableTools );
477 void HYDROGUI_Module::resetViewState()
479 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>(getApp()->viewManager( OCCViewer_Viewer::Type()));
482 foreach( SUIT_ViewWindow* wnd, mgr->getViews() )
484 OCCViewer_ViewFrame* vf = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
487 for( int i=OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++ )
489 OCCViewer_ViewWindow* iwnd = vf->getView(i);
496 OCCViewer_ViewWindow* ownd = dynamic_cast<OCCViewer_ViewWindow*>( wnd );
504 void HYDROGUI_Module::onOperation()
506 const QAction* anAction = dynamic_cast<const QAction*>( sender() );
507 int anId = actionId( anAction );
511 startOperation( anId );
514 if( anId==ShowHideArrows )
516 setArrowsVisible( !arrowsVisible() );
520 bool HYDROGUI_Module::arrowsVisible() const
523 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
526 resMgr->value( "polyline", "arrow_type", aType );
533 void HYDROGUI_Module::setArrowsVisible( bool isVisible )
535 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
543 if( resMgr->hasValue( "polyline", "prev_arrow_type" ) )
544 resMgr->value( "polyline", "prev_arrow_type", aType );
548 resMgr->setValue( "polyline", "arrow_type", aType );
552 resMgr->value( "polyline", "arrow_type", aType );
553 resMgr->setValue( "polyline", "prev_arrow_type", aType );
554 resMgr->setValue( "polyline", "arrow_type", 0 );
556 preferencesChanged( "polyline", "arrow_type" );
559 void HYDROGUI_Module::onDelete()
561 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
562 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
563 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
564 aPolylineOp->deleteSelected();
566 startOperation( DeleteId );
569 bool HYDROGUI_Module::onUndo( int theNumActions )
571 QApplication::setOverrideCursor( Qt::WaitCursor );
573 HYDROGUI_DataModel* aModel = getDataModel();
576 while( theNumActions > 0 )
578 if( !aModel->undo() )
587 QApplication::restoreOverrideCursor();
591 bool HYDROGUI_Module::onRedo( int theNumActions )
593 QApplication::setOverrideCursor( Qt::WaitCursor );
595 HYDROGUI_DataModel* aModel = getDataModel();
598 while( theNumActions > 0 )
600 if( !aModel->redo() )
609 QApplication::restoreOverrideCursor();
613 LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
615 LightApp_Operation* anOp = 0;
616 HYDROGUI_Module* aModule = const_cast<HYDROGUI_Module*>( this );
619 case SaveVisualStateId:
620 case LoadVisualStateId:
621 anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
625 anOp = new HYDROGUI_CopyPasteOp( aModule, theId == PasteId );
628 case EditImportedImageId:
629 anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImportedImageId );
631 case ImportPolylineId:
632 anOp = new HYDROGUI_ImportPolylineOp( aModule/*, theId == EditImportedPolylineId*/ );
635 anOp = new HYDROGUI_ImportSinusXOp( aModule );
638 anOp = new HYDROGUI_ExportSinusXOp( aModule );
640 case ImportBCPolygonId:
641 anOp = new HYDROGUI_ImportBCPolygonOp( aModule );
643 case MeasurementToolId:
644 anOp = new HYDROGUI_MeasurementToolOp( aModule );
647 anOp = new HYDROGUI_ObserveImageOp( aModule );
650 anOp = new HYDROGUI_ExportImageOp( aModule );
653 case ForcedUpdateObjectId:
654 anOp = new HYDROGUI_UpdateObjectOp( aModule, theId == ForcedUpdateObjectId );
656 case ExportToShapeFileID:
657 anOp = new HYDROGUI_ExportFileOp( aModule );
659 case ImportLandCoverMapId:
660 anOp = new HYDROGUI_ImportLandCoverMapOp( aModule );
662 case RemoveImageRefsId:
663 anOp = new HYDROGUI_RemoveImageRefsOp( aModule );
665 case CreatePolyline3DId:
666 case EditPolyline3DId:
667 anOp = new HYDROGUI_Poly3DOp( aModule, theId == EditPolyline3DId );
669 case CreatePolylineId:
671 anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
673 case CreateProfileId:
675 anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId );
677 case ProfileInterpolateId:
678 anOp = new HYDROGUI_ProfileInterpolateOp( aModule );
680 case ImportProfilesId:
681 anOp = new HYDROGUI_ImportProfilesOp( aModule ) ;
683 case AllGeoreferencementId:
684 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::All ) ;
686 case SelectedGeoreferencementId:
687 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::Selected ) ;
689 case ImportBathymetryId:
690 case EditImportedBathymetryId:
691 anOp = new HYDROGUI_ImportBathymetryOp( aModule, theId == EditImportedBathymetryId );
693 case BathymetryBoundsId:
694 anOp = new HYDROGUI_BathymetryBoundsOp( aModule );
696 case BathymetrySelectionId:
697 anOp = new HYDROGUI_BathymetrySelectionOp( aModule );
699 case BathymetryTextId:
700 case BathymetryRescaleSelectionId:
701 case BathymetryRescaleVisibleId:
702 case BathymetryRescaleUserId:
703 case BathymetryRescaleDefaultId:
704 anOp = new HYDROGUI_BathymetryOp( aModule, theId );
707 case CreateImmersibleZoneId:
708 case EditImmersibleZoneId:
709 anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
713 anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId );
715 case CreateChannelId:
717 anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId );
721 anOp = new HYDROGUI_DigueOp( aModule, theId == EditDigueId );
723 case ImportStricklerTableFromFileId:
724 case ExportStricklerTableFromFileId:
725 case EditStricklerTableId:
726 anOp = new HYDROGUI_StricklerTableOp( aModule, theId );
728 case CreateLandCoverMapId:
730 case RemoveLandCoverId:
731 case SplitLandCoverId:
732 case MergeLandCoverId:
733 case ChangeLandCoverTypeId:
734 anOp = new HYDROGUI_LandCoverMapOp( aModule, theId );
736 case DuplicateStricklerTableId:
737 anOp = new HYDROGUI_DuplicateOp( aModule );
739 case CreateCalculationId:
740 case EditCalculationId:
741 anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId, false );
744 case CompleteCalculationId:
745 anOp = new HYDROGUI_CalculationOp( aModule, true, true);
748 case ExportCalculationId:
749 anOp = new HYDROGUI_ExportCalculationOp( aModule );
752 case EditFusedImageId:
753 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId );
757 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut, theId == EditCutImageId );
760 case EditSplitImageId:
761 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Split, theId == EditSplitImageId );
763 case ImportObstacleFromFileId:
764 anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
766 case ImportGeomObjectAsObstacleId:
767 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsObstacle );
769 case ImportGeomObjectAsPolylineId:
770 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsPolyline );
773 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
774 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpBox );
776 case CreateCylinderId:
777 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
778 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpCylinder );
780 case TranslateObstacleId:
781 anOp = new HYDROGUI_TranslateObstacleOp( aModule );
783 case CopyViewerPositionId:
784 anOp = new HYDROGUI_CopyPastePositionOp( aModule, false );
787 anOp = new HYDROGUI_DeleteOp( aModule );
790 anOp = new HYDROGUI_SetColorOp( aModule );
792 case SetTransparencyId:
793 anOp = new HYDROGUI_SetTransparencyOp( aModule );
796 anOp = new HYDROGUI_ZLevelsOp( aModule );
799 anOp = new HYDROGUI_LocalCSOp( aModule );
802 case RiverBottomContextId:
803 anOp = new HYDROGUI_RiverBottomOp( aModule );
805 case RecognizeContoursId:
806 anOp = new HYDROGUI_RecognizeContoursOp( aModule );
813 anOp = new HYDROGUI_ShowHideOp( aModule, theId );
816 anOp = new HYDROGUI_SubmersibleOp( aModule, true );
818 case UnSubmersibleId:
819 anOp = new HYDROGUI_SubmersibleOp( aModule, false );
821 case PolylineExtractionId:
822 anOp = new HYDROGUI_PolylineExtractionOp( aModule );
824 case SplitPolylinesId:
825 anOp = new HYDROGUI_SplitPolylinesOp( aModule );
827 case MergePolylinesId:
828 anOp = new HYDROGUI_MergePolylinesOp( aModule );
830 case ShowAttrPolylinesId:
831 anOp = new HYDROGUI_ShowAttrPolyOp( aModule );
833 case SetBoundaryTypePolygonId:
834 anOp = new HYDROGUI_SetBoundaryTypePolygonOp( aModule );
836 case LandCoverScalarMapModeOnId:
837 case LandCoverScalarMapModeOffId:
838 anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
840 case RegenerateRegionColorsId:
841 anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule );
844 anOp = new HYDROGUI_ZoneSetColorOp( aModule );
849 anOp = LightApp_Module::createOperation( theId );
854 bool HYDROGUI_Module::reusableOperation( const int id )
856 if ( id == ImportGeomObjectAsObstacleId ||
857 id == ImportGeomObjectAsPolylineId ) {
861 return LightApp_Module::reusableOperation( id );
865 * Returns true if the object with the given entry can be renamed.
866 * @param theEntry the object entry
868 bool HYDROGUI_Module::renameAllowed( const QString& theEntry ) const
870 // Allow to rename all HYDRO objects
871 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
872 return !anEntity.IsNull();
875 * Returns true if the object with the given entry is renamed.
876 * @param theEntry the object entry
877 * @param theName the new name
879 bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theName )
881 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
883 if ( !anEntity.IsNull() )
885 HYDROGUI_DataModel* aModel = getDataModel();
888 if( anEntity->GetName() != theName )
890 // check that there are no other objects with the same name in the document
891 Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( this, theName );
892 if ( anObject.IsNull() )
894 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
895 if ( anOp && anOp->inherits( "HYDROGUI_CalculationOp" ) )
897 anEntity->SetName( theName );
902 aRes = aModel->rename( anEntity, theName );
907 // Inform the user that the name is already used
908 QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
909 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
910 SUIT_MessageBox::critical( getApp()->desktop(), aTitle, aMessage );
918 void HYDROGUI_Module::onBathymetrySelection()
920 QAction* a = qobject_cast<QAction*>( sender() );
924 bool isChecked = a->isChecked();
926 startOperation( BathymetrySelectionId );
929 LightApp_Operation* op = operation( BathymetryTextId );
933 op = operation( BathymetrySelectionId );
939 void HYDROGUI_Module::onBathymetryText()
941 QAction* a = qobject_cast<QAction*>( sender() );
945 bool isChecked = a->isChecked();
947 startOperation( BathymetryTextId );
950 HYDROGUI_BathymetryOp* op = dynamic_cast<HYDROGUI_BathymetryOp*>( operation( BathymetryTextId ) );