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();
665 theMenu->addAction( action( ShowAttrPolylinesId ) );
666 theMenu->addSeparator();
668 else if( anIsPolyline3D )
670 theMenu->addAction( action( EditPolyline3DId ) );
671 theMenu->addSeparator();
673 else if( anIsProfile )
675 theMenu->addAction( action( EditProfileId ) );
676 theMenu->addAction( action( SelectedGeoreferencementId ) );
677 theMenu->addSeparator();
679 else if( anIsCalculation )
681 theMenu->addAction( action( EditCalculationId ) );
682 theMenu->addAction( action( ExportCalculationId ) );
683 theMenu->addSeparator();
685 else if( anIsImmersibleZone )
687 theMenu->addAction( action( EditImmersibleZoneId ) );
688 theMenu->addSeparator();
690 else if( anIsStream )
692 theMenu->addAction( action( EditStreamId ) );
693 if ( action( RiverBottomContextId ) )
695 theMenu->addAction( action( RiverBottomContextId ) );
696 action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
698 theMenu->addAction( action( ProfileInterpolateId ) );
699 theMenu->addSeparator();
701 else if( anIsChannel )
703 theMenu->addAction( action( EditChannelId ) );
704 theMenu->addSeparator();
708 theMenu->addAction( action( EditDigueId ) );
709 theMenu->addSeparator();
711 else if( anIsObstacle )
713 theMenu->addAction( action( TranslateObstacleId ) );
714 theMenu->addSeparator();
716 else if( anIsStricklerTable )
718 theMenu->addAction( action( EditStricklerTableId ) );
719 theMenu->addAction( action( ExportStricklerTableFromFileId ) );
720 theMenu->addAction( action( DuplicateStricklerTableId ) );
721 theMenu->addSeparator();
723 Handle(HYDROData_StricklerTable) aTable =
724 Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
725 QString aCurrentTable =
726 HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
727 bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
729 if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER_MAP ).isEmpty() ) {
730 theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
731 theMenu->addSeparator();
734 else if( anIsLandCoverMap )
736 theMenu->addAction( action( AddLandCoverId ) );
737 theMenu->addAction( action( RemoveLandCoverId ) );
738 theMenu->addSeparator();
739 theMenu->addAction( action( SplitLandCoverId ) );
740 theMenu->addAction( action( MergeLandCoverId ) );
741 theMenu->addAction( action( ChangeLandCoverTypeId ) );
742 theMenu->addSeparator();
744 theMenu->addAction( action( ExportToShapeFileID ) );
745 theMenu->addSeparator();
747 else if( anIsVisualState && anIsObjectBrowser )
749 theMenu->addAction( action( SaveVisualStateId ) );
750 theMenu->addAction( action( LoadVisualStateId ) );
751 theMenu->addSeparator();
754 theMenu->addAction( action( ZoneSetColorId ) );
756 if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
758 theMenu->addAction( action( PolylineExtractionId ) );
759 theMenu->addSeparator();
762 // Add set color action for geometrical objects
763 if ( anIsObjectCanBeColored )
765 theMenu->addAction( action( SetColorId ) );
766 theMenu->addSeparator();
769 // Add transparency action for land cover map objects
770 if ( anIsLandCoverMap )
772 theMenu->addAction( action( SetTransparencyId ) );
773 theMenu->addSeparator();
776 else if ( anAllAreProfiles )
778 theMenu->addAction( action( EditProfileId ) );
779 theMenu->addAction( action( SelectedGeoreferencementId ) );
780 theMenu->addSeparator();
783 bool isPoly = anIsPolyline || anIsPolyline3D;
784 if (isPoly && !anIsLandCoverMap)
785 theMenu->addAction( action( ExportToShapeFileID ) );
788 QAction* aCopyAction = action( CopyId );
789 if( aCopyAction && aCopyAction->isEnabled() ) {
790 theMenu->addAction( action( CopyId ) );
791 theMenu->addSeparator();
795 if( !anIsDummyObject3D )
796 theMenu->addAction( action( DeleteId ) );
798 theMenu->addSeparator();
800 if( anIsImage || anIsPolyline || anIsPolyline3D ||
801 anIsImmersibleZone || anIsZone || anIsRegion ||
802 anIsBathymetry || anIsObstacle || anIsStream ||
803 anIsChannel || anIsDigue || anIsDummyObject3D ||
804 anIsValidProfile || anIsGroup || anIsLandCoverMap )
806 if( anIsHiddenInSelection )
807 theMenu->addAction( action( ShowId ) );
808 theMenu->addAction( action( ShowOnlyId ) );
809 if( anIsVisibleInSelection )
810 theMenu->addAction( action( HideId ) );
811 theMenu->addSeparator();
817 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
818 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
819 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
820 theMenu->addAction( action( DeleteId ) );
822 theMenu->addSeparator();
823 theMenu->addAction( action( SetZLevelId ) );
824 theMenu->addSeparator();
826 if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
827 theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
828 theMenu->addSeparator();
832 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
834 theMenu->addAction( action( ShowAllId ) );
835 theMenu->addAction( action( HideAllId ) );
836 theMenu->addSeparator();
839 if ( anIsOCCView || anIsVTKView )
841 theMenu->addSeparator();
842 theMenu->addAction( action( CopyViewerPositionId ) );
846 theMenu->addAction( action( EditLocalCSId ) );
848 if( anIsObjectBrowser && anOwners.size()==1 )
850 if( aSeq.Size() > 0 )
852 Handle( HYDROData_Entity ) aFirstEnt = aSeq.First();
853 Handle(HYDROData_Object) anObject;
854 Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt);
855 Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt);
857 if (!anAObject.IsNull())
858 anObject = anAObject;
859 if (!aNObject.IsNull())
862 if( !anObject.IsNull() )
864 theMenu->addSeparator();
865 bool IsSubmersible = anObject->IsSubmersible();
868 theMenu->addAction( action( SubmersibleId ) );
869 action( SubmersibleId )->setCheckable(true);
870 action( SubmersibleId )->setChecked(true);
874 theMenu->addAction( action( UnSubmersibleId ) );
875 action( UnSubmersibleId )->setCheckable(true);
876 action( UnSubmersibleId )->setChecked(true);
882 theMenu->addSeparator();
883 QAction* a = action( ShowHideArrows );
884 a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
885 theMenu->addAction( a );
888 void HYDROGUI_Module::createPreferences()
890 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
891 int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
893 int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
894 LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
896 // Set property cursor type
897 QList<QVariant> aCursorTypeIndicesList;
898 QList<QVariant> aCursorTypeIconsList;
900 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
901 for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
902 QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
903 QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
904 aCursorTypeIndicesList << i;
905 aCursorTypeIconsList << pixmap;
908 setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
909 setPreferenceProperty( typeOfCursor, "icons", aCursorTypeIconsList );
911 int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
912 addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
913 LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
915 addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
917 addPreference( tr( "PREF_VIEWER_CHAINED_PANNING" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "chained_panning" );
919 int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
920 int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
921 LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
922 setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
923 setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
924 setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
925 setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
927 int polylinesGroup = addPreference( tr( "PREF_GROUP_POLYLINES" ), genTab );
928 int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
929 LightApp_Preferences::Selector, "polyline", "arrow_type" );
931 QList<QVariant> arrow_types;
932 arrow_types.append( tr( "No" ) );
933 arrow_types.append( tr( "Triangle" ) );
934 arrow_types.append( tr( "Cone" ) );
935 setPreferenceProperty( polylineArrow, "strings", arrow_types );
937 QList<QVariant> indices;
941 setPreferenceProperty( polylineArrow, "indexes", indices );
942 setPreferenceProperty( polylineArrow, "ids", indices );
944 int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup,
945 LightApp_Preferences::IntSpin, "polyline", "arrow_size" );
948 void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
950 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
951 if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
954 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
955 if ( resMgr && !aDoc.IsNull() )
956 aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
958 else if( theSection == "polyline" )
964 resMgr->value( "polyline", "arrow_type", aType );
965 resMgr->value( "polyline", "arrow_size", aSize );
968 ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end();
969 for( ; it!=last; it++ )
971 int aViewerId = it.key();
972 OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( it.value().first );
974 getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
977 else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
979 bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
980 setAutoZoomToAllViewManagers(!aZoomShutoff);
982 else if (theSection == "HYDRO" && thePref == "chained_panning")
984 bool aChainedPan = resMgr->booleanValue( "HYDRO", "chained_panning" );
987 ViewManagerList aViewManagers = getApp()->viewManagers();
988 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
990 OCCViewer_ViewManager* anOCCViewMgr = dynamic_cast<OCCViewer_ViewManager*>( aVMgr );
992 anOCCViewMgr->setChainedOperations( aChainedPan );
995 QList<QDockWidget*> docW = getApp()->desktop()->findChildren<QDockWidget*>();
996 foreach (QDockWidget* qw, docW)
998 HYDROGUI_ProfileDlg* pdlg = dynamic_cast<HYDROGUI_ProfileDlg*>(qw);
1000 pdlg->viewManager()->setChainedOperations(aChainedPan);
1004 LightApp_Module::preferencesChanged( theSection, thePref );
1007 QCursor HYDROGUI_Module::getPrefEditCursor() const
1009 int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
1010 if ( aCursorType >= Qt::BlankCursor)
1012 QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
1016 void HYDROGUI_Module::update( const int flags )
1018 if ( !isUpdateEnabled() )
1021 QApplication::setOverrideCursor( Qt::WaitCursor );
1023 // To prevent calling this method recursively
1024 // from one of the methods called below
1025 setUpdateEnabled( false );
1027 // store selected objects
1028 QStringList aSelectedEntries = storeSelection();
1030 bool aDoFitAll = flags & UF_FitAll;
1033 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1034 aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
1037 if( ( flags & UF_Viewer ) )
1038 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
1040 if( ( flags & UF_OCCViewer ) )
1041 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
1043 if( ( flags & UF_VTKViewer ) )
1044 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
1046 if( ( flags & UF_Model ) && getDataModel() && getApp() )
1048 getDataModel()->update( getStudyId() );
1050 // Temporary workaround to prevent breaking
1051 // the selection in the object browser.
1052 // Note: processEvents() should be called after updateGV(),
1053 // otherwise the application crashes from time to time.
1054 //RKV: qApp->processEvents();
1055 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1056 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
1057 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
1058 if ( isResizeOnExpandItem && anObjectBrowser ) {
1059 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
1061 getApp()->updateObjectBrowser( true );
1062 if ( isResizeOnExpandItem && anObjectBrowser ) {
1063 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
1067 // Object browser is currently updated by using UF_Model flag
1068 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
1069 getApp()->updateObjectBrowser( true );
1071 if( ( flags & UF_Controls ) && getApp() )
1072 getApp()->updateActions();
1074 // restore selected objects
1075 restoreSelection( aSelectedEntries );
1077 setUpdateEnabled( true );
1079 preferencesChanged( "HYDRO", "zoom_shutoff" );
1081 preferencesChanged( "HYDRO", "chained_panning" );
1083 QApplication::restoreOverrideCursor();
1086 void HYDROGUI_Module::updateCommandsStatus()
1088 LightApp_Module::updateCommandsStatus();
1090 updateUndoRedoControls();
1092 action( CopyId )->setEnabled( getDataModel()->canCopy() );
1093 action( PasteId )->setEnabled( getDataModel()->canPaste() );
1096 void HYDROGUI_Module::selectionChanged()
1098 LightApp_Module::selectionChanged();
1099 updateCommandsStatus();
1102 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
1104 return (HYDROGUI_DataModel*)dataModel();
1107 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
1112 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
1114 return myOCCDisplayer;
1117 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
1119 return myVTKDisplayer;
1122 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
1124 if( myViewManagerMap.contains( theId ) )
1126 return myViewManagerMap[ theId ].first;
1131 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
1133 if( myViewManagerMap.contains( theId ) )
1135 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1136 GraphicsView_ViewManager* aViewManager =
1137 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
1139 return aViewManager->getViewer();
1144 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
1146 if( myViewManagerMap.contains( theId ) )
1148 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1149 OCCViewer_ViewManager* aViewManager =
1150 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
1152 return aViewManager->getOCCViewer();
1157 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
1159 if( myViewManagerMap.contains( theId ) )
1161 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1162 SVTK_ViewManager* aViewManager =
1163 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
1165 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
1170 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
1172 ViewManagerMapIterator anIter( myViewManagerMap );
1173 while( anIter.hasNext() )
1175 int anId = anIter.next().key();
1176 const ViewManagerInfo& anInfo = anIter.value();
1177 if( anInfo.first == theViewManager )
1183 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
1185 int anId = getViewManagerId( theViewManager );
1188 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1189 return anInfo.second;
1194 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
1195 const ViewManagerRole theRole )
1197 int anId = getViewManagerId( theViewManager );
1200 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1201 anInfo.second = theRole;
1205 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
1206 const Handle(HYDROData_Entity)& theObject ) const
1208 if( theObject.IsNull() )
1214 foreach( int aViewId, myObjectStateMap.keys() )
1216 if( isObjectVisible( aViewId, theObject ) )
1222 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1223 if( anIter1 != myObjectStateMap.end() )
1225 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1226 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1228 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1229 if( anIter2 != aEntry2ObjectStateMap.end() )
1231 const ObjectState& anObjectState = anIter2.value();
1232 return anObjectState.Visibility;
1238 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1239 const Handle(HYDROData_Entity)& theObject,
1240 const bool theState )
1242 if( !theObject.IsNull() )
1244 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1245 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1247 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1248 anObjectState.Visibility = theState;
1250 HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1253 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1256 QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1257 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1258 if ( visState != Qtx::UnpresentableState )
1259 treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1263 if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1264 setLandCoversScalarMapModeOff( theViewId );
1265 } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) {
1266 getOCCDisplayer()->SetToUpdateColorScale();
1271 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1272 const bool theState )
1274 if( !theObject.IsNull() )
1276 // Process OCC shapes
1277 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1278 while( aShapesMapIter != myShapesMap.end() )
1280 const ListOfShapes& aShapesList = aShapesMapIter.value();
1281 foreach ( HYDROGUI_Shape* aShape, aShapesList )
1283 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1285 aShape->setIsToUpdate( theState );
1290 // Process VTK shapes
1291 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1292 while( aVTKPrsMapIter != myVTKPrsMap.end() )
1294 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1295 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1297 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1299 aShape->setIsToUpdate( theState );
1307 /////////////////// OCC SHAPES PROCESSING
1308 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
1309 ObjectKind theKind ) const
1311 QList<HYDROGUI_Shape*> aResult;
1313 if ( myShapesMap.contains( theViewId ) )
1315 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1316 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1318 if( aShape && aShape->getObject()->GetKind()==theKind )
1319 aResult.append( aShape );
1325 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
1326 const Handle(HYDROData_Entity)& theObject ) const
1328 HYDROGUI_Shape* aResShape = NULL;
1329 if( theObject.IsNull() )
1332 if ( myShapesMap.contains( theViewId ) )
1334 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1335 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1337 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1348 void HYDROGUI_Module::setObjectShape( const int theViewId,
1349 const Handle(HYDROData_Entity)& theObject,
1350 HYDROGUI_Shape* theShape )
1352 if( theObject.IsNull() )
1355 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1356 aViewShapes.append( theShape );
1359 void HYDROGUI_Module::removeObjectShape( const int theViewId,
1360 const Handle(HYDROData_Entity)& theObject )
1362 if ( !myShapesMap.contains( theViewId ) )
1365 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1366 Handle(HYDROData_Entity) anObject;
1367 for ( int i = 0; i < aViewShapes.length(); )
1369 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1370 anObject = aShape->getObject();
1371 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1374 aViewShapes.removeAt( i );
1382 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1384 if ( !myShapesMap.contains( theViewId ) )
1387 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1388 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1390 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1395 myShapesMap.remove( theViewId );
1397 /////////////////// END OF OCC SHAPES PROCESSING
1399 /////////////////// VTKPrs PROCESSING
1400 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
1401 const Handle(HYDROData_Entity)& theObject ) const
1403 HYDROGUI_VTKPrs* aResShape = NULL;
1404 if( theObject.IsNull() )
1407 if ( myVTKPrsMap.contains( theViewId ) )
1409 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1410 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1412 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1423 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1424 const Handle(HYDROData_Entity)& theObject,
1425 HYDROGUI_VTKPrs* theShape )
1427 if( theObject.IsNull() )
1430 if( theShape && theShape->needScalarBar() )
1432 // Compute the new global Z range from the added presentation and the old global Z range.
1433 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1434 double* aRange = theShape->getInternalZRange();
1435 bool anIsUpdate = false;
1436 if ( aRange[0] < aGlobalRange[0] )
1438 aGlobalRange[0] = aRange[0];
1441 if ( aRange[1] > aGlobalRange[1] )
1443 aGlobalRange[1] = aRange[1];
1449 updateVTKZRange( theViewId, aGlobalRange );
1453 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1454 aViewShapes.append( theShape );
1457 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1458 const QString& theEntry )
1460 if ( !myVTKPrsMap.contains( theViewId ) )
1463 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1464 Handle(HYDROData_Entity) anObject;
1466 for ( int i = 0; i < aViewShapes.length(); )
1468 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1469 anObject = aShape->getObject();
1470 anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1471 if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1474 aViewShapes.removeAt( i );
1481 // Invalidate global Z range
1482 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1483 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1486 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1487 const Handle(HYDROData_Entity)& theObject )
1489 if ( !myVTKPrsMap.contains( theViewId ) )
1492 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1493 Handle(HYDROData_Entity) anObject;
1494 for ( int i = 0; i < aViewShapes.length(); )
1496 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1497 anObject = aShape->getObject();
1498 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1501 aViewShapes.removeAt( i );
1508 // Invalidate global Z range
1509 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1510 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1513 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1515 if ( !myVTKPrsMap.contains( theViewId ) )
1518 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1519 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1521 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1526 myVTKPrsMap.remove( theViewId );
1529 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1531 if ( myVTKPrsMap.contains( theViewId ) )
1533 // For the given viewer id update all VTK presentations ...
1534 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1535 HYDROGUI_VTKPrs* aShape;
1536 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1538 aShape = aViewShapes.at( i );
1539 if ( aShape && aShape->needScalarBar() )
1541 aShape->setZRange( theRange );
1545 // ... and update the global color legend scalar bar.
1546 getVTKDisplayer()->SetZRange( theViewId, theRange );
1548 /////////////////// END OF VTKPrs PROCESSING
1550 void HYDROGUI_Module::clearCache()
1552 myObjectStateMap.clear();
1555 CAM_DataModel* HYDROGUI_Module::createDataModel()
1557 return new HYDROGUI_DataModel( this );
1560 void HYDROGUI_Module::customEvent( QEvent* e )
1562 int aType = e->type();
1563 if ( aType == NewViewEvent )
1565 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1566 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1568 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1570 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1571 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1573 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1575 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1576 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1578 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1579 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1580 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1582 //ouv: temporarily commented
1583 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1586 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1587 update( UF_Viewer );
1589 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1595 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1597 QEvent::Type aType = theEvent->type();
1598 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1600 if( aType == QEvent::Show )
1602 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1603 e->setData( theObj );
1604 QApplication::postEvent( this, e );
1605 theObj->removeEventFilter( this );
1608 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1610 if( aType == QEvent::Leave )
1612 SUIT_Desktop* aDesktop = getApp()->desktop();
1613 if ( aDesktop && aDesktop->statusBar() ) {
1614 aDesktop->statusBar()->clearMessage();
1618 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1620 if( aType == QEvent::Leave )
1622 SUIT_Desktop* aDesktop = getApp()->desktop();
1623 if ( aDesktop && aDesktop->statusBar() ) {
1624 aDesktop->statusBar()->clearMessage();
1629 return LightApp_Module::eventFilter( theObj, theEvent );
1632 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1634 LightApp_Module::onViewManagerAdded( theViewManager );
1636 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1638 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1639 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1641 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1643 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
1644 //mgr->setChainedOperations( true );
1646 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1647 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1648 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1649 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1650 connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
1651 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
1653 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1655 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1656 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1657 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1658 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1661 createSelector( theViewManager ); // replace the default selector
1663 ViewManagerInfo anInfo( theViewManager, VMR_General );
1664 myViewManagerMap.insert( ViewManagerId++, anInfo );
1667 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1669 LightApp_Module::onViewManagerRemoved( theViewManager );
1671 createSelector( theViewManager ); // replace the default selector
1673 int anId = getViewManagerId( theViewManager );
1676 OCCViewer_ViewManager* anOCCViewManager =
1677 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1678 if ( anOCCViewManager )
1680 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1681 if ( anOCCViewer ) {
1682 int aViewerId = (size_t)anOCCViewer;
1683 removeViewShapes( aViewerId );
1684 setLandCoversScalarMapModeOff( aViewerId );
1688 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1690 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1693 getVTKDisplayer()->EraseScalarBar( anId, true );
1694 removeViewShapes( (size_t)aVTKViewer );
1698 myViewManagerMap.remove( anId );
1702 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1704 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1706 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1708 aViewFrame->installEventFilter( this );
1710 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1711 aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
1713 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1714 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1717 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1719 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1721 aViewFrame->onTopView();
1723 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1724 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1726 aViewPort->installEventFilter( this );
1730 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1732 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1734 aViewFrame->installEventFilter( this );
1739 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1741 /* ouv: currently unused
1742 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1744 SUIT_ViewManager* aViewManager = 0;
1746 QObject* aParent = aViewPort;
1747 while( aParent = aParent->parent() )
1749 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1751 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1753 aViewManager = aViewer->getViewManager();
1762 double aMouseX = theEvent->scenePos().x();
1763 double aMouseY = theEvent->scenePos().y();
1765 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1766 if( aRole == VMR_General )
1768 int aXDeg = 0, aYDeg = 0;
1769 int aXMin = 0, aYMin = 0;
1770 double aXSec = 0, aYSec = 0;
1771 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1772 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1774 QString aDegSymbol( QChar( 0x00B0 ) );
1775 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1776 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1778 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1780 else if( aRole == VMR_TransformImage )
1781 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1786 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1787 const bool theIsInit,
1788 const bool theIsForced,
1789 const bool theDoFitAll )
1791 QList<int> aViewManagerIdList;
1793 // currently, all views are updated
1794 ViewManagerMapIterator anIter( myViewManagerMap );
1795 while( anIter.hasNext() )
1797 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1799 if ( theDisplayer->IsApplicable( aViewManager ) )
1801 int anId = anIter.key();
1802 aViewManagerIdList.append( anId );
1806 QListIterator<int> anIdIter( aViewManagerIdList );
1807 while( anIdIter.hasNext() )
1809 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1810 myOverview->setTopView();
1814 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1816 if( !theViewManager )
1819 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1820 if( !aSelectionMgr )
1823 QString aViewType = theViewManager->getType();
1824 if( aViewType != GraphicsView_Viewer::Type() &&
1825 aViewType != OCCViewer_Viewer::Type())
1828 QList<SUIT_Selector*> aSelectorList;
1829 aSelectionMgr->selectors( aViewType, aSelectorList );
1831 // disable all alien selectors
1832 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1833 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1835 SUIT_Selector* aSelector = *anIter;
1836 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1837 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1838 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1839 aSelector->setEnabled( false );
1842 if ( aViewType == GraphicsView_Viewer::Type() )
1844 GraphicsView_ViewManager* aViewManager =
1845 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1847 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1849 else if ( aViewType == OCCViewer_Viewer::Type() )
1851 OCCViewer_ViewManager* aViewManager =
1852 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1854 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1858 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1860 bool aPrevState = myIsUpdateEnabled;
1861 myIsUpdateEnabled = theState;
1865 bool HYDROGUI_Module::isUpdateEnabled() const
1867 return myIsUpdateEnabled;
1870 QStringList HYDROGUI_Module::storeSelection() const
1872 QStringList anEntryList;
1873 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1875 SUIT_DataOwnerPtrList aList( true );
1876 aSelectionMgr->selected( aList );
1878 SUIT_DataOwnerPtrList::iterator anIter;
1879 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1881 const LightApp_DataOwner* anOwner =
1882 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1884 anEntryList.append( anOwner->entry() );
1890 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1892 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1894 SUIT_DataOwnerPtrList aList( true );
1895 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1896 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1897 aSelectionMgr->setSelected( aList );
1901 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1904 bool doShow = false;
1905 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1907 aDisplayer->SaveCursorViewPosition( theViewWindow );
1908 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1912 // Show the coordinates in the status bar
1913 SUIT_Desktop* aDesktop = getApp()->desktop();
1914 if ( aDesktop && aDesktop->statusBar() )
1916 gp_Pnt aWPnt( X, Y, Z );
1917 int aStudyId = application()->activeStudy()->id();
1918 HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
1919 double WX = aWPnt.X(), WY = aWPnt.Y();
1921 QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1922 QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1923 QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1924 QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1925 QString aMsg = tr( "COORDINATES_INFO" );
1926 aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1927 aDesktop->statusBar()->showMessage( aMsg );
1933 * Returns stack of active operations;
1935 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
1937 return myActiveOperationMap;
1941 * Returns the module active operation. If the active operation is show/hide,
1942 * the method returns the previous operation if it is.
1944 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
1946 HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
1948 if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
1950 QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
1952 aVIt.previous(); // skip the top show/hide operation
1953 anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
1960 * \brief Virtual public slot
1962 * This method is called after the object inserted into data view to update their visibility state
1963 * This is default implementation
1965 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
1967 if ( !isActiveModule() )
1970 HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
1972 // change visibility of object
1973 if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
1976 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1978 QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
1979 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1980 if ( visState == Qtx::UnpresentableState )
1983 visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
1984 treeModel->setVisibilityState( id, visState );
1986 bool vis = visState == Qtx::ShownState;
1987 if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
1990 setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
1992 update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
1995 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
1997 Handle(HYDROData_StricklerTable) aTable;
1999 if ( myLandCoverColoringMap.contains( theViewId ) ) {
2000 aTable = myLandCoverColoringMap.value( theViewId );
2006 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
2007 const Handle(HYDROData_StricklerTable)& theTable )
2009 if ( !theTable.IsNull() ) {
2010 myLandCoverColoringMap.insert( theViewId, theTable );
2014 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
2016 myLandCoverColoringMap.remove( theViewId );
2019 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
2021 return myLandCoverColoringMap.contains( theViewId );
2024 void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
2026 if ( theObject.IsNull() || !theObject->IsRemoved() ) {
2030 if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
2031 Handle(HYDROData_StricklerTable) aTable =
2032 Handle(HYDROData_StricklerTable)::DownCast( theObject );
2033 QList<int> aViewIds;
2034 QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
2035 while ( anIter.hasNext() ) {
2036 if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
2037 HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
2044 void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
2049 SUIT_ViewWindow* wnd = theMgr->getActiveView();
2050 OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
2054 myOverview->setMainView( occwnd );
2057 void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
2059 ViewManagerList aViewManagers = getApp()->viewManagers();
2060 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
2061 setAutoZoom(aVMgr, bAutoZoom);
2064 void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
2068 QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
2069 foreach (SUIT_ViewWindow* aView, aViews)
2073 OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
2076 anOCCViewFrame->setAutomaticZoom(bAutoZoom);
2077 for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
2079 OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
2081 aV->setAutomaticZoom(bAutoZoom);
2084 OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
2085 if (anOCCViewWindow)
2086 anOCCViewWindow->setAutomaticZoom(bAutoZoom);