Salome HOME
3433e99aec960b32d6376441fc60762b015dd008
[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 anIsMustBeUpdatedImage = 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       ObjectKind anObjectKind = anObject->GetKind();
294       if( anObjectKind == KIND_IMAGE )
295       {
296         anIsImage = true;
297         Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
298         if( !anImage.IsNull() )
299         {
300           anIsImportedImage = anImage->HasLocalPoints();
301           anIsImageHasRefs = anImage->HasReferences();
302           if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
303           {
304             if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
305             {
306               QString anOperatorName = anOperator->name();
307               if( anOperatorName == ImageComposer_FuseOperator::Type() )
308                 anIsFusedImage = true;
309               else if( anOperatorName == ImageComposer_CutOperator::Type() )
310                 anIsCutImage = true;
311               else if( anOperatorName == ImageComposer_CropOperator::Type() )
312                 anIsSplittedImage = true;
313             }
314           }
315           if ( anImage->IsMustBeUpdated() )
316           {
317             anIsMustBeUpdatedImage = true;
318           }
319         }
320       }
321       else if( anObjectKind == KIND_POLYLINEXY )
322         anIsPolyline = true;
323       else if( anObjectKind == KIND_POLYLINE )
324         anIsPolyline3D = true;
325       else if( anObjectKind == KIND_PROFILE )
326       {
327         anIsProfile = true;
328         aNbOfSelectedProfiles++;
329
330         Handle(HYDROData_Profile) aProfile = 
331           Handle(HYDROData_Profile)::DownCast( anObject );
332         if( !aProfile.IsNull() && aProfile->IsValid() ) {
333           anIsValidProfile = true;
334         }
335       }
336       else if( anObjectKind == KIND_CALCULATION )
337         anIsCalculation = true;
338       else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
339         anIsImmersibleZone = true;
340       else if( anObjectKind == KIND_VISUAL_STATE )
341         anIsVisualState = true;
342       else if( anObjectKind == KIND_REGION )
343         anIsRegion = true;
344       else if( anObjectKind == KIND_ZONE )
345         anIsZone = true;
346       else if( anObjectKind == KIND_BATHYMETRY )
347         anIsBathymetry = true;
348       else if( anObjectKind == KIND_OBSTACLE )
349         anIsObstacle = true;
350       else if( anObjectKind == KIND_STREAM )
351         anIsStream = true;
352       else if( anObjectKind == KIND_CHANNEL )
353         anIsChannel = true;
354     }
355
356     anIsGeomObject = HYDROData_Tool::IsGeometryObject( anObject );
357   }
358
359   // Check if all selected objects are profiles
360   anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
361                      ( aNbOfSelectedProfiles == aSeq.Length() );
362
363   // check the selected partitions
364   if( !anIsSelectedDataObjects && anIsObjectBrowser )
365   {
366     ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
367     if( aSelectedPartition != KIND_UNKNOWN )
368     {
369       switch( aSelectedPartition )
370       {
371         case KIND_IMAGE:
372           theMenu->addAction( action( ImportImageId ) );
373           break;
374         case KIND_BATHYMETRY:
375           theMenu->addAction( action( ImportBathymetryId ) );
376           break;
377         case KIND_ARTIFICIAL_OBJECT:
378           theMenu->addAction( action( CreateChannelId ) );
379           break;
380         case KIND_NATURAL_OBJECT:
381           theMenu->addAction( action( CreateImmersibleZoneId ) );
382           theMenu->addAction( action( CreateStreamId ) );
383           break;
384         case KIND_OBSTACLE:
385           theMenu->addAction( action( ImportObstacleFromFileId ) );
386           theMenu->addAction( action( CreateBoxId ) );
387           theMenu->addAction( action( CreateCylinderId ) );
388           break;
389         case KIND_CALCULATION:
390           theMenu->addAction( action( CreateCalculationId ) );
391           break;
392         case KIND_POLYLINEXY:
393           theMenu->addAction( action( CreatePolylineId ) );
394           break;
395         case KIND_POLYLINE:
396           theMenu->addAction( action( CreatePolyline3DId ) );
397           break;
398         case KIND_PROFILE:
399           theMenu->addAction( action( CreateProfileId ) );
400           theMenu->addAction( action( ImportProfilesId ) );
401           theMenu->addAction( action( AllGeoreferencementId ) );
402           break;
403         case KIND_VISUAL_STATE:
404           theMenu->addAction( action( SaveVisualStateId ) );
405           break;
406       }
407       theMenu->addSeparator();
408     }
409   }
410
411   if( anIsSelectedDataObjects )
412   {
413     if ( anIsMustBeUpdatedImage )
414     {
415       theMenu->addAction( action( UpdateImageId ) );
416       theMenu->addSeparator();
417     }
418
419     if( aSeq.Length() == 1 )
420     {
421       if( anIsImage )
422       {
423         if( anIsImportedImage )
424           theMenu->addAction( action( EditImportedImageId ) );
425         else if( anIsImageHasRefs )
426         {
427           if( anIsFusedImage )
428             theMenu->addAction( action( EditFusedImageId ) );
429           else if( anIsCutImage )
430             theMenu->addAction( action( EditCutImageId ) );
431           else if( anIsSplittedImage )
432             theMenu->addAction( action( EditSplittedImageId ) );
433         }
434
435         //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
436         theMenu->addAction( action( ExportImageId ) );
437         theMenu->addSeparator();
438
439         if( anIsImageHasRefs )
440         {
441           theMenu->addAction( action( RemoveImageRefsId ) );
442           theMenu->addSeparator();
443         }
444
445         theMenu->addAction( action( FuseImagesId ) );
446         theMenu->addAction( action( CutImagesId ) );
447         theMenu->addAction( action( SplitImageId ) );
448         theMenu->addSeparator();
449       }
450       else if( anIsBathymetry )
451       {
452         theMenu->addAction( action( EditImportedBathymetryId ) );
453         theMenu->addSeparator();
454       }
455       else if( anIsPolyline )
456       {
457         theMenu->addAction( action( EditPolylineId ) );
458         theMenu->addSeparator();
459       }
460       else if( anIsPolyline3D )
461       {
462         theMenu->addAction( action( EditPolyline3DId ) );
463         theMenu->addSeparator();
464       }
465       else if( anIsProfile )
466       {
467         theMenu->addAction( action( EditProfileId ) );
468         theMenu->addAction( action( SelectedGeoreferencementId ) );
469         theMenu->addSeparator();
470       }
471       else if( anIsCalculation )
472       {
473         theMenu->addAction( action( EditCalculationId ) );
474         theMenu->addAction( action( ExportCalculationId ) );
475         theMenu->addSeparator();
476       }
477       else if( anIsImmersibleZone )
478       {
479         theMenu->addAction( action( EditImmersibleZoneId ) );
480         theMenu->addSeparator();
481       }
482       else if( anIsStream )
483       {
484         theMenu->addAction( action( EditStreamId ) );
485         theMenu->addSeparator();
486       }
487       else if( anIsChannel )
488       {
489         theMenu->addAction( action( EditChannelId ) );
490         theMenu->addSeparator();
491       }
492       else if( anIsVisualState && anIsObjectBrowser )
493       {
494         theMenu->addAction( action( SaveVisualStateId ) );
495         theMenu->addAction( action( LoadVisualStateId ) );
496         theMenu->addSeparator();
497       }
498
499       // Add set color action for geometrical objects
500       if ( anIsGeomObject )
501       {
502         theMenu->addAction( action( SetColorId ) );
503         theMenu->addSeparator();
504       }
505     } else if ( anAllAreProfiles ) {
506       theMenu->addAction( action( SelectedGeoreferencementId ) );
507       theMenu->addSeparator();
508     }
509
510     theMenu->addAction( action( DeleteId ) );
511     theMenu->addSeparator();
512
513     if( anIsImage || anIsPolyline || anIsPolyline3D || 
514         anIsImmersibleZone || anIsZone || anIsRegion ||
515         anIsBathymetry || anIsObstacle || anIsStream ||
516         anIsChannel || anIsValidProfile )
517     {
518       if( anIsHiddenInSelection )
519         theMenu->addAction( action( ShowId ) );
520       theMenu->addAction( action( ShowOnlyId ) );
521       if( anIsVisibleInSelection )
522         theMenu->addAction( action( HideId ) );
523       theMenu->addSeparator();
524     }
525   }
526
527   if ( anIsOCCView )
528   {
529     SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
530     HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
531     if ( aPolylineOp && aPolylineOp->deleteEnabled() )
532       theMenu->addAction( action( DeleteId ) );
533   }
534
535   if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
536   {
537     theMenu->addAction( action( ShowAllId ) );
538     theMenu->addAction( action( HideAllId ) );
539     theMenu->addSeparator();
540   }
541 }
542
543 void HYDROGUI_Module::update( const int flags )
544 {
545   if( !isUpdateEnabled() )
546     return;
547
548   QApplication::setOverrideCursor( Qt::WaitCursor );
549
550   // To prevent calling this method recursively
551   // from one of the methods called below
552   setUpdateEnabled( false );
553
554   // store selected objects
555   QStringList aSelectedEntries = storeSelection();
556
557   bool aDoFitAll = flags & UF_FitAll;
558   if( ( flags & UF_Viewer ) )
559     updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll ); 
560
561   if( ( flags & UF_OCCViewer ) )
562     updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll ); 
563
564   if( ( flags & UF_VTKViewer ) )
565     updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll ); 
566
567   if( ( flags & UF_Model ) && getDataModel() && getApp() )
568   {
569     getDataModel()->update( getStudyId() );
570
571     // Temporary workaround to prevent breaking
572     // the selection in the object browser.
573     // Note: processEvents() should be called after updateGV(),
574     // otherwise the application crashes from time to time.
575     //RKV: qApp->processEvents(); 
576     getApp()->updateObjectBrowser( true );
577   }
578
579   // Object browser is currently updated by using UF_Model flag
580   if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
581     getApp()->updateObjectBrowser( true );
582
583   if( ( flags & UF_Controls ) && getApp() )
584     getApp()->updateActions();
585
586   // restore selected objects
587   restoreSelection( aSelectedEntries );
588
589   setUpdateEnabled( true );
590
591   QApplication::restoreOverrideCursor();
592 }
593
594 void HYDROGUI_Module::updateCommandsStatus()
595 {
596   LightApp_Module::updateCommandsStatus();
597
598   updateUndoRedoControls();
599
600   action( CopyId )->setEnabled( getDataModel()->canCopy() );
601   action( PasteId )->setEnabled( getDataModel()->canPaste() );
602 }
603
604 void HYDROGUI_Module::selectionChanged()
605 {
606   LightApp_Module::selectionChanged();
607   updateCommandsStatus();
608 }
609
610 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
611 {
612   return (HYDROGUI_DataModel*)dataModel();
613 }
614
615 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
616 {
617   return myDisplayer;
618 }
619
620 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
621 {
622   return myOCCDisplayer;
623 }
624
625 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
626 {
627   return myVTKDisplayer;
628 }
629
630 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
631 {
632   if( myViewManagerMap.contains( theId ) )
633   {
634     return myViewManagerMap[ theId ].first;
635   }
636   return NULL;
637 }
638
639 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
640 {
641   if( myViewManagerMap.contains( theId ) )
642   {
643     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
644     GraphicsView_ViewManager* aViewManager =
645       dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
646     if( aViewManager )
647       return aViewManager->getViewer();
648   }
649   return NULL;
650 }
651
652 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
653 {
654   if( myViewManagerMap.contains( theId ) )
655   {
656     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
657     OCCViewer_ViewManager* aViewManager =
658       ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
659     if( aViewManager )
660       return aViewManager->getOCCViewer();
661   }
662   return NULL;
663 }
664
665 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
666 {
667   if( myViewManagerMap.contains( theId ) )
668   {
669     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
670     SVTK_ViewManager* aViewManager =
671       ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
672     if( aViewManager )
673       return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
674   }
675   return NULL;
676 }
677
678 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
679 {
680   ViewManagerMapIterator anIter( myViewManagerMap );
681   while( anIter.hasNext() )
682   {
683     int anId = anIter.next().key();
684     const ViewManagerInfo& anInfo = anIter.value();
685     if( anInfo.first == theViewManager )
686       return anId;
687   }
688   return -1;
689 }
690
691 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
692 {
693   int anId = getViewManagerId( theViewManager );
694   if( anId != -1 )
695   {
696     const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
697     return anInfo.second;
698   }
699   return VMR_Unknown;
700 }
701
702 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
703                                           const ViewManagerRole theRole )
704 {
705   int anId = getViewManagerId( theViewManager );
706   if( anId != -1 )
707   {
708     ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
709     anInfo.second = theRole;
710   }
711 }
712
713 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
714                                        const Handle(HYDROData_Entity)& theObject ) const
715 {
716   if( theObject.IsNull() )
717     return false;
718
719   ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
720   if( anIter1 != myObjectStateMap.end() )
721   {
722     const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
723     Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
724     if( anIter2 != aName2ObjectStateMap.end() )
725     {
726       const ObjectState& anObjectState = anIter2.value();
727       return anObjectState.Visibility;
728     }
729   }
730   return false;
731 }
732
733 void HYDROGUI_Module::setObjectVisible( const int theViewId,
734                                         const Handle(HYDROData_Entity)& theObject,
735                                         const bool theState )
736 {
737   if( !theObject.IsNull() )
738   {
739     Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
740     ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
741     anObjectState.Visibility = theState;
742   }
743 }
744
745 /////////////////// OCC SHAPES PROCESSING
746 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int                       theViewId,
747                                                  const Handle(HYDROData_Entity)& theObject ) const
748 {
749   HYDROGUI_Shape* aResShape = NULL;
750   if( theObject.IsNull() )
751     return aResShape;
752
753   if ( myShapesMap.contains( theViewId ) )
754   {
755     const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
756     foreach ( HYDROGUI_Shape* aShape, aViewShapes )
757     {
758       if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
759         continue;
760
761       aResShape = aShape;
762       break;
763     }
764   }
765
766   return aResShape;
767 }
768
769 void HYDROGUI_Module::setObjectShape( const int                       theViewId,
770                                       const Handle(HYDROData_Entity)& theObject,
771                                       HYDROGUI_Shape*                 theShape )
772 {
773   if( theObject.IsNull() )
774     return;
775
776   ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
777   aViewShapes.append( theShape );
778 }
779
780 void HYDROGUI_Module::removeObjectShape( const int                       theViewId,
781                                          const Handle(HYDROData_Entity)& theObject )
782 {
783   if ( !myShapesMap.contains( theViewId ) )
784     return;
785
786   ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
787   Handle(HYDROData_Entity) anObject;
788   for ( int i = 0; i < aViewShapes.length(); )
789   {
790     HYDROGUI_Shape* aShape = aViewShapes.at( i );
791     anObject = aShape->getObject();
792     if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
793     {
794       delete aShape;
795       aViewShapes.removeAt( i );
796       continue;
797     }
798
799     ++i;
800   }
801 }
802
803 void HYDROGUI_Module::removeViewShapes( const int theViewId )
804 {
805   if ( !myShapesMap.contains( theViewId ) )
806     return;
807
808   const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
809   for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
810   {
811     HYDROGUI_Shape* aShape = aViewShapes.at( i );
812     if ( aShape )
813       delete aShape;
814   }
815
816   myShapesMap.remove( theViewId );
817 }
818 /////////////////// END OF OCC SHAPES PROCESSING
819
820 /////////////////// VTKPrs PROCESSING
821 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int                       theViewId,
822                                                  const Handle(HYDROData_Entity)& theObject ) const
823 {
824   HYDROGUI_VTKPrs* aResShape = NULL;
825   if( theObject.IsNull() )
826     return aResShape;
827
828   if ( myVTKPrsMap.contains( theViewId ) )
829   {
830     const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
831     foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
832     {
833       if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
834         continue;
835
836       aResShape = aShape;
837       break;
838     }
839   }
840
841   return aResShape;
842 }
843
844 void HYDROGUI_Module::setObjectVTKPrs( const int                       theViewId,
845                                        const Handle(HYDROData_Entity)& theObject,
846                                        HYDROGUI_VTKPrs*                 theShape )
847 {
848   if( theObject.IsNull() )
849     return;
850
851   // Compute the new global Z range from the added presentation and the old global Z range.
852   double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
853   double* aRange = theShape->getInternalZRange();
854   bool anIsUpdate = false;
855   if ( aRange[0] < aGlobalRange[0] )
856   {
857     aGlobalRange[0] = aRange[0];
858     anIsUpdate = true;
859   }
860   if ( aRange[1] > aGlobalRange[1] )
861   {
862     aGlobalRange[1] = aRange[1];
863     anIsUpdate = true;
864   }
865
866   //if ( anIsUpdate )
867   //{
868     updateVTKZRange( theViewId, aGlobalRange );
869   //}
870
871   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
872   aViewShapes.append( theShape );
873 }
874
875 void HYDROGUI_Module::removeObjectVTKPrs( const int                       theViewId,
876                                           const Handle(HYDROData_Entity)& theObject )
877 {
878   if ( !myVTKPrsMap.contains( theViewId ) )
879     return;
880
881   ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
882   Handle(HYDROData_Entity) anObject;
883   for ( int i = 0; i < aViewShapes.length(); )
884   {
885     HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
886     anObject = aShape->getObject();
887     if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
888     {
889       delete aShape;
890       aViewShapes.removeAt( i );
891       continue;
892     }
893
894     ++i;
895   }
896
897   // Invalidate global Z range
898   double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
899   getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
900 }
901
902 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
903 {
904   if ( !myVTKPrsMap.contains( theViewId ) )
905     return;
906
907   const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
908   for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
909   {
910     HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
911     if ( aShape )
912       delete aShape;
913   }
914
915   myVTKPrsMap.remove( theViewId );
916 }
917
918 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
919 {
920   if ( myVTKPrsMap.contains( theViewId ) )
921   {
922     // For the given viewer id update all VTK presentations ...
923     const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
924     HYDROGUI_VTKPrs* aShape;
925     for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
926     {
927       aShape = aViewShapes.at( i );
928       if ( aShape )
929       {
930         aShape->setZRange( theRange );
931       }
932     }
933   }
934   // ... and update the global color legend scalar bar.
935   getVTKDisplayer()->SetZRange( theViewId, theRange );
936 }
937 /////////////////// END OF VTKPrs PROCESSING
938
939 CAM_DataModel* HYDROGUI_Module::createDataModel()
940 {
941   return new HYDROGUI_DataModel( this );
942 }
943
944 void HYDROGUI_Module::customEvent( QEvent* e )
945 {
946   int aType = e->type();
947   if ( aType == NewViewEvent )
948   {
949     SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
950     if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
951     {
952       if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
953       {
954         SUIT_ViewManager* aViewManager = aViewer->getViewManager();
955         ViewManagerRole aRole = getViewManagerRole( aViewManager );
956
957         if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
958         {
959           if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
960             aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
961
962           aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
963           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
964           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
965
966           //ouv: temporarily commented
967           //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
968         }
969
970         if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
971           update( UF_Viewer );
972
973         aViewer->activateTransform( GraphicsView_Viewer::FitAll );
974       }
975     }
976   }
977 }
978
979 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
980 {
981   QEvent::Type aType = theEvent->type();
982   if( theObj->inherits( "GraphicsView_ViewFrame" ) )
983   {
984     if( aType == QEvent::Show )
985     {
986       SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
987       e->setData( theObj );
988       QApplication::postEvent( this, e );
989       theObj->removeEventFilter( this );
990     }
991   }
992   else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
993   {
994     if( aType == QEvent::Leave )
995     {
996       SUIT_Desktop* aDesktop = getApp()->desktop();
997       if ( aDesktop && aDesktop->statusBar() ) {
998         aDesktop->statusBar()->clearMessage();
999       }
1000     }
1001   }
1002
1003   return LightApp_Module::eventFilter( theObj, theEvent );
1004 }
1005
1006 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1007 {
1008   LightApp_Module::onViewManagerAdded( theViewManager );
1009
1010   if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1011   { 
1012     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1013              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1014   }
1015   else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1016   {
1017     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1018              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1019     connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1020              this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1021   }
1022
1023   createSelector( theViewManager ); // replace the default selector
1024
1025   ViewManagerInfo anInfo( theViewManager, VMR_General );
1026   myViewManagerMap.insert( ViewManagerId++, anInfo );
1027 }
1028
1029 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1030 {
1031   LightApp_Module::onViewManagerRemoved( theViewManager );
1032
1033   createSelector( theViewManager ); // replace the default selector
1034
1035   int anId = getViewManagerId( theViewManager );
1036   if( anId != -1 )
1037   {
1038     OCCViewer_ViewManager* anOCCViewManager =
1039       ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1040     if ( anOCCViewManager )
1041     {
1042       OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1043       if ( anOCCViewer )
1044         removeViewShapes( (size_t)anOCCViewer );
1045     }
1046
1047     if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1048     {
1049       SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1050       if ( aVTKViewer )
1051       {
1052         getVTKDisplayer()->DeleteScalarBar( anId );
1053         removeViewShapes( (size_t)aVTKViewer );
1054       }
1055     }
1056
1057     myViewManagerMap.remove( anId );
1058   }
1059 }
1060
1061 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1062 {
1063   if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1064   {
1065     if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1066     {
1067       aViewFrame->installEventFilter( this );
1068
1069       GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1070
1071       connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1072                this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1073     }
1074   }
1075   else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1076   {
1077     if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1078     {
1079       aViewFrame->onTopView();
1080
1081       HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1082
1083       OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1084       if ( aViewPort ) {
1085         aViewPort->installEventFilter( this );
1086       }
1087     }
1088   }
1089 }
1090
1091 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1092 {
1093   /* ouv: currently unused
1094   if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1095   {
1096     SUIT_ViewManager* aViewManager = 0;
1097
1098     QObject* aParent = aViewPort;
1099     while( aParent = aParent->parent() )
1100     {
1101       if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1102       {
1103         if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1104         {
1105           aViewManager = aViewer->getViewManager();
1106           break;
1107         }
1108       }
1109     }
1110
1111     if( !aViewManager )
1112       return;
1113
1114     double aMouseX = theEvent->scenePos().x();
1115     double aMouseY = theEvent->scenePos().y();
1116
1117     ViewManagerRole aRole = getViewManagerRole( aViewManager );
1118     if( aRole == VMR_General )
1119     {
1120       int aXDeg = 0, aYDeg = 0;
1121       int aXMin = 0, aYMin = 0;
1122       double aXSec = 0, aYSec = 0;
1123       HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1124       HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1125
1126       QString aDegSymbol( QChar( 0x00B0 ) );
1127       QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1128       QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1129
1130       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1131     }
1132     else if( aRole == VMR_TransformImage )
1133       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1134   }
1135   */
1136 }
1137
1138 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, 
1139                                     const bool theIsInit, 
1140                                     const bool theIsForced, 
1141                                     const bool theDoFitAll )
1142 {
1143   QList<int> aViewManagerIdList;
1144
1145   // currently, all views are updated
1146   ViewManagerMapIterator anIter( myViewManagerMap );
1147   while( anIter.hasNext() )
1148   { 
1149     SUIT_ViewManager* aViewManager = anIter.next().value().first;
1150
1151     if ( theDisplayer->IsApplicable( aViewManager ) )
1152     {
1153       int anId = anIter.key();
1154       aViewManagerIdList.append( anId );
1155     }
1156   }
1157
1158   QListIterator<int> anIdIter( aViewManagerIdList );
1159   while( anIdIter.hasNext() )
1160   {
1161     theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1162   }
1163 }
1164
1165 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1166 {
1167   if( !theViewManager )
1168     return;
1169
1170   LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1171   if( !aSelectionMgr )
1172     return;
1173
1174   QString aViewType = theViewManager->getType();
1175   if( aViewType != GraphicsView_Viewer::Type() &&
1176       aViewType != OCCViewer_Viewer::Type())
1177     return;
1178
1179   QList<SUIT_Selector*> aSelectorList;
1180   aSelectionMgr->selectors( aViewType, aSelectorList );
1181
1182   // disable all alien selectors
1183   QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1184   for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1185   {
1186     SUIT_Selector* aSelector = *anIter;
1187     if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1188                        !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1189                        !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1190       aSelector->setEnabled( false );
1191   }
1192
1193   if ( aViewType == GraphicsView_Viewer::Type() )
1194   {
1195     GraphicsView_ViewManager* aViewManager =
1196       ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1197     if( aViewManager )
1198       new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1199   }
1200   else if ( aViewType == OCCViewer_Viewer::Type() )
1201   {
1202     OCCViewer_ViewManager* aViewManager =
1203       ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1204     if( aViewManager )
1205       new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1206   }
1207 }
1208
1209 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1210 {
1211   bool aPrevState = myIsUpdateEnabled;
1212   myIsUpdateEnabled = theState;
1213   return aPrevState;
1214 }
1215
1216 bool HYDROGUI_Module::isUpdateEnabled() const
1217 {
1218   return myIsUpdateEnabled;
1219 }
1220
1221 QStringList HYDROGUI_Module::storeSelection() const
1222 {
1223   QStringList anEntryList;
1224   if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1225   {
1226     SUIT_DataOwnerPtrList aList( true );
1227     aSelectionMgr->selected( aList );
1228
1229     SUIT_DataOwnerPtrList::iterator anIter;
1230     for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1231     {
1232       const LightApp_DataOwner* anOwner = 
1233         dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1234       if( anOwner )
1235         anEntryList.append( anOwner->entry() );
1236     }
1237   }
1238   return anEntryList;
1239 }
1240
1241 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1242 {
1243   if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1244   {
1245     SUIT_DataOwnerPtrList aList( true );
1246     for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1247       aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1248     aSelectionMgr->setSelected( aList );
1249   }
1250 }
1251
1252 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
1253 {
1254   OCCViewer_ViewWindow* anOCCViewWindow = 
1255     dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
1256   if ( !anOCCViewWindow ) {
1257     return;
1258   }
1259
1260   // Get the selected point coordinates
1261   OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort();
1262   if ( !aViewPort ) {
1263     return;
1264   }
1265
1266   gp_Pnt aPnt = GEOMUtils::ConvertClickToPoint( theEvent->x(), theEvent->y(), 
1267                                                 aViewPort->getView() );
1268
1269   // Show the coordinates in the status bar
1270   SUIT_Desktop* aDesktop = getApp()->desktop();
1271   if ( aDesktop && aDesktop->statusBar() ) {
1272     QString aX = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
1273     QString anY = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
1274     aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
1275   }
1276 }