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_Operations.h"
33 #include "HYDROGUI_PrsImage.h"
34 #include "HYDROGUI_Tool.h"
35 #include "HYDROGUI_UpdateFlags.h"
36 #include "HYDROGUI_Shape.h"
38 #include <HYDROData_Image.h>
40 #include <HYDROOperations_Factory.h>
42 #include <GraphicsView_ViewFrame.h>
43 #include <GraphicsView_ViewManager.h>
44 #include <GraphicsView_ViewPort.h>
45 #include <GraphicsView_Viewer.h>
47 #include <ImageComposer_CutOperator.h>
48 #include <ImageComposer_CropOperator.h>
49 #include <ImageComposer_FuseOperator.h>
51 #include <LightApp_Application.h>
52 #include <LightApp_DataOwner.h>
53 #include <LightApp_GVSelector.h>
54 #include <LightApp_SelectionMgr.h>
55 #include <LightApp_UpdateFlags.h>
57 #include <OCCViewer_ViewFrame.h>
58 #include <OCCViewer_ViewManager.h>
59 #include <OCCViewer_ViewModel.h>
61 #include <SALOME_Event.h>
63 #include <SUIT_Desktop.h>
64 #include <SUIT_Study.h>
65 #include <SUIT_ViewManager.h>
68 #include <QApplication>
69 #include <QGraphicsSceneMouseEvent>
72 static int ViewManagerId = 0;
74 extern "C" HYDRO_EXPORT CAM_Module* createModule()
76 return new HYDROGUI_Module();
79 extern "C" HYDRO_EXPORT char* getModuleVersion()
81 return (char*)HYDRO_VERSION;
84 HYDROGUI_Module::HYDROGUI_Module()
85 : LightApp_Module( "HYDRO" ),
88 myIsUpdateEnabled( true )
92 HYDROGUI_Module::~HYDROGUI_Module()
96 int HYDROGUI_Module::getStudyId() const
98 LightApp_Application* anApp = getApp();
99 return anApp ? anApp->activeStudy()->id() : 0;
102 void HYDROGUI_Module::initialize( CAM_Application* theApp )
104 LightApp_Module::initialize( theApp );
107 createUndoRedoActions();
112 setMenuShown( false );
113 setToolShown( false );
115 myDisplayer = new HYDROGUI_Displayer( this );
116 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
119 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
121 bool aRes = LightApp_Module::activateModule( theStudy );
123 LightApp_Application* anApp = getApp();
124 SUIT_Desktop* aDesktop = anApp->desktop();
126 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
128 setMenuShown( true );
129 setToolShown( true );
131 #ifndef DISABLE_PYCONSOLE
132 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
133 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
138 updateCommandsStatus();
143 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
145 ViewManagerMapIterator anIter( myViewManagerMap );
146 while( anIter.hasNext() )
147 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
148 getApp()->removeViewManager( aViewManager );
149 myViewManagerMap.clear();
151 myObjectStateMap.clear();
154 // clear the data model's list of copying objects
155 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
157 setMenuShown( false );
158 setToolShown( false );
160 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
162 return LightApp_Module::deactivateModule( theStudy );
165 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
168 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
169 #ifndef DISABLE_PYCONSOLE
170 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
172 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
175 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
177 theTypesList << OCCViewer_Viewer::Type() << GraphicsView_Viewer::Type();
180 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
184 HYDROGUI_DataModel* aModel = getDataModel();
186 bool anIsObjectBrowser = theClient == "ObjectBrowser";
187 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
188 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
189 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView )
192 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
194 bool anIsSelectedDataObjects = false;
195 bool anIsVisibleInSelection = false;
196 bool anIsHiddenInSelection = false;
198 bool anIsImage = false;
199 bool anIsImportedImage = false;
200 bool anIsCompositeImage = false;
201 bool anIsFusedImage = false;
202 bool anIsCutImage = false;
203 bool anIsSplittedImage = false;
204 bool anIsMustBeUpdatedImage = false;
205 bool anIsPolyline = false;
206 bool anIsCalculation = false;
207 bool anIsZone = false;
208 bool anIsVisualState = false;
210 // check the selected data model objects
211 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
212 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
214 Handle(HYDROData_Object) anObject = aSeq.Value( anIndex );
215 if( !anObject.IsNull() )
217 anIsSelectedDataObjects = true;
219 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
220 anIsVisibleInSelection |= aVisibility;
221 anIsHiddenInSelection |= !aVisibility;
223 if( anObject->GetKind() == KIND_IMAGE )
226 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
227 if( !anImage.IsNull() )
229 anIsImportedImage = anImage->HasTrsfPoints() && !anImage->IsSelfSplitted();
230 anIsCompositeImage = anImage->NbReferences() > 0;
231 if( HYDROOperations_Factory* aFactory = HYDROOperations_Factory::Factory() )
233 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
235 QString anOperatorName = anOperator->name();
236 if( anOperatorName == ImageComposer_FuseOperator::Type() )
237 anIsFusedImage = true;
238 else if( anOperatorName == ImageComposer_CutOperator::Type() )
240 else if( anOperatorName == ImageComposer_CropOperator::Type() )
241 anIsSplittedImage = true;
244 anIsMustBeUpdatedImage = anImage->MustBeUpdated();
247 else if( anObject->GetKind() == KIND_POLYLINE )
249 else if( anObject->GetKind() == KIND_CALCULATION )
250 anIsCalculation = true;
251 else if( anObject->GetKind() == KIND_ZONE )
253 else if( anObject->GetKind() == KIND_VISUAL_STATE )
254 anIsVisualState = true;
258 // check the selected partitions
259 if( !anIsSelectedDataObjects && anIsObjectBrowser )
261 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
262 if( aSelectedPartition != KIND_UNKNOWN )
264 switch( aSelectedPartition )
267 theMenu->addAction( action( ImportImageId ) );
270 theMenu->addAction( action( CreatePolylineId ) );
272 case KIND_VISUAL_STATE:
273 theMenu->addAction( action( SaveVisualStateId ) );
275 case KIND_BATHYMETRY:
276 theMenu->addAction( action( ImportBathymetryId ) );
278 case KIND_CALCULATION:
279 theMenu->addAction( action( CreateCalculationId ) );
282 theMenu->addAction( action( CreateZoneId ) );
285 theMenu->addSeparator();
289 if( anIsSelectedDataObjects && anIsMustBeUpdatedImage )
291 theMenu->addAction( action( UpdateImageId ) );
292 theMenu->addSeparator();
295 if( anIsSelectedDataObjects && aSeq.Length() == 1 )
299 if( anIsImportedImage )
300 theMenu->addAction( action( EditImportedImageId ) );
301 else if( anIsCompositeImage )
304 theMenu->addAction( action( EditFusedImageId ) );
305 else if( anIsCutImage )
306 theMenu->addAction( action( EditCutImageId ) );
307 else if( anIsSplittedImage )
308 theMenu->addAction( action( EditSplittedImageId ) );
311 theMenu->addAction( action( ObserveImageId ) );
312 theMenu->addAction( action( ExportImageId ) );
313 theMenu->addSeparator();
315 theMenu->addAction( action( FuseImagesId ) );
316 theMenu->addAction( action( CutImagesId ) );
317 theMenu->addAction( action( SplitImageId ) );
318 theMenu->addSeparator();
320 else if( anIsPolyline )
322 theMenu->addAction( action( EditPolylineId ) );
323 theMenu->addSeparator();
325 else if( anIsCalculation )
327 theMenu->addAction( action( EditCalculationId ) );
328 theMenu->addSeparator();
332 theMenu->addAction( action( EditZoneId ) );
333 theMenu->addSeparator();
335 else if( anIsVisualState && anIsObjectBrowser )
337 theMenu->addAction( action( SaveVisualStateId ) );
338 theMenu->addAction( action( LoadVisualStateId ) );
339 theMenu->addSeparator();
343 if( anIsSelectedDataObjects )
345 theMenu->addAction( action( DeleteId ) );
346 theMenu->addSeparator();
349 if( anIsSelectedDataObjects && ( anIsImage || anIsPolyline || anIsZone ) )
351 if( anIsHiddenInSelection )
352 theMenu->addAction( action( ShowId ) );
353 theMenu->addAction( action( ShowOnlyId ) );
354 if( anIsVisibleInSelection )
355 theMenu->addAction( action( HideId ) );
356 theMenu->addSeparator();
359 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView )
361 theMenu->addAction( action( ShowAllId ) );
362 theMenu->addAction( action( HideAllId ) );
363 theMenu->addSeparator();
367 void HYDROGUI_Module::update( const int flags )
369 if( !isUpdateEnabled() )
372 QApplication::setOverrideCursor( Qt::WaitCursor );
374 // To prevent calling this method recursively
375 // from one of the methods called below
376 setUpdateEnabled( false );
378 // store selected objects
379 QStringList aSelectedEntries = storeSelection();
381 if( ( flags & UF_Viewer ) )
382 updateGV( flags & UF_GV_Init,
383 flags & UF_GV_Forced );
385 if( ( flags & UF_OCCViewer ) )
386 updateOCCViewer( flags & UF_OCC_Init,
387 flags & UF_OCC_Forced );
389 if( ( flags & UF_Model ) && getDataModel() && getApp() )
391 getDataModel()->update( getStudyId() );
393 // Temporary workaround to prevent breaking
394 // the selection in the object browser.
395 // Note: processEvents() should be called after updateGV(),
396 // otherwise the application crashes from time to time.
397 qApp->processEvents();
398 getApp()->updateObjectBrowser( true );
401 // Object browser is currently updated by using UF_Model flag
402 //if( ( flags & UF_ObjBrowser ) && getApp() )
403 // getApp()->updateObjectBrowser( true );
405 if( ( flags & UF_Controls ) && getApp() )
406 getApp()->updateActions();
408 // restore selected objects
409 restoreSelection( aSelectedEntries );
411 setUpdateEnabled( true );
413 QApplication::restoreOverrideCursor();
416 void HYDROGUI_Module::updateCommandsStatus()
418 LightApp_Module::updateCommandsStatus();
420 updateUndoRedoControls();
422 action( CopyId )->setEnabled( getDataModel()->canCopy() );
423 action( PasteId )->setEnabled( getDataModel()->canPaste() );
426 void HYDROGUI_Module::selectionChanged()
428 LightApp_Module::selectionChanged();
429 updateCommandsStatus();
432 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
434 return (HYDROGUI_DataModel*)dataModel();
437 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
442 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
444 return myOCCDisplayer;
447 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
449 if( myViewManagerMap.contains( theId ) )
451 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
452 GraphicsView_ViewManager* aViewManager =
453 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
455 return aViewManager->getViewer();
460 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
462 if( myViewManagerMap.contains( theId ) )
464 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
465 OCCViewer_ViewManager* aViewManager =
466 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
468 return aViewManager->getOCCViewer();
473 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
475 ViewManagerMapIterator anIter( myViewManagerMap );
476 while( anIter.hasNext() )
478 int anId = anIter.next().key();
479 const ViewManagerInfo& anInfo = anIter.value();
480 if( anInfo.first == theViewManager )
486 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
488 int anId = getViewManagerId( theViewManager );
491 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
492 return anInfo.second;
497 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
498 const ViewManagerRole theRole )
500 int anId = getViewManagerId( theViewManager );
503 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
504 anInfo.second = theRole;
508 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
509 const Handle(HYDROData_Object)& theObject ) const
511 if( theObject.IsNull() )
514 ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
515 if( anIter1 != myObjectStateMap.end() )
517 const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
518 Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
519 if( anIter2 != aName2ObjectStateMap.end() )
521 const ObjectState& anObjectState = anIter2.value();
522 return anObjectState.Visibility;
528 void HYDROGUI_Module::setObjectVisible( const int theViewId,
529 const Handle(HYDROData_Object)& theObject,
530 const bool theState )
532 if( !theObject.IsNull() )
534 Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
535 ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
536 anObjectState.Visibility = theState;
540 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
541 const Handle(HYDROData_Object)& theObject ) const
543 HYDROGUI_Shape* aResShape = NULL;
544 if( theObject.IsNull() )
547 if ( myShapesMap.contains( theViewId ) )
549 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
550 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
552 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
563 void HYDROGUI_Module::setObjectShape( const int theViewId,
564 const Handle(HYDROData_Object)& theObject,
565 HYDROGUI_Shape* theShape )
567 if( theObject.IsNull() )
570 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
571 aViewShapes.append( theShape );
574 void HYDROGUI_Module::removeObjectShape( const int theViewId,
575 const Handle(HYDROData_Object)& theObject )
577 if ( !myShapesMap.contains( theViewId ) )
580 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
581 for ( int i = 0; i < aViewShapes.length(); )
583 HYDROGUI_Shape* aShape = aViewShapes.at( i );
584 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
587 aViewShapes.removeAt( i );
595 void HYDROGUI_Module::removeViewShapes( const int theViewId )
597 if ( !myShapesMap.contains( theViewId ) )
600 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
601 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
603 HYDROGUI_Shape* aShape = aViewShapes.at( i );
608 myShapesMap.remove( theViewId );
611 CAM_DataModel* HYDROGUI_Module::createDataModel()
613 return new HYDROGUI_DataModel( this );
616 void HYDROGUI_Module::customEvent( QEvent* e )
618 int aType = e->type();
619 if ( aType == NewViewEvent )
621 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
622 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
624 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
626 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
628 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
629 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
630 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
632 //ouv: temporarily commented
633 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
636 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
637 ViewManagerRole aRole = getViewManagerRole( aViewManager );
638 if( aRole != VMR_TransformImage )
641 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
647 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
649 QEvent::Type aType = theEvent->type();
650 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
652 if( aType == QEvent::Show )
654 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
655 e->setData( theObj );
656 QApplication::postEvent( this, e );
657 theObj->removeEventFilter( this );
660 return LightApp_Module::eventFilter( theObj, theEvent );
663 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
665 LightApp_Module::onViewManagerAdded( theViewManager );
667 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
669 createSelector( theViewManager ); // replace the default selector
671 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
672 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
674 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
676 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
677 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
680 ViewManagerInfo anInfo( theViewManager, VMR_General );
681 myViewManagerMap.insert( ViewManagerId++, anInfo );
684 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
686 LightApp_Module::onViewManagerRemoved( theViewManager );
688 createSelector( theViewManager ); // replace the default selector
690 int anId = getViewManagerId( theViewManager );
693 OCCViewer_ViewManager* anOCCViewManager =
694 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
695 if ( anOCCViewManager )
697 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
699 removeViewShapes( (size_t)anOCCViewer );
702 myViewManagerMap.remove( anId );
706 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
708 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
710 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
712 aViewFrame->installEventFilter( this );
714 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
716 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
717 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
720 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
722 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
724 aViewFrame->onTopView();
729 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
731 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
733 SUIT_ViewManager* aViewManager = 0;
735 QObject* aParent = aViewPort;
736 while( aParent = aParent->parent() )
738 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
740 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
742 aViewManager = aViewer->getViewManager();
751 double aMouseX = theEvent->scenePos().x();
752 double aMouseY = theEvent->scenePos().y();
754 ViewManagerRole aRole = getViewManagerRole( aViewManager );
755 if( aRole == VMR_General )
757 int aXDeg = 0, aYDeg = 0;
758 int aXMin = 0, aYMin = 0;
759 double aXSec = 0, aYSec = 0;
760 HYDROGUI_Tool::DoubleToLambert( aMouseX, aXDeg, aXMin, aXSec );
761 HYDROGUI_Tool::DoubleToLambert( aMouseY, aYDeg, aYMin, aYSec );
763 QString aDegSymbol( QChar( 0x00B0 ) );
764 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
765 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
767 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
769 else if( aRole == VMR_TransformImage )
770 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
774 void HYDROGUI_Module::updateGV( const bool theIsInit,
775 const bool theIsForced )
777 if( !getDisplayer() )
780 QList<int> aViewManagerIdList;
782 // currently, all views are updated
783 ViewManagerMapIterator anIter( myViewManagerMap );
784 while( anIter.hasNext() )
786 GraphicsView_ViewManager* aViewManager =
787 dynamic_cast<GraphicsView_ViewManager*>( anIter.next().value().first );
791 int anId = anIter.key();
792 aViewManagerIdList.append( anId );
795 QListIterator<int> anIdIter( aViewManagerIdList );
796 while( anIdIter.hasNext() )
797 getDisplayer()->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
800 void HYDROGUI_Module::updateOCCViewer( const bool theIsInit,
801 const bool theIsForced )
803 HYDROGUI_OCCDisplayer* anOCCDisplayer = getOCCDisplayer();
804 if( !anOCCDisplayer )
807 QList<int> aViewManagerIdList;
809 // currently, all views are updated
810 ViewManagerMapIterator anIter( myViewManagerMap );
811 while( anIter.hasNext() )
813 OCCViewer_ViewManager* aViewManager =
814 ::qobject_cast<OCCViewer_ViewManager*>( anIter.next().value().first );
818 int anId = anIter.key();
819 aViewManagerIdList.append( anId );
822 QListIterator<int> anIdIter( aViewManagerIdList );
823 while( anIdIter.hasNext() )
824 anOCCDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced );
827 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
829 if( !theViewManager )
832 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
836 QString aViewType = theViewManager->getType();
837 if( aViewType != GraphicsView_Viewer::Type() )
840 GraphicsView_ViewManager* aViewManager =
841 dynamic_cast<GraphicsView_ViewManager*>( theViewManager );
845 QList<SUIT_Selector*> aSelectorList;
846 aSelectionMgr->selectors( aViewType, aSelectorList );
848 // disable all alien selectors
849 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
850 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
852 SUIT_Selector* aSelector = *anIter;
853 if( aSelector && !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) )
854 aSelector->setEnabled( false );
857 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
860 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
862 bool aPrevState = myIsUpdateEnabled;
863 myIsUpdateEnabled = theState;
867 bool HYDROGUI_Module::isUpdateEnabled() const
869 return myIsUpdateEnabled;
872 QStringList HYDROGUI_Module::storeSelection() const
874 QStringList anEntryList;
875 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
877 SUIT_DataOwnerPtrList aList( true );
878 aSelectionMgr->selected( aList );
880 SUIT_DataOwnerPtrList::iterator anIter;
881 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
883 const LightApp_DataOwner* anOwner =
884 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
886 anEntryList.append( anOwner->entry() );
892 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
894 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
896 SUIT_DataOwnerPtrList aList( true );
897 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
898 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
899 aSelectionMgr->setSelected( aList );