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