Salome HOME
GUI part for zones. Preview for zone is done in 2D view. (Feature #31)
[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_Operations.h"
32 #include "HYDROGUI_PrsImage.h"
33 #include "HYDROGUI_Tool.h"
34 #include "HYDROGUI_UpdateFlags.h"
35
36 #include <HYDROData_Image.h>
37
38 #include <HYDROOperations_Factory.h>
39
40 #include <GraphicsView_ViewFrame.h>
41 #include <GraphicsView_ViewManager.h>
42 #include <GraphicsView_ViewPort.h>
43 #include <GraphicsView_Viewer.h>
44
45 #include <ImageComposer_CutOperator.h>
46 #include <ImageComposer_CropOperator.h>
47 #include <ImageComposer_FuseOperator.h>
48
49 #include <LightApp_Application.h>
50 #include <LightApp_GVSelector.h>
51 #include <LightApp_SelectionMgr.h>
52 #include <LightApp_UpdateFlags.h>
53
54 #include <SALOME_Event.h>
55
56 #include <SUIT_Desktop.h>
57 #include <SUIT_Study.h>
58 #include <SUIT_ViewManager.h>
59
60 #include <QAction>
61 #include <QApplication>
62 #include <QGraphicsSceneMouseEvent>
63 #include <QMenu>
64
65 static int ViewManagerId = 0;
66
67 extern "C" HYDRO_EXPORT CAM_Module* createModule()
68 {
69   return new HYDROGUI_Module();
70 }
71
72 extern "C" HYDRO_EXPORT char* getModuleVersion()
73 {
74   return (char*)HYDRO_VERSION;
75 }
76
77 HYDROGUI_Module::HYDROGUI_Module()
78 : LightApp_Module( "HYDRO" ),
79   myDisplayer( 0 ),
80   myIsUpdateEnabled( true )
81 {
82 }
83
84 HYDROGUI_Module::~HYDROGUI_Module()
85 {
86 }
87
88 int HYDROGUI_Module::getStudyId() const
89 {
90   LightApp_Application* anApp = getApp();
91   return anApp ? anApp->activeStudy()->id() : 0;
92 }
93
94 void HYDROGUI_Module::initialize( CAM_Application* theApp )
95 {
96   LightApp_Module::initialize( theApp );
97
98   createActions();
99   createUndoRedoActions();
100   createMenus();
101   createPopups();
102   createToolbars();
103
104   setMenuShown( false );
105   setToolShown( false );
106
107   myDisplayer = new HYDROGUI_Displayer( this );
108 }
109
110 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
111 {
112   bool aRes = LightApp_Module::activateModule( theStudy );
113
114   LightApp_Application* anApp = getApp();
115   SUIT_Desktop* aDesktop = anApp->desktop();
116
117   getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
118
119   setMenuShown( true );
120   setToolShown( true );
121
122 #ifndef DISABLE_PYCONSOLE
123   aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ), 
124                               HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
125 #endif
126
127   update( UF_All );
128
129   updateCommandsStatus();
130
131   return aRes;
132 }
133
134 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
135 {
136   ViewManagerMapIterator anIter( myViewManagerMap );
137   while( anIter.hasNext() )
138     if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
139       getApp()->removeViewManager( aViewManager );
140   myViewManagerMap.clear();
141
142   myObjectStateMap.clear();
143
144   // clear the data model's list of copying objects
145   HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
146
147   setMenuShown( false );
148   setToolShown( false );
149
150   getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
151
152   return LightApp_Module::deactivateModule( theStudy );
153 }
154
155 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
156 {
157   theMap.clear();
158   theMap.insert( LightApp_Application::WT_LogWindow,     Qt::BottomDockWidgetArea );
159 #ifndef DISABLE_PYCONSOLE
160   theMap.insert( LightApp_Application::WT_PyConsole,     Qt::BottomDockWidgetArea );
161 #endif
162   theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea   );
163 }
164
165 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
166 {
167   theTypesList << GraphicsView_Viewer::Type();
168 }
169
170 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
171                                         QMenu* theMenu,
172                                         QString& theTitle )
173 {
174   HYDROGUI_DataModel* aModel = getDataModel();
175
176   bool anIsObjectBrowser = theClient == "ObjectBrowser";
177   bool anIsGraphicsView = theClient == "GraphicsView";
178   if( !anIsObjectBrowser && !anIsGraphicsView )
179     return;
180
181   size_t aViewId = HYDROGUI_Tool::GetActiveGraphicsViewId( this );
182
183   bool anIsSelectedDataObjects = false;
184   bool anIsVisibleInSelection = false;
185   bool anIsHiddenInSelection = false;
186
187   bool anIsImage = false;
188   bool anIsImportedImage = false;
189   bool anIsCompositeImage = false;
190   bool anIsFusedImage = false;
191   bool anIsCutImage = false;
192   bool anIsSplittedImage = false;
193   bool anIsMustBeUpdatedImage = false;
194   bool anIsPolyline = false;
195   bool anIsCalculation = false;
196   bool anIsZone = false;
197   bool anIsVisualState = false;
198
199   // check the selected data model objects
200   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
201   for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
202   {
203     Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
204     if( !anObject.IsNull() )
205     {
206       anIsSelectedDataObjects = true;
207
208       bool aVisibility = isObjectVisible( aViewId, anObject );
209       anIsVisibleInSelection |= aVisibility;
210       anIsHiddenInSelection |= !aVisibility;
211
212       if( anObject->GetKind() == KIND_IMAGE )
213       {
214         anIsImage = true;
215         Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
216         if( !anImage.IsNull() )
217         {
218           anIsImportedImage = anImage->HasTrsfPoints() && !anImage->IsSelfSplitted();
219           anIsCompositeImage = anImage->NbReferences() > 0;
220           if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
221           {
222             if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
223             {
224               QString anOperatorName = anOperator->name();
225               if( anOperatorName == ImageComposer_FuseOperator::Type() )
226                 anIsFusedImage = true;
227               else if( anOperatorName == ImageComposer_CutOperator::Type() )
228                 anIsCutImage = true;
229               else if( anOperatorName == ImageComposer_CropOperator::Type() )
230                 anIsSplittedImage = true;
231             }
232           }
233           anIsMustBeUpdatedImage = anImage->MustBeUpdated();
234         }
235       }
236       else if( anObject->GetKind() == KIND_POLYLINE )
237         anIsPolyline = true;
238       else if( anObject->GetKind() == KIND_CALCULATION )
239         anIsCalculation = true;
240       else if( anObject->GetKind() == KIND_ZONE )
241         anIsZone = true;
242       else if( anObject->GetKind() == KIND_VISUAL_STATE )
243         anIsVisualState = true;
244     }
245   }
246
247   // check the selected partitions
248   if( !anIsSelectedDataObjects && anIsObjectBrowser )
249   {
250     ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
251     if( aSelectedPartition != KIND_UNKNOWN )
252     {
253       switch( aSelectedPartition )
254       {
255         case KIND_IMAGE:
256           theMenu->addAction( action( ImportImageId ) );
257           break;
258         case KIND_POLYLINE:
259           theMenu->addAction( action( CreatePolylineId ) );
260           break;
261         case KIND_VISUAL_STATE:
262           theMenu->addAction( action( SaveVisualStateId ) );
263           break;
264         case KIND_BATHYMETRY:
265           theMenu->addAction( action( ImportBathymetryId ) );
266           break;
267         case KIND_CALCULATION:
268           theMenu->addAction( action( CreateCalculationId ) );
269           break;
270         case KIND_ZONE:
271           theMenu->addAction( action( CreateZoneId ) );
272           break;
273       }
274       theMenu->addSeparator();
275     }
276   }
277
278   if( anIsSelectedDataObjects && anIsMustBeUpdatedImage )
279   {
280     theMenu->addAction( action( UpdateImageId ) );
281     theMenu->addSeparator();
282   }
283
284   if( anIsSelectedDataObjects && aSeq.Length() == 1 )
285   {
286     if( anIsImage )
287     {
288       if( anIsImportedImage )
289         theMenu->addAction( action( EditImportedImageId ) );
290       else if( anIsCompositeImage )
291       {
292         if( anIsFusedImage )
293           theMenu->addAction( action( EditFusedImageId ) );
294         else if( anIsCutImage )
295           theMenu->addAction( action( EditCutImageId ) );
296         else if( anIsSplittedImage )
297           theMenu->addAction( action( EditSplittedImageId ) );
298       }
299
300       theMenu->addAction( action( ObserveImageId ) );
301       theMenu->addAction( action( ExportImageId ) );
302       theMenu->addSeparator();
303
304       theMenu->addAction( action( FuseImagesId ) );
305       theMenu->addAction( action( CutImagesId ) );
306       theMenu->addAction( action( SplitImageId ) );
307       theMenu->addSeparator();
308     }
309     else if( anIsPolyline )
310     {
311       theMenu->addAction( action( EditPolylineId ) );
312       theMenu->addSeparator();
313     }
314     else if( anIsCalculation )
315     {
316       theMenu->addAction( action( EditCalculationId ) );
317       theMenu->addSeparator();
318     }
319     else if( anIsZone )
320     {
321       theMenu->addAction( action( EditZoneId ) );
322       theMenu->addSeparator();
323     }
324     else if( anIsVisualState && anIsObjectBrowser )
325     {
326       theMenu->addAction( action( SaveVisualStateId ) );
327       theMenu->addAction( action( LoadVisualStateId ) );
328       theMenu->addSeparator();
329     }
330   }
331
332   if( anIsSelectedDataObjects )
333   {
334     theMenu->addAction( action( DeleteId ) );
335     theMenu->addSeparator();
336   }
337
338   if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsZone ) )
339   {
340     if( anIsHiddenInSelection )
341       theMenu->addAction( action( ShowId ) );
342     theMenu->addAction( action( ShowOnlyId ) );
343     if( anIsVisibleInSelection )
344       theMenu->addAction( action( HideId ) );
345     theMenu->addSeparator();
346   }
347
348   if( anIsObjectBrowser || anIsGraphicsView )
349   {
350     theMenu->addAction( action( ShowAllId ) );
351     theMenu->addAction( action( HideAllId ) );
352     theMenu->addSeparator();
353   }
354 }
355
356 void HYDROGUI_Module::update( const int flags )
357 {
358   if( !isUpdateEnabled() )
359     return;
360
361   QApplication::setOverrideCursor( Qt::WaitCursor );
362
363   // To prevent calling this method recursively
364   // from one of the methods called below
365   setUpdateEnabled( false );
366
367   if( ( flags & UF_Viewer ) )
368     updateGV( flags & UF_GV_Init,
369               flags & UF_GV_Forced );
370
371   if( ( flags & UF_Model ) && getDataModel() && getApp() )
372   {
373     getDataModel()->update( getStudyId() );
374
375     // Temporary workaround to prevent breaking
376     // the selection in the object browser.
377     // Note: processEvents() should be called after updateGV(),
378     // otherwise the application crashes from time to time.
379     qApp->processEvents(); 
380     getApp()->updateObjectBrowser( true );
381   }
382
383   // Object browser is currently updated by using UF_Model flag
384   //if( ( flags & UF_ObjBrowser ) && getApp() )
385   //  getApp()->updateObjectBrowser( true );
386
387   if( ( flags & UF_Controls ) && getApp() )
388     getApp()->updateActions();
389
390   setUpdateEnabled( true );
391
392   QApplication::restoreOverrideCursor();
393 }
394
395 void HYDROGUI_Module::updateCommandsStatus()
396 {
397   LightApp_Module::updateCommandsStatus();
398
399   updateUndoRedoControls();
400
401   action( CopyId )->setEnabled( getDataModel()->canCopy() );
402   action( PasteId )->setEnabled( getDataModel()->canPaste() );
403 }
404
405 void HYDROGUI_Module::selectionChanged()
406 {
407   LightApp_Module::selectionChanged();
408   updateCommandsStatus();
409 }
410
411 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
412 {
413   return (HYDROGUI_DataModel*)dataModel();
414 }
415
416 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
417 {
418   return myDisplayer;
419 }
420
421 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
422 {
423   if( myViewManagerMap.contains( theId ) )
424   {
425     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
426     GraphicsView_ViewManager* aViewManager =
427       dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
428     if( aViewManager )
429       return aViewManager->getViewer();
430   }
431   return NULL;
432 }
433
434 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
435 {
436   ViewManagerMapIterator anIter( myViewManagerMap );
437   while( anIter.hasNext() )
438   {
439     int anId = anIter.next().key();
440     const ViewManagerInfo& anInfo = anIter.value();
441     if( anInfo.first == theViewManager )
442       return anId;
443   }
444   return -1;
445 }
446
447 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
448 {
449   int anId = getViewManagerId( theViewManager );
450   if( anId != -1 )
451   {
452     const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
453     return anInfo.second;
454   }
455   return VMR_Unknown;
456 }
457
458 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
459                                           const ViewManagerRole theRole )
460 {
461   int anId = getViewManagerId( theViewManager );
462   if( anId != -1 )
463   {
464     ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
465     anInfo.second = theRole;
466   }
467 }
468
469 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
470                                        const Handle(HYDROData_Object)& theObject )
471 {
472   if( theObject.IsNull() )
473     return false;
474
475   ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
476   if( anIter1 != myObjectStateMap.end() )
477   {
478     const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
479     Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
480     if( anIter2 != aName2ObjectStateMap.end() )
481     {
482       const ObjectState& anObjectState = anIter2.value();
483       return anObjectState.Visibility;
484     }
485   }
486   return false;
487 }
488
489 void HYDROGUI_Module::setObjectVisible( const int theViewId,
490                                         const Handle(HYDROData_Object)& theObject,
491                                         const bool theState )
492 {
493   if( !theObject.IsNull() )
494   {
495     Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
496     ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
497     anObjectState.Visibility = theState;
498   }
499 }
500
501 CAM_DataModel* HYDROGUI_Module::createDataModel()
502 {
503   return new HYDROGUI_DataModel( this );
504 }
505
506 void HYDROGUI_Module::customEvent( QEvent* e )
507 {
508   int aType = e->type();
509   if ( aType == NewViewEvent )
510   {
511     SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
512     if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
513     {
514       if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
515       {
516         if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
517         {
518           aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
519           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
520           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
521
522           //ouv: temporarily commented
523           //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
524         }
525
526         SUIT_ViewManager* aViewManager = aViewer->getViewManager();
527         ViewManagerRole aRole = getViewManagerRole( aViewManager );
528         if( aRole != VMR_TransformImage )
529           update( UF_Viewer );
530
531         aViewer->activateTransform( GraphicsView_Viewer::FitAll );
532       }
533     }
534   }
535 }
536
537 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
538 {
539   QEvent::Type aType = theEvent->type();
540   if( theObj->inherits( "GraphicsView_ViewFrame" ) )
541   {
542     if( aType == QEvent::Show )
543     {
544       SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
545       e->setData( theObj );
546       QApplication::postEvent( this, e );
547       theObj->removeEventFilter( this );
548     }
549   }
550   return LightApp_Module::eventFilter( theObj, theEvent );
551 }
552
553 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
554 {
555   LightApp_Module::onViewManagerAdded( theViewManager );
556
557   if( theViewManager->getType() == GraphicsView_Viewer::Type() )
558   { 
559     createSelector( theViewManager ); // replace the default selector
560
561     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
562              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
563   }
564
565   ViewManagerInfo anInfo( theViewManager, VMR_General );
566   myViewManagerMap.insert( ViewManagerId++, anInfo );
567 }
568
569 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
570 {
571   LightApp_Module::onViewManagerRemoved( theViewManager );
572
573   createSelector( theViewManager ); // replace the default selector
574
575   int anId = getViewManagerId( theViewManager );
576   if( anId != -1 )
577     myViewManagerMap.remove( anId );
578 }
579
580 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
581 {
582   if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
583   {
584     if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
585     {
586       aViewFrame->installEventFilter( this );
587
588       GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
589
590       connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
591                this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
592       return;
593     }
594   }
595 }
596
597 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
598 {
599   if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
600   {
601     SUIT_ViewManager* aViewManager = 0;
602
603     QObject* aParent = aViewPort;
604     while( aParent = aParent->parent() )
605     {
606       if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
607       {
608         if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
609         {
610           aViewManager = aViewer->getViewManager();
611           break;
612         }
613       }
614     }
615
616     if( !aViewManager )
617       return;
618
619     double aMouseX = theEvent->scenePos().x();
620     double aMouseY = theEvent->scenePos().y();
621
622     ViewManagerRole aRole = getViewManagerRole( aViewManager );
623     if( aRole == VMR_General )
624     {
625       int aXDeg = 0, aYDeg = 0;
626       int aXMin = 0, aYMin = 0;
627       double aXSec = 0, aYSec = 0;
628       HYDROGUI_Tool::DoubleToLambert( aMouseX, aXDeg, aXMin, aXSec );
629       HYDROGUI_Tool::DoubleToLambert( aMouseY, aYDeg, aYMin, aYSec );
630
631       QString aDegSymbol( QChar( 0x00B0 ) );
632       QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
633       QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
634
635       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
636     }
637     else if( aRole == VMR_TransformImage )
638       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
639   }
640 }
641
642 void HYDROGUI_Module::updateGV( const bool theIsInit,
643                                 const bool theIsForced )
644 {
645   if( !getDisplayer() )
646     return;
647
648   QList<int> aViewManagerIdList;
649
650   // currently, all views are updated
651   ViewManagerMapIterator anIter( myViewManagerMap );
652   while( anIter.hasNext() )
653   {
654     int anId = anIter.next().key();
655     aViewManagerIdList.append( anId );
656   }
657
658   QListIterator<int> anIdIter( aViewManagerIdList );
659   while( anIdIter.hasNext() )
660     getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
661 }
662
663 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
664 {
665   if( !theViewManager )
666     return;
667
668   LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
669   if( !aSelectionMgr )
670     return;
671
672   QString aViewType = theViewManager->getType();
673   if( aViewType != GraphicsView_Viewer::Type() )
674     return;
675
676   GraphicsView_ViewManager* aViewManager =
677     dynamic_cast<GraphicsView_ViewManager*>( theViewManager );
678   if( !aViewManager )
679     return;
680
681   QList<SUIT_Selector*> aSelectorList;
682   aSelectionMgr->selectors( aViewType, aSelectorList );
683
684   // disable all alien selectors
685   QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
686   for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
687   {
688     SUIT_Selector* aSelector = *anIter;
689     if( aSelector && !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) )
690       aSelector->setEnabled( false );
691   }
692
693   new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
694 }
695
696 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
697 {
698   bool aPrevState = myIsUpdateEnabled;
699   myIsUpdateEnabled = theState;
700   return aPrevState;
701 }
702
703 bool HYDROGUI_Module::isUpdateEnabled() const
704 {
705   return myIsUpdateEnabled;
706 }