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();
606 } else if ( anAllAreProfiles ) {
607 theMenu->addAction( action( SelectedGeoreferencementId ) );
608 theMenu->addSeparator();
611 if( !anIsDummyObject3D )
612 theMenu->addAction( action( DeleteId ) );
613 theMenu->addSeparator();
615 if( anIsImage || anIsPolyline || anIsPolyline3D ||
616 anIsImmersibleZone || anIsZone || anIsRegion ||
617 anIsBathymetry || anIsObstacle || anIsStream ||
618 anIsChannel || anIsDigue || anIsDummyObject3D ||
619 anIsValidProfile || anIsGroup )
621 if( anIsHiddenInSelection )
622 theMenu->addAction( action( ShowId ) );
623 theMenu->addAction( action( ShowOnlyId ) );
624 if( anIsVisibleInSelection )
625 theMenu->addAction( action( HideId ) );
626 theMenu->addSeparator();
632 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
633 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
634 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
635 theMenu->addAction( action( DeleteId ) );
638 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
640 theMenu->addAction( action( ShowAllId ) );
641 theMenu->addAction( action( HideAllId ) );
642 theMenu->addSeparator();
646 void HYDROGUI_Module::update( const int flags )
648 if( !isUpdateEnabled() )
651 QApplication::setOverrideCursor( Qt::WaitCursor );
653 // To prevent calling this method recursively
654 // from one of the methods called below
655 setUpdateEnabled( false );
657 // store selected objects
658 QStringList aSelectedEntries = storeSelection();
660 bool aDoFitAll = flags & UF_FitAll;
661 if( ( flags & UF_Viewer ) )
662 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
664 if( ( flags & UF_OCCViewer ) )
665 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
667 if( ( flags & UF_VTKViewer ) )
668 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
670 if( ( flags & UF_Model ) && getDataModel() && getApp() )
672 getDataModel()->update( getStudyId() );
674 // Temporary workaround to prevent breaking
675 // the selection in the object browser.
676 // Note: processEvents() should be called after updateGV(),
677 // otherwise the application crashes from time to time.
678 //RKV: qApp->processEvents();
679 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
680 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
681 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
682 if ( isResizeOnExpandItem && anObjectBrowser ) {
683 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
685 getApp()->updateObjectBrowser( true );
686 if ( isResizeOnExpandItem && anObjectBrowser ) {
687 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
691 // Object browser is currently updated by using UF_Model flag
692 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
693 getApp()->updateObjectBrowser( true );
695 if( ( flags & UF_Controls ) && getApp() )
696 getApp()->updateActions();
698 // restore selected objects
699 restoreSelection( aSelectedEntries );
701 setUpdateEnabled( true );
703 QApplication::restoreOverrideCursor();
706 void HYDROGUI_Module::updateCommandsStatus()
708 LightApp_Module::updateCommandsStatus();
710 updateUndoRedoControls();
712 action( CopyId )->setEnabled( getDataModel()->canCopy() );
713 action( PasteId )->setEnabled( getDataModel()->canPaste() );
716 void HYDROGUI_Module::selectionChanged()
718 LightApp_Module::selectionChanged();
719 updateCommandsStatus();
722 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
724 return (HYDROGUI_DataModel*)dataModel();
727 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
732 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
734 return myOCCDisplayer;
737 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
739 return myVTKDisplayer;
742 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
744 if( myViewManagerMap.contains( theId ) )
746 return myViewManagerMap[ theId ].first;
751 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
753 if( myViewManagerMap.contains( theId ) )
755 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
756 GraphicsView_ViewManager* aViewManager =
757 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
759 return aViewManager->getViewer();
764 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
766 if( myViewManagerMap.contains( theId ) )
768 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
769 OCCViewer_ViewManager* aViewManager =
770 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
772 return aViewManager->getOCCViewer();
777 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
779 if( myViewManagerMap.contains( theId ) )
781 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
782 SVTK_ViewManager* aViewManager =
783 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
785 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
790 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
792 ViewManagerMapIterator anIter( myViewManagerMap );
793 while( anIter.hasNext() )
795 int anId = anIter.next().key();
796 const ViewManagerInfo& anInfo = anIter.value();
797 if( anInfo.first == theViewManager )
803 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
805 int anId = getViewManagerId( theViewManager );
808 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
809 return anInfo.second;
814 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
815 const ViewManagerRole theRole )
817 int anId = getViewManagerId( theViewManager );
820 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
821 anInfo.second = theRole;
825 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
826 const Handle(HYDROData_Entity)& theObject ) const
828 if( theObject.IsNull() )
831 ViewId2Name2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
832 if( anIter1 != myObjectStateMap.end() )
834 const Name2ObjectStateMap& aName2ObjectStateMap = anIter1.value();
835 Name2ObjectStateMap::const_iterator anIter2 = aName2ObjectStateMap.find( theObject->GetName());
836 if( anIter2 != aName2ObjectStateMap.end() )
838 const ObjectState& anObjectState = anIter2.value();
839 return anObjectState.Visibility;
845 void HYDROGUI_Module::setObjectVisible( const int theViewId,
846 const Handle(HYDROData_Entity)& theObject,
847 const bool theState )
849 if( !theObject.IsNull() )
851 Name2ObjectStateMap& aName2ObjectStateMap = myObjectStateMap[ theViewId ];
852 ObjectState& anObjectState = aName2ObjectStateMap[ theObject->GetName() ];
853 anObjectState.Visibility = theState;
857 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
858 const bool theState )
860 if( !theObject.IsNull() )
862 // Process OCC shapes
863 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
864 while( aShapesMapIter != myShapesMap.end() )
866 const ListOfShapes& aShapesList = aShapesMapIter.value();
867 foreach ( HYDROGUI_Shape* aShape, aShapesList )
869 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
871 aShape->setIsToUpdate( theState );
876 // Process VTK shapes
877 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
878 while( aVTKPrsMapIter != myVTKPrsMap.end() )
880 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
881 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
883 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
885 aShape->setIsToUpdate( theState );
893 /////////////////// OCC SHAPES PROCESSING
894 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
895 const Handle(HYDROData_Entity)& theObject ) const
897 HYDROGUI_Shape* aResShape = NULL;
898 if( theObject.IsNull() )
901 if ( myShapesMap.contains( theViewId ) )
903 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
904 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
906 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
917 void HYDROGUI_Module::setObjectShape( const int theViewId,
918 const Handle(HYDROData_Entity)& theObject,
919 HYDROGUI_Shape* theShape )
921 if( theObject.IsNull() )
924 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
925 aViewShapes.append( theShape );
928 void HYDROGUI_Module::removeObjectShape( const int theViewId,
929 const Handle(HYDROData_Entity)& theObject )
931 if ( !myShapesMap.contains( theViewId ) )
934 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
935 Handle(HYDROData_Entity) anObject;
936 for ( int i = 0; i < aViewShapes.length(); )
938 HYDROGUI_Shape* aShape = aViewShapes.at( i );
939 anObject = aShape->getObject();
940 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
943 aViewShapes.removeAt( i );
951 void HYDROGUI_Module::removeViewShapes( const int theViewId )
953 if ( !myShapesMap.contains( theViewId ) )
956 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
957 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
959 HYDROGUI_Shape* aShape = aViewShapes.at( i );
964 myShapesMap.remove( theViewId );
966 /////////////////// END OF OCC SHAPES PROCESSING
968 /////////////////// VTKPrs PROCESSING
969 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
970 const Handle(HYDROData_Entity)& theObject ) const
972 HYDROGUI_VTKPrs* aResShape = NULL;
973 if( theObject.IsNull() )
976 if ( myVTKPrsMap.contains( theViewId ) )
978 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
979 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
981 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
992 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
993 const Handle(HYDROData_Entity)& theObject,
994 HYDROGUI_VTKPrs* theShape )
996 if( theObject.IsNull() )
999 if( theShape && theShape->needScalarBar() )
1001 // Compute the new global Z range from the added presentation and the old global Z range.
1002 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1003 double* aRange = theShape->getInternalZRange();
1004 bool anIsUpdate = false;
1005 if ( aRange[0] < aGlobalRange[0] )
1007 aGlobalRange[0] = aRange[0];
1010 if ( aRange[1] > aGlobalRange[1] )
1012 aGlobalRange[1] = aRange[1];
1018 updateVTKZRange( theViewId, aGlobalRange );
1022 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1023 aViewShapes.append( theShape );
1026 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1027 const Handle(HYDROData_Entity)& theObject )
1029 if ( !myVTKPrsMap.contains( theViewId ) )
1032 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1033 Handle(HYDROData_Entity) anObject;
1034 for ( int i = 0; i < aViewShapes.length(); )
1036 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1037 anObject = aShape->getObject();
1038 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1041 aViewShapes.removeAt( i );
1048 // Invalidate global Z range
1049 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1050 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1053 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1055 if ( !myVTKPrsMap.contains( theViewId ) )
1058 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1059 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1061 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1066 myVTKPrsMap.remove( theViewId );
1069 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1071 if ( myVTKPrsMap.contains( theViewId ) )
1073 // For the given viewer id update all VTK presentations ...
1074 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1075 HYDROGUI_VTKPrs* aShape;
1076 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1078 aShape = aViewShapes.at( i );
1079 if ( aShape && aShape->needScalarBar() )
1081 aShape->setZRange( theRange );
1085 // ... and update the global color legend scalar bar.
1086 getVTKDisplayer()->SetZRange( theViewId, theRange );
1088 /////////////////// END OF VTKPrs PROCESSING
1090 CAM_DataModel* HYDROGUI_Module::createDataModel()
1092 return new HYDROGUI_DataModel( this );
1095 void HYDROGUI_Module::customEvent( QEvent* e )
1097 int aType = e->type();
1098 if ( aType == NewViewEvent )
1100 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1101 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1103 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1105 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1106 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1108 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1110 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1111 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1113 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1114 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1115 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1117 //ouv: temporarily commented
1118 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1121 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1122 update( UF_Viewer );
1124 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1130 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1132 QEvent::Type aType = theEvent->type();
1133 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1135 if( aType == QEvent::Show )
1137 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1138 e->setData( theObj );
1139 QApplication::postEvent( this, e );
1140 theObj->removeEventFilter( this );
1143 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1145 if( aType == QEvent::Leave )
1147 SUIT_Desktop* aDesktop = getApp()->desktop();
1148 if ( aDesktop && aDesktop->statusBar() ) {
1149 aDesktop->statusBar()->clearMessage();
1153 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1155 if( aType == QEvent::Leave )
1157 SUIT_Desktop* aDesktop = getApp()->desktop();
1158 if ( aDesktop && aDesktop->statusBar() ) {
1159 aDesktop->statusBar()->clearMessage();
1164 return LightApp_Module::eventFilter( theObj, theEvent );
1167 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1169 LightApp_Module::onViewManagerAdded( theViewManager );
1171 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1173 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1174 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1176 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1178 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1179 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1180 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1181 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1183 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1185 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1186 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1187 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1188 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1191 createSelector( theViewManager ); // replace the default selector
1193 ViewManagerInfo anInfo( theViewManager, VMR_General );
1194 myViewManagerMap.insert( ViewManagerId++, anInfo );
1197 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1199 LightApp_Module::onViewManagerRemoved( theViewManager );
1201 createSelector( theViewManager ); // replace the default selector
1203 int anId = getViewManagerId( theViewManager );
1206 OCCViewer_ViewManager* anOCCViewManager =
1207 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1208 if ( anOCCViewManager )
1210 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1212 removeViewShapes( (size_t)anOCCViewer );
1215 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1217 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1220 getVTKDisplayer()->EraseScalarBar( anId, true );
1221 removeViewShapes( (size_t)aVTKViewer );
1225 myViewManagerMap.remove( anId );
1229 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1231 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1233 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1235 aViewFrame->installEventFilter( this );
1237 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1239 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1240 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1243 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1245 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1247 aViewFrame->onTopView();
1249 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1251 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1253 aViewPort->installEventFilter( this );
1257 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1259 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1261 aViewFrame->installEventFilter( this );
1266 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1268 /* ouv: currently unused
1269 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1271 SUIT_ViewManager* aViewManager = 0;
1273 QObject* aParent = aViewPort;
1274 while( aParent = aParent->parent() )
1276 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1278 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1280 aViewManager = aViewer->getViewManager();
1289 double aMouseX = theEvent->scenePos().x();
1290 double aMouseY = theEvent->scenePos().y();
1292 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1293 if( aRole == VMR_General )
1295 int aXDeg = 0, aYDeg = 0;
1296 int aXMin = 0, aYMin = 0;
1297 double aXSec = 0, aYSec = 0;
1298 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1299 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1301 QString aDegSymbol( QChar( 0x00B0 ) );
1302 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1303 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1305 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1307 else if( aRole == VMR_TransformImage )
1308 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1313 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1314 const bool theIsInit,
1315 const bool theIsForced,
1316 const bool theDoFitAll )
1318 QList<int> aViewManagerIdList;
1320 // currently, all views are updated
1321 ViewManagerMapIterator anIter( myViewManagerMap );
1322 while( anIter.hasNext() )
1324 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1326 if ( theDisplayer->IsApplicable( aViewManager ) )
1328 int anId = anIter.key();
1329 aViewManagerIdList.append( anId );
1333 QListIterator<int> anIdIter( aViewManagerIdList );
1334 while( anIdIter.hasNext() )
1336 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1340 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1342 if( !theViewManager )
1345 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1346 if( !aSelectionMgr )
1349 QString aViewType = theViewManager->getType();
1350 if( aViewType != GraphicsView_Viewer::Type() &&
1351 aViewType != OCCViewer_Viewer::Type())
1354 QList<SUIT_Selector*> aSelectorList;
1355 aSelectionMgr->selectors( aViewType, aSelectorList );
1357 // disable all alien selectors
1358 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1359 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1361 SUIT_Selector* aSelector = *anIter;
1362 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1363 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1364 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1365 aSelector->setEnabled( false );
1368 if ( aViewType == GraphicsView_Viewer::Type() )
1370 GraphicsView_ViewManager* aViewManager =
1371 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1373 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1375 else if ( aViewType == OCCViewer_Viewer::Type() )
1377 OCCViewer_ViewManager* aViewManager =
1378 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1380 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1384 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1386 bool aPrevState = myIsUpdateEnabled;
1387 myIsUpdateEnabled = theState;
1391 bool HYDROGUI_Module::isUpdateEnabled() const
1393 return myIsUpdateEnabled;
1396 QStringList HYDROGUI_Module::storeSelection() const
1398 QStringList anEntryList;
1399 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1401 SUIT_DataOwnerPtrList aList( true );
1402 aSelectionMgr->selected( aList );
1404 SUIT_DataOwnerPtrList::iterator anIter;
1405 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1407 const LightApp_DataOwner* anOwner =
1408 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1410 anEntryList.append( anOwner->entry() );
1416 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1418 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1420 SUIT_DataOwnerPtrList aList( true );
1421 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1422 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1423 aSelectionMgr->setSelected( aList );
1427 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
1429 OCCViewer_ViewWindow* anOCCViewWindow =
1430 dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
1431 if ( anOCCViewWindow ) {
1432 // Get the selected point coordinates
1433 OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort();
1438 gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(),
1439 aViewPort->getView() );
1440 // Show the coordinates in the status bar
1441 SUIT_Desktop* aDesktop = getApp()->desktop();
1442 if ( aDesktop && aDesktop->statusBar() ) {
1443 QString aX = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
1444 QString anY = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
1445 aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
1450 SVTK_ViewWindow* aViewWindow =
1451 dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
1452 if ( aViewWindow ) {
1453 // Get the selected point coordinates
1455 SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
1458 //TODO: Use a WorldPicker to get current coords
1459 //anInteractorStyle->ComputeDisplayToWorld( theEvent->x(), theEvent->y(), 0, aCoords );
1460 aCoords[0] = theEvent->x();
1461 aCoords[1] = theEvent->y();
1462 // Show the coordinates in the status bar
1463 SUIT_Desktop* aDesktop = getApp()->desktop();
1464 if ( aDesktop && aDesktop->statusBar() ) {
1465 QString aX = HYDROGUI_Tool::GetCoordinateString( aCoords[0] );
1466 QString anY = HYDROGUI_Tool::GetCoordinateString( aCoords[1] );
1467 aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );