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_DataObject.h"
28 #include "HYDROGUI_Displayer.h"
29 #include "HYDROGUI_GVSelector.h"
30 #include "HYDROGUI_InputPanel.h"
31 #include "HYDROGUI_ObjSelector.h"
32 #include "HYDROGUI_OCCDisplayer.h"
33 #include "HYDROGUI_OCCSelector.h"
34 #include "HYDROGUI_Operations.h"
35 #include "HYDROGUI_PrsImage.h"
36 #include "HYDROGUI_Tool.h"
37 #include "HYDROGUI_UpdateFlags.h"
38 #include "HYDROGUI_Shape.h"
39 #include "HYDROGUI_VTKPrs.h"
40 #include "HYDROGUI_VTKPrsDisplayer.h"
41 #include "HYDROGUI_AbstractDisplayer.h"
42 #include "HYDROGUI_PolylineOp.h"
43 #include "HYDROGUI_SetColorOp.h"
44 #include "HYDROGUI_ImportGeomObjectOp.h"
46 #include <HYDROData_Image.h>
47 #include <HYDROData_Profile.h>
48 #include <HYDROData_Lambert93.h>
49 #include <HYDROData_Tool.h>
51 #include <HYDROData_OperationsFactory.h>
53 #include <CurveCreator_Utils.h>
55 #include <GraphicsView_ViewFrame.h>
56 #include <GraphicsView_ViewManager.h>
57 #include <GraphicsView_ViewPort.h>
58 #include <GraphicsView_Viewer.h>
60 #include <ImageComposer_CutOperator.h>
61 #include <ImageComposer_CropOperator.h>
62 #include <ImageComposer_FuseOperator.h>
64 #include <LightApp_Application.h>
65 #include <LightApp_DataOwner.h>
66 #include <LightApp_GVSelector.h>
67 #include <LightApp_SelectionMgr.h>
68 #include <LightApp_UpdateFlags.h>
70 #include <SalomeApp_Study.h>
72 #include <OCCViewer_ViewFrame.h>
73 #include <OCCViewer_ViewManager.h>
74 #include <OCCViewer_ViewModel.h>
76 #include <SALOME_Event.h>
78 #include <SUIT_DataBrowser.h>
79 #include <SUIT_Desktop.h>
80 #include <SUIT_Study.h>
81 #include <SUIT_ViewManager.h>
82 #include <SUIT_ResourceMgr.h>
84 #include <SVTK_ViewManager.h>
85 #include <SVTK_ViewModel.h>
86 #include <SVTK_ViewWindow.h>
87 #include <SVTK_Selector.h>
89 #include <OCCViewer_ViewPort3d.h>
91 #include <GEOMUtils.hxx>
92 #include <GeometryGUI.h>
94 #include <SALOMEDS_wrap.hxx>
97 #include <QApplication>
98 #include <QGraphicsSceneMouseEvent>
100 #include <QMouseEvent>
101 #include <QStatusBar>
104 static int ViewManagerId = 0;
106 extern "C" HYDRO_EXPORT CAM_Module* createModule()
108 return new HYDROGUI_Module();
111 extern "C" HYDRO_EXPORT char* getModuleVersion()
113 return (char*)HYDRO_VERSION;
116 HYDROGUI_Module::HYDROGUI_Module()
117 : LightApp_Module( "HYDRO" ),
120 myIsUpdateEnabled( true )
124 HYDROGUI_Module::~HYDROGUI_Module()
128 int HYDROGUI_Module::getStudyId() const
130 LightApp_Application* anApp = getApp();
131 return anApp ? anApp->activeStudy()->id() : 0;
134 void HYDROGUI_Module::initialize( CAM_Application* theApp )
136 LightApp_Module::initialize( theApp );
139 createUndoRedoActions();
144 setMenuShown( false );
145 setToolShown( false );
147 myDisplayer = new HYDROGUI_Displayer( this );
148 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
149 myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
152 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
154 bool aRes = LightApp_Module::activateModule( theStudy );
156 LightApp_Application* anApp = getApp();
157 SUIT_Desktop* aDesktop = anApp->desktop();
159 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
161 setMenuShown( true );
162 setToolShown( true );
164 #ifndef DISABLE_PYCONSOLE
165 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
166 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
169 // Remove defunct view managers from the map.
170 // It's essential to do this before "update( UF_All )" call!
171 QList<int> anObsoleteIds;
172 ViewManagerList anAllViewManagers = anApp->viewManagers();
173 ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
174 ViewManagerMapIterator anIter( myViewManagerMap );
175 while( anIter.hasNext() ) {
176 int anId = anIter.next().key();
177 const ViewManagerInfo& anInfo = anIter.value();
179 aHydroViewManagers << anInfo.first;
181 if ( !anAllViewManagers.contains( anInfo.first ) ) {
182 anObsoleteIds << anId;
185 foreach ( const int anId, anObsoleteIds ) {
186 myViewManagerMap.remove( anId );
187 myObjectStateMap.remove( anId );
188 myObjectDisplayOrderMap.remove( anId );
189 myShapesMap.remove( anId );
190 myVTKPrsMap.remove( anId );
192 // Replace the default selector for all view managers.
193 // Add view managers created outside of HYDRO module to the map.
194 foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
195 createSelector( aViewManager ); // replace the default selector
196 if ( !aHydroViewManagers.contains( aViewManager ) ) {
197 ViewManagerInfo anInfo( aViewManager, VMR_General );
198 myViewManagerMap.insert( ViewManagerId++, anInfo );
204 updateCommandsStatus();
206 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
208 ViewManagerList anOCCViewManagers;
209 anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
210 foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
211 connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
212 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
213 foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() ) {
214 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
215 if ( aViewFrame && aViewFrame->getViewPort() ) {
216 aViewFrame->getViewPort()->installEventFilter( this );
222 SalomeApp_Study* aStudy =
223 dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
225 SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
226 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
227 if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
228 SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
229 SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
230 if( !GEOM_var->_is_nil() ) {
231 aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
239 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
242 ViewManagerMapIterator anIter( myViewManagerMap );
243 while( anIter.hasNext() )
244 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
245 getApp()->removeViewManager( aViewManager );
246 myViewManagerMap.clear();
249 ViewManagerList anOCCViewManagers;
250 getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
251 foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
252 disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
253 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
257 myObjectStateMap.clear();
262 // clear the data model's list of copying objects
263 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
265 setMenuShown( false );
266 setToolShown( false );
268 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
270 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
272 return LightApp_Module::deactivateModule( theStudy );
275 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
278 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
279 #ifndef DISABLE_PYCONSOLE
280 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
282 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
285 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
287 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
290 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
294 HYDROGUI_DataModel* aModel = getDataModel();
296 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
297 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
298 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
299 bool anIsVTKView = theClient == SVTK_Viewer::Type();
300 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
303 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
305 bool anIsSelectedDataObjects = false;
306 bool anIsVisibleInSelection = false;
307 bool anIsHiddenInSelection = false;
309 bool anIsImage = false;
310 bool anIsImportedImage = false;
311 bool anIsImageHasRefs = false;
312 bool anIsFusedImage = false;
313 bool anIsCutImage = false;
314 bool anIsSplittedImage = false;
315 bool anIsMustObjectBeUpdated = false;
316 bool anIsPolyline = false;
317 bool anIsPolyline3D = false;
318 bool anIsProfile = false;
319 bool anIsValidProfile = false;
320 bool anAllAreProfiles = false;
321 bool anIsBathymetry = false;
322 bool anIsCalculation = false;
323 bool anIsImmersibleZone = false;
324 bool anIsVisualState = false;
325 bool anIsRegion = false;
326 bool anIsZone = false;
327 bool anIsObstacle = false;
328 bool anIsStream = false;
329 bool anIsChannel = false;
330 bool anIsDigue = false;
331 bool anIsDummyObject3D = false;
332 bool anIsGroup = false;
333 bool anIsObjectCanBeColored = false;
335 // Check the selected GEOM objects (take into account the Object Browser only)
336 if ( anIsObjectBrowser ) {
337 QList<GEOM::shape_type> anObstacleTypes =
338 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
339 QList<GEOM::shape_type> aPolylineTypes =
340 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
342 bool isCanBeImportedAsObstacle =
343 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
344 bool isCanBeImportedAsPolyline =
345 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
347 // Add import as obstacle action
348 if ( isCanBeImportedAsObstacle ) {
349 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
351 // Add import as polyline action
352 if ( isCanBeImportedAsPolyline ) {
353 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
356 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
357 theMenu->addSeparator();
361 // check the selected data model objects
362 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
363 int aNbOfSelectedProfiles = 0;
364 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
366 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
367 if( !anObject.IsNull() )
369 anIsSelectedDataObjects = true;
371 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
372 anIsVisibleInSelection |= aVisibility;
373 anIsHiddenInSelection |= !aVisibility;
375 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() )
377 anIsMustObjectBeUpdated = true;
380 ObjectKind anObjectKind = anObject->GetKind();
381 if( anObjectKind == KIND_IMAGE )
384 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
385 if( !anImage.IsNull() )
387 anIsImportedImage = anImage->HasLocalPoints();
388 anIsImageHasRefs = anImage->HasReferences();
389 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
391 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
393 QString anOperatorName = anOperator->name();
394 if( anOperatorName == ImageComposer_FuseOperator::Type() )
395 anIsFusedImage = true;
396 else if( anOperatorName == ImageComposer_CutOperator::Type() )
398 else if( anOperatorName == ImageComposer_CropOperator::Type() )
399 anIsSplittedImage = true;
404 else if( anObjectKind == KIND_POLYLINEXY )
406 else if( anObjectKind == KIND_POLYLINE )
407 anIsPolyline3D = true;
408 else if( anObjectKind == KIND_PROFILE )
411 aNbOfSelectedProfiles++;
413 Handle(HYDROData_Profile) aProfile =
414 Handle(HYDROData_Profile)::DownCast( anObject );
415 if( !aProfile.IsNull() && aProfile->IsValid() ) {
416 anIsValidProfile = true;
419 else if( anObjectKind == KIND_CALCULATION )
420 anIsCalculation = true;
421 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
422 anIsImmersibleZone = true;
423 else if( anObjectKind == KIND_VISUAL_STATE )
424 anIsVisualState = true;
425 else if( anObjectKind == KIND_REGION )
427 else if( anObjectKind == KIND_ZONE )
429 else if( anObjectKind == KIND_BATHYMETRY )
430 anIsBathymetry = true;
431 else if( anObjectKind == KIND_OBSTACLE )
433 else if( anObjectKind == KIND_STREAM )
435 else if( anObjectKind == KIND_CHANNEL )
437 else if( anObjectKind == KIND_DIGUE )
439 else if( anObjectKind == KIND_DUMMY_3D )
440 anIsDummyObject3D = true;
441 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLITTED_GROUP )
445 if ( !anIsObjectCanBeColored )
446 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject );
449 // Check if all selected objects are profiles
450 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
451 ( aNbOfSelectedProfiles == aSeq.Length() );
453 // check the selected partitions
454 if( !anIsSelectedDataObjects && anIsObjectBrowser )
456 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
457 if( aSelectedPartition != KIND_UNKNOWN )
459 switch( aSelectedPartition )
462 theMenu->addAction( action( ImportImageId ) );
464 case KIND_BATHYMETRY:
465 theMenu->addAction( action( ImportBathymetryId ) );
467 case KIND_ARTIFICIAL_OBJECT:
468 theMenu->addAction( action( CreateChannelId ) );
469 theMenu->addAction( action( CreateDigueId ) );
471 case KIND_NATURAL_OBJECT:
472 theMenu->addAction( action( CreateImmersibleZoneId ) );
473 theMenu->addAction( action( CreateStreamId ) );
476 theMenu->addAction( action( ImportObstacleFromFileId ) );
477 theMenu->addAction( action( CreateBoxId ) );
478 theMenu->addAction( action( CreateCylinderId ) );
480 case KIND_CALCULATION:
481 theMenu->addAction( action( CreateCalculationId ) );
483 case KIND_POLYLINEXY:
484 theMenu->addAction( action( CreatePolylineId ) );
487 theMenu->addAction( action( CreatePolyline3DId ) );
490 theMenu->addAction( action( CreateProfileId ) );
491 theMenu->addAction( action( ImportProfilesId ) );
492 theMenu->addAction( action( AllGeoreferencementId ) );
494 case KIND_VISUAL_STATE:
495 theMenu->addAction( action( SaveVisualStateId ) );
498 theMenu->addSeparator();
502 if( anIsSelectedDataObjects )
504 if ( anIsMustObjectBeUpdated )
506 theMenu->addAction( action( UpdateObjectId ) );
507 theMenu->addSeparator();
511 theMenu->addAction( action( ForcedUpdateObjectId ) );
512 theMenu->addSeparator();
516 if( aSeq.Length() == 1 )
520 if( anIsImportedImage )
521 theMenu->addAction( action( EditImportedImageId ) );
522 else if( anIsImageHasRefs )
525 theMenu->addAction( action( EditFusedImageId ) );
526 else if( anIsCutImage )
527 theMenu->addAction( action( EditCutImageId ) );
528 else if( anIsSplittedImage )
529 theMenu->addAction( action( EditSplittedImageId ) );
532 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
533 theMenu->addAction( action( ExportImageId ) );
534 theMenu->addSeparator();
536 if( anIsImageHasRefs )
538 theMenu->addAction( action( RemoveImageRefsId ) );
539 theMenu->addSeparator();
542 theMenu->addAction( action( FuseImagesId ) );
543 theMenu->addAction( action( CutImagesId ) );
544 theMenu->addAction( action( SplitImageId ) );
545 theMenu->addSeparator();
547 else if( anIsBathymetry )
549 theMenu->addAction( action( EditImportedBathymetryId ) );
550 theMenu->addAction( action( BathymetryBoundsId ) );
551 theMenu->addSeparator();
553 else if( anIsPolyline )
555 theMenu->addAction( action( EditPolylineId ) );
556 theMenu->addSeparator();
558 else if( anIsPolyline3D )
560 theMenu->addAction( action( EditPolyline3DId ) );
561 theMenu->addSeparator();
563 else if( anIsProfile )
565 theMenu->addAction( action( EditProfileId ) );
566 theMenu->addAction( action( SelectedGeoreferencementId ) );
567 theMenu->addSeparator();
569 else if( anIsCalculation )
571 theMenu->addAction( action( EditCalculationId ) );
572 theMenu->addAction( action( ExportCalculationId ) );
573 theMenu->addSeparator();
575 else if( anIsImmersibleZone )
577 theMenu->addAction( action( EditImmersibleZoneId ) );
578 theMenu->addSeparator();
580 else if( anIsStream )
582 theMenu->addAction( action( EditStreamId ) );
583 theMenu->addSeparator();
585 else if( anIsChannel )
587 theMenu->addAction( action( EditChannelId ) );
588 theMenu->addSeparator();
592 theMenu->addAction( action( EditDigueId ) );
593 theMenu->addSeparator();
595 else if( anIsVisualState && anIsObjectBrowser )
597 theMenu->addAction( action( SaveVisualStateId ) );
598 theMenu->addAction( action( LoadVisualStateId ) );
599 theMenu->addSeparator();
602 // Add set color action for geometrical objects
603 if ( anIsObjectCanBeColored )
605 theMenu->addAction( action( SetColorId ) );
606 theMenu->addSeparator();
608 } else if ( anAllAreProfiles ) {
609 theMenu->addAction( action( SelectedGeoreferencementId ) );
610 theMenu->addSeparator();
614 QAction* aCopyAction = action( CopyId );
615 if( aCopyAction && aCopyAction->isEnabled() ) {
616 theMenu->addAction( action( CopyId ) );
617 theMenu->addSeparator();
621 if( !anIsDummyObject3D )
622 theMenu->addAction( action( DeleteId ) );
624 theMenu->addSeparator();
626 if( anIsImage || anIsPolyline || anIsPolyline3D ||
627 anIsImmersibleZone || anIsZone || anIsRegion ||
628 anIsBathymetry || anIsObstacle || anIsStream ||
629 anIsChannel || anIsDigue || anIsDummyObject3D ||
630 anIsValidProfile || anIsGroup )
632 if( anIsHiddenInSelection )
633 theMenu->addAction( action( ShowId ) );
634 theMenu->addAction( action( ShowOnlyId ) );
635 if( anIsVisibleInSelection )
636 theMenu->addAction( action( HideId ) );
637 theMenu->addSeparator();
643 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
644 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
645 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
646 theMenu->addAction( action( DeleteId ) );
649 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
651 theMenu->addAction( action( ShowAllId ) );
652 theMenu->addAction( action( HideAllId ) );
653 theMenu->addSeparator();
655 if ( anIsOCCView || anIsVTKView ) {
656 theMenu->addSeparator();
657 theMenu->addAction( action( CopyViewerPositionId ) );
658 myPopupPos = QCursor::pos();
662 void HYDROGUI_Module::update( const int flags )
664 if( !isUpdateEnabled() )
667 QApplication::setOverrideCursor( Qt::WaitCursor );
669 // To prevent calling this method recursively
670 // from one of the methods called below
671 setUpdateEnabled( false );
673 // store selected objects
674 QStringList aSelectedEntries = storeSelection();
676 bool aDoFitAll = flags & UF_FitAll;
677 if( ( flags & UF_Viewer ) )
678 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
680 if( ( flags & UF_OCCViewer ) )
681 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
683 if( ( flags & UF_VTKViewer ) )
684 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
686 if( ( flags & UF_Model ) && getDataModel() && getApp() )
688 getDataModel()->update( getStudyId() );
690 // Temporary workaround to prevent breaking
691 // the selection in the object browser.
692 // Note: processEvents() should be called after updateGV(),
693 // otherwise the application crashes from time to time.
694 //RKV: qApp->processEvents();
695 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
696 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
697 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
698 if ( isResizeOnExpandItem && anObjectBrowser ) {
699 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
701 getApp()->updateObjectBrowser( true );
702 if ( isResizeOnExpandItem && anObjectBrowser ) {
703 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
707 // Object browser is currently updated by using UF_Model flag
708 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
709 getApp()->updateObjectBrowser( true );
711 if( ( flags & UF_Controls ) && getApp() )
712 getApp()->updateActions();
714 // restore selected objects
715 restoreSelection( aSelectedEntries );
717 setUpdateEnabled( true );
719 QApplication::restoreOverrideCursor();
722 void HYDROGUI_Module::updateCommandsStatus()
724 LightApp_Module::updateCommandsStatus();
726 updateUndoRedoControls();
728 action( CopyId )->setEnabled( getDataModel()->canCopy() );
729 action( PasteId )->setEnabled( getDataModel()->canPaste() );
732 void HYDROGUI_Module::selectionChanged()
734 LightApp_Module::selectionChanged();
735 updateCommandsStatus();
738 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
740 return (HYDROGUI_DataModel*)dataModel();
743 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
748 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
750 return myOCCDisplayer;
753 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
755 return myVTKDisplayer;
758 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
760 if( myViewManagerMap.contains( theId ) )
762 return myViewManagerMap[ theId ].first;
767 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
769 if( myViewManagerMap.contains( theId ) )
771 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
772 GraphicsView_ViewManager* aViewManager =
773 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
775 return aViewManager->getViewer();
780 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
782 if( myViewManagerMap.contains( theId ) )
784 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
785 OCCViewer_ViewManager* aViewManager =
786 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
788 return aViewManager->getOCCViewer();
793 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
795 if( myViewManagerMap.contains( theId ) )
797 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
798 SVTK_ViewManager* aViewManager =
799 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
801 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
806 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
808 ViewManagerMapIterator anIter( myViewManagerMap );
809 while( anIter.hasNext() )
811 int anId = anIter.next().key();
812 const ViewManagerInfo& anInfo = anIter.value();
813 if( anInfo.first == theViewManager )
819 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
821 int anId = getViewManagerId( theViewManager );
824 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
825 return anInfo.second;
830 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
831 const ViewManagerRole theRole )
833 int anId = getViewManagerId( theViewManager );
836 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
837 anInfo.second = theRole;
841 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
842 const Handle(HYDROData_Entity)& theObject ) const
844 if( theObject.IsNull() )
847 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
848 if( anIter1 != myObjectStateMap.end() )
850 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
851 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
853 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
854 if( anIter2 != aEntry2ObjectStateMap.end() )
856 const ObjectState& anObjectState = anIter2.value();
857 return anObjectState.Visibility;
863 void HYDROGUI_Module::setObjectVisible( const int theViewId,
864 const Handle(HYDROData_Entity)& theObject,
865 const bool theState )
867 if( !theObject.IsNull() )
869 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
870 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
872 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
873 anObjectState.Visibility = theState;
875 // Remember the display order ( needed for Z layers assignment only )
876 QStringList& anObjectEntries = myObjectDisplayOrderMap[ theViewId ];
877 anObjectEntries.removeAll( anEntry );
879 anObjectEntries.append( anEntry );
884 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
885 const bool theState )
887 if( !theObject.IsNull() )
889 // Process OCC shapes
890 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
891 while( aShapesMapIter != myShapesMap.end() )
893 const ListOfShapes& aShapesList = aShapesMapIter.value();
894 foreach ( HYDROGUI_Shape* aShape, aShapesList )
896 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
898 aShape->setIsToUpdate( theState );
903 // Process VTK shapes
904 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
905 while( aVTKPrsMapIter != myVTKPrsMap.end() )
907 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
908 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
910 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
912 aShape->setIsToUpdate( theState );
920 /////////////////// OCC SHAPES PROCESSING
921 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
922 const Handle(HYDROData_Entity)& theObject ) const
924 HYDROGUI_Shape* aResShape = NULL;
925 if( theObject.IsNull() )
928 if ( myShapesMap.contains( theViewId ) )
930 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
931 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
933 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
944 void HYDROGUI_Module::setObjectShape( const int theViewId,
945 const Handle(HYDROData_Entity)& theObject,
946 HYDROGUI_Shape* theShape )
948 if( theObject.IsNull() )
951 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
952 aViewShapes.append( theShape );
955 void HYDROGUI_Module::removeObjectShape( const int theViewId,
956 const Handle(HYDROData_Entity)& theObject )
958 if ( !myShapesMap.contains( theViewId ) )
961 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
962 Handle(HYDROData_Entity) anObject;
963 for ( int i = 0; i < aViewShapes.length(); )
965 HYDROGUI_Shape* aShape = aViewShapes.at( i );
966 anObject = aShape->getObject();
967 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
970 aViewShapes.removeAt( i );
978 void HYDROGUI_Module::removeViewShapes( const int theViewId )
980 if ( !myShapesMap.contains( theViewId ) )
983 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
984 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
986 HYDROGUI_Shape* aShape = aViewShapes.at( i );
991 myShapesMap.remove( theViewId );
993 /////////////////// END OF OCC SHAPES PROCESSING
995 /////////////////// VTKPrs PROCESSING
996 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
997 const Handle(HYDROData_Entity)& theObject ) const
999 HYDROGUI_VTKPrs* aResShape = NULL;
1000 if( theObject.IsNull() )
1003 if ( myVTKPrsMap.contains( theViewId ) )
1005 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1006 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1008 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1019 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1020 const Handle(HYDROData_Entity)& theObject,
1021 HYDROGUI_VTKPrs* theShape )
1023 if( theObject.IsNull() )
1026 if( theShape && theShape->needScalarBar() )
1028 // Compute the new global Z range from the added presentation and the old global Z range.
1029 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1030 double* aRange = theShape->getInternalZRange();
1031 bool anIsUpdate = false;
1032 if ( aRange[0] < aGlobalRange[0] )
1034 aGlobalRange[0] = aRange[0];
1037 if ( aRange[1] > aGlobalRange[1] )
1039 aGlobalRange[1] = aRange[1];
1045 updateVTKZRange( theViewId, aGlobalRange );
1049 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1050 aViewShapes.append( theShape );
1053 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1054 const Handle(HYDROData_Entity)& theObject )
1056 if ( !myVTKPrsMap.contains( theViewId ) )
1059 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1060 Handle(HYDROData_Entity) anObject;
1061 for ( int i = 0; i < aViewShapes.length(); )
1063 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1064 anObject = aShape->getObject();
1065 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1068 aViewShapes.removeAt( i );
1075 // Invalidate global Z range
1076 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1077 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1080 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1082 if ( !myVTKPrsMap.contains( theViewId ) )
1085 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1086 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1088 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1093 myVTKPrsMap.remove( theViewId );
1096 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1098 if ( myVTKPrsMap.contains( theViewId ) )
1100 // For the given viewer id update all VTK presentations ...
1101 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1102 HYDROGUI_VTKPrs* aShape;
1103 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1105 aShape = aViewShapes.at( i );
1106 if ( aShape && aShape->needScalarBar() )
1108 aShape->setZRange( theRange );
1112 // ... and update the global color legend scalar bar.
1113 getVTKDisplayer()->SetZRange( theViewId, theRange );
1115 /////////////////// END OF VTKPrs PROCESSING
1117 CAM_DataModel* HYDROGUI_Module::createDataModel()
1119 return new HYDROGUI_DataModel( this );
1122 void HYDROGUI_Module::customEvent( QEvent* e )
1124 int aType = e->type();
1125 if ( aType == NewViewEvent )
1127 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1128 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1130 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1132 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1133 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1135 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1137 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1138 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1140 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1141 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1142 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1144 //ouv: temporarily commented
1145 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1148 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1149 update( UF_Viewer );
1151 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1157 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1159 QEvent::Type aType = theEvent->type();
1160 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1162 if( aType == QEvent::Show )
1164 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1165 e->setData( theObj );
1166 QApplication::postEvent( this, e );
1167 theObj->removeEventFilter( this );
1170 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1172 if( aType == QEvent::Leave )
1174 SUIT_Desktop* aDesktop = getApp()->desktop();
1175 if ( aDesktop && aDesktop->statusBar() ) {
1176 aDesktop->statusBar()->clearMessage();
1180 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1182 if( aType == QEvent::Leave )
1184 SUIT_Desktop* aDesktop = getApp()->desktop();
1185 if ( aDesktop && aDesktop->statusBar() ) {
1186 aDesktop->statusBar()->clearMessage();
1191 return LightApp_Module::eventFilter( theObj, theEvent );
1194 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1196 LightApp_Module::onViewManagerAdded( theViewManager );
1198 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1200 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1201 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1203 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1205 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1206 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1207 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1208 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1210 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1212 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1213 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1214 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1215 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1218 createSelector( theViewManager ); // replace the default selector
1220 ViewManagerInfo anInfo( theViewManager, VMR_General );
1221 myViewManagerMap.insert( ViewManagerId++, anInfo );
1224 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1226 LightApp_Module::onViewManagerRemoved( theViewManager );
1228 createSelector( theViewManager ); // replace the default selector
1230 int anId = getViewManagerId( theViewManager );
1233 OCCViewer_ViewManager* anOCCViewManager =
1234 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1235 if ( anOCCViewManager )
1237 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1239 removeViewShapes( (size_t)anOCCViewer );
1242 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1244 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1247 getVTKDisplayer()->EraseScalarBar( anId, true );
1248 removeViewShapes( (size_t)aVTKViewer );
1252 myViewManagerMap.remove( anId );
1256 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1258 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1260 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1262 aViewFrame->installEventFilter( this );
1264 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1266 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1267 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1270 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1272 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1274 aViewFrame->onTopView();
1276 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1278 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1280 aViewPort->installEventFilter( this );
1284 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1286 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1288 aViewFrame->installEventFilter( this );
1293 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1295 /* ouv: currently unused
1296 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1298 SUIT_ViewManager* aViewManager = 0;
1300 QObject* aParent = aViewPort;
1301 while( aParent = aParent->parent() )
1303 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1305 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1307 aViewManager = aViewer->getViewManager();
1316 double aMouseX = theEvent->scenePos().x();
1317 double aMouseY = theEvent->scenePos().y();
1319 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1320 if( aRole == VMR_General )
1322 int aXDeg = 0, aYDeg = 0;
1323 int aXMin = 0, aYMin = 0;
1324 double aXSec = 0, aYSec = 0;
1325 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1326 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1328 QString aDegSymbol( QChar( 0x00B0 ) );
1329 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1330 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1332 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1334 else if( aRole == VMR_TransformImage )
1335 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1340 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1341 const bool theIsInit,
1342 const bool theIsForced,
1343 const bool theDoFitAll )
1345 QList<int> aViewManagerIdList;
1347 // currently, all views are updated
1348 ViewManagerMapIterator anIter( myViewManagerMap );
1349 while( anIter.hasNext() )
1351 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1353 if ( theDisplayer->IsApplicable( aViewManager ) )
1355 int anId = anIter.key();
1356 aViewManagerIdList.append( anId );
1360 QListIterator<int> anIdIter( aViewManagerIdList );
1361 while( anIdIter.hasNext() )
1363 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1367 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1369 if( !theViewManager )
1372 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1373 if( !aSelectionMgr )
1376 QString aViewType = theViewManager->getType();
1377 if( aViewType != GraphicsView_Viewer::Type() &&
1378 aViewType != OCCViewer_Viewer::Type())
1381 QList<SUIT_Selector*> aSelectorList;
1382 aSelectionMgr->selectors( aViewType, aSelectorList );
1384 // disable all alien selectors
1385 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1386 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1388 SUIT_Selector* aSelector = *anIter;
1389 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1390 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1391 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1392 aSelector->setEnabled( false );
1395 if ( aViewType == GraphicsView_Viewer::Type() )
1397 GraphicsView_ViewManager* aViewManager =
1398 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1400 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1402 else if ( aViewType == OCCViewer_Viewer::Type() )
1404 OCCViewer_ViewManager* aViewManager =
1405 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1407 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1411 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1413 bool aPrevState = myIsUpdateEnabled;
1414 myIsUpdateEnabled = theState;
1418 bool HYDROGUI_Module::isUpdateEnabled() const
1420 return myIsUpdateEnabled;
1423 QStringList HYDROGUI_Module::storeSelection() const
1425 QStringList anEntryList;
1426 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1428 SUIT_DataOwnerPtrList aList( true );
1429 aSelectionMgr->selected( aList );
1431 SUIT_DataOwnerPtrList::iterator anIter;
1432 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1434 const LightApp_DataOwner* anOwner =
1435 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1437 anEntryList.append( anOwner->entry() );
1443 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1445 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1447 SUIT_DataOwnerPtrList aList( true );
1448 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1449 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1450 aSelectionMgr->setSelected( aList );
1454 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1457 bool doShow = false;
1458 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1460 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, QCursor::pos(), aX, aY, aZ );
1464 // Show the coordinates in the status bar
1465 SUIT_Desktop* aDesktop = getApp()->desktop();
1466 if ( aDesktop && aDesktop->statusBar() ) {
1467 QString aXStr = HYDROGUI_Tool::GetCoordinateString( aX );
1468 QString anYStr = HYDROGUI_Tool::GetCoordinateString( aY );
1469 aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aXStr ).arg( anYStr ) );
1475 * Get the object display order. Needed for Z layers assignment only.
1477 int HYDROGUI_Module::getObjectDisplayOrder(
1478 const int theViewId, const Handle(HYDROData_Entity)& theObject) const
1480 if( theObject.IsNull() )
1483 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1484 QStringList anObjectEntries = myObjectDisplayOrderMap.value( theViewId );
1486 return anObjectEntries.indexOf( anEntry );
1490 * Get the popup menu position
1491 * \return the position
1493 QPoint HYDROGUI_Module::getPopupPosition() const