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"
38 #include "HYDROGUI_VTKPrs.h"
39 #include "HYDROGUI_VTKPrsDisplayer.h"
40 #include "HYDROGUI_AbstractDisplayer.h"
41 #include "HYDROGUI_PolylineOp.h"
42 #include "HYDROGUI_SetColorOp.h"
43 #include "HYDROGUI_ImportGeomObjectOp.h"
45 #include <HYDROData_Image.h>
46 #include <HYDROData_Profile.h>
47 #include <HYDROData_Lambert93.h>
48 #include <HYDROData_Tool.h>
50 #include <HYDROData_OperationsFactory.h>
52 #include <CurveCreator_Utils.h>
54 #include <GraphicsView_ViewFrame.h>
55 #include <GraphicsView_ViewManager.h>
56 #include <GraphicsView_ViewPort.h>
57 #include <GraphicsView_Viewer.h>
59 #include <ImageComposer_CutOperator.h>
60 #include <ImageComposer_CropOperator.h>
61 #include <ImageComposer_FuseOperator.h>
63 #include <LightApp_Application.h>
64 #include <LightApp_DataOwner.h>
65 #include <LightApp_GVSelector.h>
66 #include <LightApp_SelectionMgr.h>
67 #include <LightApp_UpdateFlags.h>
69 #include <SalomeApp_Study.h>
71 #include <OCCViewer_ViewFrame.h>
72 #include <OCCViewer_ViewManager.h>
73 #include <OCCViewer_ViewModel.h>
75 #include <SALOME_Event.h>
77 #include <SUIT_DataBrowser.h>
78 #include <SUIT_Desktop.h>
79 #include <SUIT_Study.h>
80 #include <SUIT_ViewManager.h>
81 #include <SUIT_ResourceMgr.h>
83 #include <SVTK_ViewManager.h>
84 #include <SVTK_ViewModel.h>
85 #include <SVTK_ViewWindow.h>
86 #include <SVTK_Selector.h>
87 #include <SVTK_RenderWindowInteractor.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>
103 static int ViewManagerId = 0;
105 extern "C" HYDRO_EXPORT CAM_Module* createModule()
107 return new HYDROGUI_Module();
110 extern "C" HYDRO_EXPORT char* getModuleVersion()
112 return (char*)HYDRO_VERSION;
115 HYDROGUI_Module::HYDROGUI_Module()
116 : LightApp_Module( "HYDRO" ),
119 myIsUpdateEnabled( true )
123 HYDROGUI_Module::~HYDROGUI_Module()
127 int HYDROGUI_Module::getStudyId() const
129 LightApp_Application* anApp = getApp();
130 return anApp ? anApp->activeStudy()->id() : 0;
133 void HYDROGUI_Module::initialize( CAM_Application* theApp )
135 LightApp_Module::initialize( theApp );
138 createUndoRedoActions();
143 setMenuShown( false );
144 setToolShown( false );
146 myDisplayer = new HYDROGUI_Displayer( this );
147 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
148 myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
151 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
153 bool aRes = LightApp_Module::activateModule( theStudy );
155 LightApp_Application* anApp = getApp();
156 SUIT_Desktop* aDesktop = anApp->desktop();
158 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
160 setMenuShown( true );
161 setToolShown( true );
163 #ifndef DISABLE_PYCONSOLE
164 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
165 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
168 // Remove defunct view managers from the map.
169 // It's essential to do this before "update( UF_All )" call!
170 QList<int> anObsoleteIds;
171 ViewManagerList anAllViewManagers = anApp->viewManagers();
172 ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
173 ViewManagerMapIterator anIter( myViewManagerMap );
174 while( anIter.hasNext() ) {
175 int anId = anIter.next().key();
176 const ViewManagerInfo& anInfo = anIter.value();
178 aHydroViewManagers << anInfo.first;
180 if ( !anAllViewManagers.contains( anInfo.first ) ) {
181 anObsoleteIds << anId;
184 foreach ( const int anId, anObsoleteIds ) {
185 myViewManagerMap.remove( anId );
186 myObjectStateMap.remove( anId );
187 myShapesMap.remove( anId );
188 myVTKPrsMap.remove( anId );
190 // Replace the default selector for all view managers.
191 // Add view managers created outside of HYDRO module to the map.
192 foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
193 createSelector( aViewManager ); // replace the default selector
194 if ( !aHydroViewManagers.contains( aViewManager ) ) {
195 ViewManagerInfo anInfo( aViewManager, VMR_General );
196 myViewManagerMap.insert( ViewManagerId++, anInfo );
202 updateCommandsStatus();
204 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
206 ViewManagerList anOCCViewManagers;
207 anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
208 foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
209 connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
210 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
211 foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() ) {
212 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
213 if ( aViewFrame && aViewFrame->getViewPort() ) {
214 aViewFrame->getViewPort()->installEventFilter( this );
220 SalomeApp_Study* aStudy =
221 dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
223 SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
224 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
225 if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
226 SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
227 SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
228 if( !GEOM_var->_is_nil() ) {
229 aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
237 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
240 ViewManagerMapIterator anIter( myViewManagerMap );
241 while( anIter.hasNext() )
242 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
243 getApp()->removeViewManager( aViewManager );
244 myViewManagerMap.clear();
247 ViewManagerList anOCCViewManagers;
248 getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
249 foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
250 disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
251 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
255 myObjectStateMap.clear();
260 // clear the data model's list of copying objects
261 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
263 setMenuShown( false );
264 setToolShown( false );
266 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
268 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
270 return LightApp_Module::deactivateModule( theStudy );
273 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
276 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
277 #ifndef DISABLE_PYCONSOLE
278 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
280 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
283 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
285 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
288 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
292 HYDROGUI_DataModel* aModel = getDataModel();
294 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
295 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
296 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
297 bool anIsVTKView = theClient == SVTK_Viewer::Type();
298 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
301 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
303 bool anIsSelectedDataObjects = false;
304 bool anIsVisibleInSelection = false;
305 bool anIsHiddenInSelection = false;
307 bool anIsImage = false;
308 bool anIsImportedImage = false;
309 bool anIsImageHasRefs = false;
310 bool anIsFusedImage = false;
311 bool anIsCutImage = false;
312 bool anIsSplittedImage = false;
313 bool anIsMustObjectBeUpdated = false;
314 bool anIsPolyline = false;
315 bool anIsPolyline3D = false;
316 bool anIsProfile = false;
317 bool anIsValidProfile = false;
318 bool anAllAreProfiles = false;
319 bool anIsBathymetry = false;
320 bool anIsCalculation = false;
321 bool anIsImmersibleZone = false;
322 bool anIsVisualState = false;
323 bool anIsRegion = false;
324 bool anIsZone = false;
325 bool anIsObstacle = false;
326 bool anIsStream = false;
327 bool anIsChannel = false;
328 bool anIsDigue = false;
329 bool anIsDummyObject3D = false;
330 bool anIsGroup = false;
331 bool anIsObjectCanBeColored = false;
333 // Check the selected GEOM objects (take into account the Object Browser only)
334 if ( anIsObjectBrowser ) {
335 QList<GEOM::shape_type> anObstacleTypes =
336 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
337 QList<GEOM::shape_type> aPolylineTypes =
338 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
340 bool isCanBeImportedAsObstacle =
341 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
342 bool isCanBeImportedAsPolyline =
343 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
345 // Add import as obstacle action
346 if ( isCanBeImportedAsObstacle ) {
347 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
349 // Add import as polyline action
350 if ( isCanBeImportedAsPolyline ) {
351 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
354 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
355 theMenu->addSeparator();
359 // check the selected data model objects
360 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
361 int aNbOfSelectedProfiles = 0;
362 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
364 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
365 if( !anObject.IsNull() )
367 anIsSelectedDataObjects = true;
369 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
370 anIsVisibleInSelection |= aVisibility;
371 anIsHiddenInSelection |= !aVisibility;
373 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() )
375 anIsMustObjectBeUpdated = true;
378 ObjectKind anObjectKind = anObject->GetKind();
379 if( anObjectKind == KIND_IMAGE )
382 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
383 if( !anImage.IsNull() )
385 anIsImportedImage = anImage->HasLocalPoints();
386 anIsImageHasRefs = anImage->HasReferences();
387 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
389 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
391 QString anOperatorName = anOperator->name();
392 if( anOperatorName == ImageComposer_FuseOperator::Type() )
393 anIsFusedImage = true;
394 else if( anOperatorName == ImageComposer_CutOperator::Type() )
396 else if( anOperatorName == ImageComposer_CropOperator::Type() )
397 anIsSplittedImage = true;
402 else if( anObjectKind == KIND_POLYLINEXY )
404 else if( anObjectKind == KIND_POLYLINE )
405 anIsPolyline3D = true;
406 else if( anObjectKind == KIND_PROFILE )
409 aNbOfSelectedProfiles++;
411 Handle(HYDROData_Profile) aProfile =
412 Handle(HYDROData_Profile)::DownCast( anObject );
413 if( !aProfile.IsNull() && aProfile->IsValid() ) {
414 anIsValidProfile = true;
417 else if( anObjectKind == KIND_CALCULATION )
418 anIsCalculation = true;
419 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
420 anIsImmersibleZone = true;
421 else if( anObjectKind == KIND_VISUAL_STATE )
422 anIsVisualState = true;
423 else if( anObjectKind == KIND_REGION )
425 else if( anObjectKind == KIND_ZONE )
427 else if( anObjectKind == KIND_BATHYMETRY )
428 anIsBathymetry = true;
429 else if( anObjectKind == KIND_OBSTACLE )
431 else if( anObjectKind == KIND_STREAM )
433 else if( anObjectKind == KIND_CHANNEL )
435 else if( anObjectKind == KIND_DIGUE )
437 else if( anObjectKind == KIND_DUMMY_3D )
438 anIsDummyObject3D = true;
439 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLITTED_GROUP )
443 if ( !anIsObjectCanBeColored )
444 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject );
447 // Check if all selected objects are profiles
448 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
449 ( aNbOfSelectedProfiles == aSeq.Length() );
451 // check the selected partitions
452 if( !anIsSelectedDataObjects && anIsObjectBrowser )
454 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
455 if( aSelectedPartition != KIND_UNKNOWN )
457 switch( aSelectedPartition )
460 theMenu->addAction( action( ImportImageId ) );
462 case KIND_BATHYMETRY:
463 theMenu->addAction( action( ImportBathymetryId ) );
465 case KIND_ARTIFICIAL_OBJECT:
466 theMenu->addAction( action( CreateChannelId ) );
467 theMenu->addAction( action( CreateDigueId ) );
469 case KIND_NATURAL_OBJECT:
470 theMenu->addAction( action( CreateImmersibleZoneId ) );
471 theMenu->addAction( action( CreateStreamId ) );
474 theMenu->addAction( action( ImportObstacleFromFileId ) );
475 theMenu->addAction( action( CreateBoxId ) );
476 theMenu->addAction( action( CreateCylinderId ) );
478 case KIND_CALCULATION:
479 theMenu->addAction( action( CreateCalculationId ) );
481 case KIND_POLYLINEXY:
482 theMenu->addAction( action( CreatePolylineId ) );
485 theMenu->addAction( action( CreatePolyline3DId ) );
488 theMenu->addAction( action( CreateProfileId ) );
489 theMenu->addAction( action( ImportProfilesId ) );
490 theMenu->addAction( action( AllGeoreferencementId ) );
492 case KIND_VISUAL_STATE:
493 theMenu->addAction( action( SaveVisualStateId ) );
496 theMenu->addSeparator();
500 if( anIsSelectedDataObjects )
502 if ( anIsMustObjectBeUpdated )
504 theMenu->addAction( action( UpdateObjectId ) );
505 theMenu->addSeparator();
509 theMenu->addAction( action( ForcedUpdateObjectId ) );
510 theMenu->addSeparator();
514 if( aSeq.Length() == 1 )
518 if( anIsImportedImage )
519 theMenu->addAction( action( EditImportedImageId ) );
520 else if( anIsImageHasRefs )
523 theMenu->addAction( action( EditFusedImageId ) );
524 else if( anIsCutImage )
525 theMenu->addAction( action( EditCutImageId ) );
526 else if( anIsSplittedImage )
527 theMenu->addAction( action( EditSplittedImageId ) );
530 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
531 theMenu->addAction( action( ExportImageId ) );
532 theMenu->addSeparator();
534 if( anIsImageHasRefs )
536 theMenu->addAction( action( RemoveImageRefsId ) );
537 theMenu->addSeparator();
540 theMenu->addAction( action( FuseImagesId ) );
541 theMenu->addAction( action( CutImagesId ) );
542 theMenu->addAction( action( SplitImageId ) );
543 theMenu->addSeparator();
545 else if( anIsBathymetry )
547 theMenu->addAction( action( EditImportedBathymetryId ) );
548 theMenu->addAction( action( BathymetryBoundsId ) );
549 theMenu->addSeparator();
551 else if( anIsPolyline )
553 theMenu->addAction( action( EditPolylineId ) );
554 theMenu->addSeparator();
556 else if( anIsPolyline3D )
558 theMenu->addAction( action( EditPolyline3DId ) );
559 theMenu->addSeparator();
561 else if( anIsProfile )
563 theMenu->addAction( action( EditProfileId ) );
564 theMenu->addAction( action( SelectedGeoreferencementId ) );
565 theMenu->addSeparator();
567 else if( anIsCalculation )
569 theMenu->addAction( action( EditCalculationId ) );
570 theMenu->addAction( action( ExportCalculationId ) );
571 theMenu->addSeparator();
573 else if( anIsImmersibleZone )
575 theMenu->addAction( action( EditImmersibleZoneId ) );
576 theMenu->addSeparator();
578 else if( anIsStream )
580 theMenu->addAction( action( EditStreamId ) );
581 theMenu->addSeparator();
583 else if( anIsChannel )
585 theMenu->addAction( action( EditChannelId ) );
586 theMenu->addSeparator();
590 theMenu->addAction( action( EditDigueId ) );
591 theMenu->addSeparator();
593 else if( anIsVisualState && anIsObjectBrowser )
595 theMenu->addAction( action( SaveVisualStateId ) );
596 theMenu->addAction( action( LoadVisualStateId ) );
597 theMenu->addSeparator();
600 // Add set color action for geometrical objects
601 if ( anIsObjectCanBeColored )
603 theMenu->addAction( action( SetColorId ) );
604 theMenu->addSeparator();
608 if( aModel->canCopy() ) {
609 theMenu->addAction( action( CopyId ) );
610 theMenu->addSeparator();
612 } else if ( anAllAreProfiles ) {
613 theMenu->addAction( action( SelectedGeoreferencementId ) );
614 theMenu->addSeparator();
617 if( !anIsDummyObject3D )
618 theMenu->addAction( action( DeleteId ) );
619 theMenu->addSeparator();
621 if( anIsImage || anIsPolyline || anIsPolyline3D ||
622 anIsImmersibleZone || anIsZone || anIsRegion ||
623 anIsBathymetry || anIsObstacle || anIsStream ||
624 anIsChannel || anIsDigue || anIsDummyObject3D ||
625 anIsValidProfile || anIsGroup )
627 if( anIsHiddenInSelection )
628 theMenu->addAction( action( ShowId ) );
629 theMenu->addAction( action( ShowOnlyId ) );
630 if( anIsVisibleInSelection )
631 theMenu->addAction( action( HideId ) );
632 theMenu->addSeparator();
638 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
639 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
640 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
641 theMenu->addAction( action( DeleteId ) );
644 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
646 theMenu->addAction( action( ShowAllId ) );
647 theMenu->addAction( action( HideAllId ) );
648 theMenu->addSeparator();
652 void HYDROGUI_Module::update( const int flags )
654 if( !isUpdateEnabled() )
657 QApplication::setOverrideCursor( Qt::WaitCursor );
659 // To prevent calling this method recursively
660 // from one of the methods called below
661 setUpdateEnabled( false );
663 // store selected objects
664 QStringList aSelectedEntries = storeSelection();
666 bool aDoFitAll = flags & UF_FitAll;
667 if( ( flags & UF_Viewer ) )
668 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
670 if( ( flags & UF_OCCViewer ) )
671 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
673 if( ( flags & UF_VTKViewer ) )
674 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
676 if( ( flags & UF_Model ) && getDataModel() && getApp() )
678 getDataModel()->update( getStudyId() );
680 // Temporary workaround to prevent breaking
681 // the selection in the object browser.
682 // Note: processEvents() should be called after updateGV(),
683 // otherwise the application crashes from time to time.
684 //RKV: qApp->processEvents();
685 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
686 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
687 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
688 if ( isResizeOnExpandItem && anObjectBrowser ) {
689 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
691 getApp()->updateObjectBrowser( true );
692 if ( isResizeOnExpandItem && anObjectBrowser ) {
693 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
697 // Object browser is currently updated by using UF_Model flag
698 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
699 getApp()->updateObjectBrowser( true );
701 if( ( flags & UF_Controls ) && getApp() )
702 getApp()->updateActions();
704 // restore selected objects
705 restoreSelection( aSelectedEntries );
707 setUpdateEnabled( true );
709 QApplication::restoreOverrideCursor();
712 void HYDROGUI_Module::updateCommandsStatus()
714 LightApp_Module::updateCommandsStatus();
716 updateUndoRedoControls();
718 action( CopyId )->setEnabled( getDataModel()->canCopy() );
719 action( PasteId )->setEnabled( getDataModel()->canPaste() );
722 void HYDROGUI_Module::selectionChanged()
724 LightApp_Module::selectionChanged();
725 updateCommandsStatus();
728 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
730 return (HYDROGUI_DataModel*)dataModel();
733 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
738 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
740 return myOCCDisplayer;
743 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
745 return myVTKDisplayer;
748 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
750 if( myViewManagerMap.contains( theId ) )
752 return myViewManagerMap[ theId ].first;
757 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
759 if( myViewManagerMap.contains( theId ) )
761 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
762 GraphicsView_ViewManager* aViewManager =
763 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
765 return aViewManager->getViewer();
770 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
772 if( myViewManagerMap.contains( theId ) )
774 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
775 OCCViewer_ViewManager* aViewManager =
776 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
778 return aViewManager->getOCCViewer();
783 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
785 if( myViewManagerMap.contains( theId ) )
787 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
788 SVTK_ViewManager* aViewManager =
789 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
791 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
796 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
798 ViewManagerMapIterator anIter( myViewManagerMap );
799 while( anIter.hasNext() )
801 int anId = anIter.next().key();
802 const ViewManagerInfo& anInfo = anIter.value();
803 if( anInfo.first == theViewManager )
809 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
811 int anId = getViewManagerId( theViewManager );
814 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
815 return anInfo.second;
820 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
821 const ViewManagerRole theRole )
823 int anId = getViewManagerId( theViewManager );
826 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
827 anInfo.second = theRole;
831 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
832 const Handle(HYDROData_Entity)& theObject ) const
834 if( theObject.IsNull() )
837 ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
838 if( anIter1 != myObjectStateMap.end() )
840 const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
841 Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
842 if( anIter2 != aName2ObjectStateMap.end() )
844 const ObjectState& anObjectState = anIter2.value();
845 return anObjectState.Visibility;
851 void HYDROGUI_Module::setObjectVisible( const int theViewId,
852 const Handle(HYDROData_Entity)& theObject,
853 const bool theState )
855 if( !theObject.IsNull() )
857 Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
858 ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
859 anObjectState.Visibility = theState;
863 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
864 const bool theState )
866 if( !theObject.IsNull() )
868 // Process OCC shapes
869 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
870 while( aShapesMapIter != myShapesMap.end() )
872 const ListOfShapes& aShapesList = aShapesMapIter.value();
873 foreach ( HYDROGUI_Shape* aShape, aShapesList )
875 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
877 aShape->setIsToUpdate( theState );
882 // Process VTK shapes
883 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
884 while( aVTKPrsMapIter != myVTKPrsMap.end() )
886 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
887 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
889 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
891 aShape->setIsToUpdate( theState );
899 /////////////////// OCC SHAPES PROCESSING
900 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
901 const Handle(HYDROData_Entity)& theObject ) const
903 HYDROGUI_Shape* aResShape = NULL;
904 if( theObject.IsNull() )
907 if ( myShapesMap.contains( theViewId ) )
909 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
910 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
912 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
923 void HYDROGUI_Module::setObjectShape( const int theViewId,
924 const Handle(HYDROData_Entity)& theObject,
925 HYDROGUI_Shape* theShape )
927 if( theObject.IsNull() )
930 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
931 aViewShapes.append( theShape );
934 void HYDROGUI_Module::removeObjectShape( const int theViewId,
935 const Handle(HYDROData_Entity)& theObject )
937 if ( !myShapesMap.contains( theViewId ) )
940 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
941 Handle(HYDROData_Entity) anObject;
942 for ( int i = 0; i < aViewShapes.length(); )
944 HYDROGUI_Shape* aShape = aViewShapes.at( i );
945 anObject = aShape->getObject();
946 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
949 aViewShapes.removeAt( i );
957 void HYDROGUI_Module::removeViewShapes( const int theViewId )
959 if ( !myShapesMap.contains( theViewId ) )
962 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
963 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
965 HYDROGUI_Shape* aShape = aViewShapes.at( i );
970 myShapesMap.remove( theViewId );
972 /////////////////// END OF OCC SHAPES PROCESSING
974 /////////////////// VTKPrs PROCESSING
975 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
976 const Handle(HYDROData_Entity)& theObject ) const
978 HYDROGUI_VTKPrs* aResShape = NULL;
979 if( theObject.IsNull() )
982 if ( myVTKPrsMap.contains( theViewId ) )
984 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
985 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
987 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
998 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
999 const Handle(HYDROData_Entity)& theObject,
1000 HYDROGUI_VTKPrs* theShape )
1002 if( theObject.IsNull() )
1005 if( theShape && theShape->needScalarBar() )
1007 // Compute the new global Z range from the added presentation and the old global Z range.
1008 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1009 double* aRange = theShape->getInternalZRange();
1010 bool anIsUpdate = false;
1011 if ( aRange[0] < aGlobalRange[0] )
1013 aGlobalRange[0] = aRange[0];
1016 if ( aRange[1] > aGlobalRange[1] )
1018 aGlobalRange[1] = aRange[1];
1024 updateVTKZRange( theViewId, aGlobalRange );
1028 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1029 aViewShapes.append( theShape );
1032 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1033 const Handle(HYDROData_Entity)& theObject )
1035 if ( !myVTKPrsMap.contains( theViewId ) )
1038 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1039 Handle(HYDROData_Entity) anObject;
1040 for ( int i = 0; i < aViewShapes.length(); )
1042 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1043 anObject = aShape->getObject();
1044 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1047 aViewShapes.removeAt( i );
1054 // Invalidate global Z range
1055 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1056 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1059 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1061 if ( !myVTKPrsMap.contains( theViewId ) )
1064 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1065 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1067 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1072 myVTKPrsMap.remove( theViewId );
1075 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1077 if ( myVTKPrsMap.contains( theViewId ) )
1079 // For the given viewer id update all VTK presentations ...
1080 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1081 HYDROGUI_VTKPrs* aShape;
1082 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1084 aShape = aViewShapes.at( i );
1085 if ( aShape && aShape->needScalarBar() )
1087 aShape->setZRange( theRange );
1091 // ... and update the global color legend scalar bar.
1092 getVTKDisplayer()->SetZRange( theViewId, theRange );
1094 /////////////////// END OF VTKPrs PROCESSING
1096 CAM_DataModel* HYDROGUI_Module::createDataModel()
1098 return new HYDROGUI_DataModel( this );
1101 void HYDROGUI_Module::customEvent( QEvent* e )
1103 int aType = e->type();
1104 if ( aType == NewViewEvent )
1106 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1107 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1109 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1111 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1112 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1114 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1116 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1117 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1119 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1120 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1121 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1123 //ouv: temporarily commented
1124 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1127 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1128 update( UF_Viewer );
1130 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1136 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1138 QEvent::Type aType = theEvent->type();
1139 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1141 if( aType == QEvent::Show )
1143 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1144 e->setData( theObj );
1145 QApplication::postEvent( this, e );
1146 theObj->removeEventFilter( this );
1149 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1151 if( aType == QEvent::Leave )
1153 SUIT_Desktop* aDesktop = getApp()->desktop();
1154 if ( aDesktop && aDesktop->statusBar() ) {
1155 aDesktop->statusBar()->clearMessage();
1159 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1161 if( aType == QEvent::Leave )
1163 SUIT_Desktop* aDesktop = getApp()->desktop();
1164 if ( aDesktop && aDesktop->statusBar() ) {
1165 aDesktop->statusBar()->clearMessage();
1170 return LightApp_Module::eventFilter( theObj, theEvent );
1173 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1175 LightApp_Module::onViewManagerAdded( theViewManager );
1177 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1179 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1180 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1182 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1184 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1185 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1186 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1187 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1189 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1191 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1192 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1193 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1194 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1197 createSelector( theViewManager ); // replace the default selector
1199 ViewManagerInfo anInfo( theViewManager, VMR_General );
1200 myViewManagerMap.insert( ViewManagerId++, anInfo );
1203 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1205 LightApp_Module::onViewManagerRemoved( theViewManager );
1207 createSelector( theViewManager ); // replace the default selector
1209 int anId = getViewManagerId( theViewManager );
1212 OCCViewer_ViewManager* anOCCViewManager =
1213 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1214 if ( anOCCViewManager )
1216 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1218 removeViewShapes( (size_t)anOCCViewer );
1221 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1223 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1226 getVTKDisplayer()->EraseScalarBar( anId, true );
1227 removeViewShapes( (size_t)aVTKViewer );
1231 myViewManagerMap.remove( anId );
1235 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1237 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1239 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1241 aViewFrame->installEventFilter( this );
1243 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1245 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1246 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1249 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1251 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1253 aViewFrame->onTopView();
1255 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1257 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1259 aViewPort->installEventFilter( this );
1263 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1265 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1267 aViewFrame->installEventFilter( this );
1272 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1274 /* ouv: currently unused
1275 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1277 SUIT_ViewManager* aViewManager = 0;
1279 QObject* aParent = aViewPort;
1280 while( aParent = aParent->parent() )
1282 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1284 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1286 aViewManager = aViewer->getViewManager();
1295 double aMouseX = theEvent->scenePos().x();
1296 double aMouseY = theEvent->scenePos().y();
1298 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1299 if( aRole == VMR_General )
1301 int aXDeg = 0, aYDeg = 0;
1302 int aXMin = 0, aYMin = 0;
1303 double aXSec = 0, aYSec = 0;
1304 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1305 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1307 QString aDegSymbol( QChar( 0x00B0 ) );
1308 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1309 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1311 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1313 else if( aRole == VMR_TransformImage )
1314 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1319 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1320 const bool theIsInit,
1321 const bool theIsForced,
1322 const bool theDoFitAll )
1324 QList<int> aViewManagerIdList;
1326 // currently, all views are updated
1327 ViewManagerMapIterator anIter( myViewManagerMap );
1328 while( anIter.hasNext() )
1330 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1332 if ( theDisplayer->IsApplicable( aViewManager ) )
1334 int anId = anIter.key();
1335 aViewManagerIdList.append( anId );
1339 QListIterator<int> anIdIter( aViewManagerIdList );
1340 while( anIdIter.hasNext() )
1342 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1346 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1348 if( !theViewManager )
1351 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1352 if( !aSelectionMgr )
1355 QString aViewType = theViewManager->getType();
1356 if( aViewType != GraphicsView_Viewer::Type() &&
1357 aViewType != OCCViewer_Viewer::Type())
1360 QList<SUIT_Selector*> aSelectorList;
1361 aSelectionMgr->selectors( aViewType, aSelectorList );
1363 // disable all alien selectors
1364 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1365 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1367 SUIT_Selector* aSelector = *anIter;
1368 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1369 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1370 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1371 aSelector->setEnabled( false );
1374 if ( aViewType == GraphicsView_Viewer::Type() )
1376 GraphicsView_ViewManager* aViewManager =
1377 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1379 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1381 else if ( aViewType == OCCViewer_Viewer::Type() )
1383 OCCViewer_ViewManager* aViewManager =
1384 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1386 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1390 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1392 bool aPrevState = myIsUpdateEnabled;
1393 myIsUpdateEnabled = theState;
1397 bool HYDROGUI_Module::isUpdateEnabled() const
1399 return myIsUpdateEnabled;
1402 QStringList HYDROGUI_Module::storeSelection() const
1404 QStringList anEntryList;
1405 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1407 SUIT_DataOwnerPtrList aList( true );
1408 aSelectionMgr->selected( aList );
1410 SUIT_DataOwnerPtrList::iterator anIter;
1411 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1413 const LightApp_DataOwner* anOwner =
1414 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1416 anEntryList.append( anOwner->entry() );
1422 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1424 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1426 SUIT_DataOwnerPtrList aList( true );
1427 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1428 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1429 aSelectionMgr->setSelected( aList );
1433 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
1435 OCCViewer_ViewWindow* anOCCViewWindow =
1436 dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
1437 if ( anOCCViewWindow ) {
1438 // Get the selected point coordinates
1439 OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort();
1444 gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(),
1445 aViewPort->getView() );
1446 // Show the coordinates in the status bar
1447 SUIT_Desktop* aDesktop = getApp()->desktop();
1448 if ( aDesktop && aDesktop->statusBar() ) {
1449 QString aX = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
1450 QString anY = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
1451 aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
1456 SVTK_ViewWindow* aViewWindow =
1457 dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
1458 if ( aViewWindow ) {
1459 // Get the selected point coordinates
1461 SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
1464 //TODO: Use a WorldPicker to get current coords
1465 //anInteractorStyle->ComputeDisplayToWorld( theEvent->x(), theEvent->y(), 0, aCoords );
1466 aCoords[0] = theEvent->x();
1467 aCoords[1] = theEvent->y();
1468 // Show the coordinates in the status bar
1469 SUIT_Desktop* aDesktop = getApp()->desktop();
1470 if ( aDesktop && aDesktop->statusBar() ) {
1471 QString aX = HYDROGUI_Tool::GetCoordinateString( aCoords[0] );
1472 QString anY = HYDROGUI_Tool::GetCoordinateString( aCoords[1] );
1473 aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );