1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_Module.h"
22 #include "HYDROGUI_DataModel.h"
23 #include "HYDROGUI_DataObject.h"
24 #include "HYDROGUI_Displayer.h"
25 #include "HYDROGUI_GVSelector.h"
26 #include "HYDROGUI_InputPanel.h"
27 #include "HYDROGUI_ObjSelector.h"
28 #include "HYDROGUI_OCCDisplayer.h"
29 #include "HYDROGUI_OCCSelector.h"
30 #include "HYDROGUI_Operations.h"
31 #include "HYDROGUI_PrsImage.h"
32 #include "HYDROGUI_Tool.h"
33 #include "HYDROGUI_Tool2.h"
34 #include "HYDROGUI_UpdateFlags.h"
35 #include "HYDROGUI_Shape.h"
36 #include "HYDROGUI_VTKPrs.h"
37 #include "HYDROGUI_VTKPrsDisplayer.h"
38 #include "HYDROGUI_AbstractDisplayer.h"
39 #include "HYDROGUI_PolylineOp.h"
40 #include "HYDROGUI_SetColorOp.h"
41 #include "HYDROGUI_ImportGeomObjectOp.h"
42 #include "HYDROGUI_ShowHideOp.h"
43 #include "HYDROGUI_Overview.h"
45 #include <HYDROData_Tool.h>
46 #include <HYDROData_Image.h>
47 #include <HYDROData_Stream.h>
48 #include <HYDROData_Profile.h>
49 #include <HYDROData_Lambert93.h>
50 #include <HYDROData_Polyline3D.h>
51 #include <HYDROData_StricklerTable.h>
52 #include <HYDROData_ArtificialObject.h>
53 #include <HYDROData_NaturalObject.h>
55 #include <HYDROData_OperationsFactory.h>
57 #include <CurveCreator_Utils.hxx>
59 #include <GraphicsView_ViewFrame.h>
60 #include <GraphicsView_ViewManager.h>
61 #include <GraphicsView_ViewPort.h>
62 #include <GraphicsView_Viewer.h>
64 #include <ImageComposer_CutOperator.h>
65 #include <ImageComposer_CropOperator.h>
66 #include <ImageComposer_FuseOperator.h>
68 #include <LightApp_Application.h>
69 #include <LightApp_DataOwner.h>
70 #include <LightApp_GVSelector.h>
71 #include <LightApp_SelectionMgr.h>
72 #include <LightApp_UpdateFlags.h>
74 #include <SalomeApp_Study.h>
76 #include <OCCViewer_ViewFrame.h>
77 #include <OCCViewer_ViewManager.h>
78 #include <OCCViewer_ViewModel.h>
80 #include <SALOME_Event.h>
82 #include <SUIT_DataBrowser.h>
83 #include <SUIT_DataObject.h>
84 #include <SUIT_ViewManager.h>
85 #include <SUIT_ResourceMgr.h>
86 #include <SUIT_Desktop.h>
87 #include <SUIT_Study.h>
88 #include <SUIT_Session.h>
90 #include <SVTK_ViewManager.h>
91 #include <SVTK_ViewModel.h>
92 #include <SVTK_ViewWindow.h>
93 #include <SVTK_Selector.h>
95 #include <OCCViewer_ViewPort3d.h>
97 #include <GEOMUtils.hxx>
98 #include <GeometryGUI.h>
100 #include <SALOMEDS_wrap.hxx>
103 #include <QApplication>
104 #include <QGraphicsSceneMouseEvent>
106 #include <QMouseEvent>
107 #include <QStatusBar>
110 static int ViewManagerId = 0;
112 extern "C" HYDRO_EXPORT CAM_Module* createModule()
114 return new HYDROGUI_Module();
117 extern "C" HYDRO_EXPORT char* getModuleVersion()
119 return (char*)HYDRO_VERSION;
122 HYDROGUI_Module::HYDROGUI_Module()
123 : LightApp_Module( "HYDRO" ),
126 myIsUpdateEnabled( true ),
131 HYDROGUI_Module::~HYDROGUI_Module()
135 int HYDROGUI_Module::getStudyId() const
137 LightApp_Application* anApp = getApp();
138 return anApp ? anApp->activeStudy()->id() : 0;
141 void HYDROGUI_Module::initialize( CAM_Application* theApp )
143 LightApp_Module::initialize( theApp );
146 createUndoRedoActions();
151 setMenuShown( false );
152 setToolShown( false );
154 myDisplayer = new HYDROGUI_Displayer( this );
155 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
156 myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
159 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
161 bool aRes = LightApp_Module::activateModule( theStudy );
163 LightApp_Application* anApp = getApp();
164 SUIT_Desktop* aDesktop = anApp->desktop();
166 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
168 setMenuShown( true );
169 setToolShown( true );
171 #ifndef DISABLE_PYCONSOLE
172 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
173 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
176 // Remove defunct view managers from the map.
177 // It's essential to do this before "update( UF_All )" call!
178 QList<int> anObsoleteIds;
179 ViewManagerList anAllViewManagers = anApp->viewManagers();
180 ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
181 ViewManagerMapIterator anIter( myViewManagerMap );
182 while( anIter.hasNext() ) {
183 int anId = anIter.next().key();
184 const ViewManagerInfo& anInfo = anIter.value();
186 aHydroViewManagers << anInfo.first;
188 if ( !anAllViewManagers.contains( anInfo.first ) ) {
189 anObsoleteIds << anId;
192 foreach ( const int anId, anObsoleteIds ) {
193 myViewManagerMap.remove( anId );
194 myObjectStateMap.remove( anId );
195 myShapesMap.remove( anId );
196 myVTKPrsMap.remove( anId );
198 // Replace the default selector for all view managers.
199 // Add view managers created outside of HYDRO module to the map.
200 foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
201 createSelector( aViewManager ); // replace the default selector
202 if ( !aHydroViewManagers.contains( aViewManager ) ) {
203 ViewManagerInfo anInfo( aViewManager, VMR_General );
204 myViewManagerMap.insert( ViewManagerId++, anInfo );
210 updateCommandsStatus();
212 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
214 ViewManagerList anOCCViewManagers;
215 anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
217 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
219 connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
220 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
221 connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
222 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
224 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
227 occ_mgr->setChainedOperations( true );//TODO: via preferences
230 foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() )
232 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
233 if ( aViewFrame && aViewFrame->getViewPort() )
235 aViewFrame->getViewPort()->installEventFilter( this );
240 preferencesChanged( "HYDRO", "zoom_shutoff" );
242 preferencesChanged( "HYDRO", "chained_panning" );
245 SalomeApp_Study* aStudy =
246 dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
248 SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
249 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
250 if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
251 SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
252 SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
253 if( !GEOM_var->_is_nil() ) {
254 aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
260 // SUIT_DataBrowser* ob = getApp()->objectBrowser();
261 // SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
262 // treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
267 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
270 ViewManagerMapIterator anIter( myViewManagerMap );
271 while( anIter.hasNext() )
272 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
273 getApp()->removeViewManager( aViewManager );
274 myViewManagerMap.clear();
277 ViewManagerList anOCCViewManagers;
278 getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
279 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
281 disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
282 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
284 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
287 occ_mgr->setChainedOperations( false );
288 setAutoZoom( occ_mgr, true );
293 myObjectStateMap.clear();
298 // clear the status bar
299 SUIT_Desktop* aDesktop = getApp()->desktop();
300 if ( aDesktop && aDesktop->statusBar() ) {
301 aDesktop->statusBar()->clearMessage();
304 // clear the data model's list of copying objects
305 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
307 setMenuShown( false );
308 setToolShown( false );
310 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
312 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
314 myActiveOperationMap.clear();
316 myViewManagerMap.clear();
318 return LightApp_Module::deactivateModule( theStudy );
321 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
323 static bool inWindows = false;
328 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
329 #ifndef DISABLE_PYCONSOLE
330 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
332 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
333 theMap.insert( OverviewWindow, Qt::LeftDockWidgetArea );
336 LightApp_Application* app = getApp();
337 if( app && app->getWindow( OverviewWindow )==0 )
339 const_cast<HYDROGUI_Module*>( this )->myOverview =
340 new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() );
341 app->insertDockWindow( OverviewWindow, myOverview );
342 app->placeDockWindow( OverviewWindow, Qt::LeftDockWidgetArea );
347 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
349 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
352 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
356 HYDROGUI_DataModel* aModel = getDataModel();
358 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
359 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
360 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
361 bool anIsVTKView = theClient == SVTK_Viewer::Type();
362 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
365 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
367 bool anIsSelectedDataObjects = false;
368 bool anIsVisibleInSelection = false;
369 bool anIsHiddenInSelection = false;
371 bool anIsImage = false;
372 bool anIsImportedImage = false;
373 bool anIsImageHasRefs = false;
374 bool anIsFusedImage = false;
375 bool anIsCutImage = false;
376 bool anIsSplitImage = false;
377 bool anIsMustObjectBeUpdated = false;
378 bool anIsPolyline = false;
379 bool anIsPolyline3D = false;
380 bool anIsProfile = false;
381 bool anIsValidProfile = false;
382 bool anAllAreProfiles = false;
383 bool anIsBathymetry = false;
384 bool anIsCalculation = false;
385 bool anIsImmersibleZone = false;
386 bool anIsVisualState = false;
387 bool anIsRegion = false;
388 bool anIsZone = false;
389 bool anIsObstacle = false;
390 bool anIsStricklerTable = false;
391 bool anIsLandCoverMap = false;
392 bool anIsStream = false;
393 bool anIsChannel = false;
394 bool anIsDigue = false;
395 bool anIsDummyObject3D = false;
396 bool anIsGroup = false;
397 bool anIsObjectCanBeColored = false;
399 bool isStreamHasBottom = false;
401 SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
402 SUIT_DataOwnerPtrList anOwners;
403 aSelectionMgr->selected( anOwners );
404 if( anIsObjectBrowser && anOwners.size()==1 )
406 QString anEntry = anOwners[0]->keyString();
407 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
409 isRoot = aStudy->isComponent( anEntry );
412 // Check the selected GEOM objects (take into account the Object Browser only)
413 if ( anIsObjectBrowser ) {
414 QList<GEOM::shape_type> anObstacleTypes =
415 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
416 QList<GEOM::shape_type> aPolylineTypes =
417 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
419 bool isCanBeImportedAsObstacle =
420 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
421 bool isCanBeImportedAsPolyline =
422 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
424 // Add import as obstacle action
425 if ( isCanBeImportedAsObstacle ) {
426 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
428 // Add import as polyline action
429 if ( isCanBeImportedAsPolyline ) {
430 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
433 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
434 theMenu->addSeparator();
438 // check the selected data model objects
439 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
440 int aNbOfSelectedProfiles = 0;
441 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
443 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
444 if( !anObject.IsNull() )
446 anIsSelectedDataObjects = true;
448 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
449 anIsVisibleInSelection |= aVisibility;
450 anIsHiddenInSelection |= !aVisibility;
452 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
454 anIsMustObjectBeUpdated = true;
457 ObjectKind anObjectKind = anObject->GetKind();
458 if( anObjectKind == KIND_IMAGE )
461 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
462 if( !anImage.IsNull() )
464 anIsImportedImage = anImage->HasLocalPoints();
465 anIsImageHasRefs = anImage->HasReferences();
466 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
468 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
470 QString anOperatorName = anOperator->name();
471 if( anOperatorName == ImageComposer_FuseOperator::Type() )
472 anIsFusedImage = true;
473 else if( anOperatorName == ImageComposer_CutOperator::Type() )
475 else if( anOperatorName == ImageComposer_CropOperator::Type() )
476 anIsSplitImage = true;
481 else if( anObjectKind == KIND_POLYLINEXY )
483 else if( anObjectKind == KIND_POLYLINE )
484 anIsPolyline3D = true;
485 else if( anObjectKind == KIND_PROFILE )
488 aNbOfSelectedProfiles++;
490 Handle(HYDROData_Profile) aProfile =
491 Handle(HYDROData_Profile)::DownCast( anObject );
492 if( !aProfile.IsNull() && aProfile->IsValid() ) {
493 anIsValidProfile = true;
496 else if( anObjectKind == KIND_CALCULATION )
497 anIsCalculation = true;
498 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
499 anIsImmersibleZone = true;
500 else if( anObjectKind == KIND_VISUAL_STATE )
501 anIsVisualState = true;
502 else if( anObjectKind == KIND_REGION )
504 else if( anObjectKind == KIND_ZONE )
506 else if( anObjectKind == KIND_BATHYMETRY )
507 anIsBathymetry = true;
508 else if( anObjectKind == KIND_OBSTACLE )
510 else if( anObjectKind == KIND_STRICKLER_TABLE )
511 anIsStricklerTable = true;
512 else if( anObjectKind == KIND_LAND_COVER_MAP )
513 anIsLandCoverMap = true;
514 else if( anObjectKind == KIND_STREAM )
517 Handle(HYDROData_Stream) aStream =
518 Handle(HYDROData_Stream)::DownCast( anObject );
519 if ( !aStream.IsNull() )
520 isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
522 else if( anObjectKind == KIND_CHANNEL )
524 else if( anObjectKind == KIND_DIGUE )
526 else if( anObjectKind == KIND_DUMMY_3D )
527 anIsDummyObject3D = true;
528 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLIT_GROUP )
532 if ( !anIsObjectCanBeColored )
533 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject, this );
536 // Check if all selected objects are profiles
537 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
538 ( aNbOfSelectedProfiles == aSeq.Length() );
540 // check the selected partitions
541 if( !anIsSelectedDataObjects && anIsObjectBrowser )
543 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
544 if( aSelectedPartition != KIND_UNKNOWN )
546 switch( aSelectedPartition )
549 theMenu->addAction( action( ImportImageId ) );
551 case KIND_BATHYMETRY:
552 theMenu->addAction( action( ImportBathymetryId ) );
554 case KIND_ARTIFICIAL_OBJECT:
555 theMenu->addAction( action( CreateChannelId ) );
556 theMenu->addAction( action( CreateDigueId ) );
558 case KIND_NATURAL_OBJECT:
559 theMenu->addAction( action( CreateImmersibleZoneId ) );
560 theMenu->addAction( action( CreateStreamId ) );
563 theMenu->addAction( action( ImportObstacleFromFileId ) );
564 theMenu->addAction( action( CreateBoxId ) );
565 theMenu->addAction( action( CreateCylinderId ) );
567 case KIND_STRICKLER_TABLE:
568 theMenu->addAction( action( ImportStricklerTableFromFileId ) );
570 case KIND_LAND_COVER_MAP:
571 theMenu->addAction( action( CreateLandCoverMapId ) );
572 theMenu->addAction( action( ImportLandCoverMapId ) );
574 case KIND_CALCULATION:
575 theMenu->addAction( action( CreateCalculationId ) );
577 case KIND_POLYLINEXY:
578 theMenu->addAction( action( ImportPolylineId ) );
579 theMenu->addAction( action( CreatePolylineId ) );
582 theMenu->addAction( action( CreatePolyline3DId ) );
585 theMenu->addAction( action( CreateProfileId ) );
586 theMenu->addAction( action( ImportProfilesId ) );
587 theMenu->addAction( action( AllGeoreferencementId ) );
589 case KIND_VISUAL_STATE:
590 theMenu->addAction( action( SaveVisualStateId ) );
593 theMenu->addSeparator();
597 Handle(HYDROData_CalculationCase) aCalcCase;
599 HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr);
600 if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION ))
601 theMenu->addAction( action( RegenerateRegionColorsId ) );
605 if( anIsSelectedDataObjects )
607 if ( anIsMustObjectBeUpdated )
609 theMenu->addAction( action( UpdateObjectId ) );
610 theMenu->addSeparator();
614 theMenu->addAction( action( ForcedUpdateObjectId ) );
615 theMenu->addSeparator();
619 if( aSeq.Length() == 1 )
623 if( anIsImportedImage )
624 theMenu->addAction( action( EditImportedImageId ) );
625 else if( anIsImageHasRefs )
628 theMenu->addAction( action( EditFusedImageId ) );
629 else if( anIsCutImage )
630 theMenu->addAction( action( EditCutImageId ) );
631 else if( anIsSplitImage )
632 theMenu->addAction( action( EditSplitImageId ) );
635 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
636 theMenu->addAction( action( ExportImageId ) );
637 theMenu->addSeparator();
639 if( anIsImageHasRefs )
641 theMenu->addAction( action( RemoveImageRefsId ) );
642 theMenu->addSeparator();
645 theMenu->addAction( action( FuseImagesId ) );
646 theMenu->addAction( action( CutImagesId ) );
647 theMenu->addAction( action( SplitImageId ) );
648 theMenu->addSeparator();
649 theMenu->addAction( action( RecognizeContoursId ) );
650 theMenu->addSeparator();
652 else if( anIsBathymetry )
654 theMenu->addAction( action( EditImportedBathymetryId ) );
655 theMenu->addAction( action( BathymetryBoundsId ) );
656 theMenu->addSeparator();
658 else if( anIsPolyline )
660 theMenu->addAction( action( EditPolylineId ) );
661 theMenu->addSeparator();
662 theMenu->addAction( action( SplitPolylinesId ) );
663 theMenu->addAction( action( MergePolylinesId ) );
664 theMenu->addSeparator();
666 else if( anIsPolyline3D )
668 theMenu->addAction( action( EditPolyline3DId ) );
669 theMenu->addSeparator();
671 else if( anIsProfile )
673 theMenu->addAction( action( EditProfileId ) );
674 theMenu->addAction( action( SelectedGeoreferencementId ) );
675 theMenu->addSeparator();
677 else if( anIsCalculation )
679 theMenu->addAction( action( EditCalculationId ) );
680 theMenu->addAction( action( ExportCalculationId ) );
681 theMenu->addSeparator();
683 else if( anIsImmersibleZone )
685 theMenu->addAction( action( EditImmersibleZoneId ) );
686 theMenu->addSeparator();
688 else if( anIsStream )
690 theMenu->addAction( action( EditStreamId ) );
691 if ( action( RiverBottomContextId ) )
693 theMenu->addAction( action( RiverBottomContextId ) );
694 action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
696 theMenu->addAction( action( ProfileInterpolateId ) );
697 theMenu->addSeparator();
699 else if( anIsChannel )
701 theMenu->addAction( action( EditChannelId ) );
702 theMenu->addSeparator();
706 theMenu->addAction( action( EditDigueId ) );
707 theMenu->addSeparator();
709 else if( anIsObstacle )
711 theMenu->addAction( action( TranslateObstacleId ) );
712 theMenu->addSeparator();
714 else if( anIsStricklerTable )
716 theMenu->addAction( action( EditStricklerTableId ) );
717 theMenu->addAction( action( ExportStricklerTableFromFileId ) );
718 theMenu->addAction( action( DuplicateStricklerTableId ) );
719 theMenu->addSeparator();
721 Handle(HYDROData_StricklerTable) aTable =
722 Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
723 QString aCurrentTable =
724 HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
725 bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
727 if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER_MAP ).isEmpty() ) {
728 theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
729 theMenu->addSeparator();
732 else if( anIsLandCoverMap )
734 theMenu->addAction( action( AddLandCoverId ) );
735 theMenu->addAction( action( RemoveLandCoverId ) );
736 theMenu->addSeparator();
737 theMenu->addAction( action( SplitLandCoverId ) );
738 theMenu->addAction( action( MergeLandCoverId ) );
739 theMenu->addAction( action( ChangeLandCoverTypeId ) );
740 theMenu->addSeparator();
742 theMenu->addAction( action( ExportToShapeFileID ) );
743 theMenu->addSeparator();
745 else if( anIsVisualState && anIsObjectBrowser )
747 theMenu->addAction( action( SaveVisualStateId ) );
748 theMenu->addAction( action( LoadVisualStateId ) );
749 theMenu->addSeparator();
752 theMenu->addAction( action( ZoneSetColorId ) );
754 if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
756 theMenu->addAction( action( PolylineExtractionId ) );
757 theMenu->addSeparator();
760 // Add set color action for geometrical objects
761 if ( anIsObjectCanBeColored )
763 theMenu->addAction( action( SetColorId ) );
764 theMenu->addSeparator();
767 // Add transparency action for land cover map objects
768 if ( anIsLandCoverMap )
770 theMenu->addAction( action( SetTransparencyId ) );
771 theMenu->addSeparator();
774 else if ( anAllAreProfiles )
776 theMenu->addAction( action( EditProfileId ) );
777 theMenu->addAction( action( SelectedGeoreferencementId ) );
778 theMenu->addSeparator();
781 bool isPoly = anIsPolyline || anIsPolyline3D;
782 if (isPoly && !anIsLandCoverMap)
783 theMenu->addAction( action( ExportToShapeFileID ) );
786 QAction* aCopyAction = action( CopyId );
787 if( aCopyAction && aCopyAction->isEnabled() ) {
788 theMenu->addAction( action( CopyId ) );
789 theMenu->addSeparator();
793 if( !anIsDummyObject3D )
794 theMenu->addAction( action( DeleteId ) );
796 theMenu->addSeparator();
798 if( anIsImage || anIsPolyline || anIsPolyline3D ||
799 anIsImmersibleZone || anIsZone || anIsRegion ||
800 anIsBathymetry || anIsObstacle || anIsStream ||
801 anIsChannel || anIsDigue || anIsDummyObject3D ||
802 anIsValidProfile || anIsGroup || anIsLandCoverMap )
804 if( anIsHiddenInSelection )
805 theMenu->addAction( action( ShowId ) );
806 theMenu->addAction( action( ShowOnlyId ) );
807 if( anIsVisibleInSelection )
808 theMenu->addAction( action( HideId ) );
809 theMenu->addSeparator();
815 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
816 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
817 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
818 theMenu->addAction( action( DeleteId ) );
820 theMenu->addSeparator();
821 theMenu->addAction( action( SetZLevelId ) );
822 theMenu->addSeparator();
824 if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
825 theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
826 theMenu->addSeparator();
830 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
832 theMenu->addAction( action( ShowAllId ) );
833 theMenu->addAction( action( HideAllId ) );
834 theMenu->addSeparator();
837 if ( anIsOCCView || anIsVTKView )
839 theMenu->addSeparator();
840 theMenu->addAction( action( CopyViewerPositionId ) );
844 theMenu->addAction( action( EditLocalCSId ) );
846 if( anIsObjectBrowser && anOwners.size()==1 )
848 if( aSeq.Size() > 0 )
850 Handle( HYDROData_Entity ) aFirstEnt = aSeq.First();
851 Handle(HYDROData_Object) anObject;
852 Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt);
853 Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt);
855 if (!anAObject.IsNull())
856 anObject = anAObject;
857 if (!aNObject.IsNull())
860 if( !anObject.IsNull() )
862 theMenu->addSeparator();
863 bool IsSubmersible = anObject->IsSubmersible();
866 theMenu->addAction( action( SubmersibleId ) );
867 action( SubmersibleId )->setCheckable(true);
868 action( SubmersibleId )->setChecked(true);
872 theMenu->addAction( action( UnSubmersibleId ) );
873 action( UnSubmersibleId )->setCheckable(true);
874 action( UnSubmersibleId )->setChecked(true);
880 theMenu->addSeparator();
881 QAction* a = action( ShowHideArrows );
882 a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
883 theMenu->addAction( a );
886 void HYDROGUI_Module::createPreferences()
888 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
889 int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
891 int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
892 LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
894 // Set property cursor type
895 QList<QVariant> aCursorTypeIndicesList;
896 QList<QVariant> aCursorTypeIconsList;
898 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
899 for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
900 QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
901 QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
902 aCursorTypeIndicesList << i;
903 aCursorTypeIconsList << pixmap;
906 setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
907 setPreferenceProperty( typeOfCursor, "icons", aCursorTypeIconsList );
909 int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
910 addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
911 LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
913 addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
915 addPreference( tr( "PREF_VIEWER_CHAINED_PANNING" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "chained_panning" );
917 int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
918 int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
919 LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
920 setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
921 setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
922 setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
923 setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
925 int polylinesGroup = addPreference( tr( "PREF_GROUP_POLYLINES" ), genTab );
926 int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
927 LightApp_Preferences::Selector, "polyline", "arrow_type" );
929 QList<QVariant> arrow_types;
930 arrow_types.append( tr( "No" ) );
931 arrow_types.append( tr( "Triangle" ) );
932 arrow_types.append( tr( "Cone" ) );
933 setPreferenceProperty( polylineArrow, "strings", arrow_types );
935 QList<QVariant> indices;
939 setPreferenceProperty( polylineArrow, "indexes", indices );
940 setPreferenceProperty( polylineArrow, "ids", indices );
942 int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup,
943 LightApp_Preferences::IntSpin, "polyline", "arrow_size" );
946 void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
948 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
949 if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
952 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
953 if ( resMgr && !aDoc.IsNull() )
954 aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
956 else if( theSection == "polyline" )
962 resMgr->value( "polyline", "arrow_type", aType );
963 resMgr->value( "polyline", "arrow_size", aSize );
966 ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end();
967 for( ; it!=last; it++ )
969 int aViewerId = it.key();
970 OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( it.value().first );
972 getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
975 else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
977 bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
978 setAutoZoomToAllViewManagers(!aZoomShutoff);
980 else if (theSection == "HYDRO" && thePref == "chained_panning")
982 bool aChainedPan = resMgr->booleanValue( "HYDRO", "chained_panning" );
985 ViewManagerList aViewManagers = getApp()->viewManagers();
986 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
988 OCCViewer_ViewManager* anOCCViewMgr = dynamic_cast<OCCViewer_ViewManager*>( aVMgr );
990 anOCCViewMgr->setChainedOperations( aChainedPan );
994 LightApp_Module::preferencesChanged( theSection, thePref );
997 QCursor HYDROGUI_Module::getPrefEditCursor() const
999 int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
1000 if ( aCursorType >= Qt::BlankCursor)
1002 QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
1006 void HYDROGUI_Module::update( const int flags )
1008 if ( !isUpdateEnabled() )
1011 QApplication::setOverrideCursor( Qt::WaitCursor );
1013 // To prevent calling this method recursively
1014 // from one of the methods called below
1015 setUpdateEnabled( false );
1017 // store selected objects
1018 QStringList aSelectedEntries = storeSelection();
1020 bool aDoFitAll = flags & UF_FitAll;
1023 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1024 aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
1027 if( ( flags & UF_Viewer ) )
1028 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
1030 if( ( flags & UF_OCCViewer ) )
1031 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
1033 if( ( flags & UF_VTKViewer ) )
1034 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
1036 if( ( flags & UF_Model ) && getDataModel() && getApp() )
1038 getDataModel()->update( getStudyId() );
1040 // Temporary workaround to prevent breaking
1041 // the selection in the object browser.
1042 // Note: processEvents() should be called after updateGV(),
1043 // otherwise the application crashes from time to time.
1044 //RKV: qApp->processEvents();
1045 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1046 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
1047 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
1048 if ( isResizeOnExpandItem && anObjectBrowser ) {
1049 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
1051 getApp()->updateObjectBrowser( true );
1052 if ( isResizeOnExpandItem && anObjectBrowser ) {
1053 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
1057 // Object browser is currently updated by using UF_Model flag
1058 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
1059 getApp()->updateObjectBrowser( true );
1061 if( ( flags & UF_Controls ) && getApp() )
1062 getApp()->updateActions();
1064 // restore selected objects
1065 restoreSelection( aSelectedEntries );
1067 setUpdateEnabled( true );
1069 preferencesChanged( "HYDRO", "zoom_shutoff" );
1071 preferencesChanged( "HYDRO", "chained_panning" );
1073 QApplication::restoreOverrideCursor();
1076 void HYDROGUI_Module::updateCommandsStatus()
1078 LightApp_Module::updateCommandsStatus();
1080 updateUndoRedoControls();
1082 action( CopyId )->setEnabled( getDataModel()->canCopy() );
1083 action( PasteId )->setEnabled( getDataModel()->canPaste() );
1086 void HYDROGUI_Module::selectionChanged()
1088 LightApp_Module::selectionChanged();
1089 updateCommandsStatus();
1092 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
1094 return (HYDROGUI_DataModel*)dataModel();
1097 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
1102 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
1104 return myOCCDisplayer;
1107 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
1109 return myVTKDisplayer;
1112 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
1114 if( myViewManagerMap.contains( theId ) )
1116 return myViewManagerMap[ theId ].first;
1121 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
1123 if( myViewManagerMap.contains( theId ) )
1125 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1126 GraphicsView_ViewManager* aViewManager =
1127 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
1129 return aViewManager->getViewer();
1134 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
1136 if( myViewManagerMap.contains( theId ) )
1138 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1139 OCCViewer_ViewManager* aViewManager =
1140 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
1142 return aViewManager->getOCCViewer();
1147 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
1149 if( myViewManagerMap.contains( theId ) )
1151 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1152 SVTK_ViewManager* aViewManager =
1153 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
1155 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
1160 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
1162 ViewManagerMapIterator anIter( myViewManagerMap );
1163 while( anIter.hasNext() )
1165 int anId = anIter.next().key();
1166 const ViewManagerInfo& anInfo = anIter.value();
1167 if( anInfo.first == theViewManager )
1173 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
1175 int anId = getViewManagerId( theViewManager );
1178 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1179 return anInfo.second;
1184 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
1185 const ViewManagerRole theRole )
1187 int anId = getViewManagerId( theViewManager );
1190 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1191 anInfo.second = theRole;
1195 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
1196 const Handle(HYDROData_Entity)& theObject ) const
1198 if( theObject.IsNull() )
1204 foreach( int aViewId, myObjectStateMap.keys() )
1206 if( isObjectVisible( aViewId, theObject ) )
1212 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1213 if( anIter1 != myObjectStateMap.end() )
1215 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1216 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1218 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1219 if( anIter2 != aEntry2ObjectStateMap.end() )
1221 const ObjectState& anObjectState = anIter2.value();
1222 return anObjectState.Visibility;
1228 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1229 const Handle(HYDROData_Entity)& theObject,
1230 const bool theState )
1232 if( !theObject.IsNull() )
1234 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1235 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1237 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1238 anObjectState.Visibility = theState;
1240 HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1243 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1246 QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1247 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1248 if ( visState != Qtx::UnpresentableState )
1249 treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1253 if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1254 setLandCoversScalarMapModeOff( theViewId );
1255 } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) {
1256 getOCCDisplayer()->SetToUpdateColorScale();
1261 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1262 const bool theState )
1264 if( !theObject.IsNull() )
1266 // Process OCC shapes
1267 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1268 while( aShapesMapIter != myShapesMap.end() )
1270 const ListOfShapes& aShapesList = aShapesMapIter.value();
1271 foreach ( HYDROGUI_Shape* aShape, aShapesList )
1273 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1275 aShape->setIsToUpdate( theState );
1280 // Process VTK shapes
1281 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1282 while( aVTKPrsMapIter != myVTKPrsMap.end() )
1284 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1285 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1287 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1289 aShape->setIsToUpdate( theState );
1297 /////////////////// OCC SHAPES PROCESSING
1298 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
1299 ObjectKind theKind ) const
1301 QList<HYDROGUI_Shape*> aResult;
1303 if ( myShapesMap.contains( theViewId ) )
1305 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1306 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1308 if( aShape && aShape->getObject()->GetKind()==theKind )
1309 aResult.append( aShape );
1315 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
1316 const Handle(HYDROData_Entity)& theObject ) const
1318 HYDROGUI_Shape* aResShape = NULL;
1319 if( theObject.IsNull() )
1322 if ( myShapesMap.contains( theViewId ) )
1324 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1325 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1327 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1338 void HYDROGUI_Module::setObjectShape( const int theViewId,
1339 const Handle(HYDROData_Entity)& theObject,
1340 HYDROGUI_Shape* theShape )
1342 if( theObject.IsNull() )
1345 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1346 aViewShapes.append( theShape );
1349 void HYDROGUI_Module::removeObjectShape( const int theViewId,
1350 const Handle(HYDROData_Entity)& theObject )
1352 if ( !myShapesMap.contains( theViewId ) )
1355 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1356 Handle(HYDROData_Entity) anObject;
1357 for ( int i = 0; i < aViewShapes.length(); )
1359 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1360 anObject = aShape->getObject();
1361 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1364 aViewShapes.removeAt( i );
1372 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1374 if ( !myShapesMap.contains( theViewId ) )
1377 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1378 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1380 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1385 myShapesMap.remove( theViewId );
1387 /////////////////// END OF OCC SHAPES PROCESSING
1389 /////////////////// VTKPrs PROCESSING
1390 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
1391 const Handle(HYDROData_Entity)& theObject ) const
1393 HYDROGUI_VTKPrs* aResShape = NULL;
1394 if( theObject.IsNull() )
1397 if ( myVTKPrsMap.contains( theViewId ) )
1399 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1400 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1402 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1413 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1414 const Handle(HYDROData_Entity)& theObject,
1415 HYDROGUI_VTKPrs* theShape )
1417 if( theObject.IsNull() )
1420 if( theShape && theShape->needScalarBar() )
1422 // Compute the new global Z range from the added presentation and the old global Z range.
1423 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1424 double* aRange = theShape->getInternalZRange();
1425 bool anIsUpdate = false;
1426 if ( aRange[0] < aGlobalRange[0] )
1428 aGlobalRange[0] = aRange[0];
1431 if ( aRange[1] > aGlobalRange[1] )
1433 aGlobalRange[1] = aRange[1];
1439 updateVTKZRange( theViewId, aGlobalRange );
1443 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1444 aViewShapes.append( theShape );
1447 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1448 const QString& theEntry )
1450 if ( !myVTKPrsMap.contains( theViewId ) )
1453 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1454 Handle(HYDROData_Entity) anObject;
1456 for ( int i = 0; i < aViewShapes.length(); )
1458 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1459 anObject = aShape->getObject();
1460 anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1461 if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1464 aViewShapes.removeAt( i );
1471 // Invalidate global Z range
1472 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1473 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1476 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1477 const Handle(HYDROData_Entity)& theObject )
1479 if ( !myVTKPrsMap.contains( theViewId ) )
1482 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1483 Handle(HYDROData_Entity) anObject;
1484 for ( int i = 0; i < aViewShapes.length(); )
1486 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1487 anObject = aShape->getObject();
1488 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1491 aViewShapes.removeAt( i );
1498 // Invalidate global Z range
1499 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1500 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1503 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1505 if ( !myVTKPrsMap.contains( theViewId ) )
1508 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1509 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1511 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1516 myVTKPrsMap.remove( theViewId );
1519 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1521 if ( myVTKPrsMap.contains( theViewId ) )
1523 // For the given viewer id update all VTK presentations ...
1524 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1525 HYDROGUI_VTKPrs* aShape;
1526 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1528 aShape = aViewShapes.at( i );
1529 if ( aShape && aShape->needScalarBar() )
1531 aShape->setZRange( theRange );
1535 // ... and update the global color legend scalar bar.
1536 getVTKDisplayer()->SetZRange( theViewId, theRange );
1538 /////////////////// END OF VTKPrs PROCESSING
1540 void HYDROGUI_Module::clearCache()
1542 myObjectStateMap.clear();
1545 CAM_DataModel* HYDROGUI_Module::createDataModel()
1547 return new HYDROGUI_DataModel( this );
1550 void HYDROGUI_Module::customEvent( QEvent* e )
1552 int aType = e->type();
1553 if ( aType == NewViewEvent )
1555 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1556 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1558 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1560 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1561 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1563 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1565 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1566 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1568 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1569 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1570 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1572 //ouv: temporarily commented
1573 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1576 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1577 update( UF_Viewer );
1579 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1585 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1587 QEvent::Type aType = theEvent->type();
1588 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1590 if( aType == QEvent::Show )
1592 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1593 e->setData( theObj );
1594 QApplication::postEvent( this, e );
1595 theObj->removeEventFilter( this );
1598 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1600 if( aType == QEvent::Leave )
1602 SUIT_Desktop* aDesktop = getApp()->desktop();
1603 if ( aDesktop && aDesktop->statusBar() ) {
1604 aDesktop->statusBar()->clearMessage();
1608 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1610 if( aType == QEvent::Leave )
1612 SUIT_Desktop* aDesktop = getApp()->desktop();
1613 if ( aDesktop && aDesktop->statusBar() ) {
1614 aDesktop->statusBar()->clearMessage();
1619 return LightApp_Module::eventFilter( theObj, theEvent );
1622 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1624 LightApp_Module::onViewManagerAdded( theViewManager );
1626 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1628 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1629 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1631 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1633 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
1634 //mgr->setChainedOperations( true );
1636 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1637 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1638 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1639 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1640 connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
1641 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
1643 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1645 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1646 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1647 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1648 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1651 createSelector( theViewManager ); // replace the default selector
1653 ViewManagerInfo anInfo( theViewManager, VMR_General );
1654 myViewManagerMap.insert( ViewManagerId++, anInfo );
1657 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1659 LightApp_Module::onViewManagerRemoved( theViewManager );
1661 createSelector( theViewManager ); // replace the default selector
1663 int anId = getViewManagerId( theViewManager );
1666 OCCViewer_ViewManager* anOCCViewManager =
1667 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1668 if ( anOCCViewManager )
1670 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1671 if ( anOCCViewer ) {
1672 int aViewerId = (size_t)anOCCViewer;
1673 removeViewShapes( aViewerId );
1674 setLandCoversScalarMapModeOff( aViewerId );
1678 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1680 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1683 getVTKDisplayer()->EraseScalarBar( anId, true );
1684 removeViewShapes( (size_t)aVTKViewer );
1688 myViewManagerMap.remove( anId );
1692 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1694 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1696 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1698 aViewFrame->installEventFilter( this );
1700 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1701 aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
1703 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1704 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1707 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1709 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1711 aViewFrame->onTopView();
1713 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1714 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1716 aViewPort->installEventFilter( this );
1720 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1722 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1724 aViewFrame->installEventFilter( this );
1729 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1731 /* ouv: currently unused
1732 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1734 SUIT_ViewManager* aViewManager = 0;
1736 QObject* aParent = aViewPort;
1737 while( aParent = aParent->parent() )
1739 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1741 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1743 aViewManager = aViewer->getViewManager();
1752 double aMouseX = theEvent->scenePos().x();
1753 double aMouseY = theEvent->scenePos().y();
1755 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1756 if( aRole == VMR_General )
1758 int aXDeg = 0, aYDeg = 0;
1759 int aXMin = 0, aYMin = 0;
1760 double aXSec = 0, aYSec = 0;
1761 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1762 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1764 QString aDegSymbol( QChar( 0x00B0 ) );
1765 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1766 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1768 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1770 else if( aRole == VMR_TransformImage )
1771 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1776 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1777 const bool theIsInit,
1778 const bool theIsForced,
1779 const bool theDoFitAll )
1781 QList<int> aViewManagerIdList;
1783 // currently, all views are updated
1784 ViewManagerMapIterator anIter( myViewManagerMap );
1785 while( anIter.hasNext() )
1787 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1789 if ( theDisplayer->IsApplicable( aViewManager ) )
1791 int anId = anIter.key();
1792 aViewManagerIdList.append( anId );
1796 QListIterator<int> anIdIter( aViewManagerIdList );
1797 while( anIdIter.hasNext() )
1799 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1800 myOverview->setTopView();
1804 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1806 if( !theViewManager )
1809 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1810 if( !aSelectionMgr )
1813 QString aViewType = theViewManager->getType();
1814 if( aViewType != GraphicsView_Viewer::Type() &&
1815 aViewType != OCCViewer_Viewer::Type())
1818 QList<SUIT_Selector*> aSelectorList;
1819 aSelectionMgr->selectors( aViewType, aSelectorList );
1821 // disable all alien selectors
1822 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1823 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1825 SUIT_Selector* aSelector = *anIter;
1826 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1827 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1828 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1829 aSelector->setEnabled( false );
1832 if ( aViewType == GraphicsView_Viewer::Type() )
1834 GraphicsView_ViewManager* aViewManager =
1835 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1837 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1839 else if ( aViewType == OCCViewer_Viewer::Type() )
1841 OCCViewer_ViewManager* aViewManager =
1842 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1844 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1848 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1850 bool aPrevState = myIsUpdateEnabled;
1851 myIsUpdateEnabled = theState;
1855 bool HYDROGUI_Module::isUpdateEnabled() const
1857 return myIsUpdateEnabled;
1860 QStringList HYDROGUI_Module::storeSelection() const
1862 QStringList anEntryList;
1863 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1865 SUIT_DataOwnerPtrList aList( true );
1866 aSelectionMgr->selected( aList );
1868 SUIT_DataOwnerPtrList::iterator anIter;
1869 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1871 const LightApp_DataOwner* anOwner =
1872 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1874 anEntryList.append( anOwner->entry() );
1880 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1882 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1884 SUIT_DataOwnerPtrList aList( true );
1885 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1886 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1887 aSelectionMgr->setSelected( aList );
1891 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1894 bool doShow = false;
1895 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1897 aDisplayer->SaveCursorViewPosition( theViewWindow );
1898 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1902 // Show the coordinates in the status bar
1903 SUIT_Desktop* aDesktop = getApp()->desktop();
1904 if ( aDesktop && aDesktop->statusBar() )
1906 gp_Pnt aWPnt( X, Y, Z );
1907 int aStudyId = application()->activeStudy()->id();
1908 HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
1909 double WX = aWPnt.X(), WY = aWPnt.Y();
1911 QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1912 QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1913 QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1914 QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1915 QString aMsg = tr( "COORDINATES_INFO" );
1916 aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1917 aDesktop->statusBar()->showMessage( aMsg );
1923 * Returns stack of active operations;
1925 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
1927 return myActiveOperationMap;
1931 * Returns the module active operation. If the active operation is show/hide,
1932 * the method returns the previous operation if it is.
1934 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
1936 HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
1938 if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
1940 QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
1942 aVIt.previous(); // skip the top show/hide operation
1943 anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
1950 * \brief Virtual public slot
1952 * This method is called after the object inserted into data view to update their visibility state
1953 * This is default implementation
1955 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
1957 if ( !isActiveModule() )
1960 HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
1962 // change visibility of object
1963 if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
1966 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1968 QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
1969 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1970 if ( visState == Qtx::UnpresentableState )
1973 visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
1974 treeModel->setVisibilityState( id, visState );
1976 bool vis = visState == Qtx::ShownState;
1977 if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
1980 setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
1982 update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
1985 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
1987 Handle(HYDROData_StricklerTable) aTable;
1989 if ( myLandCoverColoringMap.contains( theViewId ) ) {
1990 aTable = myLandCoverColoringMap.value( theViewId );
1996 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
1997 const Handle(HYDROData_StricklerTable)& theTable )
1999 if ( !theTable.IsNull() ) {
2000 myLandCoverColoringMap.insert( theViewId, theTable );
2004 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
2006 myLandCoverColoringMap.remove( theViewId );
2009 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
2011 return myLandCoverColoringMap.contains( theViewId );
2014 void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
2016 if ( theObject.IsNull() || !theObject->IsRemoved() ) {
2020 if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
2021 Handle(HYDROData_StricklerTable) aTable =
2022 Handle(HYDROData_StricklerTable)::DownCast( theObject );
2023 QList<int> aViewIds;
2024 QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
2025 while ( anIter.hasNext() ) {
2026 if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
2027 HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
2034 void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
2039 SUIT_ViewWindow* wnd = theMgr->getActiveView();
2040 OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
2044 myOverview->setMainView( occwnd );
2047 void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
2049 ViewManagerList aViewManagers = getApp()->viewManagers();
2050 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
2051 setAutoZoom(aVMgr, bAutoZoom);
2054 void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
2058 QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
2059 foreach (SUIT_ViewWindow* aView, aViews)
2063 OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
2066 anOCCViewFrame->setAutomaticZoom(bAutoZoom);
2067 for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
2069 OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
2071 aV->setAutomaticZoom(bAutoZoom);
2074 OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
2075 if (anOCCViewWindow)
2076 anOCCViewWindow->setAutomaticZoom(bAutoZoom);