1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include "HYDROGUI_Module.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"
39 #include <HYDROData_Image.h>
41 #include <HYDROOperations_Factory.h>
43 #include <GraphicsView_ViewFrame.h>
44 #include <GraphicsView_ViewManager.h>
45 #include <GraphicsView_ViewPort.h>
46 #include <GraphicsView_Viewer.h>
48 #include <ImageComposer_CutOperator.h>
49 #include <ImageComposer_CropOperator.h>
50 #include <ImageComposer_FuseOperator.h>
52 #include <LightApp_Application.h>
53 #include <LightApp_DataOwner.h>
54 #include <LightApp_GVSelector.h>
55 #include <LightApp_SelectionMgr.h>
56 #include <LightApp_UpdateFlags.h>
58 #include <OCCViewer_ViewFrame.h>
59 #include <OCCViewer_ViewManager.h>
60 #include <OCCViewer_ViewModel.h>
62 #include <SALOME_Event.h>
64 #include <SUIT_Desktop.h>
65 #include <SUIT_Study.h>
66 #include <SUIT_ViewManager.h>
69 #include <QApplication>
70 #include <QGraphicsSceneMouseEvent>
73 static int ViewManagerId = 0;
75 extern "C" HYDRO_EXPORT CAM_Module* createModule()
77 return new HYDROGUI_Module();
80 extern "C" HYDRO_EXPORT char* getModuleVersion()
82 return (char*)HYDRO_VERSION;
85 HYDROGUI_Module::HYDROGUI_Module()
86 : LightApp_Module( "HYDRO" ),
89 myIsUpdateEnabled( true )
93 HYDROGUI_Module::~HYDROGUI_Module()
97 int HYDROGUI_Module::getStudyId() const
99 LightApp_Application* anApp = getApp();
100 return anApp ? anApp->activeStudy()->id() : 0;
103 void HYDROGUI_Module::initialize( CAM_Application* theApp )
105 LightApp_Module::initialize( theApp );
108 createUndoRedoActions();
113 setMenuShown( false );
114 setToolShown( false );
116 myDisplayer = new HYDROGUI_Displayer( this );
117 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
120 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
122 bool aRes = LightApp_Module::activateModule( theStudy );
124 LightApp_Application* anApp = getApp();
125 SUIT_Desktop* aDesktop = anApp->desktop();
127 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
129 setMenuShown( true );
130 setToolShown( true );
132 #ifndef DISABLE_PYCONSOLE
133 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
134 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
139 updateCommandsStatus();
144 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
146 ViewManagerMapIterator anIter( myViewManagerMap );
147 while( anIter.hasNext() )
148 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
149 getApp()->removeViewManager( aViewManager );
150 myViewManagerMap.clear();
152 myObjectStateMap.clear();
155 // clear the data model's list of copying objects
156 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
158 setMenuShown( false );
159 setToolShown( false );
161 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
163 return LightApp_Module::deactivateModule( theStudy );
166 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
169 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
170 #ifndef DISABLE_PYCONSOLE
171 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
173 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
176 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
178 theTypesList << OCCViewer_Viewer::Type() << GraphicsView_Viewer::Type();
181 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
185 HYDROGUI_DataModel* aModel = getDataModel();
187 bool anIsObjectBrowser = theClient == "ObjectBrowser";
188 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
189 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
190 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView )
193 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
195 bool anIsSelectedDataObjects = false;
196 bool anIsVisibleInSelection = false;
197 bool anIsHiddenInSelection = false;
199 bool anIsImage = false;
200 bool anIsImportedImage = false;
201 bool anIsCompositeImage = false;
202 bool anIsFusedImage = false;
203 bool anIsCutImage = false;
204 bool anIsSplittedImage = false;
205 bool anIsMustBeUpdatedImage = false;
206 bool anIsPolyline = false;
207 bool anIsCalculation = false;
208 bool anIsZone = false;
209 bool anIsVisualState = false;
211 // check the selected data model objects
212 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
213 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
215 Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
216 if( !anObject.IsNull() )
218 anIsSelectedDataObjects = true;
220 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
221 anIsVisibleInSelection |= aVisibility;
222 anIsHiddenInSelection |= !aVisibility;
224 if( anObject->GetKind() == KIND_IMAGE )
227 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
228 if( !anImage.IsNull() )
230 anIsImportedImage = anImage->HasTrsfPoints() && !anImage->IsSelfSplitted();
231 anIsCompositeImage = anImage->NbReferences() > 0;
232 if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
234 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
236 QString anOperatorName = anOperator->name();
237 if( anOperatorName == ImageComposer_FuseOperator::Type() )
238 anIsFusedImage = true;
239 else if( anOperatorName == ImageComposer_CutOperator::Type() )
241 else if( anOperatorName == ImageComposer_CropOperator::Type() )
242 anIsSplittedImage = true;
245 anIsMustBeUpdatedImage = anImage->MustBeUpdated();
248 else if( anObject->GetKind() == KIND_POLYLINE )
250 else if( anObject->GetKind() == KIND_CALCULATION )
251 anIsCalculation = true;
252 else if( anObject->GetKind() == KIND_ZONE )
254 else if( anObject->GetKind() == KIND_VISUAL_STATE )
255 anIsVisualState = true;
259 // check the selected partitions
260 if( !anIsSelectedDataObjects && anIsObjectBrowser )
262 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
263 if( aSelectedPartition != KIND_UNKNOWN )
265 switch( aSelectedPartition )
268 theMenu->addAction( action( ImportImageId ) );
271 theMenu->addAction( action( CreatePolylineId ) );
273 case KIND_VISUAL_STATE:
274 theMenu->addAction( action( SaveVisualStateId ) );
276 case KIND_BATHYMETRY:
277 theMenu->addAction( action( ImportBathymetryId ) );
279 case KIND_CALCULATION:
280 theMenu->addAction( action( CreateCalculationId ) );
283 theMenu->addAction( action( CreateZoneId ) );
286 theMenu->addSeparator();
290 if( anIsSelectedDataObjects && anIsMustBeUpdatedImage )
292 theMenu->addAction( action( UpdateImageId ) );
293 theMenu->addSeparator();
296 if( anIsSelectedDataObjects && aSeq.Length() == 1 )
300 if( anIsImportedImage )
301 theMenu->addAction( action( EditImportedImageId ) );
302 else if( anIsCompositeImage )
305 theMenu->addAction( action( EditFusedImageId ) );
306 else if( anIsCutImage )
307 theMenu->addAction( action( EditCutImageId ) );
308 else if( anIsSplittedImage )
309 theMenu->addAction( action( EditSplittedImageId ) );
312 theMenu->addAction( action( ObserveImageId ) );
313 theMenu->addAction( action( ExportImageId ) );
314 theMenu->addSeparator();
316 theMenu->addAction( action( FuseImagesId ) );
317 theMenu->addAction( action( CutImagesId ) );
318 theMenu->addAction( action( SplitImageId ) );
319 theMenu->addSeparator();
321 else if( anIsPolyline )
323 theMenu->addAction( action( EditPolylineId ) );
324 theMenu->addSeparator();
326 else if( anIsCalculation )
328 theMenu->addAction( action( EditCalculationId ) );
329 theMenu->addSeparator();
333 theMenu->addAction( action( EditZoneId ) );
334 theMenu->addSeparator();
336 else if( anIsVisualState && anIsObjectBrowser )
338 theMenu->addAction( action( SaveVisualStateId ) );
339 theMenu->addAction( action( LoadVisualStateId ) );
340 theMenu->addSeparator();
344 if( anIsSelectedDataObjects )
346 theMenu->addAction( action( DeleteId ) );
347 theMenu->addSeparator();
350 if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsZone ) )
352 if( anIsHiddenInSelection )
353 theMenu->addAction( action( ShowId ) );
354 theMenu->addAction( action( ShowOnlyId ) );
355 if( anIsVisibleInSelection )
356 theMenu->addAction( action( HideId ) );
357 theMenu->addSeparator();
360 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView )
362 theMenu->addAction( action( ShowAllId ) );
363 theMenu->addAction( action( HideAllId ) );
364 theMenu->addSeparator();
368 void HYDROGUI_Module::update( const int flags )
370 if( !isUpdateEnabled() )
373 QApplication::setOverrideCursor( Qt::WaitCursor );
375 // To prevent calling this method recursively
376 // from one of the methods called below
377 setUpdateEnabled( false );
379 // store selected objects
380 QStringList aSelectedEntries = storeSelection();
382 if( ( flags & UF_Viewer ) )
383 updateGV( flags & UF_GV_Init,
384 flags & UF_GV_Forced );
386 if( ( flags & UF_OCCViewer ) )
387 updateOCCViewer( flags & UF_OCC_Init,
388 flags & UF_OCC_Forced );
390 if( ( flags & UF_Model ) && getDataModel() && getApp() )
392 getDataModel()->update( getStudyId() );
394 // Temporary workaround to prevent breaking
395 // the selection in the object browser.
396 // Note: processEvents() should be called after updateGV(),
397 // otherwise the application crashes from time to time.
398 qApp->processEvents();
399 getApp()->updateObjectBrowser( true );
402 // Object browser is currently updated by using UF_Model flag
403 //if( ( flags & UF_ObjBrowser ) && getApp() )
404 // getApp()->updateObjectBrowser( true );
406 if( ( flags & UF_Controls ) && getApp() )
407 getApp()->updateActions();
409 // restore selected objects
410 restoreSelection( aSelectedEntries );
412 setUpdateEnabled( true );
414 QApplication::restoreOverrideCursor();
417 void HYDROGUI_Module::updateCommandsStatus()
419 LightApp_Module::updateCommandsStatus();
421 updateUndoRedoControls();
423 action( CopyId )->setEnabled( getDataModel()->canCopy() );
424 action( PasteId )->setEnabled( getDataModel()->canPaste() );
427 void HYDROGUI_Module::selectionChanged()
429 LightApp_Module::selectionChanged();
430 updateCommandsStatus();
433 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
435 return (HYDROGUI_DataModel*)dataModel();
438 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
443 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
445 return myOCCDisplayer;
448 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
450 if( myViewManagerMap.contains( theId ) )
452 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
453 GraphicsView_ViewManager* aViewManager =
454 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
456 return aViewManager->getViewer();
461 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
463 if( myViewManagerMap.contains( theId ) )
465 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
466 OCCViewer_ViewManager* aViewManager =
467 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
469 return aViewManager->getOCCViewer();
474 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
476 ViewManagerMapIterator anIter( myViewManagerMap );
477 while( anIter.hasNext() )
479 int anId = anIter.next().key();
480 const ViewManagerInfo& anInfo = anIter.value();
481 if( anInfo.first == theViewManager )
487 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
489 int anId = getViewManagerId( theViewManager );
492 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
493 return anInfo.second;
498 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
499 const ViewManagerRole theRole )
501 int anId = getViewManagerId( theViewManager );
504 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
505 anInfo.second = theRole;
509 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
510 const Handle(HYDROData_Object)& theObject ) const
512 if( theObject.IsNull() )
515 ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
516 if( anIter1 != myObjectStateMap.end() )
518 const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
519 Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
520 if( anIter2 != aName2ObjectStateMap.end() )
522 const ObjectState& anObjectState = anIter2.value();
523 return anObjectState.Visibility;
529 void HYDROGUI_Module::setObjectVisible( const int theViewId,
530 const Handle(HYDROData_Object)& theObject,
531 const bool theState )
533 if( !theObject.IsNull() )
535 Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
536 ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
537 anObjectState.Visibility = theState;
541 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
542 const Handle(HYDROData_Object)& theObject ) const
544 HYDROGUI_Shape* aResShape = NULL;
545 if( theObject.IsNull() )
548 if ( myShapesMap.contains( theViewId ) )
550 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
551 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
553 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
564 void HYDROGUI_Module::setObjectShape( const int theViewId,
565 const Handle(HYDROData_Object)& theObject,
566 HYDROGUI_Shape* theShape )
568 if( theObject.IsNull() )
571 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
572 aViewShapes.append( theShape );
575 void HYDROGUI_Module::removeObjectShape( const int theViewId,
576 const Handle(HYDROData_Object)& theObject )
578 if ( !myShapesMap.contains( theViewId ) )
581 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
582 for ( int i = 0; i < aViewShapes.length(); )
584 HYDROGUI_Shape* aShape = aViewShapes.at( i );
585 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
588 aViewShapes.removeAt( i );
596 void HYDROGUI_Module::removeViewShapes( const int theViewId )
598 if ( !myShapesMap.contains( theViewId ) )
601 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
602 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
604 HYDROGUI_Shape* aShape = aViewShapes.at( i );
609 myShapesMap.remove( theViewId );
612 CAM_DataModel* HYDROGUI_Module::createDataModel()
614 return new HYDROGUI_DataModel( this );
617 void HYDROGUI_Module::customEvent( QEvent* e )
619 int aType = e->type();
620 if ( aType == NewViewEvent )
622 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
623 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
625 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
627 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
629 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
630 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
631 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
633 //ouv: temporarily commented
634 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
637 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
638 ViewManagerRole aRole = getViewManagerRole( aViewManager );
639 if( aRole != VMR_TransformImage )
642 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
648 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
650 QEvent::Type aType = theEvent->type();
651 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
653 if( aType == QEvent::Show )
655 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
656 e->setData( theObj );
657 QApplication::postEvent( this, e );
658 theObj->removeEventFilter( this );
661 return LightApp_Module::eventFilter( theObj, theEvent );
664 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
666 LightApp_Module::onViewManagerAdded( theViewManager );
668 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
670 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
671 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
673 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
675 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
676 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
679 createSelector( theViewManager ); // replace the default selector
681 ViewManagerInfo anInfo( theViewManager, VMR_General );
682 myViewManagerMap.insert( ViewManagerId++, anInfo );
685 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
687 LightApp_Module::onViewManagerRemoved( theViewManager );
689 createSelector( theViewManager ); // replace the default selector
691 int anId = getViewManagerId( theViewManager );
694 OCCViewer_ViewManager* anOCCViewManager =
695 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
696 if ( anOCCViewManager )
698 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
700 removeViewShapes( (size_t)anOCCViewer );
703 myViewManagerMap.remove( anId );
707 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
709 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
711 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
713 aViewFrame->installEventFilter( this );
715 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
717 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
718 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
721 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
723 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
725 aViewFrame->onTopView();
730 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
732 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
734 SUIT_ViewManager* aViewManager = 0;
736 QObject* aParent = aViewPort;
737 while( aParent = aParent->parent() )
739 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
741 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
743 aViewManager = aViewer->getViewManager();
752 double aMouseX = theEvent->scenePos().x();
753 double aMouseY = theEvent->scenePos().y();
755 ViewManagerRole aRole = getViewManagerRole( aViewManager );
756 if( aRole == VMR_General )
758 int aXDeg = 0, aYDeg = 0;
759 int aXMin = 0, aYMin = 0;
760 double aXSec = 0, aYSec = 0;
761 HYDROGUI_Tool::DoubleToLambert( aMouseX, aXDeg, aXMin, aXSec );
762 HYDROGUI_Tool::DoubleToLambert( aMouseY, aYDeg, aYMin, aYSec );
764 QString aDegSymbol( QChar( 0x00B0 ) );
765 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
766 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
768 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
770 else if( aRole == VMR_TransformImage )
771 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
775 void HYDROGUI_Module::updateGV( const bool theIsInit,
776 const bool theIsForced )
778 if( !getDisplayer() )
781 QList<int> aViewManagerIdList;
783 // currently, all views are updated
784 ViewManagerMapIterator anIter( myViewManagerMap );
785 while( anIter.hasNext() )
787 GraphicsView_ViewManager* aViewManager =
788 dynamic_cast<GraphicsView_ViewManager*>( anIter.next().value().first );
792 int anId = anIter.key();
793 aViewManagerIdList.append( anId );
796 QListIterator<int> anIdIter( aViewManagerIdList );
797 while( anIdIter.hasNext() )
798 getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
801 void HYDROGUI_Module::updateOCCViewer( const bool theIsInit,
802 const bool theIsForced )
804 HYDROGUI_OCCDisplayer* anOCCDisplayer = getOCCDisplayer();
805 if( !anOCCDisplayer )
808 QList<int> aViewManagerIdList;
810 // currently, all views are updated
811 ViewManagerMapIterator anIter( myViewManagerMap );
812 while( anIter.hasNext() )
814 OCCViewer_ViewManager* aViewManager =
815 ::qobject_cast<OCCViewer_ViewManager*>( anIter.next().value().first );
819 int anId = anIter.key();
820 aViewManagerIdList.append( anId );
823 QListIterator<int> anIdIter( aViewManagerIdList );
824 while( anIdIter.hasNext() )
825 anOCCDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
828 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
830 if( !theViewManager )
833 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
837 QString aViewType = theViewManager->getType();
838 if( aViewType != GraphicsView_Viewer::Type() &&
839 aViewType != OCCViewer_Viewer::Type())
842 QList<SUIT_Selector*> aSelectorList;
843 aSelectionMgr->selectors( aViewType, aSelectorList );
845 // disable all alien selectors
846 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
847 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
849 SUIT_Selector* aSelector = *anIter;
850 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
851 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
852 aSelector->setEnabled( false );
855 if ( aViewType == GraphicsView_Viewer::Type() )
857 GraphicsView_ViewManager* aViewManager =
858 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
860 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
862 else if ( aViewType == OCCViewer_Viewer::Type() )
864 OCCViewer_ViewManager* aViewManager =
865 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
867 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
871 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
873 bool aPrevState = myIsUpdateEnabled;
874 myIsUpdateEnabled = theState;
878 bool HYDROGUI_Module::isUpdateEnabled() const
880 return myIsUpdateEnabled;
883 QStringList HYDROGUI_Module::storeSelection() const
885 QStringList anEntryList;
886 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
888 SUIT_DataOwnerPtrList aList( true );
889 aSelectionMgr->selected( aList );
891 SUIT_DataOwnerPtrList::iterator anIter;
892 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
894 const LightApp_DataOwner* anOwner =
895 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
897 anEntryList.append( anOwner->entry() );
903 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
905 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
907 SUIT_DataOwnerPtrList aList( true );
908 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
909 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
910 aSelectionMgr->setSelected( aList );