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>
112 #include "HYDRO_trace.hxx"
114 QAction* HYDROGUI_Module::createAction( const int theId, const QString& theSuffix, const QString& theImg,
115 const int theKey, const bool isToggle, const QString& theSlot )
117 QString aSlot = theSlot;
118 if( aSlot.isEmpty() )
119 aSlot = SLOT( onOperation() );
120 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
121 std::string anImg = theImg.toStdString();
122 QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aResMgr->loadPixmap( "HYDRO", tr( anImg.c_str() ) );
123 std::string aMenu = ( "MEN_" + theSuffix ).toStdString();
124 std::string aDesktop = ( "DSK_" + theSuffix ).toStdString();
125 std::string aToolbar = ( "STB_" + theSuffix ).toStdString();
126 std::string aSlotStr = aSlot.toStdString();
127 return LightApp_Module::createAction( theId, tr( aDesktop.c_str() ), aPixmap,
128 tr( aMenu.c_str() ), tr( aToolbar.c_str() ),
129 theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() );
132 void HYDROGUI_Module::createActions()
134 createAction( SaveVisualStateId, "SAVE_VISUAL_STATE" );
135 createAction( LoadVisualStateId, "LOAD_VISUAL_STATE" );
137 createAction( CopyId, "COPY", "", Qt::CTRL + Qt::Key_C );
138 createAction( PasteId, "PASTE", "", Qt::CTRL + Qt::Key_V );
140 createAction( UpdateObjectId, "UPDATE_OBJECT" );
141 createAction( ForcedUpdateObjectId, "FORCED_UPDATE_OBJECT" );
143 createAction( ImportImageId, "IMPORT_IMAGE", "IMPORT_IMAGE_ICO", Qt::CTRL + Qt::Key_I );
144 createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE", "EDIT_IMPORTED_IMAGE_ICO" );
145 createAction( ObserveImageId, "OBSERVE_IMAGE", "OBSERVE_IMAGE_ICO" );
146 createAction( ExportImageId, "EXPORT_IMAGE", "EXPORT_IMAGE_ICO" );
147 createAction( RemoveImageRefsId, "REMOVE_IMAGE_REFERENCE", "REMOVE_IMAGE_REFERENCE_ICO" );
149 createAction( ImportPolylineId, "IMPORT_POLYLINE", "IMPORT_POLYLINE_ICO" );
150 createAction( ImportSinusXId, "IMPORT_SINUSX", "IMPORT_SINUSX_ICO" );
151 createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" );
152 createAction( ImportLandCoverMapId, "IMPORT_LANDCOVER_MAP", "IMPORT_LANDCOVER_MAP_ICO" );
154 createAction( MeasurementToolId, "MEASUREMENT_TOOL", "MEASUREMENT_TOOL_ICO" );
156 createAction( ImportBCPolygonId, "IMPORT_BC_POLYGON", "IMPORT_BC_POLYGON_ICO" );
158 createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" );
159 createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" );
161 createAction( CreatePolyline3DId, "CREATE_POLYLINE_3D", "CREATE_POLYLINE_3D_ICO" );
162 createAction( EditPolyline3DId, "EDIT_POLYLINE_3D", "EDIT_POLYLINE_3D_ICO" );
164 createAction( CreateProfileId, "CREATE_PROFILE", "CREATE_PROFILE_ICO" );
165 createAction( ImportProfilesId, "IMPORT_PROFILES", "IMPORT_PROFILES_ICO" );
166 createAction( EditProfileId, "EDIT_PROFILE", "EDIT_PROFILE_ICO" );
167 createAction( AllGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" );
168 createAction( SelectedGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" );
170 createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "IMPORT_BATHYMETRY_ICO", Qt::CTRL + Qt::Key_B );
171 createAction( EditImportedBathymetryId, "EDIT_IMPORTED_BATHYMETRY", "EDIT_IMPORTED_BATHYMETRY_ICO" );
172 createAction( BathymetryBoundsId, "BATHYMETRY_BOUNDS", "BATHYMETRY_BOUNDS_ICO" );
173 createAction( BathymetrySelectionId, "BATHYMETRY_SELECTION", "BATHYMETRY_SELECTION_ICO",
174 0, true, SLOT( onBathymetrySelection() ) );
176 createAction( BathymetryTextId, "BATHYMETRY_TEXT", "BATHYMETRY_TEXT_ICO",
177 0, true, SLOT( onBathymetryText() ) );
179 createAction( BathymetryRescaleSelectionId, "BATHYMETRY_RESCALE_SELECTION", "BATHYMETRY_RESCALE_SELECTION_ICO" );
180 createAction( BathymetryRescaleVisibleId, "BATHYMETRY_RESCALE_VISIBLE", "BATHYMETRY_RESCALE_VISIBLE_ICO" );
181 createAction( BathymetryRescaleUserId, "BATHYMETRY_RESCALE_USER", "BATHYMETRY_RESCALE_USER_ICO" );
182 createAction( BathymetryRescaleDefaultId, "BATHYMETRY_RESCALE_DEFAULT", "BATHYMETRY_RESCALE_DEFAULT_ICO" );
184 createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE", "CREATE_IMMERSIBLE_ZONE_ICO" );
185 createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE", "EDIT_IMMERSIBLE_ZONE_ICO" );
187 createAction( CreateStreamId, "CREATE_STREAM", "CREATE_STREAM_ICO" );
188 createAction( EditStreamId, "EDIT_STREAM", "EDIT_STREAM_ICO" );
190 createAction( CreateChannelId, "CREATE_CHANNEL", "CREATE_CHANNEL_ICO" );
191 createAction( EditChannelId, "EDIT_CHANNEL", "EDIT_CHANNEL_ICO" );
193 createAction( CreateDigueId, "CREATE_DIGUE", "CREATE_DIGUE_ICO" );
194 createAction( EditDigueId, "EDIT_DIGUE", "EDIT_DIGUE_ICO" );
196 createAction( ImportStricklerTableFromFileId, "IMPORT_STRICKLER_TABLE", "IMPORT_STRICKLER_TABLE_ICO" );
197 createAction( ExportStricklerTableFromFileId, "EXPORT_STRICKLER_TABLE", "EXPORT_STRICKLER_TABLE_ICO" );
198 createAction( EditStricklerTableId, "EDIT_STRICKLER_TABLE", "EDIT_STRICKLER_TABLE_ICO" );
199 createAction( DuplicateStricklerTableId, "DUPLICATE_STRICKLER_TABLE", "DUPLICATE_STRICKLER_TABLE_ICO" );
201 createAction( CreateLandCoverMapId, "CREATE_LAND_COVER_MAP", "CREATE_LAND_COVER_MAP_ICO" );
203 createAction( AddLandCoverId, "ADD_LAND_COVER", "ADD_LAND_COVER_ICO" );
204 createAction( RemoveLandCoverId, "REMOVE_LAND_COVER", "REMOVE_LAND_COVER_ICO" );
205 createAction( SplitLandCoverId, "SPLIT_LAND_COVER", "SPLIT_LAND_COVER_ICO" );
206 createAction( MergeLandCoverId, "MERGE_LAND_COVER", "MERGE_LAND_COVER_ICO" );
207 createAction( ChangeLandCoverTypeId, "CHANGE_LAND_COVER_TYPE", "CHANGE_LAND_COVER_TYPE_ICO" );
209 createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" );
210 createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" );
211 createAction( ImportGeomObjectAsPolylineId, "IMPORT_GEOM_OBJECT_AS_POLYLINE", "IMPORT_GEOM_OBJECT_ICO" );
212 createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" );
213 createAction( CreateCylinderId, "CREATE_CYLINDER", "CREATE_CYLINDER_ICO" );
214 createAction( TranslateObstacleId, "TRANSLATE_OBSTACLE" );
216 createAction( CreateCalculationId, "CREATE_CALCULATION", "CREATE_CALCULATION_ICO" );
217 createAction( EditCalculationId, "EDIT_CALCULATION", "EDIT_CALCULATION_ICO" );
218 createAction( ExportCalculationId, "EXPORT_CALCULATION", "EXPORT_CALCULATION_ICO" );
220 createAction( CompleteCalculationId, "COMPLETE_CALCULATION", "COMPLETE_CALCULATION_ICO" );
222 createAction( FuseImagesId, "FUSE_IMAGES", "FUSE_IMAGES_ICO" );
223 createAction( EditFusedImageId, "EDIT_FUSED_IMAGE", "EDIT_FUSED_IMAGE_ICO" );
225 createAction( CutImagesId, "CUT_IMAGES", "CUT_IMAGES_ICO" );
226 createAction( EditCutImageId, "EDIT_CUT_IMAGE", "EDIT_CUT_IMAGE_ICO" );
228 createAction( SplitImageId, "SPLIT_IMAGE", "SPLIT_IMAGE_ICO" );
229 createAction( EditSplitImageId, "EDIT_SPLIT_IMAGE", "EDIT_SPLIT_IMAGE_ICO" );
231 createAction( RecognizeContoursId, "RECOGNIZE_CONTOURS", "RECOGNIZE_CONTOURS_ICO" );
233 createAction( CopyViewerPositionId, "COPY_VIEWER_POSITION", "" );
235 createAction( DeleteId, "DELETE", "", Qt::Key_Delete, false,
236 SLOT( onDelete() ) );
238 createAction( SetColorId, "COLOR" );
239 createAction( SetTransparencyId, "TRANSPARENCY" );
240 createAction( SetZLevelId, "ZLEVEL" );
241 createAction( EditLocalCSId, "EDIT_LOCAL_CS" );
243 createAction( ShowId, "SHOW" );
244 createAction( ShowOnlyId, "SHOW_ONLY" );
245 createAction( ShowAllId, "SHOW_ALL" );
246 createAction( HideId, "HIDE" );
247 createAction( HideAllId, "HIDE_ALL" );
249 createAction( RiverBottomId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
250 createAction( RiverBottomContextId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
251 createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" );
253 createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
254 createAction( UnSubmersibleId, "UNSUBMERSIBLE", "HYDRO_UNSUBMERSIBLE16_ICO" );
255 createAction( ExportToShapeFileID, "EXPORT_TO_SHAPE_FILE", "EXPORT_TO_SHAPE_FILE_ICO" );
257 createAction( PolylineExtractionId, "POLYLINE_EXTRACTION" );
258 createAction( SplitPolylinesId, "SPLIT_POLYLINES", "SPLIT_POLYLINES_ICO" );
259 createAction( MergePolylinesId, "MERGE_POLYLINES", "MERGE_POLYLINES_ICO" );
261 createAction( ShowAttrPolylinesId, "SHOWATTR_POLYLINES");
263 createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
264 createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
266 createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" );
267 createAction( ZoneSetColorId, "ZONE_SET_COLOR" );
268 createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" );
269 createAction( SetBoundaryTypePolygonId, "SET_BOUNDARY_TYPE_POLYGON" );
272 void HYDROGUI_Module::createMenus()
274 int aFileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 );
275 int aCustomPos = 5; // to insert custom actions after "Save as" and before "Preferences"
276 createMenu( SaveVisualStateId, aFileMenu, aCustomPos );
277 createMenu( separator(), aFileMenu, -1, aCustomPos );
279 int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
280 createMenu( UndoId, anEditMenu );
281 createMenu( RedoId, anEditMenu );
282 createMenu( separator(), anEditMenu );
283 createMenu( CopyId, anEditMenu );
284 createMenu( PasteId, anEditMenu );
286 int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
287 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
288 createMenu( ImportSinusXId, aHydroId, -1, -1 );
289 createMenu( ExportSinusXId, aHydroId, -1, -1 );
291 createMenu( ImportBathymetryId, aHydroId, -1, -1 );
292 createMenu( ImportStricklerTableFromFileId, aHydroId, -1, -1 );
293 createMenu( ImportBCPolygonId, aHydroId, -1, -1 );
294 createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
295 createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
296 createMenu( CreateChannelId, aHydroId, -1, -1 );
297 createMenu( CreateDigueId, aHydroId, -1, -1 );
299 createMenu( MeasurementToolId, aHydroId, -1, -1 );
301 int aNewImageId = createMenu( tr( "MEN_DESK_IMAGE" ), aHydroId, -1 );
302 createMenu( ImportImageId, aNewImageId, -1, -1 );
303 createMenu( separator(), aNewImageId );
304 createMenu( FuseImagesId, aNewImageId, -1, -1 );
305 createMenu( CutImagesId, aNewImageId, -1, -1 );
306 createMenu( SplitImageId, aNewImageId, -1, -1 );
308 int aNewPolylineId = createMenu( tr( "MEN_DESK_POLYLINE" ), aHydroId, -1 );
309 createMenu( ImportPolylineId, aNewPolylineId, -1, -1 );
310 createMenu( CreatePolylineId, aNewPolylineId, -1, -1 );
311 createMenu( separator(), aNewPolylineId );
312 createMenu( SplitPolylinesId, aNewPolylineId, -1, -1 );
313 createMenu( MergePolylinesId, aNewPolylineId, -1, -1 );
315 int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
316 createMenu( CreateProfileId, aNewProfileId, -1, -1 );
317 createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
318 createMenu( separator(), aNewProfileId );
319 createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
321 int aStreamMenuId = createMenu( tr( "MEN_DESK_STREAM" ), aHydroId, -1 );
322 createMenu( CreateStreamId, aStreamMenuId, -1, -1 );
323 createMenu( separator(), aStreamMenuId );
324 createMenu( RiverBottomId, aStreamMenuId, -1, -1 );
325 createMenu( ProfileInterpolateId, aStreamMenuId, -1, -1 );
327 int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 );
328 createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 );
329 createMenu( separator(), anObstacleMenuId );
330 createMenu( CreateBoxId, anObstacleMenuId, -1, -1 );
331 createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 );
333 int aLandCoverMapMenuId = createMenu( tr( "MEN_DESK_LAND_COVER_MAP" ), aHydroId, -1 );
334 createMenu( ImportLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
335 createMenu( CreateLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
336 createMenu( separator(), aLandCoverMapMenuId );
337 createMenu( AddLandCoverId, aLandCoverMapMenuId, -1, -1 );
338 createMenu( RemoveLandCoverId, aLandCoverMapMenuId, -1, -1 );
339 createMenu( separator(), aLandCoverMapMenuId );
340 createMenu( SplitLandCoverId, aLandCoverMapMenuId, -1, -1 );
341 createMenu( MergeLandCoverId, aLandCoverMapMenuId, -1, -1 );
342 createMenu( ChangeLandCoverTypeId, aLandCoverMapMenuId, -1, -1 );
344 createMenu( CreateCalculationId, aHydroId, -1, -1 );
345 createMenu( separator(), aHydroId );
346 createMenu( EditLocalCSId, aHydroId, -1, -1 );
347 createMenu( separator(), aHydroId );
350 void HYDROGUI_Module::createPopups()
354 void HYDROGUI_Module::createToolbars()
356 int aToolBar = createTool( tr( "MEN_DESK_HYDRO" ) );
357 createTool( UndoId, aToolBar );
358 createTool( RedoId, aToolBar );
360 createTool( separator(), aToolBar );
361 createTool( ImportImageId, aToolBar );
362 createTool( ImportPolylineId, aToolBar );
363 createTool( ImportSinusXId, aToolBar );
364 createTool( ExportSinusXId, aToolBar );
365 createTool( ImportLandCoverMapId, aToolBar );
367 createTool( ImportBCPolygonId, aToolBar );
368 createTool( MeasurementToolId, aToolBar );
370 createTool( ImportBathymetryId, aToolBar );
371 createTool( CreatePolylineId, aToolBar );
372 createTool( CreatePolyline3DId, aToolBar );
374 createTool( separator(), aToolBar );
375 createTool( CreateProfileId, aToolBar );
376 createTool( ImportProfilesId, aToolBar );
377 createTool( AllGeoreferencementId, aToolBar );
379 createTool( separator(), aToolBar );
380 createTool( CreateChannelId, aToolBar );
381 createTool( CreateDigueId, aToolBar );
383 createTool( separator(), aToolBar );
384 createTool( CreateImmersibleZoneId, aToolBar );
385 createTool( CreateStreamId, aToolBar );
387 createTool( separator(), aToolBar );
388 createTool( ImportObstacleFromFileId, aToolBar );
389 createTool( CreateBoxId, aToolBar );
390 createTool( CreateCylinderId, aToolBar );
392 createTool( separator(), aToolBar );
393 createTool( ImportStricklerTableFromFileId, aToolBar );
395 createTool( separator(), aToolBar );
396 createTool( CreateLandCoverMapId, aToolBar );
397 createTool( AddLandCoverId, aToolBar );
398 createTool( RemoveLandCoverId, aToolBar );
399 createTool( SplitLandCoverId, aToolBar );
400 createTool( MergeLandCoverId, aToolBar );
401 createTool( ChangeLandCoverTypeId, aToolBar );
404 createTool( separator(), aToolBar );
405 createTool( CreateCalculationId, aToolBar );
407 createTool( separator(), aToolBar );
408 createTool( FuseImagesId, aToolBar );
409 createTool( CutImagesId, aToolBar );
410 createTool( SplitImageId, aToolBar );
412 createTool( separator(), aToolBar );
413 createTool( BathymetrySelectionId, aToolBar );
414 createTool( BathymetryTextId, aToolBar );
415 createTool( BathymetryRescaleSelectionId, aToolBar );
416 createTool( BathymetryRescaleVisibleId, aToolBar );
417 createTool( BathymetryRescaleUserId, aToolBar );
418 createTool( BathymetryRescaleDefaultId, aToolBar );
421 void HYDROGUI_Module::createUndoRedoActions()
423 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
425 QtxListAction* anEditUndo = new QtxListAction( tr( "MEN_UNDO" ),
426 aResMgr->loadPixmap( "HYDRO", tr( "UNDO_ICO" ) ), tr( "DSK_UNDO" ),
427 Qt::CTRL + Qt::Key_Z, application()->desktop() );
429 QtxListAction* anEditRedo = new QtxListAction( tr( "MEN_REDO" ),
430 aResMgr->loadPixmap( "HYDRO", tr( "REDO_ICO" ) ), tr( "DSK_REDO" ),
431 Qt::CTRL + Qt::Key_Y, application()->desktop() );
433 registerAction( UndoId, anEditUndo );
434 registerAction( RedoId, anEditRedo );
436 anEditUndo->setComment( tr( "STB_UNDO" ) );
437 anEditRedo->setComment( tr( "STB_REDO" ) );
439 connect( anEditUndo, SIGNAL( triggered( int ) ), this, SLOT( onUndo( int ) ) );
440 connect( anEditRedo, SIGNAL( triggered( int ) ), this, SLOT( onRedo( int ) ) );
443 void HYDROGUI_Module::updateUndoRedoControls()
445 HYDROGUI_DataModel* aModel = getDataModel();
447 QtxListAction* aUndoAction = (QtxListAction*)action( UndoId );
448 QtxListAction* aRedoAction = (QtxListAction*)action( RedoId );
450 bool aCanUndo = aModel->canUndo();
451 bool aCanRedo = aModel->canRedo();
454 aUndoAction->addNames( aModel->undoNames() );
455 aUndoAction->setEnabled( aCanUndo );
458 aRedoAction->addNames( aModel->redoNames() );
459 aRedoAction->setEnabled( aCanRedo );
462 void HYDROGUI_Module::enableLCMActions()
464 HYDROData_Iterator anIt( HYDROData_Document::Document(), KIND_LAND_COVER_MAP );
465 bool anEnableTools = anIt.More();
467 QtxListAction* anAction;
468 anAction = (QtxListAction*)action( AddLandCoverId );
469 if ( anAction ) anAction->setEnabled( anEnableTools );
470 anAction = (QtxListAction*)action( RemoveLandCoverId );
471 if ( anAction ) anAction->setEnabled( anEnableTools );
472 anAction = (QtxListAction*)action( SplitLandCoverId );
473 if ( anAction ) anAction->setEnabled( anEnableTools );
474 anAction = (QtxListAction*)action( MergeLandCoverId );
475 if ( anAction ) anAction->setEnabled( anEnableTools );
476 anAction = (QtxListAction*)action( ChangeLandCoverTypeId );
477 if ( anAction ) anAction->setEnabled( anEnableTools );
480 void HYDROGUI_Module::resetViewState()
482 DEBTRACE("HYDROGUI_Module::resetViewState");
483 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>(getApp()->viewManager( OCCViewer_Viewer::Type()));
486 foreach( SUIT_ViewWindow* wnd, mgr->getViews() )
488 OCCViewer_ViewFrame* vf = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
491 for( int i=OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++ )
493 OCCViewer_ViewWindow* iwnd = vf->getView(i);
500 OCCViewer_ViewWindow* ownd = dynamic_cast<OCCViewer_ViewWindow*>( wnd );
508 void HYDROGUI_Module::onOperation()
510 DEBTRACE("HYDROGUI_Module::onOperation");
511 const QAction* anAction = dynamic_cast<const QAction*>( sender() );
512 int anId = actionId( anAction );
515 // --- bathymetry from stream interpolation must be hidden before edition to avoid aborts after on hide show
516 if (anId == EditStreamId)
517 HYDROGUI_StreamOp::hideBathy(this);
519 startOperation( anId );
522 if( anId==ShowHideArrows )
524 setArrowsVisible( !arrowsVisible() );
528 bool HYDROGUI_Module::arrowsVisible() const
531 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
534 resMgr->value( "polyline", "arrow_type", aType );
541 void HYDROGUI_Module::setArrowsVisible( bool isVisible )
543 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
551 if( resMgr->hasValue( "polyline", "prev_arrow_type" ) )
552 resMgr->value( "polyline", "prev_arrow_type", aType );
556 resMgr->setValue( "polyline", "arrow_type", aType );
560 resMgr->value( "polyline", "arrow_type", aType );
561 resMgr->setValue( "polyline", "prev_arrow_type", aType );
562 resMgr->setValue( "polyline", "arrow_type", 0 );
564 preferencesChanged( "polyline", "arrow_type" );
567 void HYDROGUI_Module::onDelete()
569 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
570 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
571 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
572 aPolylineOp->deleteSelected();
574 startOperation( DeleteId );
577 bool HYDROGUI_Module::onUndo( int theNumActions )
579 QApplication::setOverrideCursor( Qt::WaitCursor );
581 HYDROGUI_DataModel* aModel = getDataModel();
584 while( theNumActions > 0 )
586 if( !aModel->undo() )
595 QApplication::restoreOverrideCursor();
599 bool HYDROGUI_Module::onRedo( int theNumActions )
601 QApplication::setOverrideCursor( Qt::WaitCursor );
603 HYDROGUI_DataModel* aModel = getDataModel();
606 while( theNumActions > 0 )
608 if( !aModel->redo() )
617 QApplication::restoreOverrideCursor();
621 LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
623 DEBTRACE("HYDROGUI_Module::createOperation "<< theId);
624 LightApp_Operation* anOp = 0;
625 HYDROGUI_Module* aModule = const_cast<HYDROGUI_Module*>( this );
628 case SaveVisualStateId:
629 case LoadVisualStateId:
630 anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
634 anOp = new HYDROGUI_CopyPasteOp( aModule, theId == PasteId );
637 case EditImportedImageId:
638 anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImportedImageId );
640 case ImportPolylineId:
641 anOp = new HYDROGUI_ImportPolylineOp( aModule/*, theId == EditImportedPolylineId*/ );
644 anOp = new HYDROGUI_ImportSinusXOp( aModule );
647 anOp = new HYDROGUI_ExportSinusXOp( aModule );
649 case ImportBCPolygonId:
650 anOp = new HYDROGUI_ImportBCPolygonOp( aModule );
652 case MeasurementToolId:
653 anOp = new HYDROGUI_MeasurementToolOp( aModule );
656 anOp = new HYDROGUI_ObserveImageOp( aModule );
659 anOp = new HYDROGUI_ExportImageOp( aModule );
662 case ForcedUpdateObjectId:
663 anOp = new HYDROGUI_UpdateObjectOp( aModule, theId == ForcedUpdateObjectId );
665 case ExportToShapeFileID:
666 anOp = new HYDROGUI_ExportFileOp( aModule );
668 case ImportLandCoverMapId:
669 anOp = new HYDROGUI_ImportLandCoverMapOp( aModule );
671 case RemoveImageRefsId:
672 anOp = new HYDROGUI_RemoveImageRefsOp( aModule );
674 case CreatePolyline3DId:
675 case EditPolyline3DId:
676 anOp = new HYDROGUI_Poly3DOp( aModule, theId == EditPolyline3DId );
678 case CreatePolylineId:
680 anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
682 case CreateProfileId:
684 anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId );
686 case ProfileInterpolateId:
687 anOp = new HYDROGUI_ProfileInterpolateOp( aModule );
689 case ImportProfilesId:
690 anOp = new HYDROGUI_ImportProfilesOp( aModule ) ;
692 case AllGeoreferencementId:
693 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::All ) ;
695 case SelectedGeoreferencementId:
696 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::Selected ) ;
698 case ImportBathymetryId:
699 case EditImportedBathymetryId:
700 anOp = new HYDROGUI_ImportBathymetryOp( aModule, theId == EditImportedBathymetryId );
702 case BathymetryBoundsId:
703 anOp = new HYDROGUI_BathymetryBoundsOp( aModule );
705 case BathymetrySelectionId:
706 anOp = new HYDROGUI_BathymetrySelectionOp( aModule );
708 case BathymetryTextId:
709 case BathymetryRescaleSelectionId:
710 case BathymetryRescaleVisibleId:
711 case BathymetryRescaleUserId:
712 case BathymetryRescaleDefaultId:
713 anOp = new HYDROGUI_BathymetryOp( aModule, theId );
716 case CreateImmersibleZoneId:
717 case EditImmersibleZoneId:
718 anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
722 anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId );
724 case CreateChannelId:
726 anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId );
730 anOp = new HYDROGUI_DigueOp( aModule, theId == EditDigueId );
732 case ImportStricklerTableFromFileId:
733 case ExportStricklerTableFromFileId:
734 case EditStricklerTableId:
735 anOp = new HYDROGUI_StricklerTableOp( aModule, theId );
737 case CreateLandCoverMapId:
739 case RemoveLandCoverId:
740 case SplitLandCoverId:
741 case MergeLandCoverId:
742 case ChangeLandCoverTypeId:
743 anOp = new HYDROGUI_LandCoverMapOp( aModule, theId );
745 case DuplicateStricklerTableId:
746 anOp = new HYDROGUI_DuplicateOp( aModule );
748 case CreateCalculationId:
749 case EditCalculationId:
750 anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId, false );
753 case CompleteCalculationId:
754 anOp = new HYDROGUI_CalculationOp( aModule, true, true);
757 case ExportCalculationId:
758 anOp = new HYDROGUI_ExportCalculationOp( aModule );
761 case EditFusedImageId:
762 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId );
766 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut, theId == EditCutImageId );
769 case EditSplitImageId:
770 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Split, theId == EditSplitImageId );
772 case ImportObstacleFromFileId:
773 anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
775 case ImportGeomObjectAsObstacleId:
776 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsObstacle );
778 case ImportGeomObjectAsPolylineId:
779 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsPolyline );
782 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
783 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpBox );
785 case CreateCylinderId:
786 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
787 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpCylinder );
789 case TranslateObstacleId:
790 anOp = new HYDROGUI_TranslateObstacleOp( aModule );
792 case CopyViewerPositionId:
793 anOp = new HYDROGUI_CopyPastePositionOp( aModule, false );
796 anOp = new HYDROGUI_DeleteOp( aModule );
799 anOp = new HYDROGUI_SetColorOp( aModule );
801 case SetTransparencyId:
802 anOp = new HYDROGUI_SetTransparencyOp( aModule );
805 anOp = new HYDROGUI_ZLevelsOp( aModule );
808 anOp = new HYDROGUI_LocalCSOp( aModule );
811 case RiverBottomContextId:
812 anOp = new HYDROGUI_RiverBottomOp( aModule );
814 case RecognizeContoursId:
815 anOp = new HYDROGUI_RecognizeContoursOp( aModule );
822 anOp = new HYDROGUI_ShowHideOp( aModule, theId );
825 anOp = new HYDROGUI_SubmersibleOp( aModule, true );
827 case UnSubmersibleId:
828 anOp = new HYDROGUI_SubmersibleOp( aModule, false );
830 case PolylineExtractionId:
831 anOp = new HYDROGUI_PolylineExtractionOp( aModule );
833 case SplitPolylinesId:
834 anOp = new HYDROGUI_SplitPolylinesOp( aModule );
836 case MergePolylinesId:
837 anOp = new HYDROGUI_MergePolylinesOp( aModule );
839 case ShowAttrPolylinesId:
840 anOp = new HYDROGUI_ShowAttrPolyOp( aModule );
842 case SetBoundaryTypePolygonId:
843 anOp = new HYDROGUI_SetBoundaryTypePolygonOp( aModule );
845 case LandCoverScalarMapModeOnId:
846 case LandCoverScalarMapModeOffId:
847 anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
849 case RegenerateRegionColorsId:
850 anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule );
853 anOp = new HYDROGUI_ZoneSetColorOp( aModule );
858 anOp = LightApp_Module::createOperation( theId );
863 bool HYDROGUI_Module::reusableOperation( const int id )
865 if ( id == ImportGeomObjectAsObstacleId ||
866 id == ImportGeomObjectAsPolylineId ) {
870 return LightApp_Module::reusableOperation( id );
874 * Returns true if the object with the given entry can be renamed.
875 * @param theEntry the object entry
877 bool HYDROGUI_Module::renameAllowed( const QString& theEntry ) const
879 // Allow to rename all HYDRO objects
880 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
881 return !anEntity.IsNull();
884 * Returns true if the object with the given entry is renamed.
885 * @param theEntry the object entry
886 * @param theName the new name
888 bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theName )
890 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
892 if ( !anEntity.IsNull() )
894 HYDROGUI_DataModel* aModel = getDataModel();
897 if( anEntity->GetName() != theName )
899 // check that there are no other objects with the same name in the document
900 Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( this, theName );
901 if ( anObject.IsNull() )
903 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
904 if ( anOp && anOp->inherits( "HYDROGUI_CalculationOp" ) )
906 anEntity->SetName( theName );
911 aRes = aModel->rename( anEntity, theName );
916 // Inform the user that the name is already used
917 QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
918 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
919 SUIT_MessageBox::critical( getApp()->desktop(), aTitle, aMessage );
927 void HYDROGUI_Module::onBathymetrySelection()
929 QAction* a = qobject_cast<QAction*>( sender() );
933 bool isChecked = a->isChecked();
935 startOperation( BathymetrySelectionId );
938 LightApp_Operation* op = operation( BathymetryTextId );
942 op = operation( BathymetrySelectionId );
948 void HYDROGUI_Module::onBathymetryText()
950 QAction* a = qobject_cast<QAction*>( sender() );
954 bool isChecked = a->isChecked();
956 startOperation( BathymetryTextId );
959 HYDROGUI_BathymetryOp* op = dynamic_cast<HYDROGUI_BathymetryOp*>( operation( BathymetryTextId ) );