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"
44 #include <HYDROGUI_ProfileDlg.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 );
993 QList<QDockWidget*> docW = getApp()->desktop()->findChildren<QDockWidget*>();
994 foreach (QDockWidget* qw, docW)
996 HYDROGUI_ProfileDlg* pdlg = dynamic_cast<HYDROGUI_ProfileDlg*>(qw);
998 pdlg->viewManager()->setChainedOperations(aChainedPan);
1002 LightApp_Module::preferencesChanged( theSection, thePref );
1005 QCursor HYDROGUI_Module::getPrefEditCursor() const
1007 int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
1008 if ( aCursorType >= Qt::BlankCursor)
1010 QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
1014 void HYDROGUI_Module::update( const int flags )
1016 if ( !isUpdateEnabled() )
1019 QApplication::setOverrideCursor( Qt::WaitCursor );
1021 // To prevent calling this method recursively
1022 // from one of the methods called below
1023 setUpdateEnabled( false );
1025 // store selected objects
1026 QStringList aSelectedEntries = storeSelection();
1028 bool aDoFitAll = flags & UF_FitAll;
1031 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1032 aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
1035 if( ( flags & UF_Viewer ) )
1036 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
1038 if( ( flags & UF_OCCViewer ) )
1039 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
1041 if( ( flags & UF_VTKViewer ) )
1042 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
1044 if( ( flags & UF_Model ) && getDataModel() && getApp() )
1046 getDataModel()->update( getStudyId() );
1048 // Temporary workaround to prevent breaking
1049 // the selection in the object browser.
1050 // Note: processEvents() should be called after updateGV(),
1051 // otherwise the application crashes from time to time.
1052 //RKV: qApp->processEvents();
1053 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1054 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
1055 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
1056 if ( isResizeOnExpandItem && anObjectBrowser ) {
1057 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
1059 getApp()->updateObjectBrowser( true );
1060 if ( isResizeOnExpandItem && anObjectBrowser ) {
1061 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
1065 // Object browser is currently updated by using UF_Model flag
1066 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
1067 getApp()->updateObjectBrowser( true );
1069 if( ( flags & UF_Controls ) && getApp() )
1070 getApp()->updateActions();
1072 // restore selected objects
1073 restoreSelection( aSelectedEntries );
1075 setUpdateEnabled( true );
1077 preferencesChanged( "HYDRO", "zoom_shutoff" );
1079 preferencesChanged( "HYDRO", "chained_panning" );
1081 QApplication::restoreOverrideCursor();
1084 void HYDROGUI_Module::updateCommandsStatus()
1086 LightApp_Module::updateCommandsStatus();
1088 updateUndoRedoControls();
1090 action( CopyId )->setEnabled( getDataModel()->canCopy() );
1091 action( PasteId )->setEnabled( getDataModel()->canPaste() );
1094 void HYDROGUI_Module::selectionChanged()
1096 LightApp_Module::selectionChanged();
1097 updateCommandsStatus();
1100 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
1102 return (HYDROGUI_DataModel*)dataModel();
1105 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
1110 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
1112 return myOCCDisplayer;
1115 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
1117 return myVTKDisplayer;
1120 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
1122 if( myViewManagerMap.contains( theId ) )
1124 return myViewManagerMap[ theId ].first;
1129 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
1131 if( myViewManagerMap.contains( theId ) )
1133 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1134 GraphicsView_ViewManager* aViewManager =
1135 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
1137 return aViewManager->getViewer();
1142 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
1144 if( myViewManagerMap.contains( theId ) )
1146 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1147 OCCViewer_ViewManager* aViewManager =
1148 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
1150 return aViewManager->getOCCViewer();
1155 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
1157 if( myViewManagerMap.contains( theId ) )
1159 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1160 SVTK_ViewManager* aViewManager =
1161 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
1163 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
1168 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
1170 ViewManagerMapIterator anIter( myViewManagerMap );
1171 while( anIter.hasNext() )
1173 int anId = anIter.next().key();
1174 const ViewManagerInfo& anInfo = anIter.value();
1175 if( anInfo.first == theViewManager )
1181 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
1183 int anId = getViewManagerId( theViewManager );
1186 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1187 return anInfo.second;
1192 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
1193 const ViewManagerRole theRole )
1195 int anId = getViewManagerId( theViewManager );
1198 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1199 anInfo.second = theRole;
1203 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
1204 const Handle(HYDROData_Entity)& theObject ) const
1206 if( theObject.IsNull() )
1212 foreach( int aViewId, myObjectStateMap.keys() )
1214 if( isObjectVisible( aViewId, theObject ) )
1220 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1221 if( anIter1 != myObjectStateMap.end() )
1223 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1224 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1226 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1227 if( anIter2 != aEntry2ObjectStateMap.end() )
1229 const ObjectState& anObjectState = anIter2.value();
1230 return anObjectState.Visibility;
1236 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1237 const Handle(HYDROData_Entity)& theObject,
1238 const bool theState )
1240 if( !theObject.IsNull() )
1242 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1243 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1245 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1246 anObjectState.Visibility = theState;
1248 HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1251 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1254 QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1255 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1256 if ( visState != Qtx::UnpresentableState )
1257 treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1261 if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1262 setLandCoversScalarMapModeOff( theViewId );
1263 } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) {
1264 getOCCDisplayer()->SetToUpdateColorScale();
1269 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1270 const bool theState )
1272 if( !theObject.IsNull() )
1274 // Process OCC shapes
1275 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1276 while( aShapesMapIter != myShapesMap.end() )
1278 const ListOfShapes& aShapesList = aShapesMapIter.value();
1279 foreach ( HYDROGUI_Shape* aShape, aShapesList )
1281 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1283 aShape->setIsToUpdate( theState );
1288 // Process VTK shapes
1289 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1290 while( aVTKPrsMapIter != myVTKPrsMap.end() )
1292 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1293 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1295 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1297 aShape->setIsToUpdate( theState );
1305 /////////////////// OCC SHAPES PROCESSING
1306 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
1307 ObjectKind theKind ) const
1309 QList<HYDROGUI_Shape*> aResult;
1311 if ( myShapesMap.contains( theViewId ) )
1313 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1314 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1316 if( aShape && aShape->getObject()->GetKind()==theKind )
1317 aResult.append( aShape );
1323 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
1324 const Handle(HYDROData_Entity)& theObject ) const
1326 HYDROGUI_Shape* aResShape = NULL;
1327 if( theObject.IsNull() )
1330 if ( myShapesMap.contains( theViewId ) )
1332 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1333 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1335 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1346 void HYDROGUI_Module::setObjectShape( const int theViewId,
1347 const Handle(HYDROData_Entity)& theObject,
1348 HYDROGUI_Shape* theShape )
1350 if( theObject.IsNull() )
1353 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1354 aViewShapes.append( theShape );
1357 void HYDROGUI_Module::removeObjectShape( const int theViewId,
1358 const Handle(HYDROData_Entity)& theObject )
1360 if ( !myShapesMap.contains( theViewId ) )
1363 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1364 Handle(HYDROData_Entity) anObject;
1365 for ( int i = 0; i < aViewShapes.length(); )
1367 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1368 anObject = aShape->getObject();
1369 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1372 aViewShapes.removeAt( i );
1380 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1382 if ( !myShapesMap.contains( theViewId ) )
1385 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1386 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1388 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1393 myShapesMap.remove( theViewId );
1395 /////////////////// END OF OCC SHAPES PROCESSING
1397 /////////////////// VTKPrs PROCESSING
1398 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
1399 const Handle(HYDROData_Entity)& theObject ) const
1401 HYDROGUI_VTKPrs* aResShape = NULL;
1402 if( theObject.IsNull() )
1405 if ( myVTKPrsMap.contains( theViewId ) )
1407 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1408 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1410 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1421 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1422 const Handle(HYDROData_Entity)& theObject,
1423 HYDROGUI_VTKPrs* theShape )
1425 if( theObject.IsNull() )
1428 if( theShape && theShape->needScalarBar() )
1430 // Compute the new global Z range from the added presentation and the old global Z range.
1431 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1432 double* aRange = theShape->getInternalZRange();
1433 bool anIsUpdate = false;
1434 if ( aRange[0] < aGlobalRange[0] )
1436 aGlobalRange[0] = aRange[0];
1439 if ( aRange[1] > aGlobalRange[1] )
1441 aGlobalRange[1] = aRange[1];
1447 updateVTKZRange( theViewId, aGlobalRange );
1451 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1452 aViewShapes.append( theShape );
1455 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1456 const QString& theEntry )
1458 if ( !myVTKPrsMap.contains( theViewId ) )
1461 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1462 Handle(HYDROData_Entity) anObject;
1464 for ( int i = 0; i < aViewShapes.length(); )
1466 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1467 anObject = aShape->getObject();
1468 anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1469 if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1472 aViewShapes.removeAt( i );
1479 // Invalidate global Z range
1480 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1481 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1484 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1485 const Handle(HYDROData_Entity)& theObject )
1487 if ( !myVTKPrsMap.contains( theViewId ) )
1490 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1491 Handle(HYDROData_Entity) anObject;
1492 for ( int i = 0; i < aViewShapes.length(); )
1494 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1495 anObject = aShape->getObject();
1496 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1499 aViewShapes.removeAt( i );
1506 // Invalidate global Z range
1507 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1508 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1511 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1513 if ( !myVTKPrsMap.contains( theViewId ) )
1516 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1517 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1519 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1524 myVTKPrsMap.remove( theViewId );
1527 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1529 if ( myVTKPrsMap.contains( theViewId ) )
1531 // For the given viewer id update all VTK presentations ...
1532 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1533 HYDROGUI_VTKPrs* aShape;
1534 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1536 aShape = aViewShapes.at( i );
1537 if ( aShape && aShape->needScalarBar() )
1539 aShape->setZRange( theRange );
1543 // ... and update the global color legend scalar bar.
1544 getVTKDisplayer()->SetZRange( theViewId, theRange );
1546 /////////////////// END OF VTKPrs PROCESSING
1548 void HYDROGUI_Module::clearCache()
1550 myObjectStateMap.clear();
1553 CAM_DataModel* HYDROGUI_Module::createDataModel()
1555 return new HYDROGUI_DataModel( this );
1558 void HYDROGUI_Module::customEvent( QEvent* e )
1560 int aType = e->type();
1561 if ( aType == NewViewEvent )
1563 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1564 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1566 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1568 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1569 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1571 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1573 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1574 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1576 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1577 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1578 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1580 //ouv: temporarily commented
1581 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1584 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1585 update( UF_Viewer );
1587 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1593 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1595 QEvent::Type aType = theEvent->type();
1596 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1598 if( aType == QEvent::Show )
1600 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1601 e->setData( theObj );
1602 QApplication::postEvent( this, e );
1603 theObj->removeEventFilter( this );
1606 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1608 if( aType == QEvent::Leave )
1610 SUIT_Desktop* aDesktop = getApp()->desktop();
1611 if ( aDesktop && aDesktop->statusBar() ) {
1612 aDesktop->statusBar()->clearMessage();
1616 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1618 if( aType == QEvent::Leave )
1620 SUIT_Desktop* aDesktop = getApp()->desktop();
1621 if ( aDesktop && aDesktop->statusBar() ) {
1622 aDesktop->statusBar()->clearMessage();
1627 return LightApp_Module::eventFilter( theObj, theEvent );
1630 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1632 LightApp_Module::onViewManagerAdded( theViewManager );
1634 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1636 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1637 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1639 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1641 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
1642 //mgr->setChainedOperations( true );
1644 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1645 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1646 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1647 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1648 connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
1649 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
1651 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1653 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1654 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1655 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1656 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1659 createSelector( theViewManager ); // replace the default selector
1661 ViewManagerInfo anInfo( theViewManager, VMR_General );
1662 myViewManagerMap.insert( ViewManagerId++, anInfo );
1665 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1667 LightApp_Module::onViewManagerRemoved( theViewManager );
1669 createSelector( theViewManager ); // replace the default selector
1671 int anId = getViewManagerId( theViewManager );
1674 OCCViewer_ViewManager* anOCCViewManager =
1675 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1676 if ( anOCCViewManager )
1678 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1679 if ( anOCCViewer ) {
1680 int aViewerId = (size_t)anOCCViewer;
1681 removeViewShapes( aViewerId );
1682 setLandCoversScalarMapModeOff( aViewerId );
1686 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1688 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1691 getVTKDisplayer()->EraseScalarBar( anId, true );
1692 removeViewShapes( (size_t)aVTKViewer );
1696 myViewManagerMap.remove( anId );
1700 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1702 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1704 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1706 aViewFrame->installEventFilter( this );
1708 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1709 aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
1711 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1712 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1715 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1717 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1719 aViewFrame->onTopView();
1721 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1722 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1724 aViewPort->installEventFilter( this );
1728 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1730 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1732 aViewFrame->installEventFilter( this );
1737 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1739 /* ouv: currently unused
1740 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1742 SUIT_ViewManager* aViewManager = 0;
1744 QObject* aParent = aViewPort;
1745 while( aParent = aParent->parent() )
1747 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1749 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1751 aViewManager = aViewer->getViewManager();
1760 double aMouseX = theEvent->scenePos().x();
1761 double aMouseY = theEvent->scenePos().y();
1763 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1764 if( aRole == VMR_General )
1766 int aXDeg = 0, aYDeg = 0;
1767 int aXMin = 0, aYMin = 0;
1768 double aXSec = 0, aYSec = 0;
1769 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1770 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1772 QString aDegSymbol( QChar( 0x00B0 ) );
1773 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1774 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1776 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1778 else if( aRole == VMR_TransformImage )
1779 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1784 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1785 const bool theIsInit,
1786 const bool theIsForced,
1787 const bool theDoFitAll )
1789 QList<int> aViewManagerIdList;
1791 // currently, all views are updated
1792 ViewManagerMapIterator anIter( myViewManagerMap );
1793 while( anIter.hasNext() )
1795 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1797 if ( theDisplayer->IsApplicable( aViewManager ) )
1799 int anId = anIter.key();
1800 aViewManagerIdList.append( anId );
1804 QListIterator<int> anIdIter( aViewManagerIdList );
1805 while( anIdIter.hasNext() )
1807 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1808 myOverview->setTopView();
1812 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1814 if( !theViewManager )
1817 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1818 if( !aSelectionMgr )
1821 QString aViewType = theViewManager->getType();
1822 if( aViewType != GraphicsView_Viewer::Type() &&
1823 aViewType != OCCViewer_Viewer::Type())
1826 QList<SUIT_Selector*> aSelectorList;
1827 aSelectionMgr->selectors( aViewType, aSelectorList );
1829 // disable all alien selectors
1830 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1831 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1833 SUIT_Selector* aSelector = *anIter;
1834 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1835 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1836 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1837 aSelector->setEnabled( false );
1840 if ( aViewType == GraphicsView_Viewer::Type() )
1842 GraphicsView_ViewManager* aViewManager =
1843 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1845 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1847 else if ( aViewType == OCCViewer_Viewer::Type() )
1849 OCCViewer_ViewManager* aViewManager =
1850 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1852 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1856 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1858 bool aPrevState = myIsUpdateEnabled;
1859 myIsUpdateEnabled = theState;
1863 bool HYDROGUI_Module::isUpdateEnabled() const
1865 return myIsUpdateEnabled;
1868 QStringList HYDROGUI_Module::storeSelection() const
1870 QStringList anEntryList;
1871 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1873 SUIT_DataOwnerPtrList aList( true );
1874 aSelectionMgr->selected( aList );
1876 SUIT_DataOwnerPtrList::iterator anIter;
1877 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1879 const LightApp_DataOwner* anOwner =
1880 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1882 anEntryList.append( anOwner->entry() );
1888 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1890 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1892 SUIT_DataOwnerPtrList aList( true );
1893 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1894 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1895 aSelectionMgr->setSelected( aList );
1899 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1902 bool doShow = false;
1903 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1905 aDisplayer->SaveCursorViewPosition( theViewWindow );
1906 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1910 // Show the coordinates in the status bar
1911 SUIT_Desktop* aDesktop = getApp()->desktop();
1912 if ( aDesktop && aDesktop->statusBar() )
1914 gp_Pnt aWPnt( X, Y, Z );
1915 int aStudyId = application()->activeStudy()->id();
1916 HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
1917 double WX = aWPnt.X(), WY = aWPnt.Y();
1919 QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1920 QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1921 QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1922 QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1923 QString aMsg = tr( "COORDINATES_INFO" );
1924 aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1925 aDesktop->statusBar()->showMessage( aMsg );
1931 * Returns stack of active operations;
1933 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
1935 return myActiveOperationMap;
1939 * Returns the module active operation. If the active operation is show/hide,
1940 * the method returns the previous operation if it is.
1942 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
1944 HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
1946 if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
1948 QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
1950 aVIt.previous(); // skip the top show/hide operation
1951 anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
1958 * \brief Virtual public slot
1960 * This method is called after the object inserted into data view to update their visibility state
1961 * This is default implementation
1963 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
1965 if ( !isActiveModule() )
1968 HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
1970 // change visibility of object
1971 if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
1974 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1976 QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
1977 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1978 if ( visState == Qtx::UnpresentableState )
1981 visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
1982 treeModel->setVisibilityState( id, visState );
1984 bool vis = visState == Qtx::ShownState;
1985 if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
1988 setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
1990 update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
1993 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
1995 Handle(HYDROData_StricklerTable) aTable;
1997 if ( myLandCoverColoringMap.contains( theViewId ) ) {
1998 aTable = myLandCoverColoringMap.value( theViewId );
2004 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
2005 const Handle(HYDROData_StricklerTable)& theTable )
2007 if ( !theTable.IsNull() ) {
2008 myLandCoverColoringMap.insert( theViewId, theTable );
2012 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
2014 myLandCoverColoringMap.remove( theViewId );
2017 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
2019 return myLandCoverColoringMap.contains( theViewId );
2022 void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
2024 if ( theObject.IsNull() || !theObject->IsRemoved() ) {
2028 if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
2029 Handle(HYDROData_StricklerTable) aTable =
2030 Handle(HYDROData_StricklerTable)::DownCast( theObject );
2031 QList<int> aViewIds;
2032 QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
2033 while ( anIter.hasNext() ) {
2034 if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
2035 HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
2042 void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
2047 SUIT_ViewWindow* wnd = theMgr->getActiveView();
2048 OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
2052 myOverview->setMainView( occwnd );
2055 void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
2057 ViewManagerList aViewManagers = getApp()->viewManagers();
2058 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
2059 setAutoZoom(aVMgr, bAutoZoom);
2062 void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
2066 QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
2067 foreach (SUIT_ViewWindow* aView, aViews)
2071 OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
2074 anOCCViewFrame->setAutomaticZoom(bAutoZoom);
2075 for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
2077 OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
2079 aV->setAutomaticZoom(bAutoZoom);
2082 OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
2083 if (anOCCViewWindow)
2084 anOCCViewWindow->setAutomaticZoom(bAutoZoom);