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 <HYDROGUI_SIProgressIndicator.h>
46 #include <HYDROGUI_ZIProgressIndicator.h>
47 #include <HYDROData_Tool.h>
48 #include <HYDROData_Image.h>
49 #include <HYDROData_Stream.h>
50 #include <HYDROData_Profile.h>
51 #include <HYDROData_Lambert93.h>
52 #include <HYDROData_Polyline3D.h>
53 #include <HYDROData_StricklerTable.h>
54 #include <HYDROData_ArtificialObject.h>
55 #include <HYDROData_NaturalObject.h>
57 #include <HYDROData_OperationsFactory.h>
59 #include <CurveCreator_Utils.hxx>
61 #include <GraphicsView_ViewFrame.h>
62 #include <GraphicsView_ViewManager.h>
63 #include <GraphicsView_ViewPort.h>
64 #include <GraphicsView_Viewer.h>
66 #include <ImageComposer_CutOperator.h>
67 #include <ImageComposer_CropOperator.h>
68 #include <ImageComposer_FuseOperator.h>
70 #include <LightApp_Application.h>
71 #include <LightApp_DataOwner.h>
72 #include <LightApp_GVSelector.h>
73 #include <LightApp_SelectionMgr.h>
74 #include <LightApp_UpdateFlags.h>
76 #include <SalomeApp_Study.h>
78 #include <OCCViewer_ViewFrame.h>
79 #include <OCCViewer_ViewManager.h>
80 #include <OCCViewer_ViewModel.h>
82 #include <SALOME_Event.h>
84 #include <SUIT_DataBrowser.h>
85 #include <SUIT_DataObject.h>
86 #include <SUIT_ViewManager.h>
87 #include <SUIT_ResourceMgr.h>
88 #include <SUIT_Desktop.h>
89 #include <SUIT_Study.h>
90 #include <SUIT_Session.h>
92 #include <SVTK_ViewManager.h>
93 #include <SVTK_ViewModel.h>
94 #include <SVTK_ViewWindow.h>
95 #include <SVTK_Selector.h>
97 #include <OCCViewer_ViewPort3d.h>
99 #include <GEOMUtils.hxx>
100 #include <GeometryGUI.h>
102 #include <SALOMEDS_wrap.hxx>
105 #include <QApplication>
106 #include <QGraphicsSceneMouseEvent>
108 #include <QMouseEvent>
109 #include <QStatusBar>
112 static int ViewManagerId = 0;
114 extern "C" HYDRO_EXPORT CAM_Module* createModule()
116 return new HYDROGUI_Module();
119 extern "C" HYDRO_EXPORT char* getModuleVersion()
121 return (char*)HYDRO_VERSION;
124 HYDROGUI_Module::HYDROGUI_Module()
125 : LightApp_Module( "HYDRO" ),
128 myIsUpdateEnabled( true ),
133 HYDROGUI_Module::~HYDROGUI_Module()
137 int HYDROGUI_Module::getStudyId() const
139 LightApp_Application* anApp = getApp();
140 return anApp ? anApp->activeStudy()->id() : 0;
143 void HYDROGUI_Module::initialize( CAM_Application* theApp )
145 LightApp_Module::initialize( theApp );
148 createUndoRedoActions();
153 setMenuShown( false );
154 setToolShown( false );
156 myDisplayer = new HYDROGUI_Displayer( this );
157 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
158 myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
160 HYDROData_Tool::SetSIProgress( new HYDROGUI_SIProgressIndicator( theApp->desktop() ) );
161 HYDROData_Tool::SetZIProgress( new HYDROGUI_ZIProgressIndicator( theApp->desktop() ) );
164 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
166 bool aRes = LightApp_Module::activateModule( theStudy );
168 LightApp_Application* anApp = getApp();
169 SUIT_Desktop* aDesktop = anApp->desktop();
171 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
173 setMenuShown( true );
174 setToolShown( true );
176 #ifndef DISABLE_PYCONSOLE
177 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
178 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
181 // Remove defunct view managers from the map.
182 // It's essential to do this before "update( UF_All )" call!
183 QList<int> anObsoleteIds;
184 ViewManagerList anAllViewManagers = anApp->viewManagers();
185 ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
186 ViewManagerMapIterator anIter( myViewManagerMap );
187 while( anIter.hasNext() ) {
188 int anId = anIter.next().key();
189 const ViewManagerInfo& anInfo = anIter.value();
191 aHydroViewManagers << anInfo.first;
193 if ( !anAllViewManagers.contains( anInfo.first ) ) {
194 anObsoleteIds << anId;
197 foreach ( const int anId, anObsoleteIds ) {
198 myViewManagerMap.remove( anId );
199 myObjectStateMap.remove( anId );
200 myShapesMap.remove( anId );
201 myVTKPrsMap.remove( anId );
203 // Replace the default selector for all view managers.
204 // Add view managers created outside of HYDRO module to the map.
205 foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
206 createSelector( aViewManager ); // replace the default selector
207 if ( !aHydroViewManagers.contains( aViewManager ) ) {
208 ViewManagerInfo anInfo( aViewManager, VMR_General );
209 myViewManagerMap.insert( ViewManagerId++, anInfo );
215 updateCommandsStatus();
217 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
219 ViewManagerList anOCCViewManagers;
220 anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
222 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
224 connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
225 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
226 connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
227 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
229 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
232 occ_mgr->setChainedOperations( true );//TODO: via preferences
235 foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() )
237 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
238 if ( aViewFrame && aViewFrame->getViewPort() )
240 aViewFrame->getViewPort()->installEventFilter( this );
245 preferencesChanged( "HYDRO", "zoom_shutoff" );
247 preferencesChanged( "HYDRO", "chained_panning" );
250 SalomeApp_Study* aStudy =
251 dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
253 SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
254 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
255 if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
256 SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
257 SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
258 if( !GEOM_var->_is_nil() ) {
259 aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
265 // SUIT_DataBrowser* ob = getApp()->objectBrowser();
266 // SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
267 // treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
272 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
275 ViewManagerMapIterator anIter( myViewManagerMap );
276 while( anIter.hasNext() )
277 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
278 getApp()->removeViewManager( aViewManager );
279 myViewManagerMap.clear();
282 ViewManagerList anOCCViewManagers;
283 getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
284 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
286 disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
287 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
289 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
292 occ_mgr->setChainedOperations( false );
293 setAutoZoom( occ_mgr, true );
298 myObjectStateMap.clear();
303 // clear the status bar
304 SUIT_Desktop* aDesktop = getApp()->desktop();
305 if ( aDesktop && aDesktop->statusBar() ) {
306 aDesktop->statusBar()->clearMessage();
309 // clear the data model's list of copying objects
310 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
312 setMenuShown( false );
313 setToolShown( false );
315 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
317 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
319 myActiveOperationMap.clear();
321 myViewManagerMap.clear();
323 return LightApp_Module::deactivateModule( theStudy );
326 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
328 static bool inWindows = false;
333 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
334 #ifndef DISABLE_PYCONSOLE
335 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
337 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
338 theMap.insert( OverviewWindow, Qt::LeftDockWidgetArea );
341 LightApp_Application* app = getApp();
342 if( app && app->getWindow( OverviewWindow )==0 )
344 const_cast<HYDROGUI_Module*>( this )->myOverview =
345 new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() );
346 app->insertDockWindow( OverviewWindow, myOverview );
347 app->placeDockWindow( OverviewWindow, Qt::LeftDockWidgetArea );
352 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
354 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
357 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
361 HYDROGUI_DataModel* aModel = getDataModel();
363 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
364 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
365 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
366 bool anIsVTKView = theClient == SVTK_Viewer::Type();
367 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
370 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
372 bool anIsSelectedDataObjects = false;
373 bool anIsVisibleInSelection = false;
374 bool anIsHiddenInSelection = false;
376 bool anIsImage = false;
377 bool anIsImportedImage = false;
378 bool anIsImageHasRefs = false;
379 bool anIsFusedImage = false;
380 bool anIsCutImage = false;
381 bool anIsSplitImage = false;
382 bool anIsMustObjectBeUpdated = false;
383 bool anIsPolyline = false;
384 bool anIsPolyline3D = false;
385 bool anIsProfile = false;
386 bool anIsValidProfile = false;
387 bool anAllAreProfiles = false;
388 bool anIsBathymetry = false;
389 bool anIsCalculation = false;
390 bool anIsImmersibleZone = false;
391 bool anIsVisualState = false;
392 bool anIsRegion = false;
393 bool anIsZone = false;
394 bool anIsObstacle = false;
395 bool anIsStricklerTable = false;
396 bool anIsLandCoverMap = false;
397 bool anIsStream = false;
398 bool anIsChannel = false;
399 bool anIsDigue = false;
400 bool anIsDummyObject3D = false;
401 bool anIsGroup = false;
402 bool anIsObjectCanBeColored = false;
404 bool isStreamHasBottom = false;
405 bool anIsBCPolygon = false;
407 SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
408 SUIT_DataOwnerPtrList anOwners;
409 aSelectionMgr->selected( anOwners );
410 if( anIsObjectBrowser && anOwners.size()==1 )
412 QString anEntry = anOwners[0]->keyString();
413 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
415 isRoot = aStudy->isComponent( anEntry );
418 // Check the selected GEOM objects (take into account the Object Browser only)
419 if ( anIsObjectBrowser ) {
420 QList<GEOM::shape_type> anObstacleTypes =
421 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
422 QList<GEOM::shape_type> aPolylineTypes =
423 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
425 bool isCanBeImportedAsObstacle =
426 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
427 bool isCanBeImportedAsPolyline =
428 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
430 // Add import as obstacle action
431 if ( isCanBeImportedAsObstacle ) {
432 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
434 // Add import as polyline action
435 if ( isCanBeImportedAsPolyline ) {
436 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
439 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
440 theMenu->addSeparator();
444 // check the selected data model objects
445 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
446 int aNbOfSelectedProfiles = 0;
447 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
449 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
450 if( !anObject.IsNull() )
452 anIsSelectedDataObjects = true;
454 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
455 anIsVisibleInSelection |= aVisibility;
456 anIsHiddenInSelection |= !aVisibility;
458 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
460 anIsMustObjectBeUpdated = true;
463 ObjectKind anObjectKind = anObject->GetKind();
464 if( anObjectKind == KIND_IMAGE )
467 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
468 if( !anImage.IsNull() )
470 anIsImportedImage = anImage->HasLocalPoints();
471 anIsImageHasRefs = anImage->HasReferences();
472 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
474 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
476 QString anOperatorName = anOperator->name();
477 if( anOperatorName == ImageComposer_FuseOperator::Type() )
478 anIsFusedImage = true;
479 else if( anOperatorName == ImageComposer_CutOperator::Type() )
481 else if( anOperatorName == ImageComposer_CropOperator::Type() )
482 anIsSplitImage = true;
487 else if( anObjectKind == KIND_POLYLINEXY )
489 else if( anObjectKind == KIND_POLYLINE )
490 anIsPolyline3D = true;
491 else if( anObjectKind == KIND_PROFILE )
494 aNbOfSelectedProfiles++;
496 Handle(HYDROData_Profile) aProfile =
497 Handle(HYDROData_Profile)::DownCast( anObject );
498 if( !aProfile.IsNull() && aProfile->IsValid() ) {
499 anIsValidProfile = true;
502 else if( anObjectKind == KIND_CALCULATION )
503 anIsCalculation = true;
504 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
505 anIsImmersibleZone = true;
506 else if( anObjectKind == KIND_VISUAL_STATE )
507 anIsVisualState = true;
508 else if( anObjectKind == KIND_REGION )
510 else if( anObjectKind == KIND_ZONE )
512 else if( anObjectKind == KIND_BATHYMETRY )
513 anIsBathymetry = true;
514 else if( anObjectKind == KIND_OBSTACLE )
516 else if( anObjectKind == KIND_STRICKLER_TABLE )
517 anIsStricklerTable = true;
518 else if( anObjectKind == KIND_LAND_COVER_MAP )
519 anIsLandCoverMap = true;
520 else if (anObjectKind == KIND_BC_POLYGON)
521 anIsBCPolygon = true;
522 else if( anObjectKind == KIND_STREAM )
525 Handle(HYDROData_Stream) aStream =
526 Handle(HYDROData_Stream)::DownCast( anObject );
527 if ( !aStream.IsNull() )
528 isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
530 else if( anObjectKind == KIND_CHANNEL )
532 else if( anObjectKind == KIND_DIGUE )
534 else if( anObjectKind == KIND_DUMMY_3D )
535 anIsDummyObject3D = true;
536 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLIT_GROUP )
540 if ( !anIsObjectCanBeColored )
541 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject, this );
544 // Check if all selected objects are profiles
545 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
546 ( aNbOfSelectedProfiles == aSeq.Length() );
548 // check the selected partitions
549 if( !anIsSelectedDataObjects && anIsObjectBrowser )
551 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
552 if( aSelectedPartition != KIND_UNKNOWN )
554 switch( aSelectedPartition )
557 theMenu->addAction( action( ImportImageId ) );
559 case KIND_BATHYMETRY:
560 theMenu->addAction( action( ImportBathymetryId ) );
562 case KIND_ARTIFICIAL_OBJECT:
563 theMenu->addAction( action( CreateChannelId ) );
564 theMenu->addAction( action( CreateDigueId ) );
566 case KIND_NATURAL_OBJECT:
567 theMenu->addAction( action( CreateImmersibleZoneId ) );
568 theMenu->addAction( action( CreateStreamId ) );
571 theMenu->addAction( action( ImportObstacleFromFileId ) );
572 theMenu->addAction( action( CreateBoxId ) );
573 theMenu->addAction( action( CreateCylinderId ) );
575 case KIND_STRICKLER_TABLE:
576 theMenu->addAction( action( ImportStricklerTableFromFileId ) );
578 case KIND_LAND_COVER_MAP:
579 theMenu->addAction( action( CreateLandCoverMapId ) );
580 theMenu->addAction( action( ImportLandCoverMapId ) );
582 case KIND_CALCULATION:
583 theMenu->addAction( action( CreateCalculationId ) );
585 case KIND_POLYLINEXY:
586 theMenu->addAction( action( ImportPolylineId ) );
587 theMenu->addAction( action( CreatePolylineId ) );
590 theMenu->addAction( action( CreatePolyline3DId ) );
593 theMenu->addAction( action( CreateProfileId ) );
594 theMenu->addAction( action( ImportProfilesId ) );
595 theMenu->addAction( action( AllGeoreferencementId ) );
597 case KIND_VISUAL_STATE:
598 theMenu->addAction( action( SaveVisualStateId ) );
600 case KIND_BC_POLYGON:
601 theMenu->addAction( action( ImportBCPolygonId ) );
604 theMenu->addSeparator();
608 Handle(HYDROData_CalculationCase) aCalcCase;
610 HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr);
611 if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION ))
612 theMenu->addAction( action( RegenerateRegionColorsId ) );
616 if( anIsSelectedDataObjects )
618 if ( anIsMustObjectBeUpdated )
620 theMenu->addAction( action( UpdateObjectId ) );
621 theMenu->addSeparator();
625 theMenu->addAction( action( ForcedUpdateObjectId ) );
626 theMenu->addSeparator();
630 if( aSeq.Length() == 1 )
634 if( anIsImportedImage )
635 theMenu->addAction( action( EditImportedImageId ) );
636 else if( anIsImageHasRefs )
639 theMenu->addAction( action( EditFusedImageId ) );
640 else if( anIsCutImage )
641 theMenu->addAction( action( EditCutImageId ) );
642 else if( anIsSplitImage )
643 theMenu->addAction( action( EditSplitImageId ) );
646 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
647 theMenu->addAction( action( ExportImageId ) );
648 theMenu->addSeparator();
650 if( anIsImageHasRefs )
652 theMenu->addAction( action( RemoveImageRefsId ) );
653 theMenu->addSeparator();
656 theMenu->addAction( action( FuseImagesId ) );
657 theMenu->addAction( action( CutImagesId ) );
658 theMenu->addAction( action( SplitImageId ) );
659 theMenu->addSeparator();
660 theMenu->addAction( action( RecognizeContoursId ) );
661 theMenu->addSeparator();
663 else if( anIsBathymetry )
665 theMenu->addAction( action( EditImportedBathymetryId ) );
666 theMenu->addAction( action( BathymetryBoundsId ) );
667 theMenu->addSeparator();
669 else if( anIsPolyline )
671 theMenu->addAction( action( EditPolylineId ) );
672 theMenu->addSeparator();
673 theMenu->addAction( action( SplitPolylinesId ) );
674 theMenu->addAction( action( MergePolylinesId ) );
675 theMenu->addSeparator();
676 theMenu->addAction( action( ShowAttrPolylinesId ) );
677 theMenu->addSeparator();
679 else if( anIsPolyline3D )
681 theMenu->addAction( action( EditPolyline3DId ) );
682 theMenu->addSeparator();
684 else if( anIsProfile )
686 theMenu->addAction( action( EditProfileId ) );
687 theMenu->addAction( action( SelectedGeoreferencementId ) );
688 theMenu->addSeparator();
690 else if( anIsCalculation )
692 theMenu->addAction( action( EditCalculationId ) );
693 theMenu->addAction( action( ExportCalculationId ) );
694 theMenu->addSeparator();
696 else if( anIsImmersibleZone )
698 theMenu->addAction( action( EditImmersibleZoneId ) );
699 theMenu->addSeparator();
701 else if( anIsStream )
703 theMenu->addAction( action( EditStreamId ) );
704 if ( action( RiverBottomContextId ) )
706 theMenu->addAction( action( RiverBottomContextId ) );
707 action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
709 theMenu->addAction( action( ProfileInterpolateId ) );
710 theMenu->addSeparator();
712 else if( anIsChannel )
714 theMenu->addAction( action( EditChannelId ) );
715 theMenu->addSeparator();
719 theMenu->addAction( action( EditDigueId ) );
720 theMenu->addSeparator();
722 else if( anIsObstacle )
724 theMenu->addAction( action( TranslateObstacleId ) );
725 theMenu->addSeparator();
727 else if( anIsStricklerTable )
729 theMenu->addAction( action( EditStricklerTableId ) );
730 theMenu->addAction( action( ExportStricklerTableFromFileId ) );
731 theMenu->addAction( action( DuplicateStricklerTableId ) );
732 theMenu->addSeparator();
734 Handle(HYDROData_StricklerTable) aTable =
735 Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
736 QString aCurrentTable =
737 HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
738 bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
740 if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER_MAP ).isEmpty() ) {
741 theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
742 theMenu->addSeparator();
745 else if( anIsLandCoverMap )
747 theMenu->addAction( action( AddLandCoverId ) );
748 theMenu->addAction( action( RemoveLandCoverId ) );
749 theMenu->addSeparator();
750 theMenu->addAction( action( SplitLandCoverId ) );
751 theMenu->addAction( action( MergeLandCoverId ) );
752 theMenu->addAction( action( ChangeLandCoverTypeId ) );
753 theMenu->addSeparator();
755 theMenu->addAction( action( ExportToShapeFileID ) );
756 theMenu->addSeparator();
758 else if( anIsVisualState && anIsObjectBrowser )
760 theMenu->addAction( action( SaveVisualStateId ) );
761 theMenu->addAction( action( LoadVisualStateId ) );
762 theMenu->addSeparator();
765 theMenu->addAction( action( ZoneSetColorId ) );
766 else if (anIsBCPolygon)
767 theMenu->addAction( action( SetBoundaryTypePolygonId ) );
769 if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
771 theMenu->addAction( action( PolylineExtractionId ) );
772 theMenu->addSeparator();
775 // Add set color action for geometrical objects
776 if ( anIsObjectCanBeColored )
778 theMenu->addAction( action( SetColorId ) );
779 theMenu->addSeparator();
782 // Add transparency action for land cover map objects
783 if ( anIsLandCoverMap )
785 theMenu->addAction( action( SetTransparencyId ) );
786 theMenu->addSeparator();
789 else if ( anAllAreProfiles )
791 theMenu->addAction( action( EditProfileId ) );
792 theMenu->addAction( action( SelectedGeoreferencementId ) );
793 theMenu->addSeparator();
796 bool isPoly = anIsPolyline || anIsPolyline3D;
797 if (isPoly && !anIsLandCoverMap)
798 theMenu->addAction( action( ExportToShapeFileID ) );
801 QAction* aCopyAction = action( CopyId );
802 if( aCopyAction && aCopyAction->isEnabled() ) {
803 theMenu->addAction( action( CopyId ) );
804 theMenu->addSeparator();
808 if( !anIsDummyObject3D )
809 theMenu->addAction( action( DeleteId ) );
811 theMenu->addSeparator();
813 if( anIsImage || anIsPolyline || anIsPolyline3D ||
814 anIsImmersibleZone || anIsZone || anIsRegion ||
815 anIsBathymetry || anIsObstacle || anIsStream ||
816 anIsChannel || anIsDigue || anIsDummyObject3D ||
817 anIsValidProfile || anIsGroup || anIsLandCoverMap ||
820 if( anIsHiddenInSelection )
821 theMenu->addAction( action( ShowId ) );
822 theMenu->addAction( action( ShowOnlyId ) );
823 if( anIsVisibleInSelection )
824 theMenu->addAction( action( HideId ) );
825 theMenu->addSeparator();
831 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
832 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
833 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
834 theMenu->addAction( action( DeleteId ) );
836 theMenu->addSeparator();
837 theMenu->addAction( action( SetZLevelId ) );
838 theMenu->addSeparator();
840 if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
841 theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
842 theMenu->addSeparator();
846 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
848 theMenu->addAction( action( ShowAllId ) );
849 theMenu->addAction( action( HideAllId ) );
850 theMenu->addSeparator();
853 if ( anIsOCCView || anIsVTKView )
855 theMenu->addSeparator();
856 theMenu->addAction( action( CopyViewerPositionId ) );
860 theMenu->addAction( action( EditLocalCSId ) );
862 if( anIsObjectBrowser && anOwners.size()==1 )
864 if( aSeq.Size() > 0 )
866 Handle( HYDROData_Entity ) aFirstEnt = aSeq.First();
867 Handle(HYDROData_Object) anObject;
868 Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt);
869 Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt);
871 if (!anAObject.IsNull())
872 anObject = anAObject;
873 if (!aNObject.IsNull())
876 if( !anObject.IsNull() )
878 theMenu->addSeparator();
879 bool IsSubmersible = anObject->IsSubmersible();
882 theMenu->addAction( action( SubmersibleId ) );
883 action( SubmersibleId )->setCheckable(true);
884 action( SubmersibleId )->setChecked(true);
888 theMenu->addAction( action( UnSubmersibleId ) );
889 action( UnSubmersibleId )->setCheckable(true);
890 action( UnSubmersibleId )->setChecked(true);
896 theMenu->addSeparator();
897 QAction* a = action( ShowHideArrows );
898 a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
899 theMenu->addAction( a );
902 void HYDROGUI_Module::createPreferences()
904 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
905 int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
907 int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
908 LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
910 // Set property cursor type
911 QList<QVariant> aCursorTypeIndicesList;
912 QList<QVariant> aCursorTypeIconsList;
914 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
915 for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
916 QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
917 QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
918 aCursorTypeIndicesList << i;
919 aCursorTypeIconsList << pixmap;
922 setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
923 setPreferenceProperty( typeOfCursor, "icons", aCursorTypeIconsList );
925 int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
926 addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
927 LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
929 addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
931 addPreference( tr( "PREF_VIEWER_CHAINED_PANNING" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "chained_panning" );
933 int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
934 int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
935 LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
936 setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
937 setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
938 setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
939 setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
941 int polylinesGroup = addPreference( tr( "PREF_GROUP_POLYLINES" ), genTab );
942 int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
943 LightApp_Preferences::Selector, "polyline", "arrow_type" );
945 QList<QVariant> arrow_types;
946 arrow_types.append( tr( "No" ) );
947 arrow_types.append( tr( "Triangle" ) );
948 arrow_types.append( tr( "Cone" ) );
949 setPreferenceProperty( polylineArrow, "strings", arrow_types );
951 QList<QVariant> indices;
955 setPreferenceProperty( polylineArrow, "indexes", indices );
956 setPreferenceProperty( polylineArrow, "ids", indices );
958 int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup,
959 LightApp_Preferences::IntSpin, "polyline", "arrow_size" );
962 void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
964 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
965 if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
968 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
969 if ( resMgr && !aDoc.IsNull() )
970 aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
972 else if( theSection == "polyline" )
978 resMgr->value( "polyline", "arrow_type", aType );
979 resMgr->value( "polyline", "arrow_size", aSize );
982 ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end();
983 for( ; it!=last; it++ )
985 int aViewerId = it.key();
986 OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( it.value().first );
988 getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
991 else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
993 bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
994 setAutoZoomToAllViewManagers(!aZoomShutoff);
996 else if (theSection == "HYDRO" && thePref == "chained_panning")
998 bool aChainedPan = resMgr->booleanValue( "HYDRO", "chained_panning" );
1001 ViewManagerList aViewManagers = getApp()->viewManagers();
1002 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
1004 OCCViewer_ViewManager* anOCCViewMgr = dynamic_cast<OCCViewer_ViewManager*>( aVMgr );
1006 anOCCViewMgr->setChainedOperations( aChainedPan );
1009 QList<QDockWidget*> docW = getApp()->desktop()->findChildren<QDockWidget*>();
1010 foreach (QDockWidget* qw, docW)
1012 HYDROGUI_ProfileDlg* pdlg = dynamic_cast<HYDROGUI_ProfileDlg*>(qw);
1014 pdlg->viewManager()->setChainedOperations(aChainedPan);
1018 LightApp_Module::preferencesChanged( theSection, thePref );
1021 QCursor HYDROGUI_Module::getPrefEditCursor() const
1023 int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
1024 if ( aCursorType >= Qt::BlankCursor)
1026 QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
1030 void HYDROGUI_Module::update( const int flags )
1032 if ( !isUpdateEnabled() )
1035 QApplication::setOverrideCursor( Qt::WaitCursor );
1037 // To prevent calling this method recursively
1038 // from one of the methods called below
1039 setUpdateEnabled( false );
1041 // store selected objects
1042 QStringList aSelectedEntries = storeSelection();
1044 bool aDoFitAll = flags & UF_FitAll;
1047 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1048 aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
1051 if( ( flags & UF_Viewer ) )
1052 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
1054 if( ( flags & UF_OCCViewer ) )
1055 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
1057 if( ( flags & UF_VTKViewer ) )
1058 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
1060 if( ( flags & UF_Model ) && getDataModel() && getApp() )
1062 getDataModel()->update( getStudyId() );
1064 // Temporary workaround to prevent breaking
1065 // the selection in the object browser.
1066 // Note: processEvents() should be called after updateGV(),
1067 // otherwise the application crashes from time to time.
1068 //RKV: qApp->processEvents();
1069 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1070 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
1071 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
1072 if ( isResizeOnExpandItem && anObjectBrowser ) {
1073 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
1075 getApp()->updateObjectBrowser( true );
1076 if ( isResizeOnExpandItem && anObjectBrowser ) {
1077 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
1081 // Object browser is currently updated by using UF_Model flag
1082 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
1083 getApp()->updateObjectBrowser( true );
1085 if( ( flags & UF_Controls ) && getApp() )
1086 getApp()->updateActions();
1088 // restore selected objects
1089 restoreSelection( aSelectedEntries );
1091 setUpdateEnabled( true );
1093 preferencesChanged( "HYDRO", "zoom_shutoff" );
1095 preferencesChanged( "HYDRO", "chained_panning" );
1097 QApplication::restoreOverrideCursor();
1100 void HYDROGUI_Module::updateCommandsStatus()
1102 LightApp_Module::updateCommandsStatus();
1104 updateUndoRedoControls();
1106 action( CopyId )->setEnabled( getDataModel()->canCopy() );
1107 action( PasteId )->setEnabled( getDataModel()->canPaste() );
1110 void HYDROGUI_Module::selectionChanged()
1112 LightApp_Module::selectionChanged();
1113 updateCommandsStatus();
1116 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
1118 return (HYDROGUI_DataModel*)dataModel();
1121 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
1126 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
1128 return myOCCDisplayer;
1131 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
1133 return myVTKDisplayer;
1136 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
1138 if( myViewManagerMap.contains( theId ) )
1140 return myViewManagerMap[ theId ].first;
1145 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
1147 if( myViewManagerMap.contains( theId ) )
1149 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1150 GraphicsView_ViewManager* aViewManager =
1151 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
1153 return aViewManager->getViewer();
1158 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
1160 if( myViewManagerMap.contains( theId ) )
1162 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1163 OCCViewer_ViewManager* aViewManager =
1164 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
1166 return aViewManager->getOCCViewer();
1171 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
1173 if( myViewManagerMap.contains( theId ) )
1175 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1176 SVTK_ViewManager* aViewManager =
1177 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
1179 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
1184 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
1186 ViewManagerMapIterator anIter( myViewManagerMap );
1187 while( anIter.hasNext() )
1189 int anId = anIter.next().key();
1190 const ViewManagerInfo& anInfo = anIter.value();
1191 if( anInfo.first == theViewManager )
1197 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
1199 int anId = getViewManagerId( theViewManager );
1202 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1203 return anInfo.second;
1208 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
1209 const ViewManagerRole theRole )
1211 int anId = getViewManagerId( theViewManager );
1214 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1215 anInfo.second = theRole;
1219 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
1220 const Handle(HYDROData_Entity)& theObject ) const
1222 if( theObject.IsNull() )
1228 foreach( int aViewId, myObjectStateMap.keys() )
1230 if( isObjectVisible( aViewId, theObject ) )
1236 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1237 if( anIter1 != myObjectStateMap.end() )
1239 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1240 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1242 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1243 if( anIter2 != aEntry2ObjectStateMap.end() )
1245 const ObjectState& anObjectState = anIter2.value();
1246 return anObjectState.Visibility;
1252 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1253 const Handle(HYDROData_Entity)& theObject,
1254 const bool theState )
1256 if( !theObject.IsNull() )
1258 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1259 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1261 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1262 anObjectState.Visibility = theState;
1264 HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1267 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1270 QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1271 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1272 if ( visState != Qtx::UnpresentableState )
1273 treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1277 if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1278 setLandCoversScalarMapModeOff( theViewId );
1279 } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) {
1280 getOCCDisplayer()->SetToUpdateColorScale();
1285 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1286 const bool theState )
1288 if( !theObject.IsNull() )
1290 // Process OCC shapes
1291 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1292 while( aShapesMapIter != myShapesMap.end() )
1294 const ListOfShapes& aShapesList = aShapesMapIter.value();
1295 foreach ( HYDROGUI_Shape* aShape, aShapesList )
1297 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1299 aShape->setIsToUpdate( theState );
1304 // Process VTK shapes
1305 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1306 while( aVTKPrsMapIter != myVTKPrsMap.end() )
1308 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1309 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1311 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1313 aShape->setIsToUpdate( theState );
1321 /////////////////// OCC SHAPES PROCESSING
1322 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
1323 ObjectKind theKind ) const
1325 QList<HYDROGUI_Shape*> aResult;
1327 if ( myShapesMap.contains( theViewId ) )
1329 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1330 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1332 if( aShape && aShape->getObject()->GetKind()==theKind )
1333 aResult.append( aShape );
1339 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
1340 const Handle(HYDROData_Entity)& theObject ) const
1342 HYDROGUI_Shape* aResShape = NULL;
1343 if( theObject.IsNull() )
1346 if ( myShapesMap.contains( theViewId ) )
1348 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1349 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1351 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1362 void HYDROGUI_Module::setObjectShape( const int theViewId,
1363 const Handle(HYDROData_Entity)& theObject,
1364 HYDROGUI_Shape* theShape )
1366 if( theObject.IsNull() )
1369 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1370 aViewShapes.append( theShape );
1373 void HYDROGUI_Module::removeObjectShape( const int theViewId,
1374 const Handle(HYDROData_Entity)& theObject )
1376 if ( !myShapesMap.contains( theViewId ) )
1379 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1380 Handle(HYDROData_Entity) anObject;
1381 for ( int i = 0; i < aViewShapes.length(); )
1383 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1384 anObject = aShape->getObject();
1385 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1388 aViewShapes.removeAt( i );
1396 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1398 if ( !myShapesMap.contains( theViewId ) )
1401 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1402 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1404 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1409 myShapesMap.remove( theViewId );
1411 /////////////////// END OF OCC SHAPES PROCESSING
1413 /////////////////// VTKPrs PROCESSING
1414 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
1415 const Handle(HYDROData_Entity)& theObject ) const
1417 HYDROGUI_VTKPrs* aResShape = NULL;
1418 if( theObject.IsNull() )
1421 if ( myVTKPrsMap.contains( theViewId ) )
1423 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1424 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1426 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1437 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1438 const Handle(HYDROData_Entity)& theObject,
1439 HYDROGUI_VTKPrs* theShape )
1441 if( theObject.IsNull() )
1444 if( theShape && theShape->needScalarBar() )
1446 // Compute the new global Z range from the added presentation and the old global Z range.
1447 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1448 double* aRange = theShape->getInternalZRange();
1449 bool anIsUpdate = false;
1450 if ( aRange[0] < aGlobalRange[0] )
1452 aGlobalRange[0] = aRange[0];
1455 if ( aRange[1] > aGlobalRange[1] )
1457 aGlobalRange[1] = aRange[1];
1463 updateVTKZRange( theViewId, aGlobalRange );
1467 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1468 aViewShapes.append( theShape );
1471 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1472 const QString& theEntry )
1474 if ( !myVTKPrsMap.contains( theViewId ) )
1477 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1478 Handle(HYDROData_Entity) anObject;
1480 for ( int i = 0; i < aViewShapes.length(); )
1482 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1483 anObject = aShape->getObject();
1484 anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1485 if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1488 aViewShapes.removeAt( i );
1495 // Invalidate global Z range
1496 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1497 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1500 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1501 const Handle(HYDROData_Entity)& theObject )
1503 if ( !myVTKPrsMap.contains( theViewId ) )
1506 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1507 Handle(HYDROData_Entity) anObject;
1508 for ( int i = 0; i < aViewShapes.length(); )
1510 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1511 anObject = aShape->getObject();
1512 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1515 aViewShapes.removeAt( i );
1522 // Invalidate global Z range
1523 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1524 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1527 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1529 if ( !myVTKPrsMap.contains( theViewId ) )
1532 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1533 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1535 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1540 myVTKPrsMap.remove( theViewId );
1543 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1545 if ( myVTKPrsMap.contains( theViewId ) )
1547 // For the given viewer id update all VTK presentations ...
1548 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1549 HYDROGUI_VTKPrs* aShape;
1550 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1552 aShape = aViewShapes.at( i );
1553 if ( aShape && aShape->needScalarBar() )
1555 aShape->setZRange( theRange );
1559 // ... and update the global color legend scalar bar.
1560 getVTKDisplayer()->SetZRange( theViewId, theRange );
1562 /////////////////// END OF VTKPrs PROCESSING
1564 void HYDROGUI_Module::clearCache()
1566 myObjectStateMap.clear();
1569 CAM_DataModel* HYDROGUI_Module::createDataModel()
1571 return new HYDROGUI_DataModel( this );
1574 void HYDROGUI_Module::customEvent( QEvent* e )
1576 int aType = e->type();
1577 if ( aType == NewViewEvent )
1579 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1580 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1582 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1584 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1585 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1587 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1589 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1590 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1592 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1593 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1594 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1596 //ouv: temporarily commented
1597 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1600 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1601 update( UF_Viewer );
1603 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1609 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1611 QEvent::Type aType = theEvent->type();
1612 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1614 if( aType == QEvent::Show )
1616 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1617 e->setData( theObj );
1618 QApplication::postEvent( this, e );
1619 theObj->removeEventFilter( this );
1622 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1624 if( aType == QEvent::Leave )
1626 SUIT_Desktop* aDesktop = getApp()->desktop();
1627 if ( aDesktop && aDesktop->statusBar() ) {
1628 aDesktop->statusBar()->clearMessage();
1632 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1634 if( aType == QEvent::Leave )
1636 SUIT_Desktop* aDesktop = getApp()->desktop();
1637 if ( aDesktop && aDesktop->statusBar() ) {
1638 aDesktop->statusBar()->clearMessage();
1643 return LightApp_Module::eventFilter( theObj, theEvent );
1646 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1648 LightApp_Module::onViewManagerAdded( theViewManager );
1650 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1652 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1653 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1655 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1657 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
1658 //mgr->setChainedOperations( true );
1660 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1661 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1662 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1663 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1664 connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
1665 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
1667 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1669 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1670 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1671 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1672 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1675 createSelector( theViewManager ); // replace the default selector
1677 ViewManagerInfo anInfo( theViewManager, VMR_General );
1678 myViewManagerMap.insert( ViewManagerId++, anInfo );
1681 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1683 LightApp_Module::onViewManagerRemoved( theViewManager );
1685 createSelector( theViewManager ); // replace the default selector
1687 int anId = getViewManagerId( theViewManager );
1690 OCCViewer_ViewManager* anOCCViewManager =
1691 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1692 if ( anOCCViewManager )
1694 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1695 if ( anOCCViewer ) {
1696 int aViewerId = (size_t)anOCCViewer;
1697 removeViewShapes( aViewerId );
1698 setLandCoversScalarMapModeOff( aViewerId );
1702 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1704 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1707 getVTKDisplayer()->EraseScalarBar( anId, true );
1708 removeViewShapes( (size_t)aVTKViewer );
1712 myViewManagerMap.remove( anId );
1716 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1718 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1720 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1722 aViewFrame->installEventFilter( this );
1724 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1725 aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
1727 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1728 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1731 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1733 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1735 aViewFrame->onTopView();
1737 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1738 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1740 aViewPort->installEventFilter( this );
1744 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1746 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1748 aViewFrame->installEventFilter( this );
1753 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1755 /* ouv: currently unused
1756 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1758 SUIT_ViewManager* aViewManager = 0;
1760 QObject* aParent = aViewPort;
1761 while( aParent = aParent->parent() )
1763 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1765 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1767 aViewManager = aViewer->getViewManager();
1776 double aMouseX = theEvent->scenePos().x();
1777 double aMouseY = theEvent->scenePos().y();
1779 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1780 if( aRole == VMR_General )
1782 int aXDeg = 0, aYDeg = 0;
1783 int aXMin = 0, aYMin = 0;
1784 double aXSec = 0, aYSec = 0;
1785 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1786 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1788 QString aDegSymbol( QChar( 0x00B0 ) );
1789 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1790 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1792 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1794 else if( aRole == VMR_TransformImage )
1795 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1800 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1801 const bool theIsInit,
1802 const bool theIsForced,
1803 const bool theDoFitAll )
1805 QList<int> aViewManagerIdList;
1807 // currently, all views are updated
1808 ViewManagerMapIterator anIter( myViewManagerMap );
1809 while( anIter.hasNext() )
1811 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1813 if ( theDisplayer->IsApplicable( aViewManager ) )
1815 int anId = anIter.key();
1816 aViewManagerIdList.append( anId );
1820 QListIterator<int> anIdIter( aViewManagerIdList );
1821 while( anIdIter.hasNext() )
1823 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1824 myOverview->setTopView();
1828 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1830 if( !theViewManager )
1833 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1834 if( !aSelectionMgr )
1837 QString aViewType = theViewManager->getType();
1838 if( aViewType != GraphicsView_Viewer::Type() &&
1839 aViewType != OCCViewer_Viewer::Type())
1842 QList<SUIT_Selector*> aSelectorList;
1843 aSelectionMgr->selectors( aViewType, aSelectorList );
1845 // disable all alien selectors
1846 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1847 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1849 SUIT_Selector* aSelector = *anIter;
1850 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1851 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1852 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1853 aSelector->setEnabled( false );
1856 if ( aViewType == GraphicsView_Viewer::Type() )
1858 GraphicsView_ViewManager* aViewManager =
1859 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1861 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1863 else if ( aViewType == OCCViewer_Viewer::Type() )
1865 OCCViewer_ViewManager* aViewManager =
1866 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1868 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1872 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1874 bool aPrevState = myIsUpdateEnabled;
1875 myIsUpdateEnabled = theState;
1879 bool HYDROGUI_Module::isUpdateEnabled() const
1881 return myIsUpdateEnabled;
1884 QStringList HYDROGUI_Module::storeSelection() const
1886 QStringList anEntryList;
1887 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1889 SUIT_DataOwnerPtrList aList( true );
1890 aSelectionMgr->selected( aList );
1892 SUIT_DataOwnerPtrList::iterator anIter;
1893 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1895 const LightApp_DataOwner* anOwner =
1896 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1898 anEntryList.append( anOwner->entry() );
1904 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1906 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1908 SUIT_DataOwnerPtrList aList( true );
1909 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1910 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1911 aSelectionMgr->setSelected( aList );
1915 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1918 bool doShow = false;
1919 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1921 aDisplayer->SaveCursorViewPosition( theViewWindow );
1922 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1926 // Show the coordinates in the status bar
1927 SUIT_Desktop* aDesktop = getApp()->desktop();
1928 if ( aDesktop && aDesktop->statusBar() )
1930 gp_Pnt aWPnt( X, Y, Z );
1931 int aStudyId = application()->activeStudy()->id();
1932 HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
1933 double WX = aWPnt.X(), WY = aWPnt.Y();
1935 QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1936 QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1937 QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1938 QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1939 QString aMsg = tr( "COORDINATES_INFO" );
1940 aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1941 aDesktop->statusBar()->showMessage( aMsg );
1947 * Returns stack of active operations;
1949 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
1951 return myActiveOperationMap;
1955 * Returns the module active operation. If the active operation is show/hide,
1956 * the method returns the previous operation if it is.
1958 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
1960 HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
1962 if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
1964 QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
1966 aVIt.previous(); // skip the top show/hide operation
1967 anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
1974 * \brief Virtual public slot
1976 * This method is called after the object inserted into data view to update their visibility state
1977 * This is default implementation
1979 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
1981 if ( !isActiveModule() )
1984 HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
1986 // change visibility of object
1987 if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
1990 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1992 QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
1993 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1994 if ( visState == Qtx::UnpresentableState )
1997 visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
1998 treeModel->setVisibilityState( id, visState );
2000 bool vis = visState == Qtx::ShownState;
2001 if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
2004 setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
2006 update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
2009 bool HYDROGUI_Module::isDraggable( const SUIT_DataObject* what ) const
2014 bool HYDROGUI_Module::isDropAccepted( const SUIT_DataObject* where ) const
2020 void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
2021 const int row, Qt::DropAction action )
2023 if ( action != Qt::CopyAction && action != Qt::MoveAction )
2029 if (where->level() < 2 )
2032 DataObjectList::ConstIterator it = what.constBegin();
2033 for (;it != what.constEnd();++it)
2035 if ((*it)->parent() != where)
2039 it = what.constBegin();
2042 for (;it != what.constEnd();++it)
2044 SUIT_DataObject* objWhat = *it;
2046 DataObjectList objInSect = where->children();
2048 //std::list<SUIT_DataObject*> t1 = where->children().toStdList(); //debug
2049 int ind = objInSect.indexOf(objWhat);
2052 HYDROGUI_DataModel* aModel = getDataModel();
2061 where->moveChildPos(objWhat, pos);
2062 //std::list<SUIT_DataObject*> t2 = where->children().toStdList(); //debug
2066 getApp()->updateObjectBrowser(true);
2070 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
2072 Handle(HYDROData_StricklerTable) aTable;
2074 if ( myLandCoverColoringMap.contains( theViewId ) ) {
2075 aTable = myLandCoverColoringMap.value( theViewId );
2081 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
2082 const Handle(HYDROData_StricklerTable)& theTable )
2084 if ( !theTable.IsNull() ) {
2085 myLandCoverColoringMap.insert( theViewId, theTable );
2089 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
2091 myLandCoverColoringMap.remove( theViewId );
2094 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
2096 return myLandCoverColoringMap.contains( theViewId );
2099 void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
2101 if ( theObject.IsNull() || !theObject->IsRemoved() ) {
2105 if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
2106 Handle(HYDROData_StricklerTable) aTable =
2107 Handle(HYDROData_StricklerTable)::DownCast( theObject );
2108 QList<int> aViewIds;
2109 QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
2110 while ( anIter.hasNext() ) {
2111 if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
2112 HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
2119 void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
2124 SUIT_ViewWindow* wnd = theMgr->getActiveView();
2125 OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
2129 myOverview->setMainView( occwnd );
2132 void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
2134 ViewManagerList aViewManagers = getApp()->viewManagers();
2135 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
2136 setAutoZoom(aVMgr, bAutoZoom);
2139 void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
2143 QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
2144 foreach (SUIT_ViewWindow* aView, aViews)
2148 OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
2151 anOCCViewFrame->setAutomaticZoom(bAutoZoom);
2152 for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
2154 OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
2156 aV->setAutomaticZoom(bAutoZoom);
2159 OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
2160 if (anOCCViewWindow)
2161 anOCCViewWindow->setAutomaticZoom(bAutoZoom);