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* ) ) );
288 disconnect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
289 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
291 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
294 occ_mgr->setChainedOperations( false );
295 setAutoZoom( occ_mgr, true );
300 myObjectStateMap.clear();
305 // clear the status bar
306 SUIT_Desktop* aDesktop = getApp()->desktop();
307 if ( aDesktop && aDesktop->statusBar() ) {
308 aDesktop->statusBar()->clearMessage();
311 // clear the data model's list of copying objects
312 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
314 setMenuShown( false );
315 setToolShown( false );
317 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
319 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
321 myActiveOperationMap.clear();
323 myViewManagerMap.clear();
325 return LightApp_Module::deactivateModule( theStudy );
328 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
330 static bool inWindows = false;
335 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
336 #ifndef DISABLE_PYCONSOLE
337 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
339 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
340 theMap.insert( OverviewWindow, Qt::LeftDockWidgetArea );
343 LightApp_Application* app = getApp();
344 if( app && app->getWindow( OverviewWindow )==0 )
346 const_cast<HYDROGUI_Module*>( this )->myOverview =
347 new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() );
348 app->insertDockWindow( OverviewWindow, myOverview );
349 app->placeDockWindow( OverviewWindow, Qt::LeftDockWidgetArea );
354 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
356 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
359 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
363 HYDROGUI_DataModel* aModel = getDataModel();
365 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
366 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
367 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
368 bool anIsVTKView = theClient == SVTK_Viewer::Type();
369 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
372 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
374 bool anIsSelectedDataObjects = false;
375 bool anIsVisibleInSelection = false;
376 bool anIsHiddenInSelection = false;
378 bool anIsImage = false;
379 bool anIsImportedImage = false;
380 bool anIsImageHasRefs = false;
381 bool anIsFusedImage = false;
382 bool anIsCutImage = false;
383 bool anIsSplitImage = false;
384 bool anIsMustObjectBeUpdated = false;
385 bool anIsPolyline = false;
386 bool anIsPolyline3D = false;
387 bool anIsProfile = false;
388 bool anIsValidProfile = false;
389 bool anAllAreProfiles = false;
390 bool anIsBathymetry = false;
391 bool anIsCalculation = false;
392 bool anIsImmersibleZone = false;
393 bool anIsVisualState = false;
394 bool anIsRegion = false;
395 bool anIsZone = false;
396 bool anIsObstacle = false;
397 bool anIsStricklerTable = false;
398 bool anIsLandCoverMap = false;
399 bool anIsStream = false;
400 bool anIsChannel = false;
401 bool anIsDigue = false;
402 bool anIsDummyObject3D = false;
403 bool anIsGroup = false;
404 bool anIsObjectCanBeColored = false;
406 bool isStreamHasBottom = false;
407 bool anIsBCPolygon = false;
409 SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
410 SUIT_DataOwnerPtrList anOwners;
411 aSelectionMgr->selected( anOwners );
412 if( anIsObjectBrowser && anOwners.size()==1 )
414 QString anEntry = anOwners[0]->keyString();
415 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
417 isRoot = aStudy->isComponent( anEntry );
420 // Check the selected GEOM objects (take into account the Object Browser only)
421 if ( anIsObjectBrowser ) {
422 QList<GEOM::shape_type> anObstacleTypes =
423 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
424 QList<GEOM::shape_type> aPolylineTypes =
425 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
427 bool isCanBeImportedAsObstacle =
428 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
429 bool isCanBeImportedAsPolyline =
430 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
432 // Add import as obstacle action
433 if ( isCanBeImportedAsObstacle ) {
434 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
436 // Add import as polyline action
437 if ( isCanBeImportedAsPolyline ) {
438 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
441 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
442 theMenu->addSeparator();
446 // check the selected data model objects
447 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
448 int aNbOfSelectedProfiles = 0;
449 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
451 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
452 if( !anObject.IsNull() )
454 anIsSelectedDataObjects = true;
456 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
457 anIsVisibleInSelection |= aVisibility;
458 anIsHiddenInSelection |= !aVisibility;
460 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
462 anIsMustObjectBeUpdated = true;
465 ObjectKind anObjectKind = anObject->GetKind();
466 if( anObjectKind == KIND_IMAGE )
469 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
470 if( !anImage.IsNull() )
472 anIsImportedImage = anImage->HasLocalPoints();
473 anIsImageHasRefs = anImage->HasReferences();
474 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
476 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
478 QString anOperatorName = anOperator->name();
479 if( anOperatorName == ImageComposer_FuseOperator::Type() )
480 anIsFusedImage = true;
481 else if( anOperatorName == ImageComposer_CutOperator::Type() )
483 else if( anOperatorName == ImageComposer_CropOperator::Type() )
484 anIsSplitImage = true;
489 else if( anObjectKind == KIND_POLYLINEXY )
491 else if( anObjectKind == KIND_POLYLINE )
492 anIsPolyline3D = true;
493 else if( anObjectKind == KIND_PROFILE )
496 aNbOfSelectedProfiles++;
498 Handle(HYDROData_Profile) aProfile =
499 Handle(HYDROData_Profile)::DownCast( anObject );
500 if( !aProfile.IsNull() && aProfile->IsValid() ) {
501 anIsValidProfile = true;
504 else if( anObjectKind == KIND_CALCULATION )
505 anIsCalculation = true;
506 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
507 anIsImmersibleZone = true;
508 else if( anObjectKind == KIND_VISUAL_STATE )
509 anIsVisualState = true;
510 else if( anObjectKind == KIND_REGION )
512 else if( anObjectKind == KIND_ZONE )
514 else if( anObjectKind == KIND_BATHYMETRY )
515 anIsBathymetry = true;
516 else if( anObjectKind == KIND_OBSTACLE )
518 else if( anObjectKind == KIND_STRICKLER_TABLE )
519 anIsStricklerTable = true;
520 else if( anObjectKind == KIND_LAND_COVER_MAP )
521 anIsLandCoverMap = true;
522 else if (anObjectKind == KIND_BC_POLYGON)
523 anIsBCPolygon = true;
524 else if( anObjectKind == KIND_STREAM )
527 Handle(HYDROData_Stream) aStream =
528 Handle(HYDROData_Stream)::DownCast( anObject );
529 if ( !aStream.IsNull() )
530 isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
532 else if( anObjectKind == KIND_CHANNEL )
534 else if( anObjectKind == KIND_DIGUE )
536 else if( anObjectKind == KIND_DUMMY_3D )
537 anIsDummyObject3D = true;
538 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLIT_GROUP )
542 if ( !anIsObjectCanBeColored )
543 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject, this );
546 // Check if all selected objects are profiles
547 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
548 ( aNbOfSelectedProfiles == aSeq.Length() );
550 // check the selected partitions
551 if( !anIsSelectedDataObjects && anIsObjectBrowser )
553 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
554 if( aSelectedPartition != KIND_UNKNOWN )
556 switch( aSelectedPartition )
559 theMenu->addAction( action( ImportImageId ) );
561 case KIND_BATHYMETRY:
562 theMenu->addAction( action( ImportBathymetryId ) );
564 case KIND_ARTIFICIAL_OBJECT:
565 theMenu->addAction( action( CreateChannelId ) );
566 theMenu->addAction( action( CreateDigueId ) );
568 case KIND_NATURAL_OBJECT:
569 theMenu->addAction( action( CreateImmersibleZoneId ) );
570 theMenu->addAction( action( CreateStreamId ) );
573 theMenu->addAction( action( ImportObstacleFromFileId ) );
574 theMenu->addAction( action( CreateBoxId ) );
575 theMenu->addAction( action( CreateCylinderId ) );
577 case KIND_STRICKLER_TABLE:
578 theMenu->addAction( action( ImportStricklerTableFromFileId ) );
580 case KIND_LAND_COVER_MAP:
581 theMenu->addAction( action( CreateLandCoverMapId ) );
582 theMenu->addAction( action( ImportLandCoverMapId ) );
584 case KIND_CALCULATION:
585 theMenu->addAction( action( CreateCalculationId ) );
587 case KIND_POLYLINEXY:
588 theMenu->addAction( action( ImportPolylineId ) );
589 theMenu->addAction( action( CreatePolylineId ) );
592 theMenu->addAction( action( CreatePolyline3DId ) );
595 theMenu->addAction( action( CreateProfileId ) );
596 theMenu->addAction( action( ImportProfilesId ) );
597 theMenu->addAction( action( AllGeoreferencementId ) );
599 case KIND_VISUAL_STATE:
600 theMenu->addAction( action( SaveVisualStateId ) );
602 case KIND_BC_POLYGON:
603 theMenu->addAction( action( ImportBCPolygonId ) );
606 theMenu->addSeparator();
610 Handle(HYDROData_CalculationCase) aCalcCase;
612 HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr);
613 if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION ))
614 theMenu->addAction( action( RegenerateRegionColorsId ) );
618 if( anIsSelectedDataObjects )
620 if ( anIsMustObjectBeUpdated )
622 theMenu->addAction( action( UpdateObjectId ) );
623 theMenu->addSeparator();
627 theMenu->addAction( action( ForcedUpdateObjectId ) );
628 theMenu->addSeparator();
632 if( aSeq.Length() == 1 )
636 if( anIsImportedImage )
637 theMenu->addAction( action( EditImportedImageId ) );
638 else if( anIsImageHasRefs )
641 theMenu->addAction( action( EditFusedImageId ) );
642 else if( anIsCutImage )
643 theMenu->addAction( action( EditCutImageId ) );
644 else if( anIsSplitImage )
645 theMenu->addAction( action( EditSplitImageId ) );
648 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
649 theMenu->addAction( action( ExportImageId ) );
650 theMenu->addSeparator();
652 if( anIsImageHasRefs )
654 theMenu->addAction( action( RemoveImageRefsId ) );
655 theMenu->addSeparator();
658 theMenu->addAction( action( FuseImagesId ) );
659 theMenu->addAction( action( CutImagesId ) );
660 theMenu->addAction( action( SplitImageId ) );
661 theMenu->addSeparator();
662 theMenu->addAction( action( RecognizeContoursId ) );
663 theMenu->addSeparator();
665 else if( anIsBathymetry )
667 theMenu->addAction( action( EditImportedBathymetryId ) );
668 theMenu->addAction( action( BathymetryBoundsId ) );
669 theMenu->addSeparator();
671 else if( anIsPolyline )
673 theMenu->addAction( action( EditPolylineId ) );
674 theMenu->addSeparator();
675 theMenu->addAction( action( SplitPolylinesId ) );
676 theMenu->addAction( action( MergePolylinesId ) );
677 theMenu->addSeparator();
678 theMenu->addAction( action( ShowAttrPolylinesId ) );
679 theMenu->addSeparator();
681 else if( anIsPolyline3D )
683 theMenu->addAction( action( EditPolyline3DId ) );
684 theMenu->addSeparator();
686 else if( anIsProfile )
688 theMenu->addAction( action( EditProfileId ) );
689 theMenu->addAction( action( SelectedGeoreferencementId ) );
690 theMenu->addSeparator();
692 else if( anIsCalculation )
694 theMenu->addAction( action( EditCalculationId ) );
695 theMenu->addAction( action( ExportCalculationId ) );
696 theMenu->addAction( action( CompleteCalculationId ) );
697 theMenu->addSeparator();
699 else if( anIsImmersibleZone )
701 theMenu->addAction( action( EditImmersibleZoneId ) );
702 theMenu->addSeparator();
704 else if( anIsStream )
706 theMenu->addAction( action( EditStreamId ) );
707 if ( action( RiverBottomContextId ) )
709 theMenu->addAction( action( RiverBottomContextId ) );
710 action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
712 theMenu->addAction( action( ProfileInterpolateId ) );
713 theMenu->addSeparator();
715 else if( anIsChannel )
717 theMenu->addAction( action( EditChannelId ) );
718 theMenu->addSeparator();
722 theMenu->addAction( action( EditDigueId ) );
723 theMenu->addSeparator();
725 else if( anIsObstacle )
727 theMenu->addAction( action( TranslateObstacleId ) );
728 theMenu->addSeparator();
730 else if( anIsStricklerTable )
732 theMenu->addAction( action( EditStricklerTableId ) );
733 theMenu->addAction( action( ExportStricklerTableFromFileId ) );
734 theMenu->addAction( action( DuplicateStricklerTableId ) );
735 theMenu->addSeparator();
737 Handle(HYDROData_StricklerTable) aTable =
738 Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
739 QString aCurrentTable =
740 HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
741 bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
743 if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER_MAP ).isEmpty() ) {
744 theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
745 theMenu->addSeparator();
748 else if( anIsLandCoverMap )
750 theMenu->addAction( action( AddLandCoverId ) );
751 theMenu->addAction( action( RemoveLandCoverId ) );
752 theMenu->addSeparator();
753 theMenu->addAction( action( SplitLandCoverId ) );
754 theMenu->addAction( action( MergeLandCoverId ) );
755 theMenu->addAction( action( ChangeLandCoverTypeId ) );
756 theMenu->addSeparator();
758 theMenu->addAction( action( ExportToShapeFileID ) );
759 theMenu->addSeparator();
761 else if( anIsVisualState && anIsObjectBrowser )
763 theMenu->addAction( action( SaveVisualStateId ) );
764 theMenu->addAction( action( LoadVisualStateId ) );
765 theMenu->addSeparator();
768 theMenu->addAction( action( ZoneSetColorId ) );
769 else if (anIsBCPolygon)
770 theMenu->addAction( action( SetBoundaryTypePolygonId ) );
772 if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
774 theMenu->addAction( action( PolylineExtractionId ) );
775 theMenu->addSeparator();
778 // Add set color action for geometrical objects
779 if ( anIsObjectCanBeColored )
781 theMenu->addAction( action( SetColorId ) );
782 theMenu->addSeparator();
785 // Add transparency action for land cover map objects
786 if ( anIsLandCoverMap )
788 theMenu->addAction( action( SetTransparencyId ) );
789 theMenu->addSeparator();
792 else if ( anAllAreProfiles )
794 theMenu->addAction( action( EditProfileId ) );
795 theMenu->addAction( action( SelectedGeoreferencementId ) );
796 theMenu->addSeparator();
799 bool isPoly = anIsPolyline || anIsPolyline3D;
800 if (isPoly && !anIsLandCoverMap)
801 theMenu->addAction( action( ExportToShapeFileID ) );
804 QAction* aCopyAction = action( CopyId );
805 if( aCopyAction && aCopyAction->isEnabled() ) {
806 theMenu->addAction( action( CopyId ) );
807 theMenu->addSeparator();
811 if( !anIsDummyObject3D )
812 theMenu->addAction( action( DeleteId ) );
814 theMenu->addSeparator();
816 if( anIsImage || anIsPolyline || anIsPolyline3D ||
817 anIsImmersibleZone || anIsZone || anIsRegion ||
818 anIsBathymetry || anIsObstacle || anIsStream ||
819 anIsChannel || anIsDigue || anIsDummyObject3D ||
820 anIsValidProfile || anIsGroup || anIsLandCoverMap ||
823 if( anIsHiddenInSelection )
824 theMenu->addAction( action( ShowId ) );
825 theMenu->addAction( action( ShowOnlyId ) );
826 if( anIsVisibleInSelection )
827 theMenu->addAction( action( HideId ) );
828 theMenu->addSeparator();
834 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
835 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
836 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
837 theMenu->addAction( action( DeleteId ) );
839 theMenu->addSeparator();
840 theMenu->addAction( action( SetZLevelId ) );
841 theMenu->addSeparator();
843 if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
844 theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
845 theMenu->addSeparator();
849 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
851 theMenu->addAction( action( ShowAllId ) );
852 theMenu->addAction( action( HideAllId ) );
853 theMenu->addSeparator();
856 if ( anIsOCCView || anIsVTKView )
858 theMenu->addSeparator();
859 theMenu->addAction( action( CopyViewerPositionId ) );
863 theMenu->addAction( action( EditLocalCSId ) );
865 if( anIsObjectBrowser && anOwners.size()==1 )
867 if( aSeq.Size() > 0 )
869 Handle( HYDROData_Entity ) aFirstEnt = aSeq.First();
870 Handle(HYDROData_Object) anObject;
871 Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt);
872 Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt);
874 if (!anAObject.IsNull())
875 anObject = anAObject;
876 if (!aNObject.IsNull())
879 if( !anObject.IsNull() )
881 theMenu->addSeparator();
882 bool IsSubmersible = anObject->IsSubmersible();
885 theMenu->addAction( action( SubmersibleId ) );
886 action( SubmersibleId )->setCheckable(true);
887 action( SubmersibleId )->setChecked(true);
891 theMenu->addAction( action( UnSubmersibleId ) );
892 action( UnSubmersibleId )->setCheckable(true);
893 action( UnSubmersibleId )->setChecked(true);
899 theMenu->addSeparator();
900 QAction* a = action( ShowHideArrows );
901 a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
902 theMenu->addAction( a );
905 void HYDROGUI_Module::createPreferences()
907 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
908 int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
910 int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
911 LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
913 // Set property cursor type
914 QList<QVariant> aCursorTypeIndicesList;
915 QList<QVariant> aCursorTypeIconsList;
917 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
918 for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
919 QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
920 QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
921 aCursorTypeIndicesList << i;
922 aCursorTypeIconsList << pixmap;
925 setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
926 setPreferenceProperty( typeOfCursor, "icons", aCursorTypeIconsList );
928 int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
929 addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
930 LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
932 addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
934 addPreference( tr( "PREF_VIEWER_CHAINED_PANNING" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "chained_panning" );
936 int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
937 int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
938 LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
939 setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
940 setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
941 setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
942 setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
944 int polylinesGroup = addPreference( tr( "PREF_GROUP_POLYLINES" ), genTab );
945 int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
946 LightApp_Preferences::Selector, "polyline", "arrow_type" );
948 QList<QVariant> arrow_types;
949 arrow_types.append( tr( "No" ) );
950 arrow_types.append( tr( "Triangle" ) );
951 arrow_types.append( tr( "Cone" ) );
952 setPreferenceProperty( polylineArrow, "strings", arrow_types );
954 QList<QVariant> indices;
958 setPreferenceProperty( polylineArrow, "indexes", indices );
959 setPreferenceProperty( polylineArrow, "ids", indices );
961 int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup,
962 LightApp_Preferences::IntSpin, "polyline", "arrow_size" );
965 void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
967 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
968 if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
971 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
972 if ( resMgr && !aDoc.IsNull() )
973 aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
975 else if( theSection == "polyline" )
981 resMgr->value( "polyline", "arrow_type", aType );
982 resMgr->value( "polyline", "arrow_size", aSize );
985 ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end();
986 for( ; it!=last; it++ )
988 int aViewerId = it.key();
989 OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( it.value().first );
991 getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
994 else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
996 bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
997 setAutoZoomToAllViewManagers(!aZoomShutoff);
999 else if (theSection == "HYDRO" && thePref == "chained_panning")
1001 bool aChainedPan = resMgr->booleanValue( "HYDRO", "chained_panning" );
1004 ViewManagerList aViewManagers = getApp()->viewManagers();
1005 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
1007 OCCViewer_ViewManager* anOCCViewMgr = dynamic_cast<OCCViewer_ViewManager*>( aVMgr );
1009 anOCCViewMgr->setChainedOperations( aChainedPan );
1012 QList<QDockWidget*> docW = getApp()->desktop()->findChildren<QDockWidget*>();
1013 foreach (QDockWidget* qw, docW)
1015 HYDROGUI_ProfileDlg* pdlg = dynamic_cast<HYDROGUI_ProfileDlg*>(qw);
1017 pdlg->viewManager()->setChainedOperations(aChainedPan);
1021 LightApp_Module::preferencesChanged( theSection, thePref );
1024 QCursor HYDROGUI_Module::getPrefEditCursor() const
1026 int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
1027 if ( aCursorType >= Qt::BlankCursor)
1029 QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
1033 void HYDROGUI_Module::update( const int flags )
1035 if ( !isUpdateEnabled() )
1038 QApplication::setOverrideCursor( Qt::WaitCursor );
1040 // To prevent calling this method recursively
1041 // from one of the methods called below
1042 setUpdateEnabled( false );
1044 // store selected objects
1045 QStringList aSelectedEntries = storeSelection();
1047 bool aDoFitAll = flags & UF_FitAll;
1050 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1051 aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
1054 if( ( flags & UF_Viewer ) )
1055 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
1057 if( ( flags & UF_OCCViewer ) )
1058 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
1060 if( ( flags & UF_VTKViewer ) )
1061 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
1063 if( ( flags & UF_Model ) && getDataModel() && getApp() )
1065 getDataModel()->update( getStudyId() );
1067 // Temporary workaround to prevent breaking
1068 // the selection in the object browser.
1069 // Note: processEvents() should be called after updateGV(),
1070 // otherwise the application crashes from time to time.
1071 //RKV: qApp->processEvents();
1072 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1073 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
1074 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
1075 if ( isResizeOnExpandItem && anObjectBrowser ) {
1076 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
1078 getApp()->updateObjectBrowser( true );
1079 if ( isResizeOnExpandItem && anObjectBrowser ) {
1080 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
1084 // Object browser is currently updated by using UF_Model flag
1085 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
1086 getApp()->updateObjectBrowser( true );
1088 if( ( flags & UF_Controls ) && getApp() )
1089 getApp()->updateActions();
1091 // restore selected objects
1092 restoreSelection( aSelectedEntries );
1094 setUpdateEnabled( true );
1096 preferencesChanged( "HYDRO", "zoom_shutoff" );
1098 preferencesChanged( "HYDRO", "chained_panning" );
1100 QApplication::restoreOverrideCursor();
1103 void HYDROGUI_Module::updateCommandsStatus()
1105 LightApp_Module::updateCommandsStatus();
1107 updateUndoRedoControls();
1109 action( CopyId )->setEnabled( getDataModel()->canCopy() );
1110 action( PasteId )->setEnabled( getDataModel()->canPaste() );
1113 void HYDROGUI_Module::selectionChanged()
1115 LightApp_Module::selectionChanged();
1116 updateCommandsStatus();
1119 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
1121 return (HYDROGUI_DataModel*)dataModel();
1124 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
1129 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
1131 return myOCCDisplayer;
1134 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
1136 return myVTKDisplayer;
1139 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
1141 if( myViewManagerMap.contains( theId ) )
1143 return myViewManagerMap[ theId ].first;
1148 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
1150 if( myViewManagerMap.contains( theId ) )
1152 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1153 GraphicsView_ViewManager* aViewManager =
1154 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
1156 return aViewManager->getViewer();
1161 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
1163 if( myViewManagerMap.contains( theId ) )
1165 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1166 OCCViewer_ViewManager* aViewManager =
1167 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
1169 return aViewManager->getOCCViewer();
1174 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
1176 if( myViewManagerMap.contains( theId ) )
1178 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1179 SVTK_ViewManager* aViewManager =
1180 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
1182 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
1187 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
1189 ViewManagerMapIterator anIter( myViewManagerMap );
1190 while( anIter.hasNext() )
1192 int anId = anIter.next().key();
1193 const ViewManagerInfo& anInfo = anIter.value();
1194 if( anInfo.first == theViewManager )
1200 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
1202 int anId = getViewManagerId( theViewManager );
1205 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1206 return anInfo.second;
1211 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
1212 const ViewManagerRole theRole )
1214 int anId = getViewManagerId( theViewManager );
1217 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1218 anInfo.second = theRole;
1222 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
1223 const Handle(HYDROData_Entity)& theObject ) const
1225 if( theObject.IsNull() )
1231 foreach( int aViewId, myObjectStateMap.keys() )
1233 if( isObjectVisible( aViewId, theObject ) )
1239 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1240 if( anIter1 != myObjectStateMap.end() )
1242 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1243 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1245 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1246 if( anIter2 != aEntry2ObjectStateMap.end() )
1248 const ObjectState& anObjectState = anIter2.value();
1249 return anObjectState.Visibility;
1255 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1256 const Handle(HYDROData_Entity)& theObject,
1257 const bool theState )
1259 if( !theObject.IsNull() )
1261 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1262 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1264 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1265 anObjectState.Visibility = theState;
1267 HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1270 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1273 QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1274 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1275 if ( visState != Qtx::UnpresentableState )
1276 treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1280 if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1281 setLandCoversScalarMapModeOff( theViewId );
1282 } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) {
1283 getOCCDisplayer()->SetToUpdateColorScale();
1288 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1289 const bool theState )
1291 if( !theObject.IsNull() )
1293 // Process OCC shapes
1294 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1295 while( aShapesMapIter != myShapesMap.end() )
1297 const ListOfShapes& aShapesList = aShapesMapIter.value();
1298 foreach ( HYDROGUI_Shape* aShape, aShapesList )
1300 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1302 aShape->setIsToUpdate( theState );
1307 // Process VTK shapes
1308 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1309 while( aVTKPrsMapIter != myVTKPrsMap.end() )
1311 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1312 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1314 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1316 aShape->setIsToUpdate( theState );
1324 /////////////////// OCC SHAPES PROCESSING
1325 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
1326 ObjectKind theKind ) const
1328 QList<HYDROGUI_Shape*> aResult;
1330 if ( myShapesMap.contains( theViewId ) )
1332 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1333 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1335 if( aShape && aShape->getObject()->GetKind()==theKind )
1336 aResult.append( aShape );
1342 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
1343 const Handle(HYDROData_Entity)& theObject ) const
1345 HYDROGUI_Shape* aResShape = NULL;
1346 if( theObject.IsNull() )
1349 if ( myShapesMap.contains( theViewId ) )
1351 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1352 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1354 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1365 void HYDROGUI_Module::setObjectShape( const int theViewId,
1366 const Handle(HYDROData_Entity)& theObject,
1367 HYDROGUI_Shape* theShape )
1369 if( theObject.IsNull() )
1372 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1373 aViewShapes.append( theShape );
1376 void HYDROGUI_Module::removeObjectShape( const int theViewId,
1377 const Handle(HYDROData_Entity)& theObject )
1379 if ( !myShapesMap.contains( theViewId ) )
1382 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1383 Handle(HYDROData_Entity) anObject;
1384 for ( int i = 0; i < aViewShapes.length(); )
1386 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1387 anObject = aShape->getObject();
1388 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1391 aViewShapes.removeAt( i );
1399 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1401 if ( !myShapesMap.contains( theViewId ) )
1404 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1405 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1407 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1412 myShapesMap.remove( theViewId );
1414 /////////////////// END OF OCC SHAPES PROCESSING
1416 /////////////////// VTKPrs PROCESSING
1417 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
1418 const Handle(HYDROData_Entity)& theObject ) const
1420 HYDROGUI_VTKPrs* aResShape = NULL;
1421 if( theObject.IsNull() )
1424 if ( myVTKPrsMap.contains( theViewId ) )
1426 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1427 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1429 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1440 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1441 const Handle(HYDROData_Entity)& theObject,
1442 HYDROGUI_VTKPrs* theShape )
1444 if( theObject.IsNull() )
1447 if( theShape && theShape->needScalarBar() )
1449 // Compute the new global Z range from the added presentation and the old global Z range.
1450 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1451 double* aRange = theShape->getInternalZRange();
1452 bool anIsUpdate = false;
1453 if ( aRange[0] < aGlobalRange[0] )
1455 aGlobalRange[0] = aRange[0];
1458 if ( aRange[1] > aGlobalRange[1] )
1460 aGlobalRange[1] = aRange[1];
1466 updateVTKZRange( theViewId, aGlobalRange );
1470 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1471 aViewShapes.append( theShape );
1474 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1475 const QString& theEntry )
1477 if ( !myVTKPrsMap.contains( theViewId ) )
1480 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1481 Handle(HYDROData_Entity) anObject;
1483 for ( int i = 0; i < aViewShapes.length(); )
1485 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1486 anObject = aShape->getObject();
1487 anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1488 if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1491 aViewShapes.removeAt( i );
1498 // Invalidate global Z range
1499 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1500 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1503 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1504 const Handle(HYDROData_Entity)& theObject )
1506 if ( !myVTKPrsMap.contains( theViewId ) )
1509 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1510 Handle(HYDROData_Entity) anObject;
1511 for ( int i = 0; i < aViewShapes.length(); )
1513 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1514 anObject = aShape->getObject();
1515 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1518 aViewShapes.removeAt( i );
1525 // Invalidate global Z range
1526 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1527 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1530 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1532 if ( !myVTKPrsMap.contains( theViewId ) )
1535 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1536 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1538 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1543 myVTKPrsMap.remove( theViewId );
1546 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1548 if ( myVTKPrsMap.contains( theViewId ) )
1550 // For the given viewer id update all VTK presentations ...
1551 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1552 HYDROGUI_VTKPrs* aShape;
1553 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1555 aShape = aViewShapes.at( i );
1556 if ( aShape && aShape->needScalarBar() )
1558 aShape->setZRange( theRange );
1562 // ... and update the global color legend scalar bar.
1563 getVTKDisplayer()->SetZRange( theViewId, theRange );
1565 /////////////////// END OF VTKPrs PROCESSING
1567 void HYDROGUI_Module::clearCache()
1569 myObjectStateMap.clear();
1572 CAM_DataModel* HYDROGUI_Module::createDataModel()
1574 return new HYDROGUI_DataModel( this );
1577 void HYDROGUI_Module::customEvent( QEvent* e )
1579 int aType = e->type();
1580 if ( aType == NewViewEvent )
1582 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1583 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1585 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1587 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1588 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1590 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1592 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1593 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1595 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1596 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1597 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1599 //ouv: temporarily commented
1600 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1603 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1604 update( UF_Viewer );
1606 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1612 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1614 QEvent::Type aType = theEvent->type();
1615 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1617 if( aType == QEvent::Show )
1619 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1620 e->setData( theObj );
1621 QApplication::postEvent( this, e );
1622 theObj->removeEventFilter( this );
1625 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1627 if( aType == QEvent::Leave )
1629 SUIT_Desktop* aDesktop = getApp()->desktop();
1630 if ( aDesktop && aDesktop->statusBar() ) {
1631 aDesktop->statusBar()->clearMessage();
1635 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1637 if( aType == QEvent::Leave )
1639 SUIT_Desktop* aDesktop = getApp()->desktop();
1640 if ( aDesktop && aDesktop->statusBar() ) {
1641 aDesktop->statusBar()->clearMessage();
1646 return LightApp_Module::eventFilter( theObj, theEvent );
1649 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1651 LightApp_Module::onViewManagerAdded( theViewManager );
1653 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1655 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1656 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1658 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1660 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
1661 //mgr->setChainedOperations( true );
1663 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1664 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1665 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1666 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1667 connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
1668 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
1670 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1672 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1673 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1674 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1675 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1678 createSelector( theViewManager ); // replace the default selector
1680 ViewManagerInfo anInfo( theViewManager, VMR_General );
1681 myViewManagerMap.insert( ViewManagerId++, anInfo );
1684 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1686 LightApp_Module::onViewManagerRemoved( theViewManager );
1688 createSelector( theViewManager ); // replace the default selector
1690 int anId = getViewManagerId( theViewManager );
1693 OCCViewer_ViewManager* anOCCViewManager =
1694 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1695 if ( anOCCViewManager )
1697 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1698 if ( anOCCViewer ) {
1699 int aViewerId = (size_t)anOCCViewer;
1700 removeViewShapes( aViewerId );
1701 setLandCoversScalarMapModeOff( aViewerId );
1705 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1707 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1710 getVTKDisplayer()->EraseScalarBar( anId, true );
1711 removeViewShapes( (size_t)aVTKViewer );
1715 myViewManagerMap.remove( anId );
1719 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1721 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1723 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1725 aViewFrame->installEventFilter( this );
1727 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1728 aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
1730 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1731 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1734 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1736 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1738 aViewFrame->onTopView();
1740 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1741 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1743 aViewPort->installEventFilter( this );
1747 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1749 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1751 aViewFrame->installEventFilter( this );
1756 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1758 /* ouv: currently unused
1759 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1761 SUIT_ViewManager* aViewManager = 0;
1763 QObject* aParent = aViewPort;
1764 while( aParent = aParent->parent() )
1766 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1768 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1770 aViewManager = aViewer->getViewManager();
1779 double aMouseX = theEvent->scenePos().x();
1780 double aMouseY = theEvent->scenePos().y();
1782 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1783 if( aRole == VMR_General )
1785 int aXDeg = 0, aYDeg = 0;
1786 int aXMin = 0, aYMin = 0;
1787 double aXSec = 0, aYSec = 0;
1788 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1789 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1791 QString aDegSymbol( QChar( 0x00B0 ) );
1792 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1793 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1795 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1797 else if( aRole == VMR_TransformImage )
1798 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1803 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1804 const bool theIsInit,
1805 const bool theIsForced,
1806 const bool theDoFitAll )
1808 QList<int> aViewManagerIdList;
1810 // currently, all views are updated
1811 ViewManagerMapIterator anIter( myViewManagerMap );
1812 while( anIter.hasNext() )
1814 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1816 if ( theDisplayer->IsApplicable( aViewManager ) )
1818 int anId = anIter.key();
1819 aViewManagerIdList.append( anId );
1823 QListIterator<int> anIdIter( aViewManagerIdList );
1824 while( anIdIter.hasNext() )
1826 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1827 myOverview->setTopView();
1831 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1833 if( !theViewManager )
1836 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1837 if( !aSelectionMgr )
1840 QString aViewType = theViewManager->getType();
1841 if( aViewType != GraphicsView_Viewer::Type() &&
1842 aViewType != OCCViewer_Viewer::Type())
1845 QList<SUIT_Selector*> aSelectorList;
1846 aSelectionMgr->selectors( aViewType, aSelectorList );
1848 // disable all alien selectors
1849 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1850 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1852 SUIT_Selector* aSelector = *anIter;
1853 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1854 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1855 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1856 aSelector->setEnabled( false );
1859 if ( aViewType == GraphicsView_Viewer::Type() )
1861 GraphicsView_ViewManager* aViewManager =
1862 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1864 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1866 else if ( aViewType == OCCViewer_Viewer::Type() )
1868 OCCViewer_ViewManager* aViewManager =
1869 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1871 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1875 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1877 bool aPrevState = myIsUpdateEnabled;
1878 myIsUpdateEnabled = theState;
1882 bool HYDROGUI_Module::isUpdateEnabled() const
1884 return myIsUpdateEnabled;
1887 QStringList HYDROGUI_Module::storeSelection() const
1889 QStringList anEntryList;
1890 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1892 SUIT_DataOwnerPtrList aList( true );
1893 aSelectionMgr->selected( aList );
1895 SUIT_DataOwnerPtrList::iterator anIter;
1896 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1898 const LightApp_DataOwner* anOwner =
1899 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1901 anEntryList.append( anOwner->entry() );
1907 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1909 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1911 SUIT_DataOwnerPtrList aList( true );
1912 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1913 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1914 aSelectionMgr->setSelected( aList );
1918 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1921 bool doShow = false;
1922 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1924 aDisplayer->SaveCursorViewPosition( theViewWindow );
1925 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1929 // Show the coordinates in the status bar
1930 SUIT_Desktop* aDesktop = getApp()->desktop();
1931 if ( aDesktop && aDesktop->statusBar() )
1933 gp_Pnt aWPnt( X, Y, Z );
1934 int aStudyId = application()->activeStudy()->id();
1935 HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
1936 double WX = aWPnt.X(), WY = aWPnt.Y();
1938 QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1939 QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1940 QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1941 QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1942 QString aMsg = tr( "COORDINATES_INFO" );
1943 aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1944 aDesktop->statusBar()->showMessage( aMsg );
1950 * Returns stack of active operations;
1952 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
1954 return myActiveOperationMap;
1958 * Returns the module active operation. If the active operation is show/hide,
1959 * the method returns the previous operation if it is.
1961 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
1963 HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
1965 if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
1967 QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
1969 aVIt.previous(); // skip the top show/hide operation
1970 anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
1977 * \brief Virtual public slot
1979 * This method is called after the object inserted into data view to update their visibility state
1980 * This is default implementation
1982 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
1984 if ( !isActiveModule() )
1987 HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
1989 // change visibility of object
1990 if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
1993 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1995 QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
1996 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1997 if ( visState == Qtx::UnpresentableState )
2000 visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
2001 treeModel->setVisibilityState( id, visState );
2003 bool vis = visState == Qtx::ShownState;
2004 if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
2007 setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
2009 update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
2012 bool HYDROGUI_Module::isDraggable( const SUIT_DataObject* what ) const
2017 bool HYDROGUI_Module::isDropAccepted( const SUIT_DataObject* where ) const
2023 void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
2024 const int row, Qt::DropAction action )
2026 if ( action != Qt::CopyAction && action != Qt::MoveAction )
2032 if (where->level() < 2 )
2035 DataObjectList::ConstIterator it = what.constBegin();
2036 for (;it != what.constEnd();++it)
2038 if ((*it)->parent() != where)
2042 it = what.constBegin();
2045 for (;it != what.constEnd();++it)
2047 SUIT_DataObject* objWhat = *it;
2049 DataObjectList objInSect = where->children();
2051 //std::list<SUIT_DataObject*> t1 = where->children().toStdList(); //debug
2052 int ind = objInSect.indexOf(objWhat);
2055 HYDROGUI_DataModel* aModel = getDataModel();
2064 where->moveChildPos(objWhat, pos);
2065 //std::list<SUIT_DataObject*> t2 = where->children().toStdList(); //debug
2069 getApp()->updateObjectBrowser(true);
2073 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
2075 Handle(HYDROData_StricklerTable) aTable;
2077 if ( myLandCoverColoringMap.contains( theViewId ) ) {
2078 aTable = myLandCoverColoringMap.value( theViewId );
2084 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
2085 const Handle(HYDROData_StricklerTable)& theTable )
2087 if ( !theTable.IsNull() ) {
2088 myLandCoverColoringMap.insert( theViewId, theTable );
2092 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
2094 myLandCoverColoringMap.remove( theViewId );
2097 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
2099 return myLandCoverColoringMap.contains( theViewId );
2102 void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
2104 if ( theObject.IsNull() || !theObject->IsRemoved() ) {
2108 if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
2109 Handle(HYDROData_StricklerTable) aTable =
2110 Handle(HYDROData_StricklerTable)::DownCast( theObject );
2111 QList<int> aViewIds;
2112 QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
2113 while ( anIter.hasNext() ) {
2114 if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
2115 HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
2122 void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
2127 SUIT_ViewWindow* wnd = theMgr->getActiveView();
2128 OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
2132 myOverview->setMainView( occwnd );
2135 void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
2137 ViewManagerList aViewManagers = getApp()->viewManagers();
2138 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
2139 setAutoZoom(aVMgr, bAutoZoom);
2142 void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
2146 QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
2147 foreach (SUIT_ViewWindow* aView, aViews)
2151 OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
2154 anOCCViewFrame->setAutomaticZoom(bAutoZoom);
2155 for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
2157 OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
2159 aV->setAutomaticZoom(bAutoZoom);
2162 OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
2163 if (anOCCViewWindow)
2164 anOCCViewWindow->setAutomaticZoom(bAutoZoom);