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>
40 #include <HYDROData_Lambert93.h>
42 #include <HYDROData_OperationsFactory.h>
44 #include <GraphicsView_ViewFrame.h>
45 #include <GraphicsView_ViewManager.h>
46 #include <GraphicsView_ViewPort.h>
47 #include <GraphicsView_Viewer.h>
49 #include <ImageComposer_CutOperator.h>
50 #include <ImageComposer_CropOperator.h>
51 #include <ImageComposer_FuseOperator.h>
53 #include <LightApp_Application.h>
54 #include <LightApp_DataOwner.h>
55 #include <LightApp_GVSelector.h>
56 #include <LightApp_SelectionMgr.h>
57 #include <LightApp_UpdateFlags.h>
59 #include <OCCViewer_ViewFrame.h>
60 #include <OCCViewer_ViewManager.h>
61 #include <OCCViewer_ViewModel.h>
63 #include <SALOME_Event.h>
65 #include <SUIT_Desktop.h>
66 #include <SUIT_Study.h>
67 #include <SUIT_ViewManager.h>
70 #include <QApplication>
71 #include <QGraphicsSceneMouseEvent>
74 static int ViewManagerId = 0;
76 extern "C" HYDRO_EXPORT CAM_Module* createModule()
78 return new HYDROGUI_Module();
81 extern "C" HYDRO_EXPORT char* getModuleVersion()
83 return (char*)HYDRO_VERSION;
86 HYDROGUI_Module::HYDROGUI_Module()
87 : LightApp_Module( "HYDRO" ),
90 myIsUpdateEnabled( true )
94 HYDROGUI_Module::~HYDROGUI_Module()
98 int HYDROGUI_Module::getStudyId() const
100 LightApp_Application* anApp = getApp();
101 return anApp ? anApp->activeStudy()->id() : 0;
104 void HYDROGUI_Module::initialize( CAM_Application* theApp )
106 LightApp_Module::initialize( theApp );
109 createUndoRedoActions();
114 setMenuShown( false );
115 setToolShown( false );
117 myDisplayer = new HYDROGUI_Displayer( this );
118 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
121 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
123 bool aRes = LightApp_Module::activateModule( theStudy );
125 LightApp_Application* anApp = getApp();
126 SUIT_Desktop* aDesktop = anApp->desktop();
128 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
130 setMenuShown( true );
131 setToolShown( true );
133 #ifndef DISABLE_PYCONSOLE
134 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
135 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
140 updateCommandsStatus();
145 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
147 ViewManagerMapIterator anIter( myViewManagerMap );
148 while( anIter.hasNext() )
149 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
150 getApp()->removeViewManager( aViewManager );
151 myViewManagerMap.clear();
153 myObjectStateMap.clear();
156 // clear the data model's list of copying objects
157 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
159 setMenuShown( false );
160 setToolShown( false );
162 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
164 return LightApp_Module::deactivateModule( theStudy );
167 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
170 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
171 #ifndef DISABLE_PYCONSOLE
172 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
174 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
177 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
179 theTypesList << OCCViewer_Viewer::Type() << GraphicsView_Viewer::Type();
182 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
186 HYDROGUI_DataModel* aModel = getDataModel();
188 bool anIsObjectBrowser = theClient == "ObjectBrowser";
189 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
190 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
191 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView )
194 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
196 bool anIsSelectedDataObjects = false;
197 bool anIsVisibleInSelection = false;
198 bool anIsHiddenInSelection = false;
200 bool anIsImage = false;
201 bool anIsImportedImage = false;
202 bool anIsCompositeImage = false;
203 bool anIsFusedImage = false;
204 bool anIsCutImage = false;
205 bool anIsSplittedImage = false;
206 bool anIsMustBeUpdatedImage = false;
207 bool anIsPolyline = false;
208 bool anIsCalculation = false;
209 bool anIsImmersibleZone = false;
210 bool anIsVisualState = false;
212 // check the selected data model objects
213 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
214 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
216 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
217 if( !anObject.IsNull() )
219 anIsSelectedDataObjects = true;
221 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
222 anIsVisibleInSelection |= aVisibility;
223 anIsHiddenInSelection |= !aVisibility;
225 if( anObject->GetKind() == KIND_IMAGE )
228 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
229 if( !anImage.IsNull() )
231 anIsImportedImage = anImage->HasTrsfPoints() && !anImage->IsSelfSplitted();
232 anIsCompositeImage = anImage->NbReferences() > 0;
233 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
235 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
237 QString anOperatorName = anOperator->name();
238 if( anOperatorName == ImageComposer_FuseOperator::Type() )
239 anIsFusedImage = true;
240 else if( anOperatorName == ImageComposer_CutOperator::Type() )
242 else if( anOperatorName == ImageComposer_CropOperator::Type() )
243 anIsSplittedImage = true;
246 anIsMustBeUpdatedImage = anImage->MustBeUpdated();
249 else if( anObject->GetKind() == KIND_POLYLINE )
251 else if( anObject->GetKind() == KIND_CALCULATION )
252 anIsCalculation = true;
253 else if( anObject->GetKind() == KIND_IMMERSIBLE_ZONE )
254 anIsImmersibleZone = true;
255 else if( anObject->GetKind() == KIND_VISUAL_STATE )
256 anIsVisualState = true;
260 // check the selected partitions
261 if( !anIsSelectedDataObjects && anIsObjectBrowser )
263 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
264 if( aSelectedPartition != KIND_UNKNOWN )
266 switch( aSelectedPartition )
269 theMenu->addAction( action( ImportImageId ) );
272 theMenu->addAction( action( CreatePolylineId ) );
274 case KIND_VISUAL_STATE:
275 theMenu->addAction( action( SaveVisualStateId ) );
277 case KIND_BATHYMETRY:
278 theMenu->addAction( action( ImportBathymetryId ) );
280 case KIND_CALCULATION:
281 theMenu->addAction( action( CreateCalculationId ) );
283 case KIND_IMMERSIBLE_ZONE:
284 theMenu->addAction( action( CreateImmersibleZoneId ) );
287 theMenu->addSeparator();
291 if( anIsSelectedDataObjects && anIsMustBeUpdatedImage )
293 theMenu->addAction( action( UpdateImageId ) );
294 theMenu->addSeparator();
297 if( anIsSelectedDataObjects && aSeq.Length() == 1 )
301 if( anIsImportedImage )
302 theMenu->addAction( action( EditImportedImageId ) );
303 else if( anIsCompositeImage )
306 theMenu->addAction( action( EditFusedImageId ) );
307 else if( anIsCutImage )
308 theMenu->addAction( action( EditCutImageId ) );
309 else if( anIsSplittedImage )
310 theMenu->addAction( action( EditSplittedImageId ) );
313 theMenu->addAction( action( ObserveImageId ) );
314 theMenu->addAction( action( ExportImageId ) );
315 theMenu->addSeparator();
317 theMenu->addAction( action( FuseImagesId ) );
318 theMenu->addAction( action( CutImagesId ) );
319 theMenu->addAction( action( SplitImageId ) );
320 theMenu->addSeparator();
322 else if( anIsPolyline )
324 theMenu->addAction( action( EditPolylineId ) );
325 theMenu->addSeparator();
327 else if( anIsCalculation )
329 theMenu->addAction( action( EditCalculationId ) );
330 theMenu->addSeparator();
332 else if( anIsImmersibleZone )
334 theMenu->addAction( action( EditImmersibleZoneId ) );
335 theMenu->addSeparator();
337 else if( anIsVisualState && anIsObjectBrowser )
339 theMenu->addAction( action( SaveVisualStateId ) );
340 theMenu->addAction( action( LoadVisualStateId ) );
341 theMenu->addSeparator();
345 if( anIsSelectedDataObjects )
347 theMenu->addAction( action( DeleteId ) );
348 theMenu->addSeparator();
351 if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsImmersibleZone ) )
353 if( anIsHiddenInSelection )
354 theMenu->addAction( action( ShowId ) );
355 theMenu->addAction( action( ShowOnlyId ) );
356 if( anIsVisibleInSelection )
357 theMenu->addAction( action( HideId ) );
358 theMenu->addSeparator();
361 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView )
363 theMenu->addAction( action( ShowAllId ) );
364 theMenu->addAction( action( HideAllId ) );
365 theMenu->addSeparator();
369 void HYDROGUI_Module::update( const int flags )
371 if( !isUpdateEnabled() )
374 QApplication::setOverrideCursor( Qt::WaitCursor );
376 // To prevent calling this method recursively
377 // from one of the methods called below
378 setUpdateEnabled( false );
380 // store selected objects
381 QStringList aSelectedEntries = storeSelection();
383 if( ( flags & UF_Viewer ) )
384 updateGV( flags & UF_GV_Init,
385 flags & UF_GV_Forced );
387 if( ( flags & UF_OCCViewer ) )
388 updateOCCViewer( flags & UF_OCC_Init,
389 flags & UF_OCC_Forced );
391 if( ( flags & UF_Model ) && getDataModel() && getApp() )
393 getDataModel()->update( getStudyId() );
395 // Temporary workaround to prevent breaking
396 // the selection in the object browser.
397 // Note: processEvents() should be called after updateGV(),
398 // otherwise the application crashes from time to time.
399 //RKV: qApp->processEvents();
400 getApp()->updateObjectBrowser( true );
403 // Object browser is currently updated by using UF_Model flag
404 //if( ( flags & UF_ObjBrowser ) && getApp() )
405 // getApp()->updateObjectBrowser( true );
407 if( ( flags & UF_Controls ) && getApp() )
408 getApp()->updateActions();
410 // restore selected objects
411 restoreSelection( aSelectedEntries );
413 setUpdateEnabled( true );
415 QApplication::restoreOverrideCursor();
418 void HYDROGUI_Module::updateCommandsStatus()
420 LightApp_Module::updateCommandsStatus();
422 updateUndoRedoControls();
424 action( CopyId )->setEnabled( getDataModel()->canCopy() );
425 action( PasteId )->setEnabled( getDataModel()->canPaste() );
428 void HYDROGUI_Module::selectionChanged()
430 LightApp_Module::selectionChanged();
431 updateCommandsStatus();
434 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
436 return (HYDROGUI_DataModel*)dataModel();
439 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
444 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
446 return myOCCDisplayer;
449 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
451 if( myViewManagerMap.contains( theId ) )
453 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
454 GraphicsView_ViewManager* aViewManager =
455 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
457 return aViewManager->getViewer();
462 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
464 if( myViewManagerMap.contains( theId ) )
466 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
467 OCCViewer_ViewManager* aViewManager =
468 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
470 return aViewManager->getOCCViewer();
475 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
477 ViewManagerMapIterator anIter( myViewManagerMap );
478 while( anIter.hasNext() )
480 int anId = anIter.next().key();
481 const ViewManagerInfo& anInfo = anIter.value();
482 if( anInfo.first == theViewManager )
488 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
490 int anId = getViewManagerId( theViewManager );
493 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
494 return anInfo.second;
499 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
500 const ViewManagerRole theRole )
502 int anId = getViewManagerId( theViewManager );
505 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
506 anInfo.second = theRole;
510 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
511 const Handle(HYDROData_Entity)& theObject ) const
513 if( theObject.IsNull() )
516 ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
517 if( anIter1 != myObjectStateMap.end() )
519 const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
520 Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
521 if( anIter2 != aName2ObjectStateMap.end() )
523 const ObjectState& anObjectState = anIter2.value();
524 return anObjectState.Visibility;
530 void HYDROGUI_Module::setObjectVisible( const int theViewId,
531 const Handle(HYDROData_Entity)& theObject,
532 const bool theState )
534 if( !theObject.IsNull() )
536 Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
537 ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
538 anObjectState.Visibility = theState;
542 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
543 const Handle(HYDROData_Entity)& theObject ) const
545 HYDROGUI_Shape* aResShape = NULL;
546 if( theObject.IsNull() )
549 if ( myShapesMap.contains( theViewId ) )
551 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
552 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
554 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
565 void HYDROGUI_Module::setObjectShape( const int theViewId,
566 const Handle(HYDROData_Entity)& theObject,
567 HYDROGUI_Shape* theShape )
569 if( theObject.IsNull() )
572 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
573 aViewShapes.append( theShape );
576 void HYDROGUI_Module::removeObjectShape( const int theViewId,
577 const Handle(HYDROData_Entity)& theObject )
579 if ( !myShapesMap.contains( theViewId ) )
582 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
583 for ( int i = 0; i < aViewShapes.length(); )
585 HYDROGUI_Shape* aShape = aViewShapes.at( i );
586 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
589 aViewShapes.removeAt( i );
597 void HYDROGUI_Module::removeViewShapes( const int theViewId )
599 if ( !myShapesMap.contains( theViewId ) )
602 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
603 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
605 HYDROGUI_Shape* aShape = aViewShapes.at( i );
610 myShapesMap.remove( theViewId );
613 CAM_DataModel* HYDROGUI_Module::createDataModel()
615 return new HYDROGUI_DataModel( this );
618 void HYDROGUI_Module::customEvent( QEvent* e )
620 int aType = e->type();
621 if ( aType == NewViewEvent )
623 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
624 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
626 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
628 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
629 ViewManagerRole aRole = getViewManagerRole( aViewManager );
631 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
633 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
634 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
636 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
637 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
638 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
640 //ouv: temporarily commented
641 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
644 if( aRole != VMR_TransformImage )
647 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
653 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
655 QEvent::Type aType = theEvent->type();
656 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
658 if( aType == QEvent::Show )
660 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
661 e->setData( theObj );
662 QApplication::postEvent( this, e );
663 theObj->removeEventFilter( this );
666 return LightApp_Module::eventFilter( theObj, theEvent );
669 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
671 LightApp_Module::onViewManagerAdded( theViewManager );
673 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
675 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
676 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
678 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
680 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
681 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
684 createSelector( theViewManager ); // replace the default selector
686 ViewManagerInfo anInfo( theViewManager, VMR_General );
687 myViewManagerMap.insert( ViewManagerId++, anInfo );
690 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
692 LightApp_Module::onViewManagerRemoved( theViewManager );
694 createSelector( theViewManager ); // replace the default selector
696 int anId = getViewManagerId( theViewManager );
699 OCCViewer_ViewManager* anOCCViewManager =
700 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
701 if ( anOCCViewManager )
703 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
705 removeViewShapes( (size_t)anOCCViewer );
708 myViewManagerMap.remove( anId );
712 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
714 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
716 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
718 aViewFrame->installEventFilter( this );
720 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
722 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
723 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
726 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
728 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
730 aViewFrame->onTopView();
735 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
737 /* ouv: currently unused
738 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
740 SUIT_ViewManager* aViewManager = 0;
742 QObject* aParent = aViewPort;
743 while( aParent = aParent->parent() )
745 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
747 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
749 aViewManager = aViewer->getViewManager();
758 double aMouseX = theEvent->scenePos().x();
759 double aMouseY = theEvent->scenePos().y();
761 ViewManagerRole aRole = getViewManagerRole( aViewManager );
762 if( aRole == VMR_General )
764 int aXDeg = 0, aYDeg = 0;
765 int aXMin = 0, aYMin = 0;
766 double aXSec = 0, aYSec = 0;
767 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
768 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
770 QString aDegSymbol( QChar( 0x00B0 ) );
771 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
772 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
774 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
776 else if( aRole == VMR_TransformImage )
777 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
782 void HYDROGUI_Module::updateGV( const bool theIsInit,
783 const bool theIsForced )
785 if( !getDisplayer() )
788 QList<int> aViewManagerIdList;
790 // currently, all views are updated
791 ViewManagerMapIterator anIter( myViewManagerMap );
792 while( anIter.hasNext() )
794 GraphicsView_ViewManager* aViewManager =
795 dynamic_cast<GraphicsView_ViewManager*>( anIter.next().value().first );
799 int anId = anIter.key();
800 aViewManagerIdList.append( anId );
803 QListIterator<int> anIdIter( aViewManagerIdList );
804 while( anIdIter.hasNext() )
805 getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
808 void HYDROGUI_Module::updateOCCViewer( const bool theIsInit,
809 const bool theIsForced )
811 HYDROGUI_OCCDisplayer* anOCCDisplayer = getOCCDisplayer();
812 if( !anOCCDisplayer )
815 QList<int> aViewManagerIdList;
817 // currently, all views are updated
818 ViewManagerMapIterator anIter( myViewManagerMap );
819 while( anIter.hasNext() )
821 OCCViewer_ViewManager* aViewManager =
822 ::qobject_cast<OCCViewer_ViewManager*>( anIter.next().value().first );
826 int anId = anIter.key();
827 aViewManagerIdList.append( anId );
830 QListIterator<int> anIdIter( aViewManagerIdList );
831 while( anIdIter.hasNext() )
832 anOCCDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
835 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
837 if( !theViewManager )
840 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
844 QString aViewType = theViewManager->getType();
845 if( aViewType != GraphicsView_Viewer::Type() &&
846 aViewType != OCCViewer_Viewer::Type())
849 QList<SUIT_Selector*> aSelectorList;
850 aSelectionMgr->selectors( aViewType, aSelectorList );
852 // disable all alien selectors
853 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
854 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
856 SUIT_Selector* aSelector = *anIter;
857 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
858 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
859 aSelector->setEnabled( false );
862 if ( aViewType == GraphicsView_Viewer::Type() )
864 GraphicsView_ViewManager* aViewManager =
865 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
867 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
869 else if ( aViewType == OCCViewer_Viewer::Type() )
871 OCCViewer_ViewManager* aViewManager =
872 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
874 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
878 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
880 bool aPrevState = myIsUpdateEnabled;
881 myIsUpdateEnabled = theState;
885 bool HYDROGUI_Module::isUpdateEnabled() const
887 return myIsUpdateEnabled;
890 QStringList HYDROGUI_Module::storeSelection() const
892 QStringList anEntryList;
893 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
895 SUIT_DataOwnerPtrList aList( true );
896 aSelectionMgr->selected( aList );
898 SUIT_DataOwnerPtrList::iterator anIter;
899 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
901 const LightApp_DataOwner* anOwner =
902 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
904 anEntryList.append( anOwner->entry() );
910 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
912 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
914 SUIT_DataOwnerPtrList aList( true );
915 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
916 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
917 aSelectionMgr->setSelected( aList );