1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_Operations.h"
21 #include "HYDROGUI_CopyPasteOp.h"
22 #include "HYDROGUI_CalculationOp.h"
23 #include "HYDROGUI_ChannelOp.h"
24 #include "HYDROGUI_DataModel.h"
25 #include "HYDROGUI_CopyPastePositionOp.h"
26 #include "HYDROGUI_DeleteOp.h"
27 #include "HYDROGUI_DigueOp.h"
28 #include "HYDROGUI_ExportImageOp.h"
29 #include "HYDROGUI_ExportFileOp.h"
30 #include "HYDROGUI_ImportImageOp.h"
31 #include "HYDROGUI_ImportPolylineOp.h"
32 #include "HYDROGUI_ImportSinusXOp.h"
33 #include "HYDROGUI_ImportBathymetryOp.h"
34 #include "HYDROGUI_ImmersibleZoneOp.h"
35 #include "HYDROGUI_Module.h"
36 #include "HYDROGUI_ObserveImageOp.h"
37 #include "HYDROGUI_PolylineOp.h"
38 #include "HYDROGUI_Poly3DOp.h"
39 #include "HYDROGUI_ProfileOp.h"
40 #include "HYDROGUI_RemoveImageRefsOp.h"
41 #include "HYDROGUI_ShowHideOp.h"
42 #include "HYDROGUI_StreamOp.h"
43 #include "HYDROGUI_TwoImagesOp.h"
44 #include "HYDROGUI_UpdateFlags.h"
45 #include "HYDROGUI_UpdateObjectOp.h"
46 #include "HYDROGUI_VisualStateOp.h"
47 #include "HYDROGUI_ImmersibleZoneOp.h"
48 #include "HYDROGUI_ImportGeomObjectOp.h"
49 #include "HYDROGUI_ImportObstacleFromFileOp.h"
50 #include "HYDROGUI_TranslateObstacleOp.h"
51 #include "HYDROGUI_ExportCalculationOp.h"
52 #include "HYDROGUI_ImportProfilesOp.h"
53 #include "HYDROGUI_GeoreferencementOp.h"
54 #include "HYDROGUI_SetColorOp.h"
55 #include "HYDROGUI_BathymetryBoundsOp.h"
56 #include "HYDROGUI_Tool2.h"
57 #include "HYDROGUI_ZLevelsOp.h"
58 #include "HYDROGUI_LocalCSOp.h"
59 #include "HYDROGUI_RiverBottomOp.h"
60 #include "HYDROGUI_ProfileInterpolateOp.h"
61 #include "HYDROGUI_RecognizeContoursOp.h"
62 #include <HYDROGUI_ImportBCPolygonOp.h>
63 #include "HYDROGUI_SubmersibleOp.h"
64 #include "HYDROGUI_StricklerTableOp.h"
65 #include "HYDROGUI_DuplicateOp.h"
66 #include "HYDROGUI_LandCoverMapOp.h"
67 #include "HYDROGUI_PolylineExtractionOp.h"
68 #include "HYDROGUI_ExportSinusXOp.h"
69 #include "HYDROGUI_MergePolylinesOp.h"
70 #include "HYDROGUI_SplitPolylinesOp.h"
71 #include "HYDROGUI_LandCoverColoringOp.h"
72 #include "HYDROGUI_SetTransparencyOp.h"
73 #include "HYDROGUI_ImportLandCoverMapOp.h"
74 #include "HYDROGUI_BathymetrySelectionOp.h"
75 #include "HYDROGUI_BathymetryOp.h"
76 #include "HYDROGUI_RegenerateRegionColorsOp.h"
77 #include "HYDROGUI_PolylineStyleOp.h"
78 #include "HYDROGUI_ZoneSetColorOp.h"
79 #include <HYDROGUI_ShowAttrPolyOp.h>
80 #include <HYDROGUI_SetBoundaryTypePolygonOp.h>
81 #include <HYDROData_Document.h>
82 #include <HYDROData_Obstacle.h>
83 #include <HYDROData_SplitToZonesTool.h>
84 #include <HYDROData_Iterator.h>
86 #include <GeometryGUI.h>
87 #include <GeometryGUI_Operations.h>
90 #include <SalomeApp_Study.h>
92 #include <LightApp_Application.h>
94 #include <OCCViewer_ViewModel.h>
95 #include <OCCViewer_ViewManager.h>
96 #include <OCCViewer_ViewWindow.h>
97 #include <OCCViewer_ViewFrame.h>
99 #include <QtxListAction.h>
100 #include <QtxActionToolMgr.h>
102 #include <SUIT_Desktop.h>
103 #include <SUIT_ResourceMgr.h>
104 #include <SUIT_Session.h>
105 #include <SUIT_MessageBox.h>
108 #include <QApplication>
110 QAction* HYDROGUI_Module::createAction( const int theId, const QString& theSuffix, const QString& theImg,
111 const int theKey, const bool isToggle, const QString& theSlot )
113 QString aSlot = theSlot;
114 if( aSlot.isEmpty() )
115 aSlot = SLOT( onOperation() );
116 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
117 std::string anImg = theImg.toStdString();
118 QPixmap aPixmap = theImg.isEmpty() ? QPixmap() : aResMgr->loadPixmap( "HYDRO", tr( anImg.c_str() ) );
119 std::string aMenu = ( "MEN_" + theSuffix ).toStdString();
120 std::string aDesktop = ( "DSK_" + theSuffix ).toStdString();
121 std::string aToolbar = ( "STB_" + theSuffix ).toStdString();
122 std::string aSlotStr = aSlot.toStdString();
123 return LightApp_Module::createAction( theId, tr( aDesktop.c_str() ), aPixmap,
124 tr( aMenu.c_str() ), tr( aToolbar.c_str() ),
125 theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() );
128 void HYDROGUI_Module::createActions()
130 createAction( SaveVisualStateId, "SAVE_VISUAL_STATE" );
131 createAction( LoadVisualStateId, "LOAD_VISUAL_STATE" );
133 createAction( CopyId, "COPY", "", Qt::CTRL + Qt::Key_C );
134 createAction( PasteId, "PASTE", "", Qt::CTRL + Qt::Key_V );
136 createAction( UpdateObjectId, "UPDATE_OBJECT" );
137 createAction( ForcedUpdateObjectId, "FORCED_UPDATE_OBJECT" );
139 createAction( ImportImageId, "IMPORT_IMAGE", "IMPORT_IMAGE_ICO", Qt::CTRL + Qt::Key_I );
140 createAction( EditImportedImageId, "EDIT_IMPORTED_IMAGE", "EDIT_IMPORTED_IMAGE_ICO" );
141 createAction( ObserveImageId, "OBSERVE_IMAGE", "OBSERVE_IMAGE_ICO" );
142 createAction( ExportImageId, "EXPORT_IMAGE", "EXPORT_IMAGE_ICO" );
143 createAction( RemoveImageRefsId, "REMOVE_IMAGE_REFERENCE", "REMOVE_IMAGE_REFERENCE_ICO" );
145 createAction( ImportPolylineId, "IMPORT_POLYLINE", "IMPORT_POLYLINE_ICO" );
146 createAction( ImportSinusXId, "IMPORT_SINUSX", "IMPORT_SINUSX_ICO" );
147 createAction( ExportSinusXId, "EXPORT_SINUSX", "EXPORT_SINUSX_ICO" );
148 createAction( ImportLandCoverMapId, "IMPORT_LANDCOVER_MAP", "IMPORT_LANDCOVER_MAP_ICO" );
150 createAction( ImportBCPolygonId, "IMPORT_BC_POLYGON", "IMPORT_BC_POLYGON_ICO" );
152 createAction( CreatePolylineId, "CREATE_POLYLINE", "CREATE_POLYLINE_ICO" );
153 createAction( EditPolylineId, "EDIT_POLYLINE", "EDIT_POLYLINE_ICO" );
155 createAction( CreatePolyline3DId, "CREATE_POLYLINE_3D", "CREATE_POLYLINE_3D_ICO" );
156 createAction( EditPolyline3DId, "EDIT_POLYLINE_3D", "EDIT_POLYLINE_3D_ICO" );
158 createAction( CreateProfileId, "CREATE_PROFILE", "CREATE_PROFILE_ICO" );
159 createAction( ImportProfilesId, "IMPORT_PROFILES", "IMPORT_PROFILES_ICO" );
160 createAction( EditProfileId, "EDIT_PROFILE", "EDIT_PROFILE_ICO" );
161 createAction( AllGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" );
162 createAction( SelectedGeoreferencementId, "GEOREFERENCEMENT", "GEOREFERENCEMENT_ICO" );
164 createAction( ImportBathymetryId, "IMPORT_BATHYMETRY", "IMPORT_BATHYMETRY_ICO", Qt::CTRL + Qt::Key_B );
165 createAction( EditImportedBathymetryId, "EDIT_IMPORTED_BATHYMETRY", "EDIT_IMPORTED_BATHYMETRY_ICO" );
166 createAction( BathymetryBoundsId, "BATHYMETRY_BOUNDS", "BATHYMETRY_BOUNDS_ICO" );
167 createAction( BathymetrySelectionId, "BATHYMETRY_SELECTION", "BATHYMETRY_SELECTION_ICO",
168 0, true, SLOT( onBathymetrySelection() ) );
170 createAction( BathymetryTextId, "BATHYMETRY_TEXT", "BATHYMETRY_TEXT_ICO",
171 0, true, SLOT( onBathymetryText() ) );
173 createAction( BathymetryRescaleSelectionId, "BATHYMETRY_RESCALE_SELECTION", "BATHYMETRY_RESCALE_SELECTION_ICO" );
174 createAction( BathymetryRescaleVisibleId, "BATHYMETRY_RESCALE_VISIBLE", "BATHYMETRY_RESCALE_VISIBLE_ICO" );
175 createAction( BathymetryRescaleUserId, "BATHYMETRY_RESCALE_USER", "BATHYMETRY_RESCALE_USER_ICO" );
176 createAction( BathymetryRescaleDefaultId, "BATHYMETRY_RESCALE_DEFAULT", "BATHYMETRY_RESCALE_DEFAULT_ICO" );
178 createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE", "CREATE_IMMERSIBLE_ZONE_ICO" );
179 createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE", "EDIT_IMMERSIBLE_ZONE_ICO" );
181 createAction( CreateStreamId, "CREATE_STREAM", "CREATE_STREAM_ICO" );
182 createAction( EditStreamId, "EDIT_STREAM", "EDIT_STREAM_ICO" );
184 createAction( CreateChannelId, "CREATE_CHANNEL", "CREATE_CHANNEL_ICO" );
185 createAction( EditChannelId, "EDIT_CHANNEL", "EDIT_CHANNEL_ICO" );
187 createAction( CreateDigueId, "CREATE_DIGUE", "CREATE_DIGUE_ICO" );
188 createAction( EditDigueId, "EDIT_DIGUE", "EDIT_DIGUE_ICO" );
190 createAction( ImportStricklerTableFromFileId, "IMPORT_STRICKLER_TABLE", "IMPORT_STRICKLER_TABLE_ICO" );
191 createAction( ExportStricklerTableFromFileId, "EXPORT_STRICKLER_TABLE", "EXPORT_STRICKLER_TABLE_ICO" );
192 createAction( EditStricklerTableId, "EDIT_STRICKLER_TABLE", "EDIT_STRICKLER_TABLE_ICO" );
193 createAction( DuplicateStricklerTableId, "DUPLICATE_STRICKLER_TABLE", "DUPLICATE_STRICKLER_TABLE_ICO" );
195 createAction( CreateLandCoverMapId, "CREATE_LAND_COVER_MAP", "CREATE_LAND_COVER_MAP_ICO" );
197 createAction( AddLandCoverId, "ADD_LAND_COVER", "ADD_LAND_COVER_ICO" );
198 createAction( RemoveLandCoverId, "REMOVE_LAND_COVER", "REMOVE_LAND_COVER_ICO" );
199 createAction( SplitLandCoverId, "SPLIT_LAND_COVER", "SPLIT_LAND_COVER_ICO" );
200 createAction( MergeLandCoverId, "MERGE_LAND_COVER", "MERGE_LAND_COVER_ICO" );
201 createAction( ChangeLandCoverTypeId, "CHANGE_LAND_COVER_TYPE", "CHANGE_LAND_COVER_TYPE_ICO" );
203 createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE", "IMPORT_OBSTACLE_FROM_FILE_ICO" );
204 createAction( ImportGeomObjectAsObstacleId, "IMPORT_GEOM_OBJECT_AS_OBSTACLE", "IMPORT_GEOM_OBJECT_ICO" );
205 createAction( ImportGeomObjectAsPolylineId, "IMPORT_GEOM_OBJECT_AS_POLYLINE", "IMPORT_GEOM_OBJECT_ICO" );
206 createAction( CreateBoxId, "CREATE_BOX", "CREATE_BOX_ICO" );
207 createAction( CreateCylinderId, "CREATE_CYLINDER", "CREATE_CYLINDER_ICO" );
208 createAction( TranslateObstacleId, "TRANSLATE_OBSTACLE" );
210 createAction( CreateCalculationId, "CREATE_CALCULATION", "CREATE_CALCULATION_ICO" );
211 createAction( EditCalculationId, "EDIT_CALCULATION", "EDIT_CALCULATION_ICO" );
212 createAction( ExportCalculationId, "EXPORT_CALCULATION", "EXPORT_CALCULATION_ICO" );
214 createAction( FuseImagesId, "FUSE_IMAGES", "FUSE_IMAGES_ICO" );
215 createAction( EditFusedImageId, "EDIT_FUSED_IMAGE", "EDIT_FUSED_IMAGE_ICO" );
217 createAction( CutImagesId, "CUT_IMAGES", "CUT_IMAGES_ICO" );
218 createAction( EditCutImageId, "EDIT_CUT_IMAGE", "EDIT_CUT_IMAGE_ICO" );
220 createAction( SplitImageId, "SPLIT_IMAGE", "SPLIT_IMAGE_ICO" );
221 createAction( EditSplitImageId, "EDIT_SPLIT_IMAGE", "EDIT_SPLIT_IMAGE_ICO" );
223 createAction( RecognizeContoursId, "RECOGNIZE_CONTOURS", "RECOGNIZE_CONTOURS_ICO" );
225 createAction( CopyViewerPositionId, "COPY_VIEWER_POSITION", "" );
227 createAction( DeleteId, "DELETE", "", Qt::Key_Delete, false,
228 SLOT( onDelete() ) );
230 createAction( SetColorId, "COLOR" );
231 createAction( SetTransparencyId, "TRANSPARENCY" );
232 createAction( SetZLevelId, "ZLEVEL" );
233 createAction( EditLocalCSId, "EDIT_LOCAL_CS" );
235 createAction( ShowId, "SHOW" );
236 createAction( ShowOnlyId, "SHOW_ONLY" );
237 createAction( ShowAllId, "SHOW_ALL" );
238 createAction( HideId, "HIDE" );
239 createAction( HideAllId, "HIDE_ALL" );
241 createAction( RiverBottomId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
242 createAction( RiverBottomContextId, "CREATE_STREAM_BOTTOM", "CREATE_STREAM_BOTTOM_ICO" );
243 createAction( ProfileInterpolateId, "PROFILE_INTERPOLATE", "PROFILE_INTERPOLATE_ICO" );
245 createAction( SubmersibleId, "SUBMERSIBLE", "SUBMERSIBLE_ICO" );
246 createAction( UnSubmersibleId, "UNSUBMERSIBLE", "HYDRO_UNSUBMERSIBLE16_ICO" );
247 createAction( ExportToShapeFileID, "EXPORT_TO_SHAPE_FILE", "EXPORT_TO_SHAPE_FILE_ICO" );
249 createAction( PolylineExtractionId, "POLYLINE_EXTRACTION" );
250 createAction( SplitPolylinesId, "SPLIT_POLYLINES", "SPLIT_POLYLINES_ICO" );
251 createAction( MergePolylinesId, "MERGE_POLYLINES", "MERGE_POLYLINES_ICO" );
253 createAction( ShowAttrPolylinesId, "SHOWATTR_POLYLINES");
255 createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
256 createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
258 createAction( RegenerateRegionColorsId, "REGENERATE_REGION_COLORS" );
259 createAction( ZoneSetColorId, "ZONE_SET_COLOR" );
260 createAction( ShowHideArrows, "SHOW_HIDE_ARROWS" );
261 createAction( SetBoundaryTypePolygonId, "SET_BOUNDARY_TYPE_POLYGON" );
264 void HYDROGUI_Module::createMenus()
266 int aFileMenu = createMenu( tr( "MEN_DESK_FILE" ), -1, -1, 0 );
267 int aCustomPos = 5; // to insert custom actions after "Save as" and before "Preferences"
268 createMenu( SaveVisualStateId, aFileMenu, aCustomPos );
269 createMenu( separator(), aFileMenu, -1, aCustomPos );
271 int anEditMenu = createMenu( tr( "MEN_DESK_EDIT" ), -1, -1, 5 );
272 createMenu( UndoId, anEditMenu );
273 createMenu( RedoId, anEditMenu );
274 createMenu( separator(), anEditMenu );
275 createMenu( CopyId, anEditMenu );
276 createMenu( PasteId, anEditMenu );
278 int aHydroMenu = 6; // Edit menu id == 5, View menu id == 10
279 int aHydroId = createMenu( tr( "MEN_DESK_HYDRO" ), -1, -1, aHydroMenu );
280 createMenu( ImportSinusXId, aHydroId, -1, -1 );
281 createMenu( ExportSinusXId, aHydroId, -1, -1 );
283 createMenu( ImportBathymetryId, aHydroId, -1, -1 );
284 createMenu( ImportStricklerTableFromFileId, aHydroId, -1, -1 );
285 createMenu( CreatePolyline3DId, aHydroId, -1, -1 );
286 createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
287 createMenu( CreateChannelId, aHydroId, -1, -1 );
288 createMenu( CreateDigueId, aHydroId, -1, -1 );
290 int aNewImageId = createMenu( tr( "MEN_DESK_IMAGE" ), aHydroId, -1 );
291 createMenu( ImportImageId, aNewImageId, -1, -1 );
292 createMenu( separator(), aNewImageId );
293 createMenu( FuseImagesId, aNewImageId, -1, -1 );
294 createMenu( CutImagesId, aNewImageId, -1, -1 );
295 createMenu( SplitImageId, aNewImageId, -1, -1 );
297 int aNewPolylineId = createMenu( tr( "MEN_DESK_POLYLINE" ), aHydroId, -1 );
298 createMenu( ImportPolylineId, aNewPolylineId, -1, -1 );
299 createMenu( CreatePolylineId, aNewPolylineId, -1, -1 );
300 createMenu( separator(), aNewPolylineId );
301 createMenu( SplitPolylinesId, aNewPolylineId, -1, -1 );
302 createMenu( MergePolylinesId, aNewPolylineId, -1, -1 );
304 int aNewProfileId = createMenu( tr( "MEN_DESK_PROFILE" ), aHydroId, -1 );
305 createMenu( CreateProfileId, aNewProfileId, -1, -1 );
306 createMenu( ImportProfilesId, aNewProfileId, -1, -1 );
307 createMenu( separator(), aNewProfileId );
308 createMenu( AllGeoreferencementId, aNewProfileId, -1, -1 );
310 int aStreamMenuId = createMenu( tr( "MEN_DESK_STREAM" ), aHydroId, -1 );
311 createMenu( CreateStreamId, aStreamMenuId, -1, -1 );
312 createMenu( separator(), aStreamMenuId );
313 createMenu( RiverBottomId, aStreamMenuId, -1, -1 );
314 createMenu( ProfileInterpolateId, aStreamMenuId, -1, -1 );
316 int anObstacleMenuId = createMenu( tr( "MEN_DESK_OBSTACLE" ), aHydroId, -1 );
317 createMenu( ImportObstacleFromFileId, anObstacleMenuId, -1, -1 );
318 createMenu( separator(), anObstacleMenuId );
319 createMenu( CreateBoxId, anObstacleMenuId, -1, -1 );
320 createMenu( CreateCylinderId, anObstacleMenuId, -1, -1 );
322 int aLandCoverMapMenuId = createMenu( tr( "MEN_DESK_LAND_COVER_MAP" ), aHydroId, -1 );
323 createMenu( ImportLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
324 createMenu( CreateLandCoverMapId, aLandCoverMapMenuId, -1, -1 );
325 createMenu( separator(), aLandCoverMapMenuId );
326 createMenu( AddLandCoverId, aLandCoverMapMenuId, -1, -1 );
327 createMenu( RemoveLandCoverId, aLandCoverMapMenuId, -1, -1 );
328 createMenu( separator(), aLandCoverMapMenuId );
329 createMenu( SplitLandCoverId, aLandCoverMapMenuId, -1, -1 );
330 createMenu( MergeLandCoverId, aLandCoverMapMenuId, -1, -1 );
331 createMenu( ChangeLandCoverTypeId, aLandCoverMapMenuId, -1, -1 );
333 createMenu( CreateCalculationId, aHydroId, -1, -1 );
334 createMenu( separator(), aHydroId );
335 createMenu( EditLocalCSId, aHydroId, -1, -1 );
336 createMenu( separator(), aHydroId );
339 void HYDROGUI_Module::createPopups()
343 void HYDROGUI_Module::createToolbars()
345 int aToolBar = createTool( tr( "MEN_DESK_HYDRO" ) );
346 createTool( UndoId, aToolBar );
347 createTool( RedoId, aToolBar );
349 createTool( separator(), aToolBar );
350 createTool( ImportImageId, aToolBar );
351 createTool( ImportPolylineId, aToolBar );
352 createTool( ImportSinusXId, aToolBar );
353 createTool( ExportSinusXId, aToolBar );
354 createTool( ImportLandCoverMapId, aToolBar );
356 createTool( ImportBCPolygonId, aToolBar );
358 createTool( ImportBathymetryId, aToolBar );
359 createTool( CreatePolylineId, aToolBar );
360 createTool( CreatePolyline3DId, aToolBar );
362 createTool( separator(), aToolBar );
363 createTool( CreateProfileId, aToolBar );
364 createTool( ImportProfilesId, aToolBar );
365 createTool( AllGeoreferencementId, aToolBar );
367 createTool( separator(), aToolBar );
368 createTool( CreateChannelId, aToolBar );
369 createTool( CreateDigueId, aToolBar );
371 createTool( separator(), aToolBar );
372 createTool( CreateImmersibleZoneId, aToolBar );
373 createTool( CreateStreamId, aToolBar );
375 createTool( separator(), aToolBar );
376 createTool( ImportObstacleFromFileId, aToolBar );
377 createTool( CreateBoxId, aToolBar );
378 createTool( CreateCylinderId, aToolBar );
380 createTool( separator(), aToolBar );
381 createTool( ImportStricklerTableFromFileId, aToolBar );
383 createTool( separator(), aToolBar );
384 createTool( CreateLandCoverMapId, aToolBar );
385 createTool( AddLandCoverId, aToolBar );
386 createTool( RemoveLandCoverId, aToolBar );
387 createTool( SplitLandCoverId, aToolBar );
388 createTool( MergeLandCoverId, aToolBar );
389 createTool( ChangeLandCoverTypeId, aToolBar );
392 createTool( separator(), aToolBar );
393 createTool( CreateCalculationId, aToolBar );
395 createTool( separator(), aToolBar );
396 createTool( FuseImagesId, aToolBar );
397 createTool( CutImagesId, aToolBar );
398 createTool( SplitImageId, aToolBar );
400 createTool( separator(), aToolBar );
401 createTool( BathymetrySelectionId, aToolBar );
402 createTool( BathymetryTextId, aToolBar );
403 createTool( BathymetryRescaleSelectionId, aToolBar );
404 createTool( BathymetryRescaleVisibleId, aToolBar );
405 createTool( BathymetryRescaleUserId, aToolBar );
406 createTool( BathymetryRescaleDefaultId, aToolBar );
409 void HYDROGUI_Module::createUndoRedoActions()
411 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
413 QtxListAction* anEditUndo = new QtxListAction( tr( "MEN_UNDO" ),
414 aResMgr->loadPixmap( "HYDRO", tr( "UNDO_ICO" ) ), tr( "DSK_UNDO" ),
415 Qt::CTRL + Qt::Key_Z, application()->desktop() );
417 QtxListAction* anEditRedo = new QtxListAction( tr( "MEN_REDO" ),
418 aResMgr->loadPixmap( "HYDRO", tr( "REDO_ICO" ) ), tr( "DSK_REDO" ),
419 Qt::CTRL + Qt::Key_Y, application()->desktop() );
421 registerAction( UndoId, anEditUndo );
422 registerAction( RedoId, anEditRedo );
424 anEditUndo->setComment( tr( "STB_UNDO" ) );
425 anEditRedo->setComment( tr( "STB_REDO" ) );
427 connect( anEditUndo, SIGNAL( triggered( int ) ), this, SLOT( onUndo( int ) ) );
428 connect( anEditRedo, SIGNAL( triggered( int ) ), this, SLOT( onRedo( int ) ) );
431 void HYDROGUI_Module::updateUndoRedoControls()
433 HYDROGUI_DataModel* aModel = getDataModel();
435 QtxListAction* aUndoAction = (QtxListAction*)action( UndoId );
436 QtxListAction* aRedoAction = (QtxListAction*)action( RedoId );
438 bool aCanUndo = aModel->canUndo();
439 bool aCanRedo = aModel->canRedo();
442 aUndoAction->addNames( aModel->undoNames() );
443 aUndoAction->setEnabled( aCanUndo );
446 aRedoAction->addNames( aModel->redoNames() );
447 aRedoAction->setEnabled( aCanRedo );
450 void HYDROGUI_Module::enableLCMActions()
452 HYDROData_Iterator anIt( HYDROData_Document::Document( getStudyId() ), KIND_LAND_COVER_MAP );
453 bool anEnableTools = anIt.More();
455 QtxListAction* anAction;
456 anAction = (QtxListAction*)action( AddLandCoverId );
457 if ( anAction ) anAction->setEnabled( anEnableTools );
458 anAction = (QtxListAction*)action( RemoveLandCoverId );
459 if ( anAction ) anAction->setEnabled( anEnableTools );
460 anAction = (QtxListAction*)action( SplitLandCoverId );
461 if ( anAction ) anAction->setEnabled( anEnableTools );
462 anAction = (QtxListAction*)action( MergeLandCoverId );
463 if ( anAction ) anAction->setEnabled( anEnableTools );
464 anAction = (QtxListAction*)action( ChangeLandCoverTypeId );
465 if ( anAction ) anAction->setEnabled( anEnableTools );
468 void HYDROGUI_Module::resetViewState()
470 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>(getApp()->viewManager( OCCViewer_Viewer::Type()));
473 foreach( SUIT_ViewWindow* wnd, mgr->getViews() )
475 OCCViewer_ViewFrame* vf = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
478 for( int i=OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++ )
480 OCCViewer_ViewWindow* iwnd = vf->getView(i);
487 OCCViewer_ViewWindow* ownd = dynamic_cast<OCCViewer_ViewWindow*>( wnd );
495 void HYDROGUI_Module::onOperation()
497 const QAction* anAction = dynamic_cast<const QAction*>( sender() );
498 int anId = actionId( anAction );
502 startOperation( anId );
505 if( anId==ShowHideArrows )
507 setArrowsVisible( !arrowsVisible() );
511 bool HYDROGUI_Module::arrowsVisible() const
514 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
517 resMgr->value( "polyline", "arrow_type", aType );
524 void HYDROGUI_Module::setArrowsVisible( bool isVisible )
526 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
534 if( resMgr->hasValue( "polyline", "prev_arrow_type" ) )
535 resMgr->value( "polyline", "prev_arrow_type", aType );
539 resMgr->setValue( "polyline", "arrow_type", aType );
543 resMgr->value( "polyline", "arrow_type", aType );
544 resMgr->setValue( "polyline", "prev_arrow_type", aType );
545 resMgr->setValue( "polyline", "arrow_type", 0 );
547 preferencesChanged( "polyline", "arrow_type" );
550 void HYDROGUI_Module::onDelete()
552 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
553 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
554 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
555 aPolylineOp->deleteSelected();
557 startOperation( DeleteId );
560 bool HYDROGUI_Module::onUndo( int theNumActions )
562 QApplication::setOverrideCursor( Qt::WaitCursor );
564 HYDROGUI_DataModel* aModel = getDataModel();
567 while( theNumActions > 0 )
569 if( !aModel->undo() )
578 QApplication::restoreOverrideCursor();
582 bool HYDROGUI_Module::onRedo( int theNumActions )
584 QApplication::setOverrideCursor( Qt::WaitCursor );
586 HYDROGUI_DataModel* aModel = getDataModel();
589 while( theNumActions > 0 )
591 if( !aModel->redo() )
600 QApplication::restoreOverrideCursor();
604 LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
606 LightApp_Operation* anOp = 0;
607 HYDROGUI_Module* aModule = const_cast<HYDROGUI_Module*>( this );
610 case SaveVisualStateId:
611 case LoadVisualStateId:
612 anOp = new HYDROGUI_VisualStateOp( aModule, theId == LoadVisualStateId );
616 anOp = new HYDROGUI_CopyPasteOp( aModule, theId == PasteId );
619 case EditImportedImageId:
620 anOp = new HYDROGUI_ImportImageOp( aModule, theId == EditImportedImageId );
622 case ImportPolylineId:
623 anOp = new HYDROGUI_ImportPolylineOp( aModule/*, theId == EditImportedPolylineId*/ );
626 anOp = new HYDROGUI_ImportSinusXOp( aModule );
629 anOp = new HYDROGUI_ExportSinusXOp( aModule );
631 case ImportBCPolygonId:
632 anOp = new HYDROGUI_ImportBCPolygonOp( aModule );
635 anOp = new HYDROGUI_ObserveImageOp( aModule );
638 anOp = new HYDROGUI_ExportImageOp( aModule );
641 case ForcedUpdateObjectId:
642 anOp = new HYDROGUI_UpdateObjectOp( aModule, theId == ForcedUpdateObjectId );
644 case ExportToShapeFileID:
645 anOp = new HYDROGUI_ExportFileOp( aModule );
647 case ImportLandCoverMapId:
648 anOp = new HYDROGUI_ImportLandCoverMapOp( aModule );
650 case RemoveImageRefsId:
651 anOp = new HYDROGUI_RemoveImageRefsOp( aModule );
653 case CreatePolyline3DId:
654 case EditPolyline3DId:
655 anOp = new HYDROGUI_Poly3DOp( aModule, theId == EditPolyline3DId );
657 case CreatePolylineId:
659 anOp = new HYDROGUI_PolylineOp( aModule, theId == EditPolylineId );
661 case CreateProfileId:
663 anOp = new HYDROGUI_ProfileOp( aModule, theId == EditProfileId );
665 case ProfileInterpolateId:
666 anOp = new HYDROGUI_ProfileInterpolateOp( aModule );
668 case ImportProfilesId:
669 anOp = new HYDROGUI_ImportProfilesOp( aModule ) ;
671 case AllGeoreferencementId:
672 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::All ) ;
674 case SelectedGeoreferencementId:
675 anOp = new HYDROGUI_GeoreferencementOp( aModule, HYDROGUI_GeoreferencementOp::Selected ) ;
677 case ImportBathymetryId:
678 case EditImportedBathymetryId:
679 anOp = new HYDROGUI_ImportBathymetryOp( aModule, theId == EditImportedBathymetryId );
681 case BathymetryBoundsId:
682 anOp = new HYDROGUI_BathymetryBoundsOp( aModule );
684 case BathymetrySelectionId:
685 anOp = new HYDROGUI_BathymetrySelectionOp( aModule );
687 case BathymetryTextId:
688 case BathymetryRescaleSelectionId:
689 case BathymetryRescaleVisibleId:
690 case BathymetryRescaleUserId:
691 case BathymetryRescaleDefaultId:
692 anOp = new HYDROGUI_BathymetryOp( aModule, theId );
695 case CreateImmersibleZoneId:
696 case EditImmersibleZoneId:
697 anOp = new HYDROGUI_ImmersibleZoneOp( aModule, theId == EditImmersibleZoneId );
701 anOp = new HYDROGUI_StreamOp( aModule, theId == EditStreamId );
703 case CreateChannelId:
705 anOp = new HYDROGUI_ChannelOp( aModule, theId == EditChannelId );
709 anOp = new HYDROGUI_DigueOp( aModule, theId == EditDigueId );
711 case ImportStricklerTableFromFileId:
712 case ExportStricklerTableFromFileId:
713 case EditStricklerTableId:
714 anOp = new HYDROGUI_StricklerTableOp( aModule, theId );
716 case CreateLandCoverMapId:
718 case RemoveLandCoverId:
719 case SplitLandCoverId:
720 case MergeLandCoverId:
721 case ChangeLandCoverTypeId:
722 anOp = new HYDROGUI_LandCoverMapOp( aModule, theId );
724 case DuplicateStricklerTableId:
725 anOp = new HYDROGUI_DuplicateOp( aModule );
727 case CreateCalculationId:
728 case EditCalculationId:
729 anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
731 case ExportCalculationId:
732 anOp = new HYDROGUI_ExportCalculationOp( aModule );
735 case EditFusedImageId:
736 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId );
740 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Cut, theId == EditCutImageId );
743 case EditSplitImageId:
744 anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Split, theId == EditSplitImageId );
746 case ImportObstacleFromFileId:
747 anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
749 case ImportGeomObjectAsObstacleId:
750 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsObstacle );
752 case ImportGeomObjectAsPolylineId:
753 anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelectedAsPolyline );
756 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
757 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpBox );
759 case CreateCylinderId:
760 anOp = new HYDROGUI_ImportGeomObjectOp( aModule,
761 HYDROGUI_ImportGeomObjectOp::ImportCreatedAsObstacle, GEOMOp::OpCylinder );
763 case TranslateObstacleId:
764 anOp = new HYDROGUI_TranslateObstacleOp( aModule );
766 case CopyViewerPositionId:
767 anOp = new HYDROGUI_CopyPastePositionOp( aModule, false );
770 anOp = new HYDROGUI_DeleteOp( aModule );
773 anOp = new HYDROGUI_SetColorOp( aModule );
775 case SetTransparencyId:
776 anOp = new HYDROGUI_SetTransparencyOp( aModule );
779 anOp = new HYDROGUI_ZLevelsOp( aModule );
782 anOp = new HYDROGUI_LocalCSOp( aModule );
785 case RiverBottomContextId:
786 anOp = new HYDROGUI_RiverBottomOp( aModule );
788 case RecognizeContoursId:
789 anOp = new HYDROGUI_RecognizeContoursOp( aModule );
796 anOp = new HYDROGUI_ShowHideOp( aModule, theId );
799 anOp = new HYDROGUI_SubmersibleOp( aModule, true );
801 case UnSubmersibleId:
802 anOp = new HYDROGUI_SubmersibleOp( aModule, false );
804 case PolylineExtractionId:
805 anOp = new HYDROGUI_PolylineExtractionOp( aModule );
807 case SplitPolylinesId:
808 anOp = new HYDROGUI_SplitPolylinesOp( aModule );
810 case MergePolylinesId:
811 anOp = new HYDROGUI_MergePolylinesOp( aModule );
813 case ShowAttrPolylinesId:
814 anOp = new HYDROGUI_ShowAttrPolyOp( aModule );
816 case SetBoundaryTypePolygonId:
817 anOp = new HYDROGUI_SetBoundaryTypePolygonOp( aModule );
819 case LandCoverScalarMapModeOnId:
820 case LandCoverScalarMapModeOffId:
821 anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
823 case RegenerateRegionColorsId:
824 anOp = new HYDROGUI_RegenerateRegionColorsOp( aModule );
827 anOp = new HYDROGUI_ZoneSetColorOp( aModule );
832 anOp = LightApp_Module::createOperation( theId );
837 bool HYDROGUI_Module::reusableOperation( const int id )
839 if ( id == ImportGeomObjectAsObstacleId ||
840 id == ImportGeomObjectAsPolylineId ) {
844 return LightApp_Module::reusableOperation( id );
848 * Returns true if the object with the given entry can be renamed.
849 * @param theEntry the object entry
851 bool HYDROGUI_Module::renameAllowed( const QString& theEntry ) const
853 // Allow to rename all HYDRO objects
854 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
855 return !anEntity.IsNull();
858 * Returns true if the object with the given entry is renamed.
859 * @param theEntry the object entry
860 * @param theName the new name
862 bool HYDROGUI_Module::renameObject( const QString& theEntry, const QString& theName )
864 Handle(HYDROData_Entity) anEntity = getDataModel()->objectByEntry( theEntry );
866 if ( !anEntity.IsNull() )
868 HYDROGUI_DataModel* aModel = getDataModel();
871 if( anEntity->GetName() != theName )
873 // check that there are no other objects with the same name in the document
874 Handle(HYDROData_Entity) anObject = HYDROGUI_Tool::FindObjectByName( this, theName );
875 if ( anObject.IsNull() )
877 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
878 if ( anOp && anOp->inherits( "HYDROGUI_CalculationOp" ) )
880 anEntity->SetName( theName );
885 aRes = aModel->rename( anEntity, theName );
890 // Inform the user that the name is already used
891 QString aTitle = QObject::tr( "INSUFFICIENT_INPUT_DATA" );
892 QString aMessage = QObject::tr( "OBJECT_EXISTS_IN_DOCUMENT" ).arg( theName );
893 SUIT_MessageBox::critical( getApp()->desktop(), aTitle, aMessage );
901 void HYDROGUI_Module::onBathymetrySelection()
903 QAction* a = qobject_cast<QAction*>( sender() );
907 bool isChecked = a->isChecked();
909 startOperation( BathymetrySelectionId );
912 LightApp_Operation* op = operation( BathymetryTextId );
916 op = operation( BathymetrySelectionId );
922 void HYDROGUI_Module::onBathymetryText()
924 QAction* a = qobject_cast<QAction*>( sender() );
928 bool isChecked = a->isChecked();
930 startOperation( BathymetryTextId );
933 HYDROGUI_BathymetryOp* op = dynamic_cast<HYDROGUI_BathymetryOp*>( operation( BathymetryTextId ) );