Salome HOME
Merge branch 'BR_v14_rc' into BR_quadtree
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
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.
6 //
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.
11 //
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
15 //
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
17 //
18
19 #include "HYDROGUI_Module.h"
20
21 #include "HYDROGUI.h"
22 #include "HYDROGUI_DataModel.h"
23 #include "HYDROGUI_DataObject.h"
24 #include "HYDROGUI_Displayer.h"
25 #include "HYDROGUI_GVSelector.h"
26 #include "HYDROGUI_InputPanel.h"
27 #include "HYDROGUI_ObjSelector.h"
28 #include "HYDROGUI_OCCDisplayer.h"
29 #include "HYDROGUI_OCCSelector.h"
30 #include "HYDROGUI_Operations.h"
31 #include "HYDROGUI_PrsImage.h"
32 #include "HYDROGUI_Tool.h"
33 #include "HYDROGUI_UpdateFlags.h"
34 #include "HYDROGUI_Shape.h"
35 #include "HYDROGUI_VTKPrs.h"
36 #include "HYDROGUI_VTKPrsDisplayer.h"
37 #include "HYDROGUI_AbstractDisplayer.h"
38 #include "HYDROGUI_PolylineOp.h"
39 #include "HYDROGUI_SetColorOp.h"
40 #include "HYDROGUI_ImportGeomObjectOp.h"
41 #include "HYDROGUI_ShowHideOp.h"
42
43 #include <HYDROData_Tool.h>
44 #include <HYDROData_Image.h>
45 #include <HYDROData_Stream.h>
46 #include <HYDROData_Profile.h>
47 #include <HYDROData_Lambert93.h>
48 #include <HYDROData_Polyline3D.h>
49 #include <HYDROData_StricklerTable.h>
50
51 #include <HYDROData_OperationsFactory.h>
52
53 #include <CurveCreator_Utils.hxx>
54
55 #include <GraphicsView_ViewFrame.h>
56 #include <GraphicsView_ViewManager.h>
57 #include <GraphicsView_ViewPort.h>
58 #include <GraphicsView_Viewer.h>
59
60 #include <ImageComposer_CutOperator.h>
61 #include <ImageComposer_CropOperator.h>
62 #include <ImageComposer_FuseOperator.h>
63
64 #include <LightApp_Application.h>
65 #include <LightApp_DataOwner.h>
66 #include <LightApp_GVSelector.h>
67 #include <LightApp_SelectionMgr.h>
68 #include <LightApp_UpdateFlags.h>
69
70 #include <SalomeApp_Study.h>
71
72 #include <OCCViewer_ViewFrame.h>
73 #include <OCCViewer_ViewManager.h>
74 #include <OCCViewer_ViewModel.h>
75
76 #include <SALOME_Event.h>
77
78 #include <SUIT_DataBrowser.h>
79 #include <SUIT_DataObject.h>
80 #include <SUIT_ViewManager.h>
81 #include <SUIT_ResourceMgr.h>
82 #include <SUIT_Desktop.h>
83 #include <SUIT_Study.h>
84 #include <SUIT_Session.h>
85
86 #include <SVTK_ViewManager.h>
87 #include <SVTK_ViewModel.h>
88 #include <SVTK_ViewWindow.h>
89 #include <SVTK_Selector.h>
90
91 #include <OCCViewer_ViewPort3d.h>
92
93 #include <GEOMUtils.hxx>
94 #include <GeometryGUI.h>
95
96 #include <SALOMEDS_wrap.hxx>
97
98 #include <QAction>
99 #include <QApplication>
100 #include <QGraphicsSceneMouseEvent>
101 #include <QMenu>
102 #include <QMouseEvent>
103 #include <QStatusBar>
104 #include <QCursor>
105
106 static int ViewManagerId = 0;
107
108 extern "C" HYDRO_EXPORT CAM_Module* createModule()
109 {
110   return new HYDROGUI_Module();
111 }
112
113 extern "C" HYDRO_EXPORT char* getModuleVersion()
114 {
115   return (char*)HYDRO_VERSION;
116 }
117
118 HYDROGUI_Module::HYDROGUI_Module()
119 : LightApp_Module( "HYDRO" ),
120   myDisplayer( 0 ),
121   myOCCDisplayer( 0 ),
122   myIsUpdateEnabled( true )
123 {
124 }
125
126 HYDROGUI_Module::~HYDROGUI_Module()
127 {
128 }
129
130 int HYDROGUI_Module::getStudyId() const
131 {
132   LightApp_Application* anApp = getApp();
133   return anApp ? anApp->activeStudy()->id() : 0;
134 }
135
136 void HYDROGUI_Module::initialize( CAM_Application* theApp )
137 {
138   LightApp_Module::initialize( theApp );
139
140   createActions();
141   createUndoRedoActions();
142   createMenus();
143   createPopups();
144   createToolbars();
145
146   setMenuShown( false );
147   setToolShown( false );
148
149   myDisplayer = new HYDROGUI_Displayer( this );
150   myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
151   myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
152 }
153
154 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
155 {
156   bool aRes = LightApp_Module::activateModule( theStudy );
157
158   LightApp_Application* anApp = getApp();
159   SUIT_Desktop* aDesktop = anApp->desktop();
160
161   getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
162
163   setMenuShown( true );
164   setToolShown( true );
165
166 #ifndef DISABLE_PYCONSOLE
167   aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ), 
168                               HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
169 #endif
170
171   // Remove defunct view managers from the map.
172   // It's essential to do this before "update( UF_All )" call!
173   QList<int> anObsoleteIds;
174   ViewManagerList anAllViewManagers = anApp->viewManagers();
175   ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
176   ViewManagerMapIterator anIter( myViewManagerMap );
177   while( anIter.hasNext() ) {
178     int anId = anIter.next().key();
179     const ViewManagerInfo& anInfo = anIter.value();
180   
181     aHydroViewManagers << anInfo.first;
182
183     if ( !anAllViewManagers.contains( anInfo.first ) ) {
184       anObsoleteIds << anId;
185     }
186   }
187   foreach ( const int anId, anObsoleteIds ) {
188     myViewManagerMap.remove( anId );
189     myObjectStateMap.remove( anId );
190     myShapesMap.remove( anId );
191     myVTKPrsMap.remove( anId );
192   }
193   // Replace the default selector for all view managers.
194   // Add view managers created outside of HYDRO module to the map.
195   foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
196     createSelector( aViewManager ); // replace the default selector
197     if ( !aHydroViewManagers.contains( aViewManager ) ) {
198       ViewManagerInfo anInfo( aViewManager, VMR_General );
199       myViewManagerMap.insert( ViewManagerId++, anInfo );
200     }
201   }
202
203   update( UF_All );
204
205   updateCommandsStatus();
206
207   HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
208
209   ViewManagerList anOCCViewManagers;
210   anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
211   foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
212     connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
213              this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
214     foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() ) {
215       OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
216       if ( aViewFrame && aViewFrame->getViewPort() ) {
217         aViewFrame->getViewPort()->installEventFilter( this );
218       }
219     }
220   }
221
222   // Load GEOM data
223   SalomeApp_Study* aStudy = 
224     dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
225   if ( aStudy ) {
226     SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
227     GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
228     if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
229       SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
230       SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
231       if( !GEOM_var->_is_nil() ) {
232         aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
233       }
234     }
235   }
236
237 //  SUIT_DataBrowser* ob = getApp()->objectBrowser();
238 //  SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
239 //  treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
240
241   return aRes;
242 }
243
244 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
245 {
246   /* Issues ## 68, 88.
247   ViewManagerMapIterator anIter( myViewManagerMap );
248   while( anIter.hasNext() )
249     if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
250       getApp()->removeViewManager( aViewManager );
251   myViewManagerMap.clear();
252   */
253
254   ViewManagerList anOCCViewManagers;
255   getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
256   foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
257     disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
258                 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
259   }
260
261   /* Issues ## 68, 88.
262   myObjectStateMap.clear();
263   myShapesMap.clear();
264   myVTKPrsMap.clear();
265   */
266
267   // clear the status bar
268   SUIT_Desktop* aDesktop = getApp()->desktop();
269   if ( aDesktop && aDesktop->statusBar() ) {
270     aDesktop->statusBar()->clearMessage();
271   }
272
273   // clear the data model's list of copying objects
274   HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
275
276   setMenuShown( false );
277   setToolShown( false );
278
279   getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
280
281   HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
282
283   myActiveOperationMap.clear();
284   return LightApp_Module::deactivateModule( theStudy );
285 }
286
287 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
288 {
289   theMap.clear();
290   theMap.insert( LightApp_Application::WT_LogWindow,     Qt::BottomDockWidgetArea );
291 #ifndef DISABLE_PYCONSOLE
292   theMap.insert( LightApp_Application::WT_PyConsole,     Qt::BottomDockWidgetArea );
293 #endif
294   theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea   );
295 }
296
297 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
298 {
299   theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
300 }
301
302 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
303                                         QMenu* theMenu,
304                                         QString& theTitle )
305 {
306   HYDROGUI_DataModel* aModel = getDataModel();
307
308   bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
309   bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
310   bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
311   bool anIsVTKView = theClient == SVTK_Viewer::Type();
312   if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
313     return;
314
315   size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
316
317   bool anIsSelectedDataObjects = false;
318   bool anIsVisibleInSelection = false;
319   bool anIsHiddenInSelection = false;
320
321   bool anIsImage = false;
322   bool anIsImportedImage = false;
323   bool anIsImageHasRefs = false;
324   bool anIsFusedImage = false;
325   bool anIsCutImage = false;
326   bool anIsSplittedImage = false;
327   bool anIsMustObjectBeUpdated = false;
328   bool anIsPolyline = false;
329   bool anIsPolyline3D = false;
330   bool anIsProfile = false;
331   bool anIsValidProfile = false;
332   bool anAllAreProfiles = false;
333   bool anIsBathymetry = false;
334   bool anIsCalculation = false;
335   bool anIsImmersibleZone = false;
336   bool anIsVisualState = false;
337   bool anIsRegion = false;
338   bool anIsZone = false;
339   bool anIsObstacle = false;
340   bool anIsStricklerTable = false;
341   bool anIsLandCover = false;
342   bool anIsStream = false;
343   bool anIsChannel = false;
344   bool anIsDigue = false;
345   bool anIsDummyObject3D = false;
346   bool anIsGroup = false;
347   bool anIsObjectCanBeColored = false;
348   bool isRoot = false;
349   bool isStreamHasBottom = false;
350
351   SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
352   SUIT_DataOwnerPtrList anOwners;
353   aSelectionMgr->selected( anOwners );
354   if( anIsObjectBrowser && anOwners.size()==1 )
355   {
356     QString anEntry = anOwners[0]->keyString();
357     LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
358     if( aStudy )
359       isRoot = aStudy->isComponent( anEntry );
360   }
361
362   // Check the selected GEOM objects (take into account the Object Browser only)
363   if ( anIsObjectBrowser ) {
364     QList<GEOM::shape_type> anObstacleTypes = 
365       HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
366     QList<GEOM::shape_type> aPolylineTypes = 
367       HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
368
369     bool isCanBeImportedAsObstacle = 
370       !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
371     bool isCanBeImportedAsPolyline = 
372       !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
373
374     // Add import as obstacle action
375     if ( isCanBeImportedAsObstacle ) {
376       theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
377     }
378     // Add import as polyline action
379     if ( isCanBeImportedAsPolyline ) {
380       theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
381     }
382     // Add separator
383     if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
384       theMenu->addSeparator();
385     }
386   }
387
388   // check the selected data model objects
389   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
390   int aNbOfSelectedProfiles = 0;
391   for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
392   {
393     Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
394     if( !anObject.IsNull() )
395     {
396       anIsSelectedDataObjects = true;
397
398       bool aVisibility = isObjectVisible( anActiveViewId, anObject );
399       anIsVisibleInSelection |= aVisibility;
400       anIsHiddenInSelection |= !aVisibility;
401
402       if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() )
403       {
404         anIsMustObjectBeUpdated = true;
405       }
406
407       ObjectKind anObjectKind = anObject->GetKind();
408       if( anObjectKind == KIND_IMAGE )
409       {
410         anIsImage = true;
411         Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
412         if( !anImage.IsNull() )
413         {
414           anIsImportedImage = anImage->HasLocalPoints();
415           anIsImageHasRefs = anImage->HasReferences();
416           if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
417           {
418             if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
419             {
420               QString anOperatorName = anOperator->name();
421               if( anOperatorName == ImageComposer_FuseOperator::Type() )
422                 anIsFusedImage = true;
423               else if( anOperatorName == ImageComposer_CutOperator::Type() )
424                 anIsCutImage = true;
425               else if( anOperatorName == ImageComposer_CropOperator::Type() )
426                 anIsSplittedImage = true;
427             }
428           }
429         }
430       }
431       else if( anObjectKind == KIND_POLYLINEXY )
432         anIsPolyline = true;
433       else if( anObjectKind == KIND_POLYLINE )
434         anIsPolyline3D = true;
435       else if( anObjectKind == KIND_PROFILE )
436       {
437         anIsProfile = true;
438         aNbOfSelectedProfiles++;
439
440         Handle(HYDROData_Profile) aProfile = 
441           Handle(HYDROData_Profile)::DownCast( anObject );
442         if( !aProfile.IsNull() && aProfile->IsValid() ) {
443           anIsValidProfile = true;
444         }
445       }
446       else if( anObjectKind == KIND_CALCULATION )
447         anIsCalculation = true;
448       else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
449         anIsImmersibleZone = true;
450       else if( anObjectKind == KIND_VISUAL_STATE )
451         anIsVisualState = true;
452       else if( anObjectKind == KIND_REGION )
453         anIsRegion = true;
454       else if( anObjectKind == KIND_ZONE )
455         anIsZone = true;
456       else if( anObjectKind == KIND_BATHYMETRY )
457         anIsBathymetry = true;
458       else if( anObjectKind == KIND_OBSTACLE )
459         anIsObstacle = true;
460       else if( anObjectKind == KIND_STRICKLER_TABLE )
461         anIsStricklerTable = true;
462       else if( anObjectKind == KIND_LAND_COVER )
463         anIsLandCover = true;
464       else if( anObjectKind == KIND_STREAM )
465       {
466         anIsStream = true;
467         Handle(HYDROData_Stream) aStream = 
468           Handle(HYDROData_Stream)::DownCast( anObject );
469         if ( !aStream.IsNull() )
470             isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
471       }
472       else if( anObjectKind == KIND_CHANNEL )
473         anIsChannel = true;
474       else if( anObjectKind == KIND_DIGUE )
475         anIsDigue = true;
476       else if( anObjectKind == KIND_DUMMY_3D )
477         anIsDummyObject3D = true;
478       else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLITTED_GROUP )
479         anIsGroup = true;
480     }
481
482     if ( !anIsObjectCanBeColored )
483       anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject, this );
484   }
485
486   // Check if all selected objects are profiles
487   anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
488                      ( aNbOfSelectedProfiles == aSeq.Length() );
489
490   // check the selected partitions
491   if( !anIsSelectedDataObjects && anIsObjectBrowser )
492   {
493     ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
494     if( aSelectedPartition != KIND_UNKNOWN )
495     {
496       switch( aSelectedPartition )
497       {
498         case KIND_IMAGE:
499           theMenu->addAction( action( ImportImageId ) );
500           break;
501         case KIND_BATHYMETRY:
502           theMenu->addAction( action( ImportBathymetryId ) );
503           break;
504         case KIND_ARTIFICIAL_OBJECT:
505           theMenu->addAction( action( CreateChannelId ) );
506           theMenu->addAction( action( CreateDigueId ) );
507           break;
508         case KIND_NATURAL_OBJECT:
509           theMenu->addAction( action( CreateImmersibleZoneId ) );
510           theMenu->addAction( action( CreateStreamId ) );
511           break;
512         case KIND_OBSTACLE:
513           theMenu->addAction( action( ImportObstacleFromFileId ) );
514           theMenu->addAction( action( CreateBoxId ) );
515           theMenu->addAction( action( CreateCylinderId ) );
516           break;
517         case KIND_STRICKLER_TABLE:
518           theMenu->addAction( action( ImportStricklerTableFromFileId ) );          
519           break;
520         case KIND_LAND_COVER:
521           theMenu->addAction( action( CreateLandCoverId ) );          
522           break;
523         case KIND_CALCULATION:
524           theMenu->addAction( action( CreateCalculationId ) );
525           break;
526         case KIND_POLYLINEXY:
527           theMenu->addAction( action( CreatePolylineId ) );
528           break;
529         case KIND_POLYLINE:
530           theMenu->addAction( action( CreatePolyline3DId ) );
531           break;
532         case KIND_PROFILE:
533           theMenu->addAction( action( CreateProfileId ) );
534           theMenu->addAction( action( ImportProfilesId ) );
535           theMenu->addAction( action( AllGeoreferencementId ) );
536           break;
537         case KIND_VISUAL_STATE:
538           theMenu->addAction( action( SaveVisualStateId ) );
539           break;
540       }
541       theMenu->addSeparator();
542     }
543   }
544
545   if( anIsSelectedDataObjects )
546   {
547     if ( anIsMustObjectBeUpdated )
548     {
549       theMenu->addAction( action( UpdateObjectId ) );
550       theMenu->addSeparator();
551     }
552     else
553     {
554       theMenu->addAction( action( ForcedUpdateObjectId ) );
555       theMenu->addSeparator();
556     }
557
558
559     if( aSeq.Length() == 1 )
560     {
561       if( anIsImage )
562       {
563         if( anIsImportedImage )
564           theMenu->addAction( action( EditImportedImageId ) );
565         else if( anIsImageHasRefs )
566         {
567           if( anIsFusedImage )
568             theMenu->addAction( action( EditFusedImageId ) );
569           else if( anIsCutImage )
570             theMenu->addAction( action( EditCutImageId ) );
571           else if( anIsSplittedImage )
572             theMenu->addAction( action( EditSplittedImageId ) );
573         }
574
575         //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
576         theMenu->addAction( action( ExportImageId ) );
577         theMenu->addSeparator();
578
579         if( anIsImageHasRefs )
580         {
581           theMenu->addAction( action( RemoveImageRefsId ) );
582           theMenu->addSeparator();
583         }
584
585         theMenu->addAction( action( FuseImagesId ) );
586         theMenu->addAction( action( CutImagesId ) );
587         theMenu->addAction( action( SplitImageId ) );
588         theMenu->addSeparator();
589         theMenu->addAction( action( RecognizeContoursId ) );
590         theMenu->addSeparator();
591       }
592       else if( anIsBathymetry )
593       {
594         theMenu->addAction( action( EditImportedBathymetryId ) );
595         theMenu->addAction( action( BathymetryBoundsId ) );
596         theMenu->addSeparator();
597       }
598       else if( anIsPolyline )
599       {
600         theMenu->addAction( action( EditPolylineId ) );
601         theMenu->addSeparator();
602       }
603       else if( anIsPolyline3D )
604       {
605         theMenu->addAction( action( EditPolyline3DId ) );
606         theMenu->addSeparator();
607       }
608       else if( anIsProfile )
609       {
610         theMenu->addAction( action( EditProfileId ) );
611         theMenu->addAction( action( SelectedGeoreferencementId ) );
612         theMenu->addSeparator();
613       }
614       else if( anIsCalculation )
615       {
616         theMenu->addAction( action( EditCalculationId ) );
617         theMenu->addAction( action( ExportCalculationId ) );
618         theMenu->addSeparator();
619       }
620       else if( anIsImmersibleZone )
621       {
622         theMenu->addAction( action( EditImmersibleZoneId ) );
623         theMenu->addSeparator();
624       }
625       else if( anIsStream )
626       {
627         theMenu->addAction( action( EditStreamId ) );
628         if ( action( RiverBottomContextId ) )
629         {
630             theMenu->addAction( action( RiverBottomContextId ) );
631             action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
632         }
633         theMenu->addAction( action( ProfileInterpolateId ) );
634         theMenu->addSeparator();
635       }
636       else if( anIsChannel )
637       {
638         theMenu->addAction( action( EditChannelId ) );
639         theMenu->addSeparator();
640       }
641       else if( anIsDigue )
642       {
643         theMenu->addAction( action( EditDigueId ) );
644         theMenu->addSeparator();
645       }
646       else if( anIsObstacle )
647       {
648         theMenu->addAction( action( TranslateObstacleId ) );
649         theMenu->addSeparator();
650       }
651       else if( anIsStricklerTable )
652       {
653         theMenu->addAction( action( EditStricklerTableId ) );
654         theMenu->addAction( action( ExportStricklerTableFromFileId ) );
655         theMenu->addAction( action( DuplicateStricklerTableId ) );
656         theMenu->addSeparator();
657
658         if ( !isLandCoversScalarMapModeOn( anActiveViewId ) ) {
659           theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
660           theMenu->addSeparator();
661         }
662       }
663       else if( anIsLandCover )
664       {
665         theMenu->addAction( action( EditLandCoverId ) );
666         theMenu->addSeparator();
667       }      
668       else if( anIsVisualState && anIsObjectBrowser )
669       {
670         theMenu->addAction( action( SaveVisualStateId ) );
671         theMenu->addAction( action( LoadVisualStateId ) );
672         theMenu->addSeparator();
673       }
674
675       // Add set color action for geometrical objects
676       if ( anIsObjectCanBeColored )
677       {
678         theMenu->addAction( action( SetColorId ) );
679         theMenu->addSeparator();
680       }
681     } else if ( anAllAreProfiles ) {
682       theMenu->addAction( action( SelectedGeoreferencementId ) );
683       theMenu->addSeparator();
684     }
685
686     if (anIsPolyline || anIsPolyline3D)
687       theMenu->addAction( action( ExportPolylineId ) );
688
689     // Add copy action
690     QAction* aCopyAction = action( CopyId );
691     if( aCopyAction && aCopyAction->isEnabled() ) {
692       theMenu->addAction( action( CopyId ) );
693       theMenu->addSeparator();
694     }
695
696     // Add delete action
697     if( !anIsDummyObject3D )
698       theMenu->addAction( action( DeleteId ) );
699
700     theMenu->addSeparator();
701
702     if( anIsImage || anIsPolyline || anIsPolyline3D || 
703         anIsImmersibleZone || anIsZone || anIsRegion ||
704         anIsBathymetry || anIsObstacle || anIsStream ||
705         anIsChannel || anIsDigue || anIsDummyObject3D ||
706         anIsValidProfile || anIsGroup || anIsLandCover )
707     {
708       if( anIsHiddenInSelection )
709         theMenu->addAction( action( ShowId ) );
710       theMenu->addAction( action( ShowOnlyId ) );
711       if( anIsVisibleInSelection )
712         theMenu->addAction( action( HideId ) );
713       theMenu->addSeparator();
714     }
715   }
716
717   if ( anIsOCCView )
718   {
719     SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
720     HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
721     if ( aPolylineOp && aPolylineOp->deleteEnabled() )
722       theMenu->addAction( action( DeleteId ) );
723
724     theMenu->addSeparator();
725     theMenu->addAction( action( SetZLevelId ) );
726     theMenu->addSeparator();
727
728     if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
729       theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
730       theMenu->addSeparator();
731     }
732   }
733
734   if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
735   {
736     theMenu->addAction( action( ShowAllId ) );
737     theMenu->addAction( action( HideAllId ) );
738     theMenu->addSeparator();
739   }
740   
741   if ( anIsOCCView || anIsVTKView )
742   {
743     theMenu->addSeparator();
744     theMenu->addAction( action( CopyViewerPositionId ) );
745   }
746
747   if( isRoot )
748     theMenu->addAction( action( EditLocalCSId ) );
749
750   if( anIsObjectBrowser && anOwners.size()==1 )
751   {
752     if( aSeq.Size() > 0 )
753     {
754       Handle( HYDROData_Object ) anObject = Handle( HYDROData_Object )::DownCast( aSeq.First() );
755       if( !anObject.IsNull() )
756       {
757         theMenu->addSeparator();
758         theMenu->addAction( action( SubmersibleId ) );
759         action( SubmersibleId )->setCheckable( true );
760         action( SubmersibleId )->setChecked( anObject->IsSubmersible() );
761       }
762     }
763   }
764 }
765
766 void HYDROGUI_Module::createPreferences()
767 {
768   int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
769   int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
770
771   int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
772                                     LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
773
774   // Set property cursor type
775   QList<QVariant> aCursorTypeIndicesList;
776   QList<QVariant> aCursorTypeIconsList;
777
778   SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
779   for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
780     QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
781     QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
782     aCursorTypeIndicesList << i;
783     aCursorTypeIconsList << pixmap;
784   }
785
786   setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
787   setPreferenceProperty( typeOfCursor, "icons",   aCursorTypeIconsList );
788
789   int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
790   addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
791                  LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
792
793   int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
794   int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
795                                             LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
796   setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
797   setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
798   setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
799   setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
800 }
801
802 QCursor HYDROGUI_Module::getPrefEditCursor() const
803 {
804   int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
805   if ( aCursorType >= Qt::BlankCursor)
806     aCursorType++;
807   QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
808   return aCursor;
809 }
810
811 void HYDROGUI_Module::update( const int flags )
812 {
813   if ( !isUpdateEnabled() )
814     return;
815
816   QApplication::setOverrideCursor( Qt::WaitCursor );
817
818   // To prevent calling this method recursively
819   // from one of the methods called below
820   setUpdateEnabled( false );
821
822   // store selected objects
823   QStringList aSelectedEntries = storeSelection();
824
825   bool aDoFitAll = flags & UF_FitAll;
826   if ( aDoFitAll )
827   {
828     SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
829     aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
830   }
831
832   if( ( flags & UF_Viewer ) )
833     updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll ); 
834
835   if( ( flags & UF_OCCViewer ) )
836     updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll ); 
837
838   if( ( flags & UF_VTKViewer ) )
839     updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll ); 
840
841   if( ( flags & UF_Model ) && getDataModel() && getApp() )
842   {
843     getDataModel()->update( getStudyId() );
844
845     // Temporary workaround to prevent breaking
846     // the selection in the object browser.
847     // Note: processEvents() should be called after updateGV(),
848     // otherwise the application crashes from time to time.
849     //RKV: qApp->processEvents();
850     SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
851     bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
852     SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
853     if ( isResizeOnExpandItem && anObjectBrowser ) {
854       anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280 
855     }
856     getApp()->updateObjectBrowser( true );
857     if ( isResizeOnExpandItem && anObjectBrowser ) {
858       anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280 
859     }
860   }
861
862   // Object browser is currently updated by using UF_Model flag
863   if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
864     getApp()->updateObjectBrowser( true );
865
866   if( ( flags & UF_Controls ) && getApp() )
867     getApp()->updateActions();
868
869   // restore selected objects
870   restoreSelection( aSelectedEntries );
871
872   setUpdateEnabled( true );
873
874   QApplication::restoreOverrideCursor();
875 }
876
877 void HYDROGUI_Module::updateCommandsStatus()
878 {
879   LightApp_Module::updateCommandsStatus();
880
881   updateUndoRedoControls();
882
883   action( CopyId )->setEnabled( getDataModel()->canCopy() );
884   action( PasteId )->setEnabled( getDataModel()->canPaste() );
885 }
886
887 void HYDROGUI_Module::selectionChanged()
888 {
889   LightApp_Module::selectionChanged();
890   updateCommandsStatus();
891 }
892
893 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
894 {
895   return (HYDROGUI_DataModel*)dataModel();
896 }
897
898 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
899 {
900   return myDisplayer;
901 }
902
903 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
904 {
905   return myOCCDisplayer;
906 }
907
908 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
909 {
910   return myVTKDisplayer;
911 }
912
913 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
914 {
915   if( myViewManagerMap.contains( theId ) )
916   {
917     return myViewManagerMap[ theId ].first;
918   }
919   return NULL;
920 }
921
922 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
923 {
924   if( myViewManagerMap.contains( theId ) )
925   {
926     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
927     GraphicsView_ViewManager* aViewManager =
928       dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
929     if( aViewManager )
930       return aViewManager->getViewer();
931   }
932   return NULL;
933 }
934
935 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
936 {
937   if( myViewManagerMap.contains( theId ) )
938   {
939     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
940     OCCViewer_ViewManager* aViewManager =
941       ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
942     if( aViewManager )
943       return aViewManager->getOCCViewer();
944   }
945   return NULL;
946 }
947
948 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
949 {
950   if( myViewManagerMap.contains( theId ) )
951   {
952     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
953     SVTK_ViewManager* aViewManager =
954       ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
955     if( aViewManager )
956       return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
957   }
958   return NULL;
959 }
960
961 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
962 {
963   ViewManagerMapIterator anIter( myViewManagerMap );
964   while( anIter.hasNext() )
965   {
966     int anId = anIter.next().key();
967     const ViewManagerInfo& anInfo = anIter.value();
968     if( anInfo.first == theViewManager )
969       return anId;
970   }
971   return -1;
972 }
973
974 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
975 {
976   int anId = getViewManagerId( theViewManager );
977   if( anId != -1 )
978   {
979     const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
980     return anInfo.second;
981   }
982   return VMR_Unknown;
983 }
984
985 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
986                                           const ViewManagerRole theRole )
987 {
988   int anId = getViewManagerId( theViewManager );
989   if( anId != -1 )
990   {
991     ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
992     anInfo.second = theRole;
993   }
994 }
995
996 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
997                                        const Handle(HYDROData_Entity)& theObject ) const
998 {
999   if( theObject.IsNull() )
1000     return false;
1001
1002   if( theViewId < 0 )
1003   {
1004     //search in all
1005     foreach( int aViewId, myObjectStateMap.keys() )
1006     {
1007       if( isObjectVisible( aViewId, theObject ) )
1008         return true;
1009     }
1010     return false;
1011   }
1012
1013   ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1014   if( anIter1 != myObjectStateMap.end() )
1015   {
1016     const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1017     QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1018
1019     Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1020     if( anIter2 != aEntry2ObjectStateMap.end() )
1021     {
1022       const ObjectState& anObjectState = anIter2.value();
1023       return anObjectState.Visibility;
1024     }
1025   }
1026   return false;
1027 }
1028
1029 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1030                                         const Handle(HYDROData_Entity)& theObject,
1031                                         const bool theState )
1032 {
1033   if( !theObject.IsNull() )
1034   {
1035     Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1036     QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1037
1038     ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1039     anObjectState.Visibility = theState;
1040
1041     HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1042     if ( hydroObject )
1043     {
1044         SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1045         QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1046         Qtx::VisibilityState visState = treeModel->visibilityState( id );
1047         if ( visState != Qtx::UnpresentableState )
1048             treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1049     }
1050
1051     if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1052       setLandCoversScalarMapModeOff( theViewId );
1053     }
1054   }
1055 }
1056
1057 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1058                                      const bool theState )
1059 {
1060   if( !theObject.IsNull() )
1061   {
1062     // Process OCC shapes
1063     ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1064     while( aShapesMapIter != myShapesMap.end() )
1065     {
1066       const ListOfShapes& aShapesList = aShapesMapIter.value();
1067       foreach ( HYDROGUI_Shape* aShape, aShapesList )
1068       {
1069         if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1070         {
1071           aShape->setIsToUpdate( theState );
1072         }
1073       }
1074       aShapesMapIter++;
1075     }
1076     // Process VTK shapes
1077     ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1078     while( aVTKPrsMapIter != myVTKPrsMap.end() )
1079     {
1080       const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1081       foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1082       {
1083         if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1084         {
1085           aShape->setIsToUpdate( theState );
1086         }
1087       }
1088       aVTKPrsMapIter++;
1089     }
1090   }
1091 }
1092
1093 /////////////////// OCC SHAPES PROCESSING
1094 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int  theViewId,
1095                                                          ObjectKind theKind ) const
1096 {
1097   QList<HYDROGUI_Shape*> aResult;
1098
1099   if ( myShapesMap.contains( theViewId ) )
1100   {
1101     const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1102     foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1103     {
1104       if( aShape && aShape->getObject()->GetKind()==theKind )
1105         aResult.append( aShape );
1106     }
1107   }
1108   return aResult;
1109 }
1110
1111 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int                       theViewId,
1112                                                  const Handle(HYDROData_Entity)& theObject ) const
1113 {
1114   HYDROGUI_Shape* aResShape = NULL;
1115   if( theObject.IsNull() )
1116     return aResShape;
1117
1118   if ( myShapesMap.contains( theViewId ) )
1119   {
1120     const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1121     foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1122     {
1123       if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1124         continue;
1125
1126       aResShape = aShape;
1127       break;
1128     }
1129   }
1130
1131   return aResShape;
1132 }
1133
1134 void HYDROGUI_Module::setObjectShape( const int                       theViewId,
1135                                       const Handle(HYDROData_Entity)& theObject,
1136                                       HYDROGUI_Shape*                 theShape )
1137 {
1138   if( theObject.IsNull() )
1139     return;
1140
1141   ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1142   aViewShapes.append( theShape );
1143 }
1144
1145 void HYDROGUI_Module::removeObjectShape( const int                       theViewId,
1146                                          const Handle(HYDROData_Entity)& theObject )
1147 {
1148   if ( !myShapesMap.contains( theViewId ) )
1149     return;
1150
1151   ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1152   Handle(HYDROData_Entity) anObject;
1153   for ( int i = 0; i < aViewShapes.length(); )
1154   {
1155     HYDROGUI_Shape* aShape = aViewShapes.at( i );
1156     anObject = aShape->getObject();
1157     if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1158     {
1159       delete aShape;
1160       aViewShapes.removeAt( i );
1161       continue;
1162     }
1163
1164     ++i;
1165   }
1166 }
1167
1168 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1169 {
1170   if ( !myShapesMap.contains( theViewId ) )
1171     return;
1172
1173   const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1174   for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1175   {
1176     HYDROGUI_Shape* aShape = aViewShapes.at( i );
1177     if ( aShape )
1178       delete aShape;
1179   }
1180
1181   myShapesMap.remove( theViewId );
1182 }
1183 /////////////////// END OF OCC SHAPES PROCESSING
1184
1185 /////////////////// VTKPrs PROCESSING
1186 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int                       theViewId,
1187                                                  const Handle(HYDROData_Entity)& theObject ) const
1188 {
1189   HYDROGUI_VTKPrs* aResShape = NULL;
1190   if( theObject.IsNull() )
1191     return aResShape;
1192
1193   if ( myVTKPrsMap.contains( theViewId ) )
1194   {
1195     const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1196     foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1197     {
1198       if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1199         continue;
1200
1201       aResShape = aShape;
1202       break;
1203     }
1204   }
1205
1206   return aResShape;
1207 }
1208
1209 void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId,
1210                                        const Handle(HYDROData_Entity)& theObject,
1211                                        HYDROGUI_VTKPrs*                 theShape )
1212 {
1213   if( theObject.IsNull() )
1214     return;
1215
1216   if( theShape && theShape->needScalarBar() )
1217   {
1218     // Compute the new global Z range from the added presentation and the old global Z range.
1219     double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1220     double* aRange = theShape->getInternalZRange();
1221     bool anIsUpdate = false;
1222     if ( aRange[0] < aGlobalRange[0] )
1223     {
1224       aGlobalRange[0] = aRange[0];
1225       anIsUpdate = true;
1226     }
1227     if ( aRange[1] > aGlobalRange[1] )
1228     {
1229       aGlobalRange[1] = aRange[1];
1230       anIsUpdate = true;
1231     }
1232
1233     //if ( anIsUpdate )
1234     //{
1235       updateVTKZRange( theViewId, aGlobalRange );
1236     //}
1237   }
1238
1239   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1240   aViewShapes.append( theShape );
1241 }
1242
1243 void HYDROGUI_Module::removeObjectVTKPrs( const int      theViewId,
1244                                           const QString& theEntry )
1245 {
1246   if ( !myVTKPrsMap.contains( theViewId ) )
1247     return;
1248
1249   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1250   Handle(HYDROData_Entity) anObject;
1251   QString anEntryRef;
1252   for ( int i = 0; i < aViewShapes.length(); )
1253   {
1254     HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1255     anObject = aShape->getObject();
1256     anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1257     if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1258     {
1259       delete aShape;
1260       aViewShapes.removeAt( i );
1261       continue;
1262     }
1263
1264     ++i;
1265   }
1266
1267   // Invalidate global Z range
1268   double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1269   getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1270 }
1271
1272 void HYDROGUI_Module::removeObjectVTKPrs( const int                       theViewId,
1273                                           const Handle(HYDROData_Entity)& theObject )
1274 {
1275   if ( !myVTKPrsMap.contains( theViewId ) )
1276     return;
1277
1278   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1279   Handle(HYDROData_Entity) anObject;
1280   for ( int i = 0; i < aViewShapes.length(); )
1281   {
1282     HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1283     anObject = aShape->getObject();
1284     if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1285     {
1286       delete aShape;
1287       aViewShapes.removeAt( i );
1288       continue;
1289     }
1290
1291     ++i;
1292   }
1293
1294   // Invalidate global Z range
1295   double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1296   getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1297 }
1298
1299 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1300 {
1301   if ( !myVTKPrsMap.contains( theViewId ) )
1302     return;
1303
1304   const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1305   for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1306   {
1307     HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1308     if ( aShape )
1309       delete aShape;
1310   }
1311
1312   myVTKPrsMap.remove( theViewId );
1313 }
1314
1315 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1316 {
1317   if ( myVTKPrsMap.contains( theViewId ) )
1318   {
1319     // For the given viewer id update all VTK presentations ...
1320     const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1321     HYDROGUI_VTKPrs* aShape;
1322     for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1323     {
1324       aShape = aViewShapes.at( i );
1325       if ( aShape && aShape->needScalarBar() )
1326       {
1327         aShape->setZRange( theRange );
1328       }
1329     }
1330   }
1331   // ... and update the global color legend scalar bar.
1332   getVTKDisplayer()->SetZRange( theViewId, theRange );
1333 }
1334 /////////////////// END OF VTKPrs PROCESSING
1335
1336 CAM_DataModel* HYDROGUI_Module::createDataModel()
1337 {
1338   return new HYDROGUI_DataModel( this );
1339 }
1340
1341 void HYDROGUI_Module::customEvent( QEvent* e )
1342 {
1343   int aType = e->type();
1344   if ( aType == NewViewEvent )
1345   {
1346     SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1347     if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1348     {
1349       if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1350       {
1351         SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1352         ViewManagerRole aRole = getViewManagerRole( aViewManager );
1353
1354         if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1355         {
1356           if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1357             aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1358
1359           aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1360           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1361           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1362
1363           //ouv: temporarily commented
1364           //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1365         }
1366
1367         if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1368           update( UF_Viewer );
1369
1370         aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1371       }
1372     }
1373   }
1374 }
1375
1376 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1377 {
1378   QEvent::Type aType = theEvent->type();
1379   if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1380   {
1381     if( aType == QEvent::Show )
1382     {
1383       SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1384       e->setData( theObj );
1385       QApplication::postEvent( this, e );
1386       theObj->removeEventFilter( this );
1387     }
1388   }
1389   else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1390   {
1391     if( aType == QEvent::Leave )
1392     {
1393       SUIT_Desktop* aDesktop = getApp()->desktop();
1394       if ( aDesktop && aDesktop->statusBar() ) {
1395         aDesktop->statusBar()->clearMessage();
1396       }
1397     }
1398   }
1399   else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1400   {
1401     if( aType == QEvent::Leave )
1402     {
1403       SUIT_Desktop* aDesktop = getApp()->desktop();
1404       if ( aDesktop && aDesktop->statusBar() ) {
1405         aDesktop->statusBar()->clearMessage();
1406       }
1407     }
1408   }
1409
1410   return LightApp_Module::eventFilter( theObj, theEvent );
1411 }
1412
1413 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1414 {
1415   LightApp_Module::onViewManagerAdded( theViewManager );
1416
1417   if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1418   { 
1419     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1420              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1421   }
1422   else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1423   {
1424     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1425              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1426     connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1427              this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1428   }
1429   else if( theViewManager->getType() == SVTK_Viewer::Type() )
1430   {
1431     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1432              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1433     connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1434              this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1435   }
1436
1437   createSelector( theViewManager ); // replace the default selector
1438
1439   ViewManagerInfo anInfo( theViewManager, VMR_General );
1440   myViewManagerMap.insert( ViewManagerId++, anInfo );
1441 }
1442
1443 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1444 {
1445   LightApp_Module::onViewManagerRemoved( theViewManager );
1446
1447   createSelector( theViewManager ); // replace the default selector
1448
1449   int anId = getViewManagerId( theViewManager );
1450   if( anId != -1 )
1451   {
1452     OCCViewer_ViewManager* anOCCViewManager =
1453       ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1454     if ( anOCCViewManager )
1455     {
1456       OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1457       if ( anOCCViewer ) {
1458         int aViewerId = (size_t)anOCCViewer;
1459         removeViewShapes( aViewerId );
1460         setLandCoversScalarMapModeOff( aViewerId );
1461       }
1462     }
1463
1464     if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1465     {
1466       SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1467       if ( aVTKViewer )
1468       {
1469         getVTKDisplayer()->EraseScalarBar( anId, true );
1470         removeViewShapes( (size_t)aVTKViewer );
1471       }
1472     }
1473
1474     myViewManagerMap.remove( anId );
1475   }
1476 }
1477
1478 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1479 {
1480   if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1481   {
1482     if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1483     {
1484       aViewFrame->installEventFilter( this );
1485
1486       GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1487
1488       connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1489                this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1490     }
1491   }
1492   else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1493   {
1494     if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1495     {
1496       aViewFrame->onTopView();
1497
1498       HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1499
1500       OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1501       if ( aViewPort ) {
1502         aViewPort->installEventFilter( this );
1503       }
1504     }
1505   }
1506   else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1507   {
1508     if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1509     {
1510       aViewFrame->installEventFilter( this );
1511     }
1512   }
1513 }
1514
1515 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1516 {
1517   /* ouv: currently unused
1518   if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1519   {
1520     SUIT_ViewManager* aViewManager = 0;
1521
1522     QObject* aParent = aViewPort;
1523     while( aParent = aParent->parent() )
1524     {
1525       if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1526       {
1527         if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1528         {
1529           aViewManager = aViewer->getViewManager();
1530           break;
1531         }
1532       }
1533     }
1534
1535     if( !aViewManager )
1536       return;
1537
1538     double aMouseX = theEvent->scenePos().x();
1539     double aMouseY = theEvent->scenePos().y();
1540
1541     ViewManagerRole aRole = getViewManagerRole( aViewManager );
1542     if( aRole == VMR_General )
1543     {
1544       int aXDeg = 0, aYDeg = 0;
1545       int aXMin = 0, aYMin = 0;
1546       double aXSec = 0, aYSec = 0;
1547       HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1548       HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1549
1550       QString aDegSymbol( QChar( 0x00B0 ) );
1551       QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1552       QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1553
1554       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1555     }
1556     else if( aRole == VMR_TransformImage )
1557       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1558   }
1559   */
1560 }
1561
1562 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, 
1563                                     const bool theIsInit, 
1564                                     const bool theIsForced, 
1565                                     const bool theDoFitAll )
1566 {
1567   QList<int> aViewManagerIdList;
1568
1569   // currently, all views are updated
1570   ViewManagerMapIterator anIter( myViewManagerMap );
1571   while( anIter.hasNext() )
1572   { 
1573     SUIT_ViewManager* aViewManager = anIter.next().value().first;
1574
1575     if ( theDisplayer->IsApplicable( aViewManager ) )
1576     {
1577       int anId = anIter.key();
1578       aViewManagerIdList.append( anId );
1579     }
1580   }
1581
1582   QListIterator<int> anIdIter( aViewManagerIdList );
1583   while( anIdIter.hasNext() )
1584   {
1585     theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1586   }
1587 }
1588
1589 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1590 {
1591   if( !theViewManager )
1592     return;
1593
1594   LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1595   if( !aSelectionMgr )
1596     return;
1597
1598   QString aViewType = theViewManager->getType();
1599   if( aViewType != GraphicsView_Viewer::Type() &&
1600       aViewType != OCCViewer_Viewer::Type())
1601     return;
1602
1603   QList<SUIT_Selector*> aSelectorList;
1604   aSelectionMgr->selectors( aViewType, aSelectorList );
1605
1606   // disable all alien selectors
1607   QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1608   for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1609   {
1610     SUIT_Selector* aSelector = *anIter;
1611     if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1612                        !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1613                        !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1614       aSelector->setEnabled( false );
1615   }
1616
1617   if ( aViewType == GraphicsView_Viewer::Type() )
1618   {
1619     GraphicsView_ViewManager* aViewManager =
1620       ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1621     if( aViewManager )
1622       new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1623   }
1624   else if ( aViewType == OCCViewer_Viewer::Type() )
1625   {
1626     OCCViewer_ViewManager* aViewManager =
1627       ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1628     if( aViewManager )
1629       new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1630   }
1631 }
1632
1633 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1634 {
1635   bool aPrevState = myIsUpdateEnabled;
1636   myIsUpdateEnabled = theState;
1637   return aPrevState;
1638 }
1639
1640 bool HYDROGUI_Module::isUpdateEnabled() const
1641 {
1642   return myIsUpdateEnabled;
1643 }
1644
1645 QStringList HYDROGUI_Module::storeSelection() const
1646 {
1647   QStringList anEntryList;
1648   if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1649   {
1650     SUIT_DataOwnerPtrList aList( true );
1651     aSelectionMgr->selected( aList );
1652
1653     SUIT_DataOwnerPtrList::iterator anIter;
1654     for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1655     {
1656       const LightApp_DataOwner* anOwner = 
1657         dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1658       if( anOwner )
1659         anEntryList.append( anOwner->entry() );
1660     }
1661   }
1662   return anEntryList;
1663 }
1664
1665 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1666 {
1667   if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1668   {
1669     SUIT_DataOwnerPtrList aList( true );
1670     for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1671       aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1672     aSelectionMgr->setSelected( aList );
1673   }
1674 }
1675
1676 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1677 {
1678   double X, Y, Z;
1679   bool doShow = false;
1680   HYDROGUI_Displayer* aDisplayer = getDisplayer();
1681   if ( aDisplayer )
1682     aDisplayer->SaveCursorViewPosition( theViewWindow );
1683     doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1684
1685   if ( doShow )
1686   {
1687     // Show the coordinates in the status bar
1688     SUIT_Desktop* aDesktop = getApp()->desktop();
1689     if ( aDesktop && aDesktop->statusBar() )
1690     {
1691       gp_Pnt aWPnt( X, Y, Z );
1692       int aStudyId = application()->activeStudy()->id();
1693       HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
1694       double WX = aWPnt.X(), WY = aWPnt.Y();
1695
1696       QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1697       QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1698       QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1699       QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1700       QString aMsg = tr( "COORDINATES_INFO" );
1701       aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1702       aDesktop->statusBar()->showMessage( aMsg );
1703     }
1704   }
1705 }
1706
1707 /**
1708  * Returns stack of active operations;
1709  */
1710 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
1711 {
1712   return myActiveOperationMap;
1713 }
1714
1715 /**
1716  * Returns the module active operation. If the active operation is show/hide,
1717  * the method returns the previous operation if it is.
1718  */
1719 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
1720 {
1721   HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
1722
1723   if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
1724   {
1725     QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
1726     aVIt.toBack();
1727     aVIt.previous(); // skip the top show/hide operation
1728     anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
1729   }
1730
1731   return anOp;
1732 }
1733
1734 /*!
1735  * \brief Virtual public slot
1736  *
1737  * This method is called after the object inserted into data view to update their visibility state
1738  * This is default implementation
1739  */
1740 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
1741 {
1742   if ( !isActiveModule() )
1743       return;
1744
1745   HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
1746
1747   // change visibility of object
1748   if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
1749       return;
1750
1751   SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1752
1753   QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
1754   Qtx::VisibilityState visState = treeModel->visibilityState( id );
1755   if ( visState == Qtx::UnpresentableState )
1756       return;
1757
1758   visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
1759   treeModel->setVisibilityState( id, visState );
1760
1761   bool vis = visState == Qtx::ShownState;
1762   if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
1763       return;
1764
1765   setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
1766
1767   update( UF_OCCViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
1768 }
1769
1770 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
1771 {
1772   Handle(HYDROData_StricklerTable) aTable;
1773
1774   if ( myLandCoverColoringMap.contains( theViewId ) ) {
1775     aTable = myLandCoverColoringMap.value( theViewId );
1776   }
1777
1778   return aTable;
1779 }
1780
1781 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
1782                                                  const Handle(HYDROData_StricklerTable)& theTable )
1783 {
1784   if ( !theTable.IsNull() ) {
1785     myLandCoverColoringMap.insert( theViewId, theTable );
1786   }
1787 }
1788
1789 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
1790 {
1791   myLandCoverColoringMap.remove( theViewId );
1792 }
1793
1794 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
1795 {
1796   return myLandCoverColoringMap.contains( theViewId );
1797 }