]> SALOME platform Git repositories - modules/hydro.git/blob - src/HYDROGUI/HYDROGUI_Module.cxx
Salome HOME
Bug 23: popup menu.
[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 anIsVisualState = false;
197
198   // check the selected data model objects
199   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
200   for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
201   {
202     Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
203     if( !anObject.IsNull() )
204     {
205       anIsSelectedDataObjects = true;
206
207       bool aVisibility = isObjectVisible( aViewId, anObject );
208       anIsVisibleInSelection |= aVisibility;
209       anIsHiddenInSelection |= !aVisibility;
210
211       if( anObject->GetKind() == KIND_IMAGE )
212       {
213         anIsImage = true;
214         Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
215         if( !anImage.IsNull() )
216         {
217           anIsImportedImage = anImage->HasTrsfPoints() && !anImage->IsSelfSplitted();
218           anIsCompositeImage = anImage->NbReferences() > 0;
219           if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
220           {
221             if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
222             {
223               QString anOperatorName = anOperator->name();
224               if( anOperatorName == ImageComposer_FuseOperator::Type() )
225                 anIsFusedImage = true;
226               else if( anOperatorName == ImageComposer_CutOperator::Type() )
227                 anIsCutImage = true;
228               else if( anOperatorName == ImageComposer_CropOperator::Type() )
229                 anIsSplittedImage = true;
230             }
231           }
232           anIsMustBeUpdatedImage = anImage->MustBeUpdated();
233         }
234       }
235       else if( anObject->GetKind() == KIND_POLYLINE )
236         anIsPolyline = true;
237       else if( anObject->GetKind() == KIND_CALCULATION )
238         anIsCalculation = true;
239       else if( anObject->GetKind() == KIND_VISUAL_STATE )
240         anIsVisualState = true;
241     }
242   }
243
244   // check the selected partitions
245   if( !anIsSelectedDataObjects && anIsObjectBrowser )
246   {
247     ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
248     if( aSelectedPartition != KIND_UNKNOWN )
249     {
250       switch( aSelectedPartition )
251       {
252         case KIND_IMAGE:
253           theMenu->addAction( action( ImportImageId ) );
254           break;
255         case KIND_POLYLINE:
256           theMenu->addAction( action( CreatePolylineId ) );
257           break;
258         case KIND_VISUAL_STATE:
259           theMenu->addAction( action( SaveVisualStateId ) );
260           break;
261         case KIND_BATHYMETRY:
262           theMenu->addAction( action( ImportBathymetryId ) );
263           break;
264         case KIND_CALCULATION:
265           theMenu->addAction( action( CreateCalculationId ) );
266           break;
267       }
268       theMenu->addSeparator();
269     }
270   }
271
272   if( anIsSelectedDataObjects && anIsMustBeUpdatedImage )
273   {
274     theMenu->addAction( action( UpdateImageId ) );
275     theMenu->addSeparator();
276   }
277
278   if( anIsSelectedDataObjects && aSeq.Length() == 1 )
279   {
280     if( anIsImage )
281     {
282       if( anIsImportedImage )
283         theMenu->addAction( action( EditImportedImageId ) );
284       else if( anIsCompositeImage )
285       {
286         if( anIsFusedImage )
287           theMenu->addAction( action( EditFusedImageId ) );
288         else if( anIsCutImage )
289           theMenu->addAction( action( EditCutImageId ) );
290         else if( anIsSplittedImage )
291           theMenu->addAction( action( EditSplittedImageId ) );
292       }
293
294       theMenu->addAction( action( ObserveImageId ) );
295       theMenu->addAction( action( ExportImageId ) );
296       theMenu->addSeparator();
297
298       theMenu->addAction( action( FuseImagesId ) );
299       theMenu->addAction( action( CutImagesId ) );
300       theMenu->addAction( action( SplitImageId ) );
301       theMenu->addSeparator();
302     }
303     else if( anIsPolyline )
304     {
305       theMenu->addAction( action( EditPolylineId ) );
306       theMenu->addSeparator();
307     }
308     else if( anIsCalculation )
309     {
310       theMenu->addAction( action( EditCalculationId ) );
311       theMenu->addSeparator();
312     }
313     else if( anIsVisualState && anIsObjectBrowser )
314     {
315       theMenu->addAction( action( SaveVisualStateId ) );
316       theMenu->addAction( action( LoadVisualStateId ) );
317       theMenu->addSeparator();
318     }
319   }
320
321   if( anIsSelectedDataObjects )
322   {
323     theMenu->addAction( action( DeleteId ) );
324     theMenu->addSeparator();
325   }
326
327   if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline ) )
328   {
329     if( anIsHiddenInSelection )
330       theMenu->addAction( action( ShowId ) );
331     theMenu->addAction( action( ShowOnlyId ) );
332     if( anIsVisibleInSelection )
333       theMenu->addAction( action( HideId ) );
334     theMenu->addSeparator();
335   }
336
337   if( anIsObjectBrowser || anIsGraphicsView )
338   {
339     theMenu->addAction( action( ShowAllId ) );
340     theMenu->addAction( action( HideAllId ) );
341     theMenu->addSeparator();
342   }
343 }
344
345 void HYDROGUI_Module::update( const int flags )
346 {
347   if( !isUpdateEnabled() )
348     return;
349
350   QApplication::setOverrideCursor( Qt::WaitCursor );
351
352   // To prevent calling this method recursively
353   // from one of the methods called below
354   setUpdateEnabled( false );
355
356   if( ( flags & UF_Viewer ) )
357     updateGV( flags & UF_GV_Init,
358               flags & UF_GV_Forced );
359
360   if( ( flags & UF_Model ) && getDataModel() && getApp() )
361   {
362     getDataModel()->update( getStudyId() );
363
364     // Temporary workaround to prevent breaking
365     // the selection in the object browser.
366     // Note: processEvents() should be called after updateGV(),
367     // otherwise the application crashes from time to time.
368     qApp->processEvents(); 
369     getApp()->updateObjectBrowser( true );
370   }
371
372   // Object browser is currently updated by using UF_Model flag
373   //if( ( flags & UF_ObjBrowser ) && getApp() )
374   //  getApp()->updateObjectBrowser( true );
375
376   if( ( flags & UF_Controls ) && getApp() )
377     getApp()->updateActions();
378
379   setUpdateEnabled( true );
380
381   QApplication::restoreOverrideCursor();
382 }
383
384 void HYDROGUI_Module::updateCommandsStatus()
385 {
386   LightApp_Module::updateCommandsStatus();
387
388   updateUndoRedoControls();
389
390   action( CopyId )->setEnabled( getDataModel()->canCopy() );
391   action( PasteId )->setEnabled( getDataModel()->canPaste() );
392 }
393
394 void HYDROGUI_Module::selectionChanged()
395 {
396   LightApp_Module::selectionChanged();
397   updateCommandsStatus();
398 }
399
400 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
401 {
402   return (HYDROGUI_DataModel*)dataModel();
403 }
404
405 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
406 {
407   return myDisplayer;
408 }
409
410 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
411 {
412   if( myViewManagerMap.contains( theId ) )
413   {
414     ViewManagerInfo anInfo = myViewManagerMap[ theId ];
415     GraphicsView_ViewManager* aViewManager =
416       dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
417     if( aViewManager )
418       return aViewManager->getViewer();
419   }
420   return NULL;
421 }
422
423 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
424 {
425   ViewManagerMapIterator anIter( myViewManagerMap );
426   while( anIter.hasNext() )
427   {
428     int anId = anIter.next().key();
429     const ViewManagerInfo& anInfo = anIter.value();
430     if( anInfo.first == theViewManager )
431       return anId;
432   }
433   return -1;
434 }
435
436 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
437 {
438   int anId = getViewManagerId( theViewManager );
439   if( anId != -1 )
440   {
441     const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
442     return anInfo.second;
443   }
444   return VMR_Unknown;
445 }
446
447 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
448                                           const ViewManagerRole theRole )
449 {
450   int anId = getViewManagerId( theViewManager );
451   if( anId != -1 )
452   {
453     ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
454     anInfo.second = theRole;
455   }
456 }
457
458 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
459                                        const Handle(HYDROData_Object)& theObject )
460 {
461   if( theObject.IsNull() )
462     return false;
463
464   ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
465   if( anIter1 != myObjectStateMap.end() )
466   {
467     const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
468     Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
469     if( anIter2 != aName2ObjectStateMap.end() )
470     {
471       const ObjectState& anObjectState = anIter2.value();
472       return anObjectState.Visibility;
473     }
474   }
475   return false;
476 }
477
478 void HYDROGUI_Module::setObjectVisible( const int theViewId,
479                                         const Handle(HYDROData_Object)& theObject,
480                                         const bool theState )
481 {
482   if( !theObject.IsNull() )
483   {
484     Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
485     ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
486     anObjectState.Visibility = theState;
487   }
488 }
489
490 CAM_DataModel* HYDROGUI_Module::createDataModel()
491 {
492   return new HYDROGUI_DataModel( this );
493 }
494
495 void HYDROGUI_Module::customEvent( QEvent* e )
496 {
497   int aType = e->type();
498   if ( aType == NewViewEvent )
499   {
500     SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
501     if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
502     {
503       if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
504       {
505         if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
506         {
507           aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
508           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
509           aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
510
511           //ouv: temporarily commented
512           //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
513         }
514
515         SUIT_ViewManager* aViewManager = aViewer->getViewManager();
516         ViewManagerRole aRole = getViewManagerRole( aViewManager );
517         if( aRole != VMR_TransformImage )
518           update( UF_Viewer );
519
520         aViewer->activateTransform( GraphicsView_Viewer::FitAll );
521       }
522     }
523   }
524 }
525
526 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
527 {
528   QEvent::Type aType = theEvent->type();
529   if( theObj->inherits( "GraphicsView_ViewFrame" ) )
530   {
531     if( aType == QEvent::Show )
532     {
533       SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
534       e->setData( theObj );
535       QApplication::postEvent( this, e );
536       theObj->removeEventFilter( this );
537     }
538   }
539   return LightApp_Module::eventFilter( theObj, theEvent );
540 }
541
542 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
543 {
544   LightApp_Module::onViewManagerAdded( theViewManager );
545
546   if( theViewManager->getType() == GraphicsView_Viewer::Type() )
547   { 
548     createSelector( theViewManager ); // replace the default selector
549
550     connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
551              this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
552   }
553
554   ViewManagerInfo anInfo( theViewManager, VMR_General );
555   myViewManagerMap.insert( ViewManagerId++, anInfo );
556 }
557
558 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
559 {
560   LightApp_Module::onViewManagerRemoved( theViewManager );
561
562   createSelector( theViewManager ); // replace the default selector
563
564   int anId = getViewManagerId( theViewManager );
565   if( anId != -1 )
566     myViewManagerMap.remove( anId );
567 }
568
569 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
570 {
571   if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
572   {
573     if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
574     {
575       aViewFrame->installEventFilter( this );
576
577       GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
578
579       connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
580                this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
581       return;
582     }
583   }
584 }
585
586 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
587 {
588   if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
589   {
590     SUIT_ViewManager* aViewManager = 0;
591
592     QObject* aParent = aViewPort;
593     while( aParent = aParent->parent() )
594     {
595       if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
596       {
597         if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
598         {
599           aViewManager = aViewer->getViewManager();
600           break;
601         }
602       }
603     }
604
605     if( !aViewManager )
606       return;
607
608     double aMouseX = theEvent->scenePos().x();
609     double aMouseY = theEvent->scenePos().y();
610
611     ViewManagerRole aRole = getViewManagerRole( aViewManager );
612     if( aRole == VMR_General )
613     {
614       int aXDeg = 0, aYDeg = 0;
615       int aXMin = 0, aYMin = 0;
616       double aXSec = 0, aYSec = 0;
617       HYDROGUI_Tool::DoubleToLambert( aMouseX, aXDeg, aXMin, aXSec );
618       HYDROGUI_Tool::DoubleToLambert( aMouseY, aYDeg, aYMin, aYSec );
619
620       QString aDegSymbol( QChar( 0x00B0 ) );
621       QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
622       QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
623
624       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
625     }
626     else if( aRole == VMR_TransformImage )
627       aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
628   }
629 }
630
631 void HYDROGUI_Module::updateGV( const bool theIsInit,
632                                 const bool theIsForced )
633 {
634   if( !getDisplayer() )
635     return;
636
637   QList<int> aViewManagerIdList;
638
639   // currently, all views are updated
640   ViewManagerMapIterator anIter( myViewManagerMap );
641   while( anIter.hasNext() )
642   {
643     int anId = anIter.next().key();
644     aViewManagerIdList.append( anId );
645   }
646
647   QListIterator<int> anIdIter( aViewManagerIdList );
648   while( anIdIter.hasNext() )
649     getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
650 }
651
652 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
653 {
654   if( !theViewManager )
655     return;
656
657   LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
658   if( !aSelectionMgr )
659     return;
660
661   QString aViewType = theViewManager->getType();
662   if( aViewType != GraphicsView_Viewer::Type() )
663     return;
664
665   GraphicsView_ViewManager* aViewManager =
666     dynamic_cast<GraphicsView_ViewManager*>( theViewManager );
667   if( !aViewManager )
668     return;
669
670   QList<SUIT_Selector*> aSelectorList;
671   aSelectionMgr->selectors( aViewType, aSelectorList );
672
673   // disable all alien selectors
674   QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
675   for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
676   {
677     SUIT_Selector* aSelector = *anIter;
678     if( aSelector && !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) )
679       aSelector->setEnabled( false );
680   }
681
682   new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
683 }
684
685 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
686 {
687   bool aPrevState = myIsUpdateEnabled;
688   myIsUpdateEnabled = theState;
689   return aPrevState;
690 }
691
692 bool HYDROGUI_Module::isUpdateEnabled() const
693 {
694   return myIsUpdateEnabled;
695 }