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( FuseImagesId, "FUSE_IMAGES", "FUSE_IMAGES_ICO" );
218 createAction( EditFusedImageId, "EDIT_FUSED_IMAGE", "EDIT_FUSED_IMAGE_ICO" );
220 createAction( CutImagesId, "CUT_IMAGES", "CUT_IMAGES_ICO" );
221 createAction( EditCutImageId, "EDIT_CUT_IMAGE", "EDIT_CUT_IMAGE_ICO" );
223 createAction( SplitImageId, "SPLIT_IMAGE", "SPLIT_IMAGE_ICO" );
224 createAction( EditSplitImageId, "EDIT_SPLIT_IMAGE", "EDIT_SPLIT_IMAGE_ICO" );
226 createAction( RecognizeContoursId, "RECOGNIZE_CONTOURS", "RECOGNIZE_CONTOURS_ICO" );
228 createAction( CopyViewerPositionId, "COPY_VIEWER_POSITION", "" );
230 createAction( DeleteId, "DELETE", "", Qt::Key_Delete, false,
231 SLOT( onDelete() ) );
233 createAction( SetColorId, "COLOR" );
234 createAction( SetTransparencyId, "TRANSPARENCY" );
235 createAction( SetZLevelId, "ZLEVEL" );
236 createAction( EditLocalCSId, "EDIT_LOCAL_CS" );
238 createAction( ShowId, "SHOW" );
239 createAction( ShowOnlyId, "SHOW_ONLY" );
240 createAction( ShowAllId, "SHOW_ALL" );
241 createAction( HideId, "HIDE" );
242 createAction( HideAllId, "HIDE_ALL" );
244 createAction( RiverBottomId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
245 createAction( RiverBottomContextId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
246 createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" );
248 createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
249 createAction( UnSubmersibleId, "UNSUBMERSIBLE", "HYDRO_UNSUBMERSIBLE16_ICO" );
250 createAction( ExportToShapeFileID, "EXPORT_TO_SHAPE_FILE", "EXPORT_TO_SHAPE_FILE_ICO" );
252 createAction( PolylineExtractionId, "POLYLINE_EXTRACTION" );
253 createAction( SplitPolylinesId, "SPLIT_POLYLINES", "SPLIT_POLYLINES_ICO" );
254 createAction( MergePolylinesId, "MERGE_POLYLINES", "MERGE_POLYLINES_ICO" );
256 createAction( ShowAttrPolylinesId, "SHOWATTR_POLYLINES");
258 createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
259 createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
261 createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" );
262 createAction( ZoneSetColorId, "ZONE_SET_COLOR" );
263 createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" );
264 createAction( SetBoundaryTypePolygonId, "SET_BOUNDARY_TYPE_POLYGON" );
267 void HYDROGUI_Module::createMenus()
269 int aFileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 );
270 int aCustomPos = 5; // to insert custom actions after "Save as" and before "Preferences"
271 createMenu( SaveVisualStateId, aFileMenu, aCustomPos );
272 createMenu( separator(), aFileMenu, -1, aCustomPos );
274 int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
275 createMenu( UndoId, anEditMenu );
276 createMenu( RedoId, anEditMenu );
277 createMenu( separator(), anEditMenu );
278 createMenu( CopyId, anEditMenu );
279 createMenu( PasteId, anEditMenu );
281 int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
282 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
283 createMenu( ImportSinusXId, aHydroId, -1, -1 );
284 createMenu( ExportSinusXId, aHydroId, -1, -1 );
286 createMenu( ImportBathymetryId, aHydroId, -1, -1 );
287 createMenu( ImportStricklerTableFromFileId, aHydroId, -1, -1 );
288 createMenu( ImportBCPolygonId, aHydroId, -1, -1 );
289 createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
290 createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
291 createMenu( CreateChannelId, aHydroId, -1, -1 );
292 createMenu( CreateDigueId, aHydroId, -1, -1 );
294 createMenu( MeasurementToolId, aHydroId, -1, -1 );
296 int aNewImageId = createMenu( tr( "MEN_DESK_IMAGE" ), aHydroId, -1 );
297 createMenu( ImportImageId, aNewImageId, -1, -1 );
298 createMenu( separator(), aNewImageId );
299 createMenu( FuseImagesId, aNewImageId, -1, -1 );
300 createMenu( CutImagesId, aNewImageId, -1, -1 );
301 createMenu( SplitImageId, aNewImageId, -1, -1 );
303 int aNewPolylineId = createMenu( tr( "MEN_DESK_POLYLINE" ), aHydroId, -1 );
304 createMenu( ImportPolylineId, aNewPolylineId, -1, -1 );
305 createMenu( CreatePolylineId, aNewPolylineId, -1, -1 );
306 createMenu( separator(), aNewPolylineId );
307 createMenu( SplitPolylinesId, aNewPolylineId, -1, -1 );
308 createMenu( MergePolylinesId, aNewPolylineId, -1, -1 );
310 int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
311 createMenu( CreateProfileId, aNewProfileId, -1, -1 );
312 createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
313 createMenu( separator(), aNewProfileId );
314 createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
316 int aStreamMenuId = createMenu( tr( "MEN_DESK_STREAM" ), aHydroId, -1 );
317 createMenu( CreateStreamId, aStreamMenuId, -1, -1 );
318 createMenu( separator(), aStreamMenuId );
319 createMenu( RiverBottomId, aStreamMenuId, -1, -1 );
320 createMenu( ProfileInterpolateId, aStreamMenuId, -1, -1 );
322 int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 );
323 createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 );
324 createMenu( separator(), anObstacleMenuId );
325 createMenu( CreateBoxId, anObstacleMenuId, -1, -1 );
326 createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 );
328 int aLandCoverMapMenuId = createMenu( tr( "MEN_DESK_LAND_COVER_MAP" ), aHydroId, -1 );
329 createMenu( ImportLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
330 createMenu( CreateLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
331 createMenu( separator(), aLandCoverMapMenuId );
332 createMenu( AddLandCoverId, aLandCoverMapMenuId, -1, -1 );
333 createMenu( RemoveLandCoverId, aLandCoverMapMenuId, -1, -1 );
334 createMenu( separator(), aLandCoverMapMenuId );
335 createMenu( SplitLandCoverId, aLandCoverMapMenuId, -1, -1 );
336 createMenu( MergeLandCoverId, aLandCoverMapMenuId, -1, -1 );
337 createMenu( ChangeLandCoverTypeId, aLandCoverMapMenuId, -1, -1 );
339 createMenu( CreateCalculationId, aHydroId, -1, -1 );
340 createMenu( separator(), aHydroId );
341 createMenu( EditLocalCSId, aHydroId, -1, -1 );
342 createMenu( separator(), aHydroId );
345 void HYDROGUI_Module::createPopups()
349 void HYDROGUI_Module::createToolbars()
351 int aToolBar = createTool( tr( "MEN_DESK_HYDRO" ) );
352 createTool( UndoId, aToolBar );
353 createTool( RedoId, aToolBar );
355 createTool( separator(), aToolBar );
356 createTool( ImportImageId, aToolBar );
357 createTool( ImportPolylineId, aToolBar );
358 createTool( ImportSinusXId, aToolBar );
359 createTool( ExportSinusXId, aToolBar );
360 createTool( ImportLandCoverMapId, aToolBar );
362 createTool( ImportBCPolygonId, aToolBar );
363 createTool( MeasurementToolId, aToolBar );
365 createTool( ImportBathymetryId, aToolBar );
366 createTool( CreatePolylineId, aToolBar );
367 createTool( CreatePolyline3DId, aToolBar );
369 createTool( separator(), aToolBar );
370 createTool( CreateProfileId, aToolBar );
371 createTool( ImportProfilesId, aToolBar );
372 createTool( AllGeoreferencementId, aToolBar );
374 createTool( separator(), aToolBar );
375 createTool( CreateChannelId, aToolBar );
376 createTool( CreateDigueId, aToolBar );
378 createTool( separator(), aToolBar );
379 createTool( CreateImmersibleZoneId, aToolBar );
380 createTool( CreateStreamId, aToolBar );
382 createTool( separator(), aToolBar );
383 createTool( ImportObstacleFromFileId, aToolBar );
384 createTool( CreateBoxId, aToolBar );
385 createTool( CreateCylinderId, aToolBar );
387 createTool( separator(), aToolBar );
388 createTool( ImportStricklerTableFromFileId, aToolBar );
390 createTool( separator(), aToolBar );
391 createTool( CreateLandCoverMapId, aToolBar );
392 createTool( AddLandCoverId, aToolBar );
393 createTool( RemoveLandCoverId, aToolBar );
394 createTool( SplitLandCoverId, aToolBar );
395 createTool( MergeLandCoverId, aToolBar );
396 createTool( ChangeLandCoverTypeId, aToolBar );
399 createTool( separator(), aToolBar );
400 createTool( CreateCalculationId, aToolBar );
402 createTool( separator(), aToolBar );
403 createTool( FuseImagesId, aToolBar );
404 createTool( CutImagesId, aToolBar );
405 createTool( SplitImageId, aToolBar );
407 createTool( separator(), aToolBar );
408 createTool( BathymetrySelectionId, aToolBar );
409 createTool( BathymetryTextId, aToolBar );
410 createTool( BathymetryRescaleSelectionId, aToolBar );
411 createTool( BathymetryRescaleVisibleId, aToolBar );
412 createTool( BathymetryRescaleUserId, aToolBar );
413 createTool( BathymetryRescaleDefaultId, aToolBar );
416 void HYDROGUI_Module::createUndoRedoActions()
418 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
420 QtxListAction* anEditUndo = new QtxListAction( tr( "MEN_UNDO" ),
421 aResMgr->loadPixmap( "HYDRO", tr( "UNDO_ICO" ) ), tr( "DSK_UNDO" ),
422 Qt::CTRL + Qt::Key_Z, application()->desktop() );
424 QtxListAction* anEditRedo = new QtxListAction( tr( "MEN_REDO" ),
425 aResMgr->loadPixmap( "HYDRO", tr( "REDO_ICO" ) ), tr( "DSK_REDO" ),
426 Qt::CTRL + Qt::Key_Y, application()->desktop() );
428 registerAction( UndoId, anEditUndo );
429 registerAction( RedoId, anEditRedo );
431 anEditUndo->setComment( tr( "STB_UNDO" ) );
432 anEditRedo->setComment( tr( "STB_REDO" ) );
434 connect( anEditUndo, SIGNAL( triggered( int ) ), this, SLOT( onUndo( int ) ) );
435 connect( anEditRedo, SIGNAL( triggered( int ) ), this, SLOT( onRedo( int ) ) );
438 void HYDROGUI_Module::updateUndoRedoControls()
440 HYDROGUI_DataModel* aModel = getDataModel();
442 QtxListAction* aUndoAction = (QtxListAction*)action( UndoId );
443 QtxListAction* aRedoAction = (QtxListAction*)action( RedoId );
445 bool aCanUndo = aModel->canUndo();
446 bool aCanRedo = aModel->canRedo();
449 aUndoAction->addNames( aModel->undoNames() );
450 aUndoAction->setEnabled( aCanUndo );
453 aRedoAction->addNames( aModel->redoNames() );
454 aRedoAction->setEnabled( aCanRedo );
457 void HYDROGUI_Module::enableLCMActions()
459 HYDROData_Iterator anIt( HYDROData_Document::Document( getStudyId() ), KIND_LAND_COVER_MAP );
460 bool anEnableTools = anIt.More();
462 QtxListAction* anAction;
463 anAction = (QtxListAction*)action( AddLandCoverId );
464 if ( anAction ) anAction->setEnabled( anEnableTools );
465 anAction = (QtxListAction*)action( RemoveLandCoverId );
466 if ( anAction ) anAction->setEnabled( anEnableTools );
467 anAction = (QtxListAction*)action( SplitLandCoverId );
468 if ( anAction ) anAction->setEnabled( anEnableTools );
469 anAction = (QtxListAction*)action( MergeLandCoverId );
470 if ( anAction ) anAction->setEnabled( anEnableTools );
471 anAction = (QtxListAction*)action( ChangeLandCoverTypeId );
472 if ( anAction ) anAction->setEnabled( anEnableTools );
475 void HYDROGUI_Module::resetViewState()
477 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>(getApp()->viewManager( OCCViewer_Viewer::Type()));
480 foreach( SUIT_ViewWindow* wnd, mgr->getViews() )
482 OCCViewer_ViewFrame* vf = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
485 for( int i=OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++ )
487 OCCViewer_ViewWindow* iwnd = vf->getView(i);
494 OCCViewer_ViewWindow* ownd = dynamic_cast<OCCViewer_ViewWindow*>( wnd );
502 void HYDROGUI_Module::onOperation()
504 const QAction* anAction = dynamic_cast<const QAction*>( sender() );
505 int anId = actionId( anAction );
509 startOperation( anId );
512 if( anId==ShowHideArrows )
514 setArrowsVisible( !arrowsVisible() );
518 bool HYDROGUI_Module::arrowsVisible() const
521 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
524 resMgr->value( "polyline", "arrow_type", aType );
531 void HYDROGUI_Module::setArrowsVisible( bool isVisible )
533 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
541 if( resMgr->hasValue( "polyline", "prev_arrow_type" ) )
542 resMgr->value( "polyline", "prev_arrow_type", aType );
546 resMgr->setValue( "polyline", "arrow_type", aType );
550 resMgr->value( "polyline", "arrow_type", aType );
551 resMgr->setValue( "polyline", "prev_arrow_type", aType );
552 resMgr->setValue( "polyline", "arrow_type", 0 );
554 preferencesChanged( "polyline", "arrow_type" );
557 void HYDROGUI_Module::onDelete()
559 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
560 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
561 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
562 aPolylineOp->deleteSelected();
564 startOperation( DeleteId );
567 bool HYDROGUI_Module::onUndo( int theNumActions )
569 QApplication::setOverrideCursor( Qt::WaitCursor );
571 HYDROGUI_DataModel* aModel = getDataModel();
574 while( theNumActions > 0 )
576 if( !aModel->undo() )
585 QApplication::restoreOverrideCursor();
589 bool HYDROGUI_Module::onRedo( int theNumActions )
591 QApplication::setOverrideCursor( Qt::WaitCursor );
593 HYDROGUI_DataModel* aModel = getDataModel();
596 while( theNumActions > 0 )
598 if( !aModel->redo() )
607 QApplication::restoreOverrideCursor();
611 LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
613 LightApp_Operation* anOp = 0;
614 HYDROGUI_Module* aModule = const_cast<HYDROGUI_Module*>( this );
617 case SaveVisualStateId:
618 case LoadVisualStateId:
619 anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
623 anOp = new HYDROGUI_CopyPasteOp( aModule, theId == PasteId );
626 case EditImportedImageId:
627 anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImportedImageId );
629 case ImportPolylineId:
630 anOp = new HYDROGUI_ImportPolylineOp( aModule/*, theId == EditImportedPolylineId*/ );
633 anOp = new HYDROGUI_ImportSinusXOp( aModule );
636 anOp = new HYDROGUI_ExportSinusXOp( aModule );
638 case ImportBCPolygonId:
639 anOp = new HYDROGUI_ImportBCPolygonOp( aModule );
641 case MeasurementToolId:
642 anOp = new HYDROGUI_MeasurementToolOp( aModule );
645 anOp = new HYDROGUI_ObserveImageOp( aModule );
648 anOp = new HYDROGUI_ExportImageOp( aModule );
651 case ForcedUpdateObjectId:
652 anOp = new HYDROGUI_UpdateObjectOp( aModule, theId == ForcedUpdateObjectId );
654 case ExportToShapeFileID:
655 anOp = new HYDROGUI_ExportFileOp( aModule );
657 case ImportLandCoverMapId:
658 anOp = new HYDROGUI_ImportLandCoverMapOp( aModule );
660 case RemoveImageRefsId:
661 anOp = new HYDROGUI_RemoveImageRefsOp( aModule );
663 case CreatePolyline3DId:
664 case EditPolyline3DId:
665 anOp = new HYDROGUI_Poly3DOp( aModule, theId == EditPolyline3DId );
667 case CreatePolylineId:
669 anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
671 case CreateProfileId:
673 anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId );
675 case ProfileInterpolateId:
676 anOp = new HYDROGUI_ProfileInterpolateOp( aModule );
678 case ImportProfilesId:
679 anOp = new HYDROGUI_ImportProfilesOp( aModule ) ;
681 case AllGeoreferencementId:
682 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::All ) ;
684 case SelectedGeoreferencementId:
685 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::Selected ) ;
687 case ImportBathymetryId:
688 case EditImportedBathymetryId:
689 anOp = new HYDROGUI_ImportBathymetryOp( aModule, theId == EditImportedBathymetryId );
691 case BathymetryBoundsId:
692 anOp = new HYDROGUI_BathymetryBoundsOp( aModule );
694 case BathymetrySelectionId:
695 anOp = new HYDROGUI_BathymetrySelectionOp( aModule );
697 case BathymetryTextId:
698 case BathymetryRescaleSelectionId:
699 case BathymetryRescaleVisibleId:
700 case BathymetryRescaleUserId:
701 case BathymetryRescaleDefaultId:
702 anOp = new HYDROGUI_BathymetryOp( aModule, theId );
705 case CreateImmersibleZoneId:
706 case EditImmersibleZoneId:
707 anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
711 anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId );
713 case CreateChannelId:
715 anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId );
719 anOp = new HYDROGUI_DigueOp( aModule, theId == EditDigueId );
721 case ImportStricklerTableFromFileId:
722 case ExportStricklerTableFromFileId:
723 case EditStricklerTableId:
724 anOp = new HYDROGUI_StricklerTableOp( aModule, theId );
726 case CreateLandCoverMapId:
728 case RemoveLandCoverId:
729 case SplitLandCoverId:
730 case MergeLandCoverId:
731 case ChangeLandCoverTypeId:
732 anOp = new HYDROGUI_LandCoverMapOp( aModule, theId );
734 case DuplicateStricklerTableId:
735 anOp = new HYDROGUI_DuplicateOp( aModule );
737 case CreateCalculationId:
738 case EditCalculationId:
739 anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
741 case ExportCalculationId:
742 anOp = new HYDROGUI_ExportCalculationOp( aModule );
745 case EditFusedImageId:
746 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId );
750 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut, theId == EditCutImageId );
753 case EditSplitImageId:
754 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Split, theId == EditSplitImageId );
756 case ImportObstacleFromFileId:
757 anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
759 case ImportGeomObjectAsObstacleId:
760 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsObstacle );
762 case ImportGeomObjectAsPolylineId:
763 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsPolyline );
766 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
767 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpBox );
769 case CreateCylinderId:
770 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
771 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpCylinder );
773 case TranslateObstacleId:
774 anOp = new HYDROGUI_TranslateObstacleOp( aModule );
776 case CopyViewerPositionId:
777 anOp = new HYDROGUI_CopyPastePositionOp( aModule, false );
780 anOp = new HYDROGUI_DeleteOp( aModule );
783 anOp = new HYDROGUI_SetColorOp( aModule );
785 case SetTransparencyId:
786 anOp = new HYDROGUI_SetTransparencyOp( aModule );
789 anOp = new HYDROGUI_ZLevelsOp( aModule );
792 anOp = new HYDROGUI_LocalCSOp( aModule );
795 case RiverBottomContextId:
796 anOp = new HYDROGUI_RiverBottomOp( aModule );
798 case RecognizeContoursId:
799 anOp = new HYDROGUI_RecognizeContoursOp( aModule );
806 anOp = new HYDROGUI_ShowHideOp( aModule, theId );
809 anOp = new HYDROGUI_SubmersibleOp( aModule, true );
811 case UnSubmersibleId:
812 anOp = new HYDROGUI_SubmersibleOp( aModule, false );
814 case PolylineExtractionId:
815 anOp = new HYDROGUI_PolylineExtractionOp( aModule );
817 case SplitPolylinesId:
818 anOp = new HYDROGUI_SplitPolylinesOp( aModule );
820 case MergePolylinesId:
821 anOp = new HYDROGUI_MergePolylinesOp( aModule );
823 case ShowAttrPolylinesId:
824 anOp = new HYDROGUI_ShowAttrPolyOp( aModule );
826 case SetBoundaryTypePolygonId:
827 anOp = new HYDROGUI_SetBoundaryTypePolygonOp( aModule );
829 case LandCoverScalarMapModeOnId:
830 case LandCoverScalarMapModeOffId:
831 anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
833 case RegenerateRegionColorsId:
834 anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule );
837 anOp = new HYDROGUI_ZoneSetColorOp( aModule );
842 anOp = LightApp_Module::createOperation( theId );
847 bool HYDROGUI_Module::reusableOperation( const int id )
849 if ( id == ImportGeomObjectAsObstacleId ||
850 id == ImportGeomObjectAsPolylineId ) {
854 return LightApp_Module::reusableOperation( id );
858 * Returns true if the object with the given entry can be renamed.
859 * @param theEntry the object entry
861 bool HYDROGUI_Module::renameAllowed( const QString& theEntry ) const
863 // Allow to rename all HYDRO objects
864 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
865 return !anEntity.IsNull();
868 * Returns true if the object with the given entry is renamed.
869 * @param theEntry the object entry
870 * @param theName the new name
872 bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theName )
874 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
876 if ( !anEntity.IsNull() )
878 HYDROGUI_DataModel* aModel = getDataModel();
881 if( anEntity->GetName() != theName )
883 // check that there are no other objects with the same name in the document
884 Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( this, theName );
885 if ( anObject.IsNull() )
887 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
888 if ( anOp && anOp->inherits( "HYDROGUI_CalculationOp" ) )
890 anEntity->SetName( theName );
895 aRes = aModel->rename( anEntity, theName );
900 // Inform the user that the name is already used
901 QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
902 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
903 SUIT_MessageBox::critical( getApp()->desktop(), aTitle, aMessage );
911 void HYDROGUI_Module::onBathymetrySelection()
913 QAction* a = qobject_cast<QAction*>( sender() );
917 bool isChecked = a->isChecked();
919 startOperation( BathymetrySelectionId );
922 LightApp_Operation* op = operation( BathymetryTextId );
926 op = operation( BathymetrySelectionId );
932 void HYDROGUI_Module::onBathymetryText()
934 QAction* a = qobject_cast<QAction*>( sender() );
938 bool isChecked = a->isChecked();
940 startOperation( BathymetryTextId );
943 HYDROGUI_BathymetryOp* op = dynamic_cast<HYDROGUI_BathymetryOp*>( operation( BathymetryTextId ) );