Salome HOME
Update mechanism for calculation case and it child objects corrected.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_Module.cxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #include "HYDROGUI_Module.h"
24
25 #include "HYDROGUI.h"
26 #include "HYDROGUI_DataModel.h"
27 #include "HYDROGUI_Displayer.h"
28 #include "HYDROGUI_GVSelector.h"
29 #include "HYDROGUI_InputPanel.h"
30 #include "HYDROGUI_ObjSelector.h"
31 #include "HYDROGUI_OCCDisplayer.h"
32 #include "HYDROGUI_OCCSelector.h"
33 #include "HYDROGUI_Operations.h"
34 #include "HYDROGUI_PrsImage.h"
35 #include "HYDROGUI_Tool.h"
36 #include "HYDROGUI_UpdateFlags.h"
37 #include "HYDROGUI_Shape.h"
38 #include "HYDROGUI_VTKPrs.h"
39 #include "HYDROGUI_VTKPrsDisplayer.h"
40 #include "HYDROGUI_AbstractDisplayer.h"
41 #include "HYDROGUI_PolylineOp.h"
42
43 #include <HYDROData_Image.h>
44 #include <HYDROData_Profile.h>
45 #include <HYDROData_Lambert93.h>
46 #include <HYDROData_Tool.h>
47
48 #include <HYDROData_OperationsFactory.h>
49
50 #include <GraphicsView_ViewFrame.h>
51 #include <GraphicsView_ViewManager.h>
52 #include <GraphicsView_ViewPort.h>
53 #include <GraphicsView_Viewer.h>
54
55 #include <ImageComposer_CutOperator.h>
56 #include <ImageComposer_CropOperator.h>
57 #include <ImageComposer_FuseOperator.h>
58
59 #include <LightApp_Application.h>
60 #include <LightApp_DataOwner.h>
61 #include <LightApp_GVSelector.h>
62 #include <LightApp_SelectionMgr.h>
63 #include <LightApp_UpdateFlags.h>
64
65 #include <OCCViewer_ViewFrame.h>
66 #include <OCCViewer_ViewManager.h>
67 #include <OCCViewer_ViewModel.h>
68
69 #include <SALOME_Event.h>
70
71 #include <SUIT_DataBrowser.h>
72 #include <SUIT_Desktop.h>
73 #include <SUIT_Study.h>
74 #include <SUIT_ViewManager.h>
75
76 #include <SVTK_ViewManager.h>
77 #include <SVTK_ViewModel.h>
78 #include <SVTK_Selector.h>
79
80 #include <OCCViewer_ViewPort3d.h>
81
82 #include <GEOMUtils.hxx>
83
84 #include <QAction>
85 #include <QApplication>
86 #include <QGraphicsSceneMouseEvent>
87 #include <QMenu>
88 #include <QMouseEvent>
89 #include <QStatusBar>
90
91 static int ViewManagerId = 0;
92
93 extern "C" HYDRO_EXPORT CAM_Module* createModule()
94 {
95   return new HYDROGUI_Module();
96 }
97
98 extern "C" HYDRO_EXPORT char* getModuleVersion()
99 {
100   return (char*)HYDRO_VERSION;
101 }
102
103 HYDROGUI_Module::HYDROGUI_Module()
104 : LightApp_Module( "HYDRO" ),
105   myDisplayer( 0 ),
106   myOCCDisplayer( 0 ),
107   myIsUpdateEnabled( true )
108 {
109 }
110
111 HYDROGUI_Module::~HYDROGUI_Module()
112 {
113 }
114
115 int HYDROGUI_Module::getStudyId() const
116 {
117   LightApp_Application* anApp = getApp();
118   return anApp ? anApp->activeStudy()->id() : 0;
119 }
120
121 void HYDROGUI_Module::initialize( CAM_Application* theApp )
122 {
123   LightApp_Module::initialize( theApp );
124
125   createActions();
126   createUndoRedoActions();
127   createMenus();
128   createPopups();
129   createToolbars();
130
131   setMenuShown( false );
132   setToolShown( false );
133
134   myDisplayer = new HYDROGUI_Displayer( this );
135   myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
136   myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
137 }
138
139 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
140 {
141   bool aRes = LightApp_Module::activateModule( theStudy );
142
143   LightApp_Application* anApp = getApp();
144   SUIT_Desktop* aDesktop = anApp->desktop();
145
146   getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
147
148   setMenuShown( true );
149   setToolShown( true );
150
151 #ifndef DISABLE_PYCONSOLE
152   aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ), 
153                               HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
154 #endif
155
156   update( UF_All );
157
158   updateCommandsStatus();
159
160   connect( anApp, SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ), 
161            this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
162
163   HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
164
165   ViewManagerList anOCCViewManagers;
166   anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
167   foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
168     connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
169              this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
170     foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() ) {
171       OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
172       if ( aViewFrame && aViewFrame->getViewPort() ) {
173         aViewFrame->getViewPort()->installEventFilter( this );
174       }
175     }
176   }
177
178   return aRes;
179 }
180
181 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
182 {
183   ViewManagerMapIterator anIter( myViewManagerMap );
184   while( anIter.hasNext() )
185     if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
186       getApp()->removeViewManager( aViewManager );
187   myViewManagerMap.clear();
188
189   ViewManagerList anOCCViewManagers;
190   getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
191   foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
192     disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
193                 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
194   }
195
196   myObjectStateMap.clear();
197   myShapesMap.clear();
198   myVTKPrsMap.clear();
199
200   // clear the data model's list of copying objects
201   HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
202
203   setMenuShown( false );
204   setToolShown( false );
205
206   getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
207
208   disconnect( getApp(), SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ), 
209               this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
210
211   HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
212
213   return LightApp_Module::deactivateModule( theStudy );
214 }
215
216 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
217 {
218   theMap.clear();
219   theMap.insert( LightApp_Application::WT_LogWindow,     Qt::BottomDockWidgetArea );
220 #ifndef DISABLE_PYCONSOLE
221   theMap.insert( LightApp_Application::WT_PyConsole,     Qt::BottomDockWidgetArea );
222 #endif
223   theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea   );
224 }
225
226 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
227 {
228   theTypesList << OCCViewer_Viewer::Type() << GraphicsView_Viewer::Type();
229 }
230
231 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
232                                         QMenu* theMenu,
233                                         QString& theTitle )
234 {
235   HYDROGUI_DataModel* aModel = getDataModel();
236
237   bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
238   bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
239   bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
240   bool anIsVTKView = theClient == SVTK_Viewer::Type();
241   if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
242     return;
243
244   size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
245
246   bool anIsSelectedDataObjects = false;
247   bool anIsVisibleInSelection = false;
248   bool anIsHiddenInSelection = false;
249
250   bool anIsImage = false;
251   bool anIsImportedImage = false;
252   bool anIsImageHasRefs = false;
253   bool anIsFusedImage = false;
254   bool anIsCutImage = false;
255   bool anIsSplittedImage = false;
256   bool anIsMustObjectBeUpdated = false;
257   bool anIsPolyline = false;
258   bool anIsPolyline3D = false;
259   bool anIsProfile = false;
260   bool anIsValidProfile = false;
261   bool anAllAreProfiles = false;
262   bool anIsBathymetry = false;
263   bool anIsCalculation = false;
264   bool anIsImmersibleZone = false;
265   bool anIsVisualState = false;
266   bool anIsRegion = false;
267   bool anIsZone = false;
268   bool anIsObstacle = false;
269   bool anIsStream = false;
270   bool anIsChannel = false;
271   bool anIsGeomObject = false;
272
273   // check the selected GEOM objects
274   if ( !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
275     theMenu->addAction( action( ImportGeomObjectId ) );
276     theMenu->addSeparator();
277   }
278
279   // check the selected data model objects
280   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
281   int aNbOfSelectedProfiles = 0;
282   for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
283   {
284     Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
285     if( !anObject.IsNull() )
286     {
287       anIsSelectedDataObjects = true;
288
289       bool aVisibility = isObjectVisible( anActiveViewId, anObject );
290       anIsVisibleInSelection |= aVisibility;
291       anIsHiddenInSelection |= !aVisibility;
292
293       if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() )
294       {
295         anIsMustObjectBeUpdated = true;
296       }
297
298       ObjectKind anObjectKind = anObject->GetKind();
299       if( anObjectKind == KIND_IMAGE )
300       {
301         anIsImage = true;
302         Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
303         if( !anImage.IsNull() )
304         {
305           anIsImportedImage = anImage->HasLocalPoints();
306           anIsImageHasRefs = anImage->HasReferences();
307           if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
308           {
309             if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
310             {
311               QString anOperatorName = anOperator->name();
312               if( anOperatorName == ImageComposer_FuseOperator::Type() )
313                 anIsFusedImage = true;
314               else if( anOperatorName == ImageComposer_CutOperator::Type() )
315                 anIsCutImage = true;
316               else if( anOperatorName == ImageComposer_CropOperator::Type() )
317                 anIsSplittedImage = true;
318             }
319           }
320         }
321       }
322       else if( anObjectKind == KIND_POLYLINEXY )
323         anIsPolyline = true;
324       else if( anObjectKind == KIND_POLYLINE )
325         anIsPolyline3D = true;
326       else if( anObjectKind == KIND_PROFILE )
327       {
328         anIsProfile = true;
329         aNbOfSelectedProfiles++;
330
331         Handle(HYDROData_Profile) aProfile = 
332           Handle(HYDROData_Profile)::DownCast( anObject );
333         if( !aProfile.IsNull() && aProfile->IsValid() ) {
334           anIsValidProfile = true;
335         }
336       }
337       else if( anObjectKind == KIND_CALCULATION )
338         anIsCalculation = true;
339       else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
340         anIsImmersibleZone = true;
341       else if( anObjectKind == KIND_VISUAL_STATE )
342         anIsVisualState = true;
343       else if( anObjectKind == KIND_REGION )
344         anIsRegion = true;
345       else if( anObjectKind == KIND_ZONE )
346         anIsZone = true;
347       else if( anObjectKind == KIND_BATHYMETRY )
348         anIsBathymetry = true;
349       else if( anObjectKind == KIND_OBSTACLE )
350         anIsObstacle = true;
351       else if( anObjectKind == KIND_STREAM )
352         anIsStream = true;
353       else if( anObjectKind == KIND_CHANNEL )
354         anIsChannel = true;
355     }
356
357     anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
358   }
359
360   // Check if all selected objects are profiles
361   anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
362                      ( aNbOfSelectedProfiles == aSeq.Length() );
363
364   // check the selected partitions
365   if( !anIsSelectedDataObjects && anIsObjectBrowser )
366   {
367     ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
368     if( aSelectedPartition != KIND_UNKNOWN )
369     {
370       switch( aSelectedPartition )
371       {
372         case KIND_IMAGE:
373           theMenu->addAction( action( ImportImageId ) );
374           break;
375         case KIND_BATHYMETRY:
376           theMenu->addAction( action( ImportBathymetryId ) );
377           break;
378         case KIND_ARTIFICIAL_OBJECT:
379           theMenu->addAction( action( CreateChannelId ) );
380           break;
381         case KIND_NATURAL_OBJECT:
382           theMenu->addAction( action( CreateImmersibleZoneId ) );
383           theMenu->addAction( action( CreateStreamId ) );
384           break;
385         case KIND_OBSTACLE:
386           theMenu->addAction( action( ImportObstacleFromFileId ) );
387           theMenu->addAction( action( CreateBoxId ) );
388           theMenu->addAction( action( CreateCylinderId ) );
389           break;
390         case KIND_CALCULATION:
391           theMenu->addAction( action( CreateCalculationId ) );
392           break;
393         case KIND_POLYLINEXY:
394           theMenu->addAction( action( CreatePolylineId ) );
395           break;
396         case KIND_POLYLINE:
397           theMenu->addAction( action( CreatePolyline3DId ) );
398           break;
399         case KIND_PROFILE:
400           theMenu->addAction( action( CreateProfileId ) );
401           theMenu->addAction( action( ImportProfilesId ) );
402           theMenu->addAction( action( AllGeoreferencementId ) );
403           break;
404         case KIND_VISUAL_STATE:
405           theMenu->addAction( action( SaveVisualStateId ) );
406           break;
407       }
408       theMenu->addSeparator();
409     }
410   }
411
412   if( anIsSelectedDataObjects )
413   {
414     if ( anIsMustObjectBeUpdated )
415     {
416       theMenu->addAction( action( UpdateObjectId ) );
417       theMenu->addSeparator();
418     }
419
420     if( aSeq.Length() == 1 )
421     {
422       if( anIsImage )
423       {
424         if( anIsImportedImage )
425           theMenu->addAction( action( EditImportedImageId ) );
426         else if( anIsImageHasRefs )
427         {
428           if( anIsFusedImage )
429             theMenu->addAction( action( EditFusedImageId ) );
430           else if( anIsCutImage )
431             theMenu->addAction( action( EditCutImageId ) );
432           else if( anIsSplittedImage )
433             theMenu->addAction( action( EditSplittedImageId ) );
434         }
435
436         //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
437         theMenu->addAction( action( ExportImageId ) );
438         theMenu->addSeparator();
439
440         if( anIsImageHasRefs )
441         {
442           theMenu->addAction( action( RemoveImageRefsId ) );
443           theMenu->addSeparator();
444         }
445
446         theMenu->addAction( action( FuseImagesId ) );
447         theMenu->addAction( action( CutImagesId ) );
448         theMenu->addAction( action( SplitImageId ) );
449         theMenu->addSeparator();
450       }
451       else if( anIsBathymetry )
452       {
453         theMenu->addAction( action( EditImportedBathymetryId ) );
454         theMenu->addSeparator();
455       }
456       else if( anIsPolyline )
457       {
458         theMenu->addAction( action( EditPolylineId ) );
459         theMenu->addSeparator();
460       }
461       else if( anIsPolyline3D )
462       {
463         theMenu->addAction( action( EditPolyline3DId ) );
464         theMenu->addSeparator();
465       }
466       else if( anIsProfile )
467       {
468         theMenu->addAction( action( EditProfileId ) );
469         theMenu->addAction( action( SelectedGeoreferencementId ) );
470         theMenu->addSeparator();
471       }
472       else if( anIsCalculation )
473       {
474         theMenu->addAction( action( EditCalculationId ) );
475         theMenu->addAction( action( ExportCalculationId ) );
476         theMenu->addSeparator();
477       }
478       else if( anIsImmersibleZone )
479       {
480         theMenu->addAction( action( EditImmersibleZoneId ) );
481         theMenu->addSeparator();
482       }
483       else if( anIsStream )
484       {
485         theMenu->addAction( action( EditStreamId ) );
486         theMenu->addSeparator();
487       }
488       else if( anIsChannel )
489       {
490         theMenu->addAction( action( EditChannelId ) );
491         theMenu->addSeparator();
492       }
493       else if( anIsVisualState && anIsObjectBrowser )
494       {
495         theMenu->addAction( action( SaveVisualStateId ) );
496         theMenu->addAction( action( LoadVisualStateId ) );
497         theMenu->addSeparator();
498       }
499
500       // Add set color action for geometrical objects
501       if ( anIsGeomObject )
502       {
503         theMenu->addAction( action( SetColorId ) );
504         theMenu->addSeparator();
505       }
506     } else if ( anAllAreProfiles ) {
507       theMenu->addAction( action( SelectedGeoreferencementId ) );
508       theMenu->addSeparator();
509     }
510
511     theMenu->addAction( action( DeleteId ) );
512     theMenu->addSeparator();
513
514     if( anIsImage || anIsPolyline || anIsPolyline3D || 
515         anIsImmersibleZone || anIsZone || anIsRegion ||
516         anIsBathymetry || anIsObstacle || anIsStream ||
517         anIsChannel || anIsValidProfile )
518     {
519       if( anIsHiddenInSelection )
520         theMenu->addAction( action( ShowId ) );
521       theMenu->addAction( action( ShowOnlyId ) );
522       if( anIsVisibleInSelection )
523         theMenu->addAction( action( HideId ) );
524       theMenu->addSeparator();
525     }
526   }
527
528   if ( anIsOCCView )
529   {
530     SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
531     HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
532     if ( aPolylineOp && aPolylineOp->deleteEnabled() )
533       theMenu->addAction( action( DeleteId ) );
534   }
535
536   if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
537   {
538     theMenu->addAction( action( ShowAllId ) );
539     theMenu->addAction( action( HideAllId ) );
540     theMenu->addSeparator();
541   }
542 }
543
544 void HYDROGUI_Module::update( const int flags )
545 {
546   if( !isUpdateEnabled() )
547     return;
548
549   QApplication::setOverrideCursor( Qt::WaitCursor );
550
551   // To prevent calling this method recursively
552   // from one of the methods called below
553   setUpdateEnabled( false );
554
555   // store selected objects
556   QStringList aSelectedEntries = storeSelection();
557
558   bool aDoFitAll = flags & UF_FitAll;
559   if( ( flags & UF_Viewer ) )
560     updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll ); 
561
562   if( ( flags & UF_OCCViewer ) )
563     updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll ); 
564
565   if( ( flags & UF_VTKViewer ) )
566     updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll ); 
567
568   if( ( flags & UF_Model ) && getDataModel() && getApp() )
569   {
570     getDataModel()->update( getStudyId() );
571
572     // Temporary workaround to prevent breaking
573     // the selection in the object browser.
574     // Note: processEvents() should be called after updateGV(),
575     // otherwise the application crashes from time to time.
576     //RKV: qApp->processEvents(); 
577     getApp()->updateObjectBrowser( true );
578   }
579
580   // Object browser is currently updated by using UF_Model flag
581   if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
582     getApp()->updateObjectBrowser( true );
583
584   if( ( flags & UF_Controls ) && getApp() )
585     getApp()->updateActions();
586
587   // restore selected objects
588   restoreSelection( aSelectedEntries );
589
590   setUpdateEnabled( true );
591
592   QApplication::restoreOverrideCursor();
593 }
594
595 void HYDROGUI_Module::updateCommandsStatus()
596 {
597   LightApp_Module::updateCommandsStatus();
598
599   updateUndoRedoControls();
600
601   action( CopyId )->setEnabled( getDataModel()->canCopy() );
602   action( PasteId )->setEnabled( getDataModel()->canPaste() );
603 }
604
605 void HYDROGUI_Module::selectionChanged()
606 {
607   LightApp_Module::selectionChanged();
608   updateCommandsStatus();
609 }
610
611 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
612 {
613   return (HYDROGUI_DataModel*)dataModel();
614 }
615
616 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
617 {
618   return myDisplayer;
619 }
620
621 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
622 {
623   return myOCCDisplayer;
624 }
625
626 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
627 {
628   return myVTKDisplayer;
629 }
630
631 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
632 {
633   if( myViewManagerMap.contains( theId ) )
634   {
635     return myViewManagerMap[ theId ].first;
636   }
637   return NULL;
638 }
639
640 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
641 {
642   if( myViewManagerMap.contains( theId ) )
643   {
644     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
645     GraphicsView_ViewManager* aViewManager =
646       dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
647     if( aViewManager )
648       return aViewManager->getViewer();
649   }
650   return NULL;
651 }
652
653 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
654 {
655   if( myViewManagerMap.contains( theId ) )
656   {
657     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
658     OCCViewer_ViewManager* aViewManager =
659       ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
660     if( aViewManager )
661       return aViewManager->getOCCViewer();
662   }
663   return NULL;
664 }
665
666 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
667 {
668   if( myViewManagerMap.contains( theId ) )
669   {
670     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
671     SVTK_ViewManager* aViewManager =
672       ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
673     if( aViewManager )
674       return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
675   }
676   return NULL;
677 }
678
679 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
680 {
681   ViewManagerMapIterator anIter( myViewManagerMap );
682   while( anIter.hasNext() )
683   {
684     int anId = anIter.next().key();
685     const ViewManagerInfo& anInfo = anIter.value();
686     if( anInfo.first == theViewManager )
687       return anId;
688   }
689   return -1;
690 }
691
692 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
693 {
694   int anId = getViewManagerId( theViewManager );
695   if( anId != -1 )
696   {
697     const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
698     return anInfo.second;
699   }
700   return VMR_Unknown;
701 }
702
703 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
704                                           const ViewManagerRole theRole )
705 {
706   int anId = getViewManagerId( theViewManager );
707   if( anId != -1 )
708   {
709     ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
710     anInfo.second = theRole;
711   }
712 }
713
714 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
715                                        const Handle(HYDROData_Entity)& theObject ) const
716 {
717   if( theObject.IsNull() )
718     return false;
719
720   ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
721   if( anIter1 != myObjectStateMap.end() )
722   {
723     const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
724     Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
725     if( anIter2 != aName2ObjectStateMap.end() )
726     {
727       const ObjectState& anObjectState = anIter2.value();
728       return anObjectState.Visibility;
729     }
730   }
731   return false;
732 }
733
734 void HYDROGUI_Module::setObjectVisible( const int theViewId,
735                                         const Handle(HYDROData_Entity)& theObject,
736                                         const bool theState )
737 {
738   if( !theObject.IsNull() )
739   {
740     Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
741     ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
742     anObjectState.Visibility = theState;
743   }
744 }
745
746 /////////////////// OCC SHAPES PROCESSING
747 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int                       theViewId,
748                                                  const Handle(HYDROData_Entity)& theObject ) const
749 {
750   HYDROGUI_Shape* aResShape = NULL;
751   if( theObject.IsNull() )
752     return aResShape;
753
754   if ( myShapesMap.contains( theViewId ) )
755   {
756     const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
757     foreach ( HYDROGUI_Shape* aShape, aViewShapes )
758     {
759       if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
760         continue;
761
762       aResShape = aShape;
763       break;
764     }
765   }
766
767   return aResShape;
768 }
769
770 void HYDROGUI_Module::setObjectShape( const int                       theViewId,
771                                       const Handle(HYDROData_Entity)& theObject,
772                                       HYDROGUI_Shape*                 theShape )
773 {
774   if( theObject.IsNull() )
775     return;
776
777   ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
778   aViewShapes.append( theShape );
779 }
780
781 void HYDROGUI_Module::removeObjectShape( const int                       theViewId,
782                                          const Handle(HYDROData_Entity)& theObject )
783 {
784   if ( !myShapesMap.contains( theViewId ) )
785     return;
786
787   ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
788   Handle(HYDROData_Entity) anObject;
789   for ( int i = 0; i < aViewShapes.length(); )
790   {
791     HYDROGUI_Shape* aShape = aViewShapes.at( i );
792     anObject = aShape->getObject();
793     if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
794     {
795       delete aShape;
796       aViewShapes.removeAt( i );
797       continue;
798     }
799
800     ++i;
801   }
802 }
803
804 void HYDROGUI_Module::removeViewShapes( const int theViewId )
805 {
806   if ( !myShapesMap.contains( theViewId ) )
807     return;
808
809   const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
810   for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
811   {
812     HYDROGUI_Shape* aShape = aViewShapes.at( i );
813     if ( aShape )
814       delete aShape;
815   }
816
817   myShapesMap.remove( theViewId );
818 }
819 /////////////////// END OF OCC SHAPES PROCESSING
820
821 /////////////////// VTKPrs PROCESSING
822 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int                       theViewId,
823                                                  const Handle(HYDROData_Entity)& theObject ) const
824 {
825   HYDROGUI_VTKPrs* aResShape = NULL;
826   if( theObject.IsNull() )
827     return aResShape;
828
829   if ( myVTKPrsMap.contains( theViewId ) )
830   {
831     const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
832     foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
833     {
834       if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
835         continue;
836
837       aResShape = aShape;
838       break;
839     }
840   }
841
842   return aResShape;
843 }
844
845 void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId,
846                                        const Handle(HYDROData_Entity)& theObject,
847                                        HYDROGUI_VTKPrs*                 theShape )
848 {
849   if( theObject.IsNull() )
850     return;
851
852   // Compute the new global Z range from the added presentation and the old global Z range.
853   double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
854   double* aRange = theShape->getInternalZRange();
855   bool anIsUpdate = false;
856   if ( aRange[0] < aGlobalRange[0] )
857   {
858     aGlobalRange[0] = aRange[0];
859     anIsUpdate = true;
860   }
861   if ( aRange[1] > aGlobalRange[1] )
862   {
863     aGlobalRange[1] = aRange[1];
864     anIsUpdate = true;
865   }
866
867   //if ( anIsUpdate )
868   //{
869     updateVTKZRange( theViewId, aGlobalRange );
870   //}
871
872   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
873   aViewShapes.append( theShape );
874 }
875
876 void HYDROGUI_Module::removeObjectVTKPrs( const int                       theViewId,
877                                           const Handle(HYDROData_Entity)& theObject )
878 {
879   if ( !myVTKPrsMap.contains( theViewId ) )
880     return;
881
882   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
883   Handle(HYDROData_Entity) anObject;
884   for ( int i = 0; i < aViewShapes.length(); )
885   {
886     HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
887     anObject = aShape->getObject();
888     if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
889     {
890       delete aShape;
891       aViewShapes.removeAt( i );
892       continue;
893     }
894
895     ++i;
896   }
897
898   // Invalidate global Z range
899   double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
900   getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
901 }
902
903 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
904 {
905   if ( !myVTKPrsMap.contains( theViewId ) )
906     return;
907
908   const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
909   for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
910   {
911     HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
912     if ( aShape )
913       delete aShape;
914   }
915
916   myVTKPrsMap.remove( theViewId );
917 }
918
919 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
920 {
921   if ( myVTKPrsMap.contains( theViewId ) )
922   {
923     // For the given viewer id update all VTK presentations ...
924     const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
925     HYDROGUI_VTKPrs* aShape;
926     for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
927     {
928       aShape = aViewShapes.at( i );
929       if ( aShape )
930       {
931         aShape->setZRange( theRange );
932       }
933     }
934   }
935   // ... and update the global color legend scalar bar.
936   getVTKDisplayer()->SetZRange( theViewId, theRange );
937 }
938 /////////////////// END OF VTKPrs PROCESSING
939
940 CAM_DataModel* HYDROGUI_Module::createDataModel()
941 {
942   return new HYDROGUI_DataModel( this );
943 }
944
945 void HYDROGUI_Module::customEvent( QEvent* e )
946 {
947   int aType = e->type();
948   if ( aType == NewViewEvent )
949   {
950     SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
951     if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
952     {
953       if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
954       {
955         SUIT_ViewManager* aViewManager = aViewer->getViewManager();
956         ViewManagerRole aRole = getViewManagerRole( aViewManager );
957
958         if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
959         {
960           if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
961             aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
962
963           aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
964           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
965           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
966
967           //ouv: temporarily commented
968           //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
969         }
970
971         if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
972           update( UF_Viewer );
973
974         aViewer->activateTransform( GraphicsView_Viewer::FitAll );
975       }
976     }
977   }
978 }
979
980 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
981 {
982   QEvent::Type aType = theEvent->type();
983   if( theObj->inherits( "GraphicsView_ViewFrame" ) )
984   {
985     if( aType == QEvent::Show )
986     {
987       SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
988       e->setData( theObj );
989       QApplication::postEvent( this, e );
990       theObj->removeEventFilter( this );
991     }
992   }
993   else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
994   {
995     if( aType == QEvent::Leave )
996     {
997       SUIT_Desktop* aDesktop = getApp()->desktop();
998       if ( aDesktop && aDesktop->statusBar() ) {
999         aDesktop->statusBar()->clearMessage();
1000       }
1001     }
1002   }
1003
1004   return LightApp_Module::eventFilter( theObj, theEvent );
1005 }
1006
1007 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1008 {
1009   LightApp_Module::onViewManagerAdded( theViewManager );
1010
1011   if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1012   { 
1013     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1014              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1015   }
1016   else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1017   {
1018     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1019              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1020     connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1021              this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1022   }
1023
1024   createSelector( theViewManager ); // replace the default selector
1025
1026   ViewManagerInfo anInfo( theViewManager, VMR_General );
1027   myViewManagerMap.insert( ViewManagerId++, anInfo );
1028 }
1029
1030 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1031 {
1032   LightApp_Module::onViewManagerRemoved( theViewManager );
1033
1034   createSelector( theViewManager ); // replace the default selector
1035
1036   int anId = getViewManagerId( theViewManager );
1037   if( anId != -1 )
1038   {
1039     OCCViewer_ViewManager* anOCCViewManager =
1040       ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1041     if ( anOCCViewManager )
1042     {
1043       OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1044       if ( anOCCViewer )
1045         removeViewShapes( (size_t)anOCCViewer );
1046     }
1047
1048     if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1049     {
1050       SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1051       if ( aVTKViewer )
1052       {
1053         getVTKDisplayer()->DeleteScalarBar( anId );
1054         removeViewShapes( (size_t)aVTKViewer );
1055       }
1056     }
1057
1058     myViewManagerMap.remove( anId );
1059   }
1060 }
1061
1062 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1063 {
1064   if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1065   {
1066     if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1067     {
1068       aViewFrame->installEventFilter( this );
1069
1070       GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1071
1072       connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1073                this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1074     }
1075   }
1076   else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1077   {
1078     if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1079     {
1080       aViewFrame->onTopView();
1081
1082       HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1083
1084       OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1085       if ( aViewPort ) {
1086         aViewPort->installEventFilter( this );
1087       }
1088     }
1089   }
1090 }
1091
1092 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1093 {
1094   /* ouv: currently unused
1095   if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1096   {
1097     SUIT_ViewManager* aViewManager = 0;
1098
1099     QObject* aParent = aViewPort;
1100     while( aParent = aParent->parent() )
1101     {
1102       if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1103       {
1104         if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1105         {
1106           aViewManager = aViewer->getViewManager();
1107           break;
1108         }
1109       }
1110     }
1111
1112     if( !aViewManager )
1113       return;
1114
1115     double aMouseX = theEvent->scenePos().x();
1116     double aMouseY = theEvent->scenePos().y();
1117
1118     ViewManagerRole aRole = getViewManagerRole( aViewManager );
1119     if( aRole == VMR_General )
1120     {
1121       int aXDeg = 0, aYDeg = 0;
1122       int aXMin = 0, aYMin = 0;
1123       double aXSec = 0, aYSec = 0;
1124       HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1125       HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1126
1127       QString aDegSymbol( QChar( 0x00B0 ) );
1128       QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1129       QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1130
1131       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1132     }
1133     else if( aRole == VMR_TransformImage )
1134       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1135   }
1136   */
1137 }
1138
1139 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, 
1140                                     const bool theIsInit, 
1141                                     const bool theIsForced, 
1142                                     const bool theDoFitAll )
1143 {
1144   QList<int> aViewManagerIdList;
1145
1146   // currently, all views are updated
1147   ViewManagerMapIterator anIter( myViewManagerMap );
1148   while( anIter.hasNext() )
1149   { 
1150     SUIT_ViewManager* aViewManager = anIter.next().value().first;
1151
1152     if ( theDisplayer->IsApplicable( aViewManager ) )
1153     {
1154       int anId = anIter.key();
1155       aViewManagerIdList.append( anId );
1156     }
1157   }
1158
1159   QListIterator<int> anIdIter( aViewManagerIdList );
1160   while( anIdIter.hasNext() )
1161   {
1162     theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1163   }
1164 }
1165
1166 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1167 {
1168   if( !theViewManager )
1169     return;
1170
1171   LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1172   if( !aSelectionMgr )
1173     return;
1174
1175   QString aViewType = theViewManager->getType();
1176   if( aViewType != GraphicsView_Viewer::Type() &&
1177       aViewType != OCCViewer_Viewer::Type())
1178     return;
1179
1180   QList<SUIT_Selector*> aSelectorList;
1181   aSelectionMgr->selectors( aViewType, aSelectorList );
1182
1183   // disable all alien selectors
1184   QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1185   for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1186   {
1187     SUIT_Selector* aSelector = *anIter;
1188     if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1189                        !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1190                        !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1191       aSelector->setEnabled( false );
1192   }
1193
1194   if ( aViewType == GraphicsView_Viewer::Type() )
1195   {
1196     GraphicsView_ViewManager* aViewManager =
1197       ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1198     if( aViewManager )
1199       new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1200   }
1201   else if ( aViewType == OCCViewer_Viewer::Type() )
1202   {
1203     OCCViewer_ViewManager* aViewManager =
1204       ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1205     if( aViewManager )
1206       new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1207   }
1208 }
1209
1210 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1211 {
1212   bool aPrevState = myIsUpdateEnabled;
1213   myIsUpdateEnabled = theState;
1214   return aPrevState;
1215 }
1216
1217 bool HYDROGUI_Module::isUpdateEnabled() const
1218 {
1219   return myIsUpdateEnabled;
1220 }
1221
1222 QStringList HYDROGUI_Module::storeSelection() const
1223 {
1224   QStringList anEntryList;
1225   if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1226   {
1227     SUIT_DataOwnerPtrList aList( true );
1228     aSelectionMgr->selected( aList );
1229
1230     SUIT_DataOwnerPtrList::iterator anIter;
1231     for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1232     {
1233       const LightApp_DataOwner* anOwner = 
1234         dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1235       if( anOwner )
1236         anEntryList.append( anOwner->entry() );
1237     }
1238   }
1239   return anEntryList;
1240 }
1241
1242 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1243 {
1244   if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1245   {
1246     SUIT_DataOwnerPtrList aList( true );
1247     for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1248       aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1249     aSelectionMgr->setSelected( aList );
1250   }
1251 }
1252
1253 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
1254 {
1255   OCCViewer_ViewWindow* anOCCViewWindow = 
1256     dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
1257   if ( !anOCCViewWindow ) {
1258     return;
1259   }
1260
1261   // Get the selected point coordinates
1262   OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort();
1263   if ( !aViewPort ) {
1264     return;
1265   }
1266
1267   gp_Pnt aPnt = GEOMUtils::ConvertClickToPoint( theEvent->x(), theEvent->y(), 
1268                                                 aViewPort->getView() );
1269
1270   // Show the coordinates in the status bar
1271   SUIT_Desktop* aDesktop = getApp()->desktop();
1272   if ( aDesktop && aDesktop->statusBar() ) {
1273     QString aX = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
1274     QString anY = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
1275     aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
1276   }
1277 }