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>
88 #include <SVTK_RenderWindowInteractor.h>
90 #include <OCCViewer_ViewPort3d.h>
92 #include <GEOMUtils.hxx>
93 #include <GeometryGUI.h>
95 #include <SALOMEDS_wrap.hxx>
98 #include <QApplication>
99 #include <QGraphicsSceneMouseEvent>
101 #include <QMouseEvent>
102 #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 myShapesMap.remove( anId );
189 myVTKPrsMap.remove( anId );
191 // Replace the default selector for all view managers.
192 // Add view managers created outside of HYDRO module to the map.
193 foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
194 createSelector( aViewManager ); // replace the default selector
195 if ( !aHydroViewManagers.contains( aViewManager ) ) {
196 ViewManagerInfo anInfo( aViewManager, VMR_General );
197 myViewManagerMap.insert( ViewManagerId++, anInfo );
203 updateCommandsStatus();
205 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
207 ViewManagerList anOCCViewManagers;
208 anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
209 foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
210 connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
211 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
212 foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() ) {
213 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
214 if ( aViewFrame && aViewFrame->getViewPort() ) {
215 aViewFrame->getViewPort()->installEventFilter( this );
221 SalomeApp_Study* aStudy =
222 dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
224 SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
225 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
226 if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
227 SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
228 SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
229 if( !GEOM_var->_is_nil() ) {
230 aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
238 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
241 ViewManagerMapIterator anIter( myViewManagerMap );
242 while( anIter.hasNext() )
243 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
244 getApp()->removeViewManager( aViewManager );
245 myViewManagerMap.clear();
248 ViewManagerList anOCCViewManagers;
249 getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
250 foreach ( const SUIT_ViewManager* aViewManager, anOCCViewManagers ) {
251 disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
252 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
256 myObjectStateMap.clear();
261 // clear the data model's list of copying objects
262 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
264 setMenuShown( false );
265 setToolShown( false );
267 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
269 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
271 return LightApp_Module::deactivateModule( theStudy );
274 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
277 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
278 #ifndef DISABLE_PYCONSOLE
279 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
281 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
284 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
286 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
289 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
293 HYDROGUI_DataModel* aModel = getDataModel();
295 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
296 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
297 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
298 bool anIsVTKView = theClient == SVTK_Viewer::Type();
299 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
302 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
304 bool anIsSelectedDataObjects = false;
305 bool anIsVisibleInSelection = false;
306 bool anIsHiddenInSelection = false;
308 bool anIsImage = false;
309 bool anIsImportedImage = false;
310 bool anIsImageHasRefs = false;
311 bool anIsFusedImage = false;
312 bool anIsCutImage = false;
313 bool anIsSplittedImage = false;
314 bool anIsMustObjectBeUpdated = false;
315 bool anIsPolyline = false;
316 bool anIsPolyline3D = false;
317 bool anIsProfile = false;
318 bool anIsValidProfile = false;
319 bool anAllAreProfiles = false;
320 bool anIsBathymetry = false;
321 bool anIsCalculation = false;
322 bool anIsImmersibleZone = false;
323 bool anIsVisualState = false;
324 bool anIsRegion = false;
325 bool anIsZone = false;
326 bool anIsObstacle = false;
327 bool anIsStream = false;
328 bool anIsChannel = false;
329 bool anIsDigue = false;
330 bool anIsDummyObject3D = false;
331 bool anIsGroup = false;
332 bool anIsObjectCanBeColored = false;
334 // Check the selected GEOM objects (take into account the Object Browser only)
335 if ( anIsObjectBrowser ) {
336 QList<GEOM::shape_type> anObstacleTypes =
337 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
338 QList<GEOM::shape_type> aPolylineTypes =
339 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
341 bool isCanBeImportedAsObstacle =
342 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
343 bool isCanBeImportedAsPolyline =
344 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
346 // Add import as obstacle action
347 if ( isCanBeImportedAsObstacle ) {
348 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
350 // Add import as polyline action
351 if ( isCanBeImportedAsPolyline ) {
352 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
355 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
356 theMenu->addSeparator();
360 // check the selected data model objects
361 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
362 int aNbOfSelectedProfiles = 0;
363 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
365 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
366 if( !anObject.IsNull() )
368 anIsSelectedDataObjects = true;
370 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
371 anIsVisibleInSelection |= aVisibility;
372 anIsHiddenInSelection |= !aVisibility;
374 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated() )
376 anIsMustObjectBeUpdated = true;
379 ObjectKind anObjectKind = anObject->GetKind();
380 if( anObjectKind == KIND_IMAGE )
383 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
384 if( !anImage.IsNull() )
386 anIsImportedImage = anImage->HasLocalPoints();
387 anIsImageHasRefs = anImage->HasReferences();
388 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
390 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
392 QString anOperatorName = anOperator->name();
393 if( anOperatorName == ImageComposer_FuseOperator::Type() )
394 anIsFusedImage = true;
395 else if( anOperatorName == ImageComposer_CutOperator::Type() )
397 else if( anOperatorName == ImageComposer_CropOperator::Type() )
398 anIsSplittedImage = true;
403 else if( anObjectKind == KIND_POLYLINEXY )
405 else if( anObjectKind == KIND_POLYLINE )
406 anIsPolyline3D = true;
407 else if( anObjectKind == KIND_PROFILE )
410 aNbOfSelectedProfiles++;
412 Handle(HYDROData_Profile) aProfile =
413 Handle(HYDROData_Profile)::DownCast( anObject );
414 if( !aProfile.IsNull() && aProfile->IsValid() ) {
415 anIsValidProfile = true;
418 else if( anObjectKind == KIND_CALCULATION )
419 anIsCalculation = true;
420 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
421 anIsImmersibleZone = true;
422 else if( anObjectKind == KIND_VISUAL_STATE )
423 anIsVisualState = true;
424 else if( anObjectKind == KIND_REGION )
426 else if( anObjectKind == KIND_ZONE )
428 else if( anObjectKind == KIND_BATHYMETRY )
429 anIsBathymetry = true;
430 else if( anObjectKind == KIND_OBSTACLE )
432 else if( anObjectKind == KIND_STREAM )
434 else if( anObjectKind == KIND_CHANNEL )
436 else if( anObjectKind == KIND_DIGUE )
438 else if( anObjectKind == KIND_DUMMY_3D )
439 anIsDummyObject3D = true;
440 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLITTED_GROUP )
444 if ( !anIsObjectCanBeColored )
445 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject );
448 // Check if all selected objects are profiles
449 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
450 ( aNbOfSelectedProfiles == aSeq.Length() );
452 // check the selected partitions
453 if( !anIsSelectedDataObjects && anIsObjectBrowser )
455 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
456 if( aSelectedPartition != KIND_UNKNOWN )
458 switch( aSelectedPartition )
461 theMenu->addAction( action( ImportImageId ) );
463 case KIND_BATHYMETRY:
464 theMenu->addAction( action( ImportBathymetryId ) );
466 case KIND_ARTIFICIAL_OBJECT:
467 theMenu->addAction( action( CreateChannelId ) );
468 theMenu->addAction( action( CreateDigueId ) );
470 case KIND_NATURAL_OBJECT:
471 theMenu->addAction( action( CreateImmersibleZoneId ) );
472 theMenu->addAction( action( CreateStreamId ) );
475 theMenu->addAction( action( ImportObstacleFromFileId ) );
476 theMenu->addAction( action( CreateBoxId ) );
477 theMenu->addAction( action( CreateCylinderId ) );
479 case KIND_CALCULATION:
480 theMenu->addAction( action( CreateCalculationId ) );
482 case KIND_POLYLINEXY:
483 theMenu->addAction( action( CreatePolylineId ) );
486 theMenu->addAction( action( CreatePolyline3DId ) );
489 theMenu->addAction( action( CreateProfileId ) );
490 theMenu->addAction( action( ImportProfilesId ) );
491 theMenu->addAction( action( AllGeoreferencementId ) );
493 case KIND_VISUAL_STATE:
494 theMenu->addAction( action( SaveVisualStateId ) );
497 theMenu->addSeparator();
501 if( anIsSelectedDataObjects )
503 if ( anIsMustObjectBeUpdated )
505 theMenu->addAction( action( UpdateObjectId ) );
506 theMenu->addSeparator();
510 theMenu->addAction( action( ForcedUpdateObjectId ) );
511 theMenu->addSeparator();
515 if( aSeq.Length() == 1 )
519 if( anIsImportedImage )
520 theMenu->addAction( action( EditImportedImageId ) );
521 else if( anIsImageHasRefs )
524 theMenu->addAction( action( EditFusedImageId ) );
525 else if( anIsCutImage )
526 theMenu->addAction( action( EditCutImageId ) );
527 else if( anIsSplittedImage )
528 theMenu->addAction( action( EditSplittedImageId ) );
531 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
532 theMenu->addAction( action( ExportImageId ) );
533 theMenu->addSeparator();
535 if( anIsImageHasRefs )
537 theMenu->addAction( action( RemoveImageRefsId ) );
538 theMenu->addSeparator();
541 theMenu->addAction( action( FuseImagesId ) );
542 theMenu->addAction( action( CutImagesId ) );
543 theMenu->addAction( action( SplitImageId ) );
544 theMenu->addSeparator();
546 else if( anIsBathymetry )
548 theMenu->addAction( action( EditImportedBathymetryId ) );
549 theMenu->addAction( action( BathymetryBoundsId ) );
550 theMenu->addSeparator();
552 else if( anIsPolyline )
554 theMenu->addAction( action( EditPolylineId ) );
555 theMenu->addSeparator();
557 else if( anIsPolyline3D )
559 theMenu->addAction( action( EditPolyline3DId ) );
560 theMenu->addSeparator();
562 else if( anIsProfile )
564 theMenu->addAction( action( EditProfileId ) );
565 theMenu->addAction( action( SelectedGeoreferencementId ) );
566 theMenu->addSeparator();
568 else if( anIsCalculation )
570 theMenu->addAction( action( EditCalculationId ) );
571 theMenu->addAction( action( ExportCalculationId ) );
572 theMenu->addSeparator();
574 else if( anIsImmersibleZone )
576 theMenu->addAction( action( EditImmersibleZoneId ) );
577 theMenu->addSeparator();
579 else if( anIsStream )
581 theMenu->addAction( action( EditStreamId ) );
582 theMenu->addSeparator();
584 else if( anIsChannel )
586 theMenu->addAction( action( EditChannelId ) );
587 theMenu->addSeparator();
591 theMenu->addAction( action( EditDigueId ) );
592 theMenu->addSeparator();
594 else if( anIsVisualState && anIsObjectBrowser )
596 theMenu->addAction( action( SaveVisualStateId ) );
597 theMenu->addAction( action( LoadVisualStateId ) );
598 theMenu->addSeparator();
601 // Add set color action for geometrical objects
602 if ( anIsObjectCanBeColored )
604 theMenu->addAction( action( SetColorId ) );
605 theMenu->addSeparator();
609 if( aModel->canCopy() ) {
610 theMenu->addAction( action( CopyId ) );
611 theMenu->addSeparator();
613 } else if ( anAllAreProfiles ) {
614 theMenu->addAction( action( SelectedGeoreferencementId ) );
615 theMenu->addSeparator();
618 if( !anIsDummyObject3D )
619 theMenu->addAction( action( DeleteId ) );
620 theMenu->addSeparator();
622 if( anIsImage || anIsPolyline || anIsPolyline3D ||
623 anIsImmersibleZone || anIsZone || anIsRegion ||
624 anIsBathymetry || anIsObstacle || anIsStream ||
625 anIsChannel || anIsDigue || anIsDummyObject3D ||
626 anIsValidProfile || anIsGroup )
628 if( anIsHiddenInSelection )
629 theMenu->addAction( action( ShowId ) );
630 theMenu->addAction( action( ShowOnlyId ) );
631 if( anIsVisibleInSelection )
632 theMenu->addAction( action( HideId ) );
633 theMenu->addSeparator();
639 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
640 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
641 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
642 theMenu->addAction( action( DeleteId ) );
645 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
647 theMenu->addAction( action( ShowAllId ) );
648 theMenu->addAction( action( HideAllId ) );
649 theMenu->addSeparator();
653 void HYDROGUI_Module::update( const int flags )
655 if( !isUpdateEnabled() )
658 QApplication::setOverrideCursor( Qt::WaitCursor );
660 // To prevent calling this method recursively
661 // from one of the methods called below
662 setUpdateEnabled( false );
664 // store selected objects
665 QStringList aSelectedEntries = storeSelection();
667 bool aDoFitAll = flags & UF_FitAll;
668 if( ( flags & UF_Viewer ) )
669 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
671 if( ( flags & UF_OCCViewer ) )
672 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
674 if( ( flags & UF_VTKViewer ) )
675 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
677 if( ( flags & UF_Model ) && getDataModel() && getApp() )
679 getDataModel()->update( getStudyId() );
681 // Temporary workaround to prevent breaking
682 // the selection in the object browser.
683 // Note: processEvents() should be called after updateGV(),
684 // otherwise the application crashes from time to time.
685 //RKV: qApp->processEvents();
686 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
687 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
688 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
689 if ( isResizeOnExpandItem && anObjectBrowser ) {
690 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
692 getApp()->updateObjectBrowser( true );
693 if ( isResizeOnExpandItem && anObjectBrowser ) {
694 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
698 // Object browser is currently updated by using UF_Model flag
699 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
700 getApp()->updateObjectBrowser( true );
702 if( ( flags & UF_Controls ) && getApp() )
703 getApp()->updateActions();
705 // restore selected objects
706 restoreSelection( aSelectedEntries );
708 setUpdateEnabled( true );
710 QApplication::restoreOverrideCursor();
713 void HYDROGUI_Module::updateCommandsStatus()
715 LightApp_Module::updateCommandsStatus();
717 updateUndoRedoControls();
719 action( CopyId )->setEnabled( getDataModel()->canCopy() );
720 action( PasteId )->setEnabled( getDataModel()->canPaste() );
723 void HYDROGUI_Module::selectionChanged()
725 LightApp_Module::selectionChanged();
726 updateCommandsStatus();
729 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
731 return (HYDROGUI_DataModel*)dataModel();
734 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
739 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
741 return myOCCDisplayer;
744 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
746 return myVTKDisplayer;
749 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
751 if( myViewManagerMap.contains( theId ) )
753 return myViewManagerMap[ theId ].first;
758 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
760 if( myViewManagerMap.contains( theId ) )
762 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
763 GraphicsView_ViewManager* aViewManager =
764 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
766 return aViewManager->getViewer();
771 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
773 if( myViewManagerMap.contains( theId ) )
775 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
776 OCCViewer_ViewManager* aViewManager =
777 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
779 return aViewManager->getOCCViewer();
784 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
786 if( myViewManagerMap.contains( theId ) )
788 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
789 SVTK_ViewManager* aViewManager =
790 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
792 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
797 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
799 ViewManagerMapIterator anIter( myViewManagerMap );
800 while( anIter.hasNext() )
802 int anId = anIter.next().key();
803 const ViewManagerInfo& anInfo = anIter.value();
804 if( anInfo.first == theViewManager )
810 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
812 int anId = getViewManagerId( theViewManager );
815 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
816 return anInfo.second;
821 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
822 const ViewManagerRole theRole )
824 int anId = getViewManagerId( theViewManager );
827 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
828 anInfo.second = theRole;
832 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
833 const Handle(HYDROData_Entity)& theObject ) const
835 if( theObject.IsNull() )
838 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
839 if( anIter1 != myObjectStateMap.end() )
841 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
842 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
844 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
845 if( anIter2 != aEntry2ObjectStateMap.end() )
847 const ObjectState& anObjectState = anIter2.value();
848 return anObjectState.Visibility;
854 void HYDROGUI_Module::setObjectVisible( const int theViewId,
855 const Handle(HYDROData_Entity)& theObject,
856 const bool theState )
858 if( !theObject.IsNull() )
860 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
861 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
863 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
864 anObjectState.Visibility = theState;
868 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
869 const bool theState )
871 if( !theObject.IsNull() )
873 // Process OCC shapes
874 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
875 while( aShapesMapIter != myShapesMap.end() )
877 const ListOfShapes& aShapesList = aShapesMapIter.value();
878 foreach ( HYDROGUI_Shape* aShape, aShapesList )
880 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
882 aShape->setIsToUpdate( theState );
887 // Process VTK shapes
888 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
889 while( aVTKPrsMapIter != myVTKPrsMap.end() )
891 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
892 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
894 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
896 aShape->setIsToUpdate( theState );
904 /////////////////// OCC SHAPES PROCESSING
905 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
906 const Handle(HYDROData_Entity)& theObject ) const
908 HYDROGUI_Shape* aResShape = NULL;
909 if( theObject.IsNull() )
912 if ( myShapesMap.contains( theViewId ) )
914 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
915 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
917 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
928 void HYDROGUI_Module::setObjectShape( const int theViewId,
929 const Handle(HYDROData_Entity)& theObject,
930 HYDROGUI_Shape* theShape )
932 if( theObject.IsNull() )
935 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
936 aViewShapes.append( theShape );
939 void HYDROGUI_Module::removeObjectShape( const int theViewId,
940 const Handle(HYDROData_Entity)& theObject )
942 if ( !myShapesMap.contains( theViewId ) )
945 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
946 Handle(HYDROData_Entity) anObject;
947 for ( int i = 0; i < aViewShapes.length(); )
949 HYDROGUI_Shape* aShape = aViewShapes.at( i );
950 anObject = aShape->getObject();
951 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
954 aViewShapes.removeAt( i );
962 void HYDROGUI_Module::removeViewShapes( const int theViewId )
964 if ( !myShapesMap.contains( theViewId ) )
967 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
968 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
970 HYDROGUI_Shape* aShape = aViewShapes.at( i );
975 myShapesMap.remove( theViewId );
977 /////////////////// END OF OCC SHAPES PROCESSING
979 /////////////////// VTKPrs PROCESSING
980 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
981 const Handle(HYDROData_Entity)& theObject ) const
983 HYDROGUI_VTKPrs* aResShape = NULL;
984 if( theObject.IsNull() )
987 if ( myVTKPrsMap.contains( theViewId ) )
989 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
990 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
992 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1003 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1004 const Handle(HYDROData_Entity)& theObject,
1005 HYDROGUI_VTKPrs* theShape )
1007 if( theObject.IsNull() )
1010 if( theShape && theShape->needScalarBar() )
1012 // Compute the new global Z range from the added presentation and the old global Z range.
1013 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1014 double* aRange = theShape->getInternalZRange();
1015 bool anIsUpdate = false;
1016 if ( aRange[0] < aGlobalRange[0] )
1018 aGlobalRange[0] = aRange[0];
1021 if ( aRange[1] > aGlobalRange[1] )
1023 aGlobalRange[1] = aRange[1];
1029 updateVTKZRange( theViewId, aGlobalRange );
1033 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1034 aViewShapes.append( theShape );
1037 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1038 const Handle(HYDROData_Entity)& theObject )
1040 if ( !myVTKPrsMap.contains( theViewId ) )
1043 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1044 Handle(HYDROData_Entity) anObject;
1045 for ( int i = 0; i < aViewShapes.length(); )
1047 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1048 anObject = aShape->getObject();
1049 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1052 aViewShapes.removeAt( i );
1059 // Invalidate global Z range
1060 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1061 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1064 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1066 if ( !myVTKPrsMap.contains( theViewId ) )
1069 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1070 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1072 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1077 myVTKPrsMap.remove( theViewId );
1080 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1082 if ( myVTKPrsMap.contains( theViewId ) )
1084 // For the given viewer id update all VTK presentations ...
1085 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1086 HYDROGUI_VTKPrs* aShape;
1087 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1089 aShape = aViewShapes.at( i );
1090 if ( aShape && aShape->needScalarBar() )
1092 aShape->setZRange( theRange );
1096 // ... and update the global color legend scalar bar.
1097 getVTKDisplayer()->SetZRange( theViewId, theRange );
1099 /////////////////// END OF VTKPrs PROCESSING
1101 CAM_DataModel* HYDROGUI_Module::createDataModel()
1103 return new HYDROGUI_DataModel( this );
1106 void HYDROGUI_Module::customEvent( QEvent* e )
1108 int aType = e->type();
1109 if ( aType == NewViewEvent )
1111 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1112 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1114 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1116 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1117 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1119 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1121 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1122 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1124 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1125 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1126 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1128 //ouv: temporarily commented
1129 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1132 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1133 update( UF_Viewer );
1135 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1141 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1143 QEvent::Type aType = theEvent->type();
1144 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1146 if( aType == QEvent::Show )
1148 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1149 e->setData( theObj );
1150 QApplication::postEvent( this, e );
1151 theObj->removeEventFilter( this );
1154 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1156 if( aType == QEvent::Leave )
1158 SUIT_Desktop* aDesktop = getApp()->desktop();
1159 if ( aDesktop && aDesktop->statusBar() ) {
1160 aDesktop->statusBar()->clearMessage();
1164 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1166 if( aType == QEvent::Leave )
1168 SUIT_Desktop* aDesktop = getApp()->desktop();
1169 if ( aDesktop && aDesktop->statusBar() ) {
1170 aDesktop->statusBar()->clearMessage();
1175 return LightApp_Module::eventFilter( theObj, theEvent );
1178 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1180 LightApp_Module::onViewManagerAdded( theViewManager );
1182 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1184 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1185 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1187 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1189 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1190 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1191 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1192 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1194 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1196 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1197 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1198 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1199 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1202 createSelector( theViewManager ); // replace the default selector
1204 ViewManagerInfo anInfo( theViewManager, VMR_General );
1205 myViewManagerMap.insert( ViewManagerId++, anInfo );
1208 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1210 LightApp_Module::onViewManagerRemoved( theViewManager );
1212 createSelector( theViewManager ); // replace the default selector
1214 int anId = getViewManagerId( theViewManager );
1217 OCCViewer_ViewManager* anOCCViewManager =
1218 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1219 if ( anOCCViewManager )
1221 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1223 removeViewShapes( (size_t)anOCCViewer );
1226 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1228 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1231 getVTKDisplayer()->EraseScalarBar( anId, true );
1232 removeViewShapes( (size_t)aVTKViewer );
1236 myViewManagerMap.remove( anId );
1240 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1242 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1244 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1246 aViewFrame->installEventFilter( this );
1248 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1250 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1251 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1254 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1256 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1258 aViewFrame->onTopView();
1260 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1262 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1264 aViewPort->installEventFilter( this );
1268 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1270 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1272 aViewFrame->installEventFilter( this );
1277 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1279 /* ouv: currently unused
1280 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1282 SUIT_ViewManager* aViewManager = 0;
1284 QObject* aParent = aViewPort;
1285 while( aParent = aParent->parent() )
1287 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1289 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1291 aViewManager = aViewer->getViewManager();
1300 double aMouseX = theEvent->scenePos().x();
1301 double aMouseY = theEvent->scenePos().y();
1303 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1304 if( aRole == VMR_General )
1306 int aXDeg = 0, aYDeg = 0;
1307 int aXMin = 0, aYMin = 0;
1308 double aXSec = 0, aYSec = 0;
1309 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1310 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1312 QString aDegSymbol( QChar( 0x00B0 ) );
1313 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1314 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1316 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1318 else if( aRole == VMR_TransformImage )
1319 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1324 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1325 const bool theIsInit,
1326 const bool theIsForced,
1327 const bool theDoFitAll )
1329 QList<int> aViewManagerIdList;
1331 // currently, all views are updated
1332 ViewManagerMapIterator anIter( myViewManagerMap );
1333 while( anIter.hasNext() )
1335 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1337 if ( theDisplayer->IsApplicable( aViewManager ) )
1339 int anId = anIter.key();
1340 aViewManagerIdList.append( anId );
1344 QListIterator<int> anIdIter( aViewManagerIdList );
1345 while( anIdIter.hasNext() )
1347 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1351 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1353 if( !theViewManager )
1356 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1357 if( !aSelectionMgr )
1360 QString aViewType = theViewManager->getType();
1361 if( aViewType != GraphicsView_Viewer::Type() &&
1362 aViewType != OCCViewer_Viewer::Type())
1365 QList<SUIT_Selector*> aSelectorList;
1366 aSelectionMgr->selectors( aViewType, aSelectorList );
1368 // disable all alien selectors
1369 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1370 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1372 SUIT_Selector* aSelector = *anIter;
1373 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1374 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1375 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1376 aSelector->setEnabled( false );
1379 if ( aViewType == GraphicsView_Viewer::Type() )
1381 GraphicsView_ViewManager* aViewManager =
1382 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1384 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1386 else if ( aViewType == OCCViewer_Viewer::Type() )
1388 OCCViewer_ViewManager* aViewManager =
1389 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1391 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1395 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1397 bool aPrevState = myIsUpdateEnabled;
1398 myIsUpdateEnabled = theState;
1402 bool HYDROGUI_Module::isUpdateEnabled() const
1404 return myIsUpdateEnabled;
1407 QStringList HYDROGUI_Module::storeSelection() const
1409 QStringList anEntryList;
1410 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1412 SUIT_DataOwnerPtrList aList( true );
1413 aSelectionMgr->selected( aList );
1415 SUIT_DataOwnerPtrList::iterator anIter;
1416 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1418 const LightApp_DataOwner* anOwner =
1419 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1421 anEntryList.append( anOwner->entry() );
1427 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1429 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1431 SUIT_DataOwnerPtrList aList( true );
1432 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1433 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1434 aSelectionMgr->setSelected( aList );
1438 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* theEvent )
1440 OCCViewer_ViewWindow* anOCCViewWindow =
1441 dynamic_cast<OCCViewer_ViewWindow*>(theViewWindow);
1442 if ( anOCCViewWindow ) {
1443 // Get the selected point coordinates
1444 OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort();
1449 gp_Pnt aPnt = CurveCreator_Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(),
1450 aViewPort->getView() );
1451 // Show the coordinates in the status bar
1452 SUIT_Desktop* aDesktop = getApp()->desktop();
1453 if ( aDesktop && aDesktop->statusBar() ) {
1454 QString aX = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
1455 QString anY = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
1456 aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );
1461 SVTK_ViewWindow* aViewWindow =
1462 dynamic_cast<SVTK_ViewWindow*>(theViewWindow);
1463 if ( aViewWindow ) {
1464 // Get the selected point coordinates
1466 SVTK_RenderWindowInteractor* anInteractor = aViewWindow->GetInteractor();
1469 //TODO: Use a WorldPicker to get current coords
1470 //anInteractorStyle->ComputeDisplayToWorld( theEvent->x(), theEvent->y(), 0, aCoords );
1471 aCoords[0] = theEvent->x();
1472 aCoords[1] = theEvent->y();
1473 // Show the coordinates in the status bar
1474 SUIT_Desktop* aDesktop = getApp()->desktop();
1475 if ( aDesktop && aDesktop->statusBar() ) {
1476 QString aX = HYDROGUI_Tool::GetCoordinateString( aCoords[0] );
1477 QString anY = HYDROGUI_Tool::GetCoordinateString( aCoords[1] );
1478 aDesktop->statusBar()->showMessage( tr("COORDINATES_INFO").arg( aX ).arg( anY ) );