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_ProgressIndicator.h>
46 #include <HYDROData_Tool.h>
47 #include <HYDROData_Image.h>
48 #include <HYDROData_Stream.h>
49 #include <HYDROData_Profile.h>
50 #include <HYDROData_Lambert93.h>
51 #include <HYDROData_Polyline3D.h>
52 #include <HYDROData_StricklerTable.h>
53 #include <HYDROData_ArtificialObject.h>
54 #include <HYDROData_NaturalObject.h>
56 #include <HYDROData_OperationsFactory.h>
58 #include <CurveCreator_Utils.hxx>
60 #include <GraphicsView_ViewFrame.h>
61 #include <GraphicsView_ViewManager.h>
62 #include <GraphicsView_ViewPort.h>
63 #include <GraphicsView_Viewer.h>
65 #include <ImageComposer_CutOperator.h>
66 #include <ImageComposer_CropOperator.h>
67 #include <ImageComposer_FuseOperator.h>
69 #include <LightApp_Application.h>
70 #include <LightApp_DataOwner.h>
71 #include <LightApp_GVSelector.h>
72 #include <LightApp_SelectionMgr.h>
73 #include <LightApp_UpdateFlags.h>
75 #include <SalomeApp_Study.h>
77 #include <OCCViewer_ViewFrame.h>
78 #include <OCCViewer_ViewManager.h>
79 #include <OCCViewer_ViewModel.h>
81 #include <SALOME_Event.h>
83 #include <SUIT_DataBrowser.h>
84 #include <SUIT_DataObject.h>
85 #include <SUIT_ViewManager.h>
86 #include <SUIT_ResourceMgr.h>
87 #include <SUIT_Desktop.h>
88 #include <SUIT_Study.h>
89 #include <SUIT_Session.h>
91 #include <SVTK_ViewManager.h>
92 #include <SVTK_ViewModel.h>
93 #include <SVTK_ViewWindow.h>
94 #include <SVTK_Selector.h>
96 #include <OCCViewer_ViewPort3d.h>
98 #include <GEOMUtils.hxx>
99 #include <GeometryGUI.h>
101 #include <SALOMEDS_wrap.hxx>
104 #include <QApplication>
105 #include <QGraphicsSceneMouseEvent>
107 #include <QMouseEvent>
108 #include <QStatusBar>
111 static int ViewManagerId = 0;
113 extern "C" HYDRO_EXPORT CAM_Module* createModule()
115 return new HYDROGUI_Module();
118 extern "C" HYDRO_EXPORT char* getModuleVersion()
120 return (char*)HYDRO_VERSION;
123 HYDROGUI_Module::HYDROGUI_Module()
124 : LightApp_Module( "HYDRO" ),
127 myIsUpdateEnabled( true ),
132 HYDROGUI_Module::~HYDROGUI_Module()
136 int HYDROGUI_Module::getStudyId() const
138 LightApp_Application* anApp = getApp();
139 return anApp ? anApp->activeStudy()->id() : 0;
142 void HYDROGUI_Module::initialize( CAM_Application* theApp )
144 LightApp_Module::initialize( theApp );
147 createUndoRedoActions();
152 setMenuShown( false );
153 setToolShown( false );
155 myDisplayer = new HYDROGUI_Displayer( this );
156 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
157 myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
159 HYDROData_Tool::SetSIProgress( new HYDROGUI_ProgressIndicator( theApp->desktop(), tr( "STRICKLER_INTERPOLATION_TLT" ) ) );
162 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
164 bool aRes = LightApp_Module::activateModule( theStudy );
166 LightApp_Application* anApp = getApp();
167 SUIT_Desktop* aDesktop = anApp->desktop();
169 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
171 setMenuShown( true );
172 setToolShown( true );
174 #ifndef DISABLE_PYCONSOLE
175 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
176 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
179 // Remove defunct view managers from the map.
180 // It's essential to do this before "update( UF_All )" call!
181 QList<int> anObsoleteIds;
182 ViewManagerList anAllViewManagers = anApp->viewManagers();
183 ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
184 ViewManagerMapIterator anIter( myViewManagerMap );
185 while( anIter.hasNext() ) {
186 int anId = anIter.next().key();
187 const ViewManagerInfo& anInfo = anIter.value();
189 aHydroViewManagers << anInfo.first;
191 if ( !anAllViewManagers.contains( anInfo.first ) ) {
192 anObsoleteIds << anId;
195 foreach ( const int anId, anObsoleteIds ) {
196 myViewManagerMap.remove( anId );
197 myObjectStateMap.remove( anId );
198 myShapesMap.remove( anId );
199 myVTKPrsMap.remove( anId );
201 // Replace the default selector for all view managers.
202 // Add view managers created outside of HYDRO module to the map.
203 foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
204 createSelector( aViewManager ); // replace the default selector
205 if ( !aHydroViewManagers.contains( aViewManager ) ) {
206 ViewManagerInfo anInfo( aViewManager, VMR_General );
207 myViewManagerMap.insert( ViewManagerId++, anInfo );
213 updateCommandsStatus();
215 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
217 ViewManagerList anOCCViewManagers;
218 anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
220 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
222 connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
223 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
224 connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
225 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
227 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
230 occ_mgr->setChainedOperations( true );//TODO: via preferences
233 foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() )
235 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
236 if ( aViewFrame && aViewFrame->getViewPort() )
238 aViewFrame->getViewPort()->installEventFilter( this );
243 preferencesChanged( "HYDRO", "zoom_shutoff" );
245 preferencesChanged( "HYDRO", "chained_panning" );
248 SalomeApp_Study* aStudy =
249 dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
251 SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
252 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
253 if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
254 SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
255 SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
256 if( !GEOM_var->_is_nil() ) {
257 aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
263 // SUIT_DataBrowser* ob = getApp()->objectBrowser();
264 // SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
265 // treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
270 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
273 ViewManagerMapIterator anIter( myViewManagerMap );
274 while( anIter.hasNext() )
275 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
276 getApp()->removeViewManager( aViewManager );
277 myViewManagerMap.clear();
280 ViewManagerList anOCCViewManagers;
281 getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
282 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
284 disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
285 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
287 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
290 occ_mgr->setChainedOperations( false );
291 setAutoZoom( occ_mgr, true );
296 myObjectStateMap.clear();
301 // clear the status bar
302 SUIT_Desktop* aDesktop = getApp()->desktop();
303 if ( aDesktop && aDesktop->statusBar() ) {
304 aDesktop->statusBar()->clearMessage();
307 // clear the data model's list of copying objects
308 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
310 setMenuShown( false );
311 setToolShown( false );
313 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
315 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
317 myActiveOperationMap.clear();
319 myViewManagerMap.clear();
321 return LightApp_Module::deactivateModule( theStudy );
324 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
326 static bool inWindows = false;
331 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
332 #ifndef DISABLE_PYCONSOLE
333 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
335 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
336 theMap.insert( OverviewWindow, Qt::LeftDockWidgetArea );
339 LightApp_Application* app = getApp();
340 if( app && app->getWindow( OverviewWindow )==0 )
342 const_cast<HYDROGUI_Module*>( this )->myOverview =
343 new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() );
344 app->insertDockWindow( OverviewWindow, myOverview );
345 app->placeDockWindow( OverviewWindow, Qt::LeftDockWidgetArea );
350 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
352 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
355 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
359 HYDROGUI_DataModel* aModel = getDataModel();
361 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
362 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
363 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
364 bool anIsVTKView = theClient == SVTK_Viewer::Type();
365 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
368 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
370 bool anIsSelectedDataObjects = false;
371 bool anIsVisibleInSelection = false;
372 bool anIsHiddenInSelection = false;
374 bool anIsImage = false;
375 bool anIsImportedImage = false;
376 bool anIsImageHasRefs = false;
377 bool anIsFusedImage = false;
378 bool anIsCutImage = false;
379 bool anIsSplitImage = false;
380 bool anIsMustObjectBeUpdated = false;
381 bool anIsPolyline = false;
382 bool anIsPolyline3D = false;
383 bool anIsProfile = false;
384 bool anIsValidProfile = false;
385 bool anAllAreProfiles = false;
386 bool anIsBathymetry = false;
387 bool anIsCalculation = false;
388 bool anIsImmersibleZone = false;
389 bool anIsVisualState = false;
390 bool anIsRegion = false;
391 bool anIsZone = false;
392 bool anIsObstacle = false;
393 bool anIsStricklerTable = false;
394 bool anIsLandCoverMap = false;
395 bool anIsStream = false;
396 bool anIsChannel = false;
397 bool anIsDigue = false;
398 bool anIsDummyObject3D = false;
399 bool anIsGroup = false;
400 bool anIsObjectCanBeColored = false;
402 bool isStreamHasBottom = false;
403 bool anIsBCPolygon = false;
405 SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
406 SUIT_DataOwnerPtrList anOwners;
407 aSelectionMgr->selected( anOwners );
408 if( anIsObjectBrowser && anOwners.size()==1 )
410 QString anEntry = anOwners[0]->keyString();
411 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
413 isRoot = aStudy->isComponent( anEntry );
416 // Check the selected GEOM objects (take into account the Object Browser only)
417 if ( anIsObjectBrowser ) {
418 QList<GEOM::shape_type> anObstacleTypes =
419 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
420 QList<GEOM::shape_type> aPolylineTypes =
421 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
423 bool isCanBeImportedAsObstacle =
424 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
425 bool isCanBeImportedAsPolyline =
426 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
428 // Add import as obstacle action
429 if ( isCanBeImportedAsObstacle ) {
430 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
432 // Add import as polyline action
433 if ( isCanBeImportedAsPolyline ) {
434 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
437 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
438 theMenu->addSeparator();
442 // check the selected data model objects
443 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
444 int aNbOfSelectedProfiles = 0;
445 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
447 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
448 if( !anObject.IsNull() )
450 anIsSelectedDataObjects = true;
452 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
453 anIsVisibleInSelection |= aVisibility;
454 anIsHiddenInSelection |= !aVisibility;
456 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
458 anIsMustObjectBeUpdated = true;
461 ObjectKind anObjectKind = anObject->GetKind();
462 if( anObjectKind == KIND_IMAGE )
465 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
466 if( !anImage.IsNull() )
468 anIsImportedImage = anImage->HasLocalPoints();
469 anIsImageHasRefs = anImage->HasReferences();
470 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
472 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
474 QString anOperatorName = anOperator->name();
475 if( anOperatorName == ImageComposer_FuseOperator::Type() )
476 anIsFusedImage = true;
477 else if( anOperatorName == ImageComposer_CutOperator::Type() )
479 else if( anOperatorName == ImageComposer_CropOperator::Type() )
480 anIsSplitImage = true;
485 else if( anObjectKind == KIND_POLYLINEXY )
487 else if( anObjectKind == KIND_POLYLINE )
488 anIsPolyline3D = true;
489 else if( anObjectKind == KIND_PROFILE )
492 aNbOfSelectedProfiles++;
494 Handle(HYDROData_Profile) aProfile =
495 Handle(HYDROData_Profile)::DownCast( anObject );
496 if( !aProfile.IsNull() && aProfile->IsValid() ) {
497 anIsValidProfile = true;
500 else if( anObjectKind == KIND_CALCULATION )
501 anIsCalculation = true;
502 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
503 anIsImmersibleZone = true;
504 else if( anObjectKind == KIND_VISUAL_STATE )
505 anIsVisualState = true;
506 else if( anObjectKind == KIND_REGION )
508 else if( anObjectKind == KIND_ZONE )
510 else if( anObjectKind == KIND_BATHYMETRY )
511 anIsBathymetry = true;
512 else if( anObjectKind == KIND_OBSTACLE )
514 else if( anObjectKind == KIND_STRICKLER_TABLE )
515 anIsStricklerTable = true;
516 else if( anObjectKind == KIND_LAND_COVER_MAP )
517 anIsLandCoverMap = true;
518 else if (anObjectKind == KIND_BC_POLYGON)
519 anIsBCPolygon = true;
520 else if( anObjectKind == KIND_STREAM )
523 Handle(HYDROData_Stream) aStream =
524 Handle(HYDROData_Stream)::DownCast( anObject );
525 if ( !aStream.IsNull() )
526 isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
528 else if( anObjectKind == KIND_CHANNEL )
530 else if( anObjectKind == KIND_DIGUE )
532 else if( anObjectKind == KIND_DUMMY_3D )
533 anIsDummyObject3D = true;
534 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLIT_GROUP )
538 if ( !anIsObjectCanBeColored )
539 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject, this );
542 // Check if all selected objects are profiles
543 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
544 ( aNbOfSelectedProfiles == aSeq.Length() );
546 // check the selected partitions
547 if( !anIsSelectedDataObjects && anIsObjectBrowser )
549 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
550 if( aSelectedPartition != KIND_UNKNOWN )
552 switch( aSelectedPartition )
555 theMenu->addAction( action( ImportImageId ) );
557 case KIND_BATHYMETRY:
558 theMenu->addAction( action( ImportBathymetryId ) );
560 case KIND_ARTIFICIAL_OBJECT:
561 theMenu->addAction( action( CreateChannelId ) );
562 theMenu->addAction( action( CreateDigueId ) );
564 case KIND_NATURAL_OBJECT:
565 theMenu->addAction( action( CreateImmersibleZoneId ) );
566 theMenu->addAction( action( CreateStreamId ) );
569 theMenu->addAction( action( ImportObstacleFromFileId ) );
570 theMenu->addAction( action( CreateBoxId ) );
571 theMenu->addAction( action( CreateCylinderId ) );
573 case KIND_STRICKLER_TABLE:
574 theMenu->addAction( action( ImportStricklerTableFromFileId ) );
576 case KIND_LAND_COVER_MAP:
577 theMenu->addAction( action( CreateLandCoverMapId ) );
578 theMenu->addAction( action( ImportLandCoverMapId ) );
580 case KIND_CALCULATION:
581 theMenu->addAction( action( CreateCalculationId ) );
583 case KIND_POLYLINEXY:
584 theMenu->addAction( action( ImportPolylineId ) );
585 theMenu->addAction( action( CreatePolylineId ) );
588 theMenu->addAction( action( CreatePolyline3DId ) );
591 theMenu->addAction( action( CreateProfileId ) );
592 theMenu->addAction( action( ImportProfilesId ) );
593 theMenu->addAction( action( AllGeoreferencementId ) );
595 case KIND_VISUAL_STATE:
596 theMenu->addAction( action( SaveVisualStateId ) );
598 case KIND_BC_POLYGON:
599 theMenu->addAction( action( ImportBCPolygonId ) );
602 theMenu->addSeparator();
606 Handle(HYDROData_CalculationCase) aCalcCase;
608 HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr);
609 if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION ))
610 theMenu->addAction( action( RegenerateRegionColorsId ) );
614 if( anIsSelectedDataObjects )
616 if ( anIsMustObjectBeUpdated )
618 theMenu->addAction( action( UpdateObjectId ) );
619 theMenu->addSeparator();
623 theMenu->addAction( action( ForcedUpdateObjectId ) );
624 theMenu->addSeparator();
628 if( aSeq.Length() == 1 )
632 if( anIsImportedImage )
633 theMenu->addAction( action( EditImportedImageId ) );
634 else if( anIsImageHasRefs )
637 theMenu->addAction( action( EditFusedImageId ) );
638 else if( anIsCutImage )
639 theMenu->addAction( action( EditCutImageId ) );
640 else if( anIsSplitImage )
641 theMenu->addAction( action( EditSplitImageId ) );
644 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
645 theMenu->addAction( action( ExportImageId ) );
646 theMenu->addSeparator();
648 if( anIsImageHasRefs )
650 theMenu->addAction( action( RemoveImageRefsId ) );
651 theMenu->addSeparator();
654 theMenu->addAction( action( FuseImagesId ) );
655 theMenu->addAction( action( CutImagesId ) );
656 theMenu->addAction( action( SplitImageId ) );
657 theMenu->addSeparator();
658 theMenu->addAction( action( RecognizeContoursId ) );
659 theMenu->addSeparator();
661 else if( anIsBathymetry )
663 theMenu->addAction( action( EditImportedBathymetryId ) );
664 theMenu->addAction( action( BathymetryBoundsId ) );
665 theMenu->addSeparator();
667 else if( anIsPolyline )
669 theMenu->addAction( action( EditPolylineId ) );
670 theMenu->addSeparator();
671 theMenu->addAction( action( SplitPolylinesId ) );
672 theMenu->addAction( action( MergePolylinesId ) );
673 theMenu->addSeparator();
674 theMenu->addAction( action( ShowAttrPolylinesId ) );
675 theMenu->addSeparator();
677 else if( anIsPolyline3D )
679 theMenu->addAction( action( EditPolyline3DId ) );
680 theMenu->addSeparator();
682 else if( anIsProfile )
684 theMenu->addAction( action( EditProfileId ) );
685 theMenu->addAction( action( SelectedGeoreferencementId ) );
686 theMenu->addSeparator();
688 else if( anIsCalculation )
690 theMenu->addAction( action( EditCalculationId ) );
691 theMenu->addAction( action( ExportCalculationId ) );
692 theMenu->addSeparator();
694 else if( anIsImmersibleZone )
696 theMenu->addAction( action( EditImmersibleZoneId ) );
697 theMenu->addSeparator();
699 else if( anIsStream )
701 theMenu->addAction( action( EditStreamId ) );
702 if ( action( RiverBottomContextId ) )
704 theMenu->addAction( action( RiverBottomContextId ) );
705 action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
707 theMenu->addAction( action( ProfileInterpolateId ) );
708 theMenu->addSeparator();
710 else if( anIsChannel )
712 theMenu->addAction( action( EditChannelId ) );
713 theMenu->addSeparator();
717 theMenu->addAction( action( EditDigueId ) );
718 theMenu->addSeparator();
720 else if( anIsObstacle )
722 theMenu->addAction( action( TranslateObstacleId ) );
723 theMenu->addSeparator();
725 else if( anIsStricklerTable )
727 theMenu->addAction( action( EditStricklerTableId ) );
728 theMenu->addAction( action( ExportStricklerTableFromFileId ) );
729 theMenu->addAction( action( DuplicateStricklerTableId ) );
730 theMenu->addSeparator();
732 Handle(HYDROData_StricklerTable) aTable =
733 Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
734 QString aCurrentTable =
735 HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
736 bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
738 if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER_MAP ).isEmpty() ) {
739 theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
740 theMenu->addSeparator();
743 else if( anIsLandCoverMap )
745 theMenu->addAction( action( AddLandCoverId ) );
746 theMenu->addAction( action( RemoveLandCoverId ) );
747 theMenu->addSeparator();
748 theMenu->addAction( action( SplitLandCoverId ) );
749 theMenu->addAction( action( MergeLandCoverId ) );
750 theMenu->addAction( action( ChangeLandCoverTypeId ) );
751 theMenu->addSeparator();
753 theMenu->addAction( action( ExportToShapeFileID ) );
754 theMenu->addSeparator();
756 else if( anIsVisualState && anIsObjectBrowser )
758 theMenu->addAction( action( SaveVisualStateId ) );
759 theMenu->addAction( action( LoadVisualStateId ) );
760 theMenu->addSeparator();
763 theMenu->addAction( action( ZoneSetColorId ) );
764 else if (anIsBCPolygon)
765 theMenu->addAction( action( SetBoundaryTypePolygonId ) );
767 if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
769 theMenu->addAction( action( PolylineExtractionId ) );
770 theMenu->addSeparator();
773 // Add set color action for geometrical objects
774 if ( anIsObjectCanBeColored )
776 theMenu->addAction( action( SetColorId ) );
777 theMenu->addSeparator();
780 // Add transparency action for land cover map objects
781 if ( anIsLandCoverMap )
783 theMenu->addAction( action( SetTransparencyId ) );
784 theMenu->addSeparator();
787 else if ( anAllAreProfiles )
789 theMenu->addAction( action( EditProfileId ) );
790 theMenu->addAction( action( SelectedGeoreferencementId ) );
791 theMenu->addSeparator();
794 bool isPoly = anIsPolyline || anIsPolyline3D;
795 if (isPoly && !anIsLandCoverMap)
796 theMenu->addAction( action( ExportToShapeFileID ) );
799 QAction* aCopyAction = action( CopyId );
800 if( aCopyAction && aCopyAction->isEnabled() ) {
801 theMenu->addAction( action( CopyId ) );
802 theMenu->addSeparator();
806 if( !anIsDummyObject3D )
807 theMenu->addAction( action( DeleteId ) );
809 theMenu->addSeparator();
811 if( anIsImage || anIsPolyline || anIsPolyline3D ||
812 anIsImmersibleZone || anIsZone || anIsRegion ||
813 anIsBathymetry || anIsObstacle || anIsStream ||
814 anIsChannel || anIsDigue || anIsDummyObject3D ||
815 anIsValidProfile || anIsGroup || anIsLandCoverMap ||
818 if( anIsHiddenInSelection )
819 theMenu->addAction( action( ShowId ) );
820 theMenu->addAction( action( ShowOnlyId ) );
821 if( anIsVisibleInSelection )
822 theMenu->addAction( action( HideId ) );
823 theMenu->addSeparator();
829 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
830 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
831 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
832 theMenu->addAction( action( DeleteId ) );
834 theMenu->addSeparator();
835 theMenu->addAction( action( SetZLevelId ) );
836 theMenu->addSeparator();
838 if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
839 theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
840 theMenu->addSeparator();
844 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
846 theMenu->addAction( action( ShowAllId ) );
847 theMenu->addAction( action( HideAllId ) );
848 theMenu->addSeparator();
851 if ( anIsOCCView || anIsVTKView )
853 theMenu->addSeparator();
854 theMenu->addAction( action( CopyViewerPositionId ) );
858 theMenu->addAction( action( EditLocalCSId ) );
860 if( anIsObjectBrowser && anOwners.size()==1 )
862 if( aSeq.Size() > 0 )
864 Handle( HYDROData_Entity ) aFirstEnt = aSeq.First();
865 Handle(HYDROData_Object) anObject;
866 Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt);
867 Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt);
869 if (!anAObject.IsNull())
870 anObject = anAObject;
871 if (!aNObject.IsNull())
874 if( !anObject.IsNull() )
876 theMenu->addSeparator();
877 bool IsSubmersible = anObject->IsSubmersible();
880 theMenu->addAction( action( SubmersibleId ) );
881 action( SubmersibleId )->setCheckable(true);
882 action( SubmersibleId )->setChecked(true);
886 theMenu->addAction( action( UnSubmersibleId ) );
887 action( UnSubmersibleId )->setCheckable(true);
888 action( UnSubmersibleId )->setChecked(true);
894 theMenu->addSeparator();
895 QAction* a = action( ShowHideArrows );
896 a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
897 theMenu->addAction( a );
900 void HYDROGUI_Module::createPreferences()
902 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
903 int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
905 int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
906 LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
908 // Set property cursor type
909 QList<QVariant> aCursorTypeIndicesList;
910 QList<QVariant> aCursorTypeIconsList;
912 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
913 for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
914 QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
915 QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
916 aCursorTypeIndicesList << i;
917 aCursorTypeIconsList << pixmap;
920 setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
921 setPreferenceProperty( typeOfCursor, "icons", aCursorTypeIconsList );
923 int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
924 addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
925 LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
927 addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
929 addPreference( tr( "PREF_VIEWER_CHAINED_PANNING" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "chained_panning" );
931 int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
932 int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
933 LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
934 setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
935 setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
936 setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
937 setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
939 int polylinesGroup = addPreference( tr( "PREF_GROUP_POLYLINES" ), genTab );
940 int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
941 LightApp_Preferences::Selector, "polyline", "arrow_type" );
943 QList<QVariant> arrow_types;
944 arrow_types.append( tr( "No" ) );
945 arrow_types.append( tr( "Triangle" ) );
946 arrow_types.append( tr( "Cone" ) );
947 setPreferenceProperty( polylineArrow, "strings", arrow_types );
949 QList<QVariant> indices;
953 setPreferenceProperty( polylineArrow, "indexes", indices );
954 setPreferenceProperty( polylineArrow, "ids", indices );
956 int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup,
957 LightApp_Preferences::IntSpin, "polyline", "arrow_size" );
960 void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
962 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
963 if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
966 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
967 if ( resMgr && !aDoc.IsNull() )
968 aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
970 else if( theSection == "polyline" )
976 resMgr->value( "polyline", "arrow_type", aType );
977 resMgr->value( "polyline", "arrow_size", aSize );
980 ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end();
981 for( ; it!=last; it++ )
983 int aViewerId = it.key();
984 OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( it.value().first );
986 getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
989 else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
991 bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
992 setAutoZoomToAllViewManagers(!aZoomShutoff);
994 else if (theSection == "HYDRO" && thePref == "chained_panning")
996 bool aChainedPan = resMgr->booleanValue( "HYDRO", "chained_panning" );
999 ViewManagerList aViewManagers = getApp()->viewManagers();
1000 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
1002 OCCViewer_ViewManager* anOCCViewMgr = dynamic_cast<OCCViewer_ViewManager*>( aVMgr );
1004 anOCCViewMgr->setChainedOperations( aChainedPan );
1007 QList<QDockWidget*> docW = getApp()->desktop()->findChildren<QDockWidget*>();
1008 foreach (QDockWidget* qw, docW)
1010 HYDROGUI_ProfileDlg* pdlg = dynamic_cast<HYDROGUI_ProfileDlg*>(qw);
1012 pdlg->viewManager()->setChainedOperations(aChainedPan);
1016 LightApp_Module::preferencesChanged( theSection, thePref );
1019 QCursor HYDROGUI_Module::getPrefEditCursor() const
1021 int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
1022 if ( aCursorType >= Qt::BlankCursor)
1024 QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
1028 void HYDROGUI_Module::update( const int flags )
1030 if ( !isUpdateEnabled() )
1033 QApplication::setOverrideCursor( Qt::WaitCursor );
1035 // To prevent calling this method recursively
1036 // from one of the methods called below
1037 setUpdateEnabled( false );
1039 // store selected objects
1040 QStringList aSelectedEntries = storeSelection();
1042 bool aDoFitAll = flags & UF_FitAll;
1045 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1046 aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
1049 if( ( flags & UF_Viewer ) )
1050 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
1052 if( ( flags & UF_OCCViewer ) )
1053 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
1055 if( ( flags & UF_VTKViewer ) )
1056 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
1058 if( ( flags & UF_Model ) && getDataModel() && getApp() )
1060 getDataModel()->update( getStudyId() );
1062 // Temporary workaround to prevent breaking
1063 // the selection in the object browser.
1064 // Note: processEvents() should be called after updateGV(),
1065 // otherwise the application crashes from time to time.
1066 //RKV: qApp->processEvents();
1067 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1068 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
1069 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
1070 if ( isResizeOnExpandItem && anObjectBrowser ) {
1071 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
1073 getApp()->updateObjectBrowser( true );
1074 if ( isResizeOnExpandItem && anObjectBrowser ) {
1075 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
1079 // Object browser is currently updated by using UF_Model flag
1080 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
1081 getApp()->updateObjectBrowser( true );
1083 if( ( flags & UF_Controls ) && getApp() )
1084 getApp()->updateActions();
1086 // restore selected objects
1087 restoreSelection( aSelectedEntries );
1089 setUpdateEnabled( true );
1091 preferencesChanged( "HYDRO", "zoom_shutoff" );
1093 preferencesChanged( "HYDRO", "chained_panning" );
1095 QApplication::restoreOverrideCursor();
1098 void HYDROGUI_Module::updateCommandsStatus()
1100 LightApp_Module::updateCommandsStatus();
1102 updateUndoRedoControls();
1104 action( CopyId )->setEnabled( getDataModel()->canCopy() );
1105 action( PasteId )->setEnabled( getDataModel()->canPaste() );
1108 void HYDROGUI_Module::selectionChanged()
1110 LightApp_Module::selectionChanged();
1111 updateCommandsStatus();
1114 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
1116 return (HYDROGUI_DataModel*)dataModel();
1119 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
1124 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
1126 return myOCCDisplayer;
1129 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
1131 return myVTKDisplayer;
1134 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
1136 if( myViewManagerMap.contains( theId ) )
1138 return myViewManagerMap[ theId ].first;
1143 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
1145 if( myViewManagerMap.contains( theId ) )
1147 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1148 GraphicsView_ViewManager* aViewManager =
1149 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
1151 return aViewManager->getViewer();
1156 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
1158 if( myViewManagerMap.contains( theId ) )
1160 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1161 OCCViewer_ViewManager* aViewManager =
1162 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
1164 return aViewManager->getOCCViewer();
1169 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
1171 if( myViewManagerMap.contains( theId ) )
1173 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1174 SVTK_ViewManager* aViewManager =
1175 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
1177 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
1182 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
1184 ViewManagerMapIterator anIter( myViewManagerMap );
1185 while( anIter.hasNext() )
1187 int anId = anIter.next().key();
1188 const ViewManagerInfo& anInfo = anIter.value();
1189 if( anInfo.first == theViewManager )
1195 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
1197 int anId = getViewManagerId( theViewManager );
1200 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1201 return anInfo.second;
1206 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
1207 const ViewManagerRole theRole )
1209 int anId = getViewManagerId( theViewManager );
1212 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1213 anInfo.second = theRole;
1217 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
1218 const Handle(HYDROData_Entity)& theObject ) const
1220 if( theObject.IsNull() )
1226 foreach( int aViewId, myObjectStateMap.keys() )
1228 if( isObjectVisible( aViewId, theObject ) )
1234 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1235 if( anIter1 != myObjectStateMap.end() )
1237 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1238 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1240 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1241 if( anIter2 != aEntry2ObjectStateMap.end() )
1243 const ObjectState& anObjectState = anIter2.value();
1244 return anObjectState.Visibility;
1250 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1251 const Handle(HYDROData_Entity)& theObject,
1252 const bool theState )
1254 if( !theObject.IsNull() )
1256 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1257 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1259 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1260 anObjectState.Visibility = theState;
1262 HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1265 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1268 QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1269 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1270 if ( visState != Qtx::UnpresentableState )
1271 treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1275 if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1276 setLandCoversScalarMapModeOff( theViewId );
1277 } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) {
1278 getOCCDisplayer()->SetToUpdateColorScale();
1283 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1284 const bool theState )
1286 if( !theObject.IsNull() )
1288 // Process OCC shapes
1289 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1290 while( aShapesMapIter != myShapesMap.end() )
1292 const ListOfShapes& aShapesList = aShapesMapIter.value();
1293 foreach ( HYDROGUI_Shape* aShape, aShapesList )
1295 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1297 aShape->setIsToUpdate( theState );
1302 // Process VTK shapes
1303 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1304 while( aVTKPrsMapIter != myVTKPrsMap.end() )
1306 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1307 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1309 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1311 aShape->setIsToUpdate( theState );
1319 /////////////////// OCC SHAPES PROCESSING
1320 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
1321 ObjectKind theKind ) const
1323 QList<HYDROGUI_Shape*> aResult;
1325 if ( myShapesMap.contains( theViewId ) )
1327 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1328 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1330 if( aShape && aShape->getObject()->GetKind()==theKind )
1331 aResult.append( aShape );
1337 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
1338 const Handle(HYDROData_Entity)& theObject ) const
1340 HYDROGUI_Shape* aResShape = NULL;
1341 if( theObject.IsNull() )
1344 if ( myShapesMap.contains( theViewId ) )
1346 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1347 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1349 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1360 void HYDROGUI_Module::setObjectShape( const int theViewId,
1361 const Handle(HYDROData_Entity)& theObject,
1362 HYDROGUI_Shape* theShape )
1364 if( theObject.IsNull() )
1367 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1368 aViewShapes.append( theShape );
1371 void HYDROGUI_Module::removeObjectShape( const int theViewId,
1372 const Handle(HYDROData_Entity)& theObject )
1374 if ( !myShapesMap.contains( theViewId ) )
1377 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1378 Handle(HYDROData_Entity) anObject;
1379 for ( int i = 0; i < aViewShapes.length(); )
1381 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1382 anObject = aShape->getObject();
1383 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1386 aViewShapes.removeAt( i );
1394 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1396 if ( !myShapesMap.contains( theViewId ) )
1399 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1400 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1402 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1407 myShapesMap.remove( theViewId );
1409 /////////////////// END OF OCC SHAPES PROCESSING
1411 /////////////////// VTKPrs PROCESSING
1412 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
1413 const Handle(HYDROData_Entity)& theObject ) const
1415 HYDROGUI_VTKPrs* aResShape = NULL;
1416 if( theObject.IsNull() )
1419 if ( myVTKPrsMap.contains( theViewId ) )
1421 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1422 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1424 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1435 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1436 const Handle(HYDROData_Entity)& theObject,
1437 HYDROGUI_VTKPrs* theShape )
1439 if( theObject.IsNull() )
1442 if( theShape && theShape->needScalarBar() )
1444 // Compute the new global Z range from the added presentation and the old global Z range.
1445 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1446 double* aRange = theShape->getInternalZRange();
1447 bool anIsUpdate = false;
1448 if ( aRange[0] < aGlobalRange[0] )
1450 aGlobalRange[0] = aRange[0];
1453 if ( aRange[1] > aGlobalRange[1] )
1455 aGlobalRange[1] = aRange[1];
1461 updateVTKZRange( theViewId, aGlobalRange );
1465 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1466 aViewShapes.append( theShape );
1469 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1470 const QString& theEntry )
1472 if ( !myVTKPrsMap.contains( theViewId ) )
1475 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1476 Handle(HYDROData_Entity) anObject;
1478 for ( int i = 0; i < aViewShapes.length(); )
1480 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1481 anObject = aShape->getObject();
1482 anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1483 if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1486 aViewShapes.removeAt( i );
1493 // Invalidate global Z range
1494 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1495 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1498 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1499 const Handle(HYDROData_Entity)& theObject )
1501 if ( !myVTKPrsMap.contains( theViewId ) )
1504 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1505 Handle(HYDROData_Entity) anObject;
1506 for ( int i = 0; i < aViewShapes.length(); )
1508 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1509 anObject = aShape->getObject();
1510 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1513 aViewShapes.removeAt( i );
1520 // Invalidate global Z range
1521 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1522 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1525 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1527 if ( !myVTKPrsMap.contains( theViewId ) )
1530 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1531 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1533 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1538 myVTKPrsMap.remove( theViewId );
1541 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1543 if ( myVTKPrsMap.contains( theViewId ) )
1545 // For the given viewer id update all VTK presentations ...
1546 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1547 HYDROGUI_VTKPrs* aShape;
1548 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1550 aShape = aViewShapes.at( i );
1551 if ( aShape && aShape->needScalarBar() )
1553 aShape->setZRange( theRange );
1557 // ... and update the global color legend scalar bar.
1558 getVTKDisplayer()->SetZRange( theViewId, theRange );
1560 /////////////////// END OF VTKPrs PROCESSING
1562 void HYDROGUI_Module::clearCache()
1564 myObjectStateMap.clear();
1567 CAM_DataModel* HYDROGUI_Module::createDataModel()
1569 return new HYDROGUI_DataModel( this );
1572 void HYDROGUI_Module::customEvent( QEvent* e )
1574 int aType = e->type();
1575 if ( aType == NewViewEvent )
1577 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1578 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1580 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1582 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1583 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1585 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1587 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1588 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1590 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1591 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1592 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1594 //ouv: temporarily commented
1595 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1598 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1599 update( UF_Viewer );
1601 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1607 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1609 QEvent::Type aType = theEvent->type();
1610 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1612 if( aType == QEvent::Show )
1614 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1615 e->setData( theObj );
1616 QApplication::postEvent( this, e );
1617 theObj->removeEventFilter( this );
1620 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1622 if( aType == QEvent::Leave )
1624 SUIT_Desktop* aDesktop = getApp()->desktop();
1625 if ( aDesktop && aDesktop->statusBar() ) {
1626 aDesktop->statusBar()->clearMessage();
1630 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1632 if( aType == QEvent::Leave )
1634 SUIT_Desktop* aDesktop = getApp()->desktop();
1635 if ( aDesktop && aDesktop->statusBar() ) {
1636 aDesktop->statusBar()->clearMessage();
1641 return LightApp_Module::eventFilter( theObj, theEvent );
1644 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1646 LightApp_Module::onViewManagerAdded( theViewManager );
1648 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1650 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1651 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1653 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1655 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
1656 //mgr->setChainedOperations( true );
1658 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1659 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1660 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1661 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1662 connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
1663 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
1665 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1667 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1668 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1669 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1670 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1673 createSelector( theViewManager ); // replace the default selector
1675 ViewManagerInfo anInfo( theViewManager, VMR_General );
1676 myViewManagerMap.insert( ViewManagerId++, anInfo );
1679 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1681 LightApp_Module::onViewManagerRemoved( theViewManager );
1683 createSelector( theViewManager ); // replace the default selector
1685 int anId = getViewManagerId( theViewManager );
1688 OCCViewer_ViewManager* anOCCViewManager =
1689 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1690 if ( anOCCViewManager )
1692 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1693 if ( anOCCViewer ) {
1694 int aViewerId = (size_t)anOCCViewer;
1695 removeViewShapes( aViewerId );
1696 setLandCoversScalarMapModeOff( aViewerId );
1700 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1702 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1705 getVTKDisplayer()->EraseScalarBar( anId, true );
1706 removeViewShapes( (size_t)aVTKViewer );
1710 myViewManagerMap.remove( anId );
1714 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1716 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1718 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1720 aViewFrame->installEventFilter( this );
1722 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1723 aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
1725 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1726 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1729 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1731 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1733 aViewFrame->onTopView();
1735 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1736 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1738 aViewPort->installEventFilter( this );
1742 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1744 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1746 aViewFrame->installEventFilter( this );
1751 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1753 /* ouv: currently unused
1754 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1756 SUIT_ViewManager* aViewManager = 0;
1758 QObject* aParent = aViewPort;
1759 while( aParent = aParent->parent() )
1761 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1763 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1765 aViewManager = aViewer->getViewManager();
1774 double aMouseX = theEvent->scenePos().x();
1775 double aMouseY = theEvent->scenePos().y();
1777 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1778 if( aRole == VMR_General )
1780 int aXDeg = 0, aYDeg = 0;
1781 int aXMin = 0, aYMin = 0;
1782 double aXSec = 0, aYSec = 0;
1783 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1784 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1786 QString aDegSymbol( QChar( 0x00B0 ) );
1787 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1788 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1790 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1792 else if( aRole == VMR_TransformImage )
1793 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1798 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1799 const bool theIsInit,
1800 const bool theIsForced,
1801 const bool theDoFitAll )
1803 QList<int> aViewManagerIdList;
1805 // currently, all views are updated
1806 ViewManagerMapIterator anIter( myViewManagerMap );
1807 while( anIter.hasNext() )
1809 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1811 if ( theDisplayer->IsApplicable( aViewManager ) )
1813 int anId = anIter.key();
1814 aViewManagerIdList.append( anId );
1818 QListIterator<int> anIdIter( aViewManagerIdList );
1819 while( anIdIter.hasNext() )
1821 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1822 myOverview->setTopView();
1826 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1828 if( !theViewManager )
1831 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1832 if( !aSelectionMgr )
1835 QString aViewType = theViewManager->getType();
1836 if( aViewType != GraphicsView_Viewer::Type() &&
1837 aViewType != OCCViewer_Viewer::Type())
1840 QList<SUIT_Selector*> aSelectorList;
1841 aSelectionMgr->selectors( aViewType, aSelectorList );
1843 // disable all alien selectors
1844 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1845 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1847 SUIT_Selector* aSelector = *anIter;
1848 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1849 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1850 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1851 aSelector->setEnabled( false );
1854 if ( aViewType == GraphicsView_Viewer::Type() )
1856 GraphicsView_ViewManager* aViewManager =
1857 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1859 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1861 else if ( aViewType == OCCViewer_Viewer::Type() )
1863 OCCViewer_ViewManager* aViewManager =
1864 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1866 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1870 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1872 bool aPrevState = myIsUpdateEnabled;
1873 myIsUpdateEnabled = theState;
1877 bool HYDROGUI_Module::isUpdateEnabled() const
1879 return myIsUpdateEnabled;
1882 QStringList HYDROGUI_Module::storeSelection() const
1884 QStringList anEntryList;
1885 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1887 SUIT_DataOwnerPtrList aList( true );
1888 aSelectionMgr->selected( aList );
1890 SUIT_DataOwnerPtrList::iterator anIter;
1891 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1893 const LightApp_DataOwner* anOwner =
1894 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1896 anEntryList.append( anOwner->entry() );
1902 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1904 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1906 SUIT_DataOwnerPtrList aList( true );
1907 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1908 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1909 aSelectionMgr->setSelected( aList );
1913 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1916 bool doShow = false;
1917 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1919 aDisplayer->SaveCursorViewPosition( theViewWindow );
1920 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1924 // Show the coordinates in the status bar
1925 SUIT_Desktop* aDesktop = getApp()->desktop();
1926 if ( aDesktop && aDesktop->statusBar() )
1928 gp_Pnt aWPnt( X, Y, Z );
1929 int aStudyId = application()->activeStudy()->id();
1930 HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
1931 double WX = aWPnt.X(), WY = aWPnt.Y();
1933 QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1934 QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1935 QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1936 QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1937 QString aMsg = tr( "COORDINATES_INFO" );
1938 aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1939 aDesktop->statusBar()->showMessage( aMsg );
1945 * Returns stack of active operations;
1947 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
1949 return myActiveOperationMap;
1953 * Returns the module active operation. If the active operation is show/hide,
1954 * the method returns the previous operation if it is.
1956 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
1958 HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
1960 if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
1962 QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
1964 aVIt.previous(); // skip the top show/hide operation
1965 anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
1972 * \brief Virtual public slot
1974 * This method is called after the object inserted into data view to update their visibility state
1975 * This is default implementation
1977 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
1979 if ( !isActiveModule() )
1982 HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
1984 // change visibility of object
1985 if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
1988 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1990 QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
1991 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1992 if ( visState == Qtx::UnpresentableState )
1995 visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
1996 treeModel->setVisibilityState( id, visState );
1998 bool vis = visState == Qtx::ShownState;
1999 if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
2002 setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
2004 update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
2007 bool HYDROGUI_Module::isDraggable( const SUIT_DataObject* what ) const
2012 bool HYDROGUI_Module::isDropAccepted( const SUIT_DataObject* where ) const
2018 void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
2019 const int row, Qt::DropAction action )
2021 if ( action != Qt::CopyAction && action != Qt::MoveAction )
2027 if (where->level() < 2 )
2030 DataObjectList::ConstIterator it = what.constBegin();
2031 for (;it != what.constEnd();++it)
2033 if ((*it)->parent() != where)
2037 it = what.constBegin();
2040 for (;it != what.constEnd();++it)
2042 SUIT_DataObject* objWhat = *it;
2044 DataObjectList objInSect = where->children();
2046 //std::list<SUIT_DataObject*> t1 = where->children().toStdList(); //debug
2047 int ind = objInSect.indexOf(objWhat);
2050 HYDROGUI_DataModel* aModel = getDataModel();
2059 where->moveChildPos(objWhat, pos);
2060 //std::list<SUIT_DataObject*> t2 = where->children().toStdList(); //debug
2064 getApp()->updateObjectBrowser(true);
2068 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
2070 Handle(HYDROData_StricklerTable) aTable;
2072 if ( myLandCoverColoringMap.contains( theViewId ) ) {
2073 aTable = myLandCoverColoringMap.value( theViewId );
2079 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
2080 const Handle(HYDROData_StricklerTable)& theTable )
2082 if ( !theTable.IsNull() ) {
2083 myLandCoverColoringMap.insert( theViewId, theTable );
2087 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
2089 myLandCoverColoringMap.remove( theViewId );
2092 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
2094 return myLandCoverColoringMap.contains( theViewId );
2097 void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
2099 if ( theObject.IsNull() || !theObject->IsRemoved() ) {
2103 if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
2104 Handle(HYDROData_StricklerTable) aTable =
2105 Handle(HYDROData_StricklerTable)::DownCast( theObject );
2106 QList<int> aViewIds;
2107 QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
2108 while ( anIter.hasNext() ) {
2109 if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
2110 HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
2117 void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
2122 SUIT_ViewWindow* wnd = theMgr->getActiveView();
2123 OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
2127 myOverview->setMainView( occwnd );
2130 void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
2132 ViewManagerList aViewManagers = getApp()->viewManagers();
2133 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
2134 setAutoZoom(aVMgr, bAutoZoom);
2137 void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
2141 QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
2142 foreach (SUIT_ViewWindow* aView, aViews)
2146 OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
2149 anOCCViewFrame->setAutomaticZoom(bAutoZoom);
2150 for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
2152 OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
2154 aV->setAutomaticZoom(bAutoZoom);
2157 OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
2158 if (anOCCViewWindow)
2159 anOCCViewWindow->setAutomaticZoom(bAutoZoom);