1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_Module.h"
22 #include "HYDROGUI_DataModel.h"
23 #include "HYDROGUI_DataObject.h"
24 #include "HYDROGUI_Displayer.h"
25 #include "HYDROGUI_GVSelector.h"
26 #include "HYDROGUI_InputPanel.h"
27 #include "HYDROGUI_ObjSelector.h"
28 #include "HYDROGUI_OCCDisplayer.h"
29 #include "HYDROGUI_OCCSelector.h"
30 #include "HYDROGUI_Operations.h"
31 #include "HYDROGUI_PrsImage.h"
32 #include "HYDROGUI_Tool.h"
33 #include "HYDROGUI_Tool2.h"
34 #include "HYDROGUI_UpdateFlags.h"
35 #include "HYDROGUI_Shape.h"
36 #include "HYDROGUI_VTKPrs.h"
37 #include "HYDROGUI_VTKPrsDisplayer.h"
38 #include "HYDROGUI_AbstractDisplayer.h"
39 #include "HYDROGUI_PolylineOp.h"
40 #include "HYDROGUI_SetColorOp.h"
41 #include "HYDROGUI_ImportGeomObjectOp.h"
42 #include "HYDROGUI_ShowHideOp.h"
43 #include "HYDROGUI_Overview.h"
44 #include <HYDROGUI_ProfileDlg.h>
45 #include <HYDROData_Tool.h>
46 #include <HYDROData_Image.h>
47 #include <HYDROData_Stream.h>
48 #include <HYDROData_Profile.h>
49 #include <HYDROData_Lambert93.h>
50 #include <HYDROData_Polyline3D.h>
51 #include <HYDROData_StricklerTable.h>
52 #include <HYDROData_ArtificialObject.h>
53 #include <HYDROData_NaturalObject.h>
55 #include <HYDROData_OperationsFactory.h>
57 #include <CurveCreator_Utils.hxx>
59 #include <GraphicsView_ViewFrame.h>
60 #include <GraphicsView_ViewManager.h>
61 #include <GraphicsView_ViewPort.h>
62 #include <GraphicsView_Viewer.h>
64 #include <ImageComposer_CutOperator.h>
65 #include <ImageComposer_CropOperator.h>
66 #include <ImageComposer_FuseOperator.h>
68 #include <LightApp_Application.h>
69 #include <LightApp_DataOwner.h>
70 #include <LightApp_GVSelector.h>
71 #include <LightApp_SelectionMgr.h>
72 #include <LightApp_UpdateFlags.h>
74 #include <SalomeApp_Study.h>
76 #include <OCCViewer_ViewFrame.h>
77 #include <OCCViewer_ViewManager.h>
78 #include <OCCViewer_ViewModel.h>
80 #include <SALOME_Event.h>
82 #include <SUIT_DataBrowser.h>
83 #include <SUIT_DataObject.h>
84 #include <SUIT_ViewManager.h>
85 #include <SUIT_ResourceMgr.h>
86 #include <SUIT_Desktop.h>
87 #include <SUIT_Study.h>
88 #include <SUIT_Session.h>
90 #include <SVTK_ViewManager.h>
91 #include <SVTK_ViewModel.h>
92 #include <SVTK_ViewWindow.h>
93 #include <SVTK_Selector.h>
95 #include <OCCViewer_ViewPort3d.h>
97 #include <GEOMUtils.hxx>
98 #include <GeometryGUI.h>
100 #include <SALOMEDS_wrap.hxx>
103 #include <QApplication>
104 #include <QGraphicsSceneMouseEvent>
106 #include <QMouseEvent>
107 #include <QStatusBar>
110 static int ViewManagerId = 0;
112 extern "C" HYDRO_EXPORT CAM_Module* createModule()
114 return new HYDROGUI_Module();
117 extern "C" HYDRO_EXPORT char* getModuleVersion()
119 return (char*)HYDRO_VERSION;
122 HYDROGUI_Module::HYDROGUI_Module()
123 : LightApp_Module( "HYDRO" ),
126 myIsUpdateEnabled( true ),
131 HYDROGUI_Module::~HYDROGUI_Module()
135 int HYDROGUI_Module::getStudyId() const
137 LightApp_Application* anApp = getApp();
138 return anApp ? anApp->activeStudy()->id() : 0;
141 void HYDROGUI_Module::initialize( CAM_Application* theApp )
143 LightApp_Module::initialize( theApp );
146 createUndoRedoActions();
151 setMenuShown( false );
152 setToolShown( false );
154 myDisplayer = new HYDROGUI_Displayer( this );
155 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
156 myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
159 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
161 bool aRes = LightApp_Module::activateModule( theStudy );
163 LightApp_Application* anApp = getApp();
164 SUIT_Desktop* aDesktop = anApp->desktop();
166 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
168 setMenuShown( true );
169 setToolShown( true );
171 #ifndef DISABLE_PYCONSOLE
172 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
173 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
176 // Remove defunct view managers from the map.
177 // It's essential to do this before "update( UF_All )" call!
178 QList<int> anObsoleteIds;
179 ViewManagerList anAllViewManagers = anApp->viewManagers();
180 ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
181 ViewManagerMapIterator anIter( myViewManagerMap );
182 while( anIter.hasNext() ) {
183 int anId = anIter.next().key();
184 const ViewManagerInfo& anInfo = anIter.value();
186 aHydroViewManagers << anInfo.first;
188 if ( !anAllViewManagers.contains( anInfo.first ) ) {
189 anObsoleteIds << anId;
192 foreach ( const int anId, anObsoleteIds ) {
193 myViewManagerMap.remove( anId );
194 myObjectStateMap.remove( anId );
195 myShapesMap.remove( anId );
196 myVTKPrsMap.remove( anId );
198 // Replace the default selector for all view managers.
199 // Add view managers created outside of HYDRO module to the map.
200 foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
201 createSelector( aViewManager ); // replace the default selector
202 if ( !aHydroViewManagers.contains( aViewManager ) ) {
203 ViewManagerInfo anInfo( aViewManager, VMR_General );
204 myViewManagerMap.insert( ViewManagerId++, anInfo );
210 updateCommandsStatus();
212 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
214 ViewManagerList anOCCViewManagers;
215 anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
217 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
219 connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
220 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
221 connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
222 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
224 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
227 occ_mgr->setChainedOperations( true );//TODO: via preferences
230 foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() )
232 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
233 if ( aViewFrame && aViewFrame->getViewPort() )
235 aViewFrame->getViewPort()->installEventFilter( this );
240 preferencesChanged( "HYDRO", "zoom_shutoff" );
242 preferencesChanged( "HYDRO", "chained_panning" );
245 SalomeApp_Study* aStudy =
246 dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
248 SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
249 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
250 if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
251 SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
252 SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
253 if( !GEOM_var->_is_nil() ) {
254 aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
260 // SUIT_DataBrowser* ob = getApp()->objectBrowser();
261 // SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
262 // treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
267 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
270 ViewManagerMapIterator anIter( myViewManagerMap );
271 while( anIter.hasNext() )
272 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
273 getApp()->removeViewManager( aViewManager );
274 myViewManagerMap.clear();
277 ViewManagerList anOCCViewManagers;
278 getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
279 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
281 disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
282 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
284 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
287 occ_mgr->setChainedOperations( false );
288 setAutoZoom( occ_mgr, true );
293 myObjectStateMap.clear();
298 // clear the status bar
299 SUIT_Desktop* aDesktop = getApp()->desktop();
300 if ( aDesktop && aDesktop->statusBar() ) {
301 aDesktop->statusBar()->clearMessage();
304 // clear the data model's list of copying objects
305 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
307 setMenuShown( false );
308 setToolShown( false );
310 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
312 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
314 myActiveOperationMap.clear();
316 myViewManagerMap.clear();
318 return LightApp_Module::deactivateModule( theStudy );
321 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
323 static bool inWindows = false;
328 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
329 #ifndef DISABLE_PYCONSOLE
330 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
332 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
333 theMap.insert( OverviewWindow, Qt::LeftDockWidgetArea );
336 LightApp_Application* app = getApp();
337 if( app && app->getWindow( OverviewWindow )==0 )
339 const_cast<HYDROGUI_Module*>( this )->myOverview =
340 new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() );
341 app->insertDockWindow( OverviewWindow, myOverview );
342 app->placeDockWindow( OverviewWindow, Qt::LeftDockWidgetArea );
347 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
349 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
352 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
356 HYDROGUI_DataModel* aModel = getDataModel();
358 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
359 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
360 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
361 bool anIsVTKView = theClient == SVTK_Viewer::Type();
362 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
365 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
367 bool anIsSelectedDataObjects = false;
368 bool anIsVisibleInSelection = false;
369 bool anIsHiddenInSelection = false;
371 bool anIsImage = false;
372 bool anIsImportedImage = false;
373 bool anIsImageHasRefs = false;
374 bool anIsFusedImage = false;
375 bool anIsCutImage = false;
376 bool anIsSplitImage = false;
377 bool anIsMustObjectBeUpdated = false;
378 bool anIsPolyline = false;
379 bool anIsPolyline3D = false;
380 bool anIsProfile = false;
381 bool anIsValidProfile = false;
382 bool anAllAreProfiles = false;
383 bool anIsBathymetry = false;
384 bool anIsCalculation = false;
385 bool anIsImmersibleZone = false;
386 bool anIsVisualState = false;
387 bool anIsRegion = false;
388 bool anIsZone = false;
389 bool anIsObstacle = false;
390 bool anIsStricklerTable = false;
391 bool anIsLandCoverMap = false;
392 bool anIsStream = false;
393 bool anIsChannel = false;
394 bool anIsDigue = false;
395 bool anIsDummyObject3D = false;
396 bool anIsGroup = false;
397 bool anIsObjectCanBeColored = false;
399 bool isStreamHasBottom = false;
400 bool anIsBCPolygon = false;
402 SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
403 SUIT_DataOwnerPtrList anOwners;
404 aSelectionMgr->selected( anOwners );
405 if( anIsObjectBrowser && anOwners.size()==1 )
407 QString anEntry = anOwners[0]->keyString();
408 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
410 isRoot = aStudy->isComponent( anEntry );
413 // Check the selected GEOM objects (take into account the Object Browser only)
414 if ( anIsObjectBrowser ) {
415 QList<GEOM::shape_type> anObstacleTypes =
416 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
417 QList<GEOM::shape_type> aPolylineTypes =
418 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
420 bool isCanBeImportedAsObstacle =
421 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
422 bool isCanBeImportedAsPolyline =
423 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
425 // Add import as obstacle action
426 if ( isCanBeImportedAsObstacle ) {
427 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
429 // Add import as polyline action
430 if ( isCanBeImportedAsPolyline ) {
431 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
434 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
435 theMenu->addSeparator();
439 // check the selected data model objects
440 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
441 int aNbOfSelectedProfiles = 0;
442 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
444 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
445 if( !anObject.IsNull() )
447 anIsSelectedDataObjects = true;
449 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
450 anIsVisibleInSelection |= aVisibility;
451 anIsHiddenInSelection |= !aVisibility;
453 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
455 anIsMustObjectBeUpdated = true;
458 ObjectKind anObjectKind = anObject->GetKind();
459 if( anObjectKind == KIND_IMAGE )
462 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
463 if( !anImage.IsNull() )
465 anIsImportedImage = anImage->HasLocalPoints();
466 anIsImageHasRefs = anImage->HasReferences();
467 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
469 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
471 QString anOperatorName = anOperator->name();
472 if( anOperatorName == ImageComposer_FuseOperator::Type() )
473 anIsFusedImage = true;
474 else if( anOperatorName == ImageComposer_CutOperator::Type() )
476 else if( anOperatorName == ImageComposer_CropOperator::Type() )
477 anIsSplitImage = true;
482 else if( anObjectKind == KIND_POLYLINEXY )
484 else if( anObjectKind == KIND_POLYLINE )
485 anIsPolyline3D = true;
486 else if( anObjectKind == KIND_PROFILE )
489 aNbOfSelectedProfiles++;
491 Handle(HYDROData_Profile) aProfile =
492 Handle(HYDROData_Profile)::DownCast( anObject );
493 if( !aProfile.IsNull() && aProfile->IsValid() ) {
494 anIsValidProfile = true;
497 else if( anObjectKind == KIND_CALCULATION )
498 anIsCalculation = true;
499 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
500 anIsImmersibleZone = true;
501 else if( anObjectKind == KIND_VISUAL_STATE )
502 anIsVisualState = true;
503 else if( anObjectKind == KIND_REGION )
505 else if( anObjectKind == KIND_ZONE )
507 else if( anObjectKind == KIND_BATHYMETRY )
508 anIsBathymetry = true;
509 else if( anObjectKind == KIND_OBSTACLE )
511 else if( anObjectKind == KIND_STRICKLER_TABLE )
512 anIsStricklerTable = true;
513 else if( anObjectKind == KIND_LAND_COVER_MAP )
514 anIsLandCoverMap = true;
515 else if (anObjectKind == KIND_BC_POLYGON)
516 anIsBCPolygon = true;
517 else if( anObjectKind == KIND_STREAM )
520 Handle(HYDROData_Stream) aStream =
521 Handle(HYDROData_Stream)::DownCast( anObject );
522 if ( !aStream.IsNull() )
523 isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
525 else if( anObjectKind == KIND_CHANNEL )
527 else if( anObjectKind == KIND_DIGUE )
529 else if( anObjectKind == KIND_DUMMY_3D )
530 anIsDummyObject3D = true;
531 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLIT_GROUP )
535 if ( !anIsObjectCanBeColored )
536 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject, this );
539 // Check if all selected objects are profiles
540 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
541 ( aNbOfSelectedProfiles == aSeq.Length() );
543 // check the selected partitions
544 if( !anIsSelectedDataObjects && anIsObjectBrowser )
546 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
547 if( aSelectedPartition != KIND_UNKNOWN )
549 switch( aSelectedPartition )
552 theMenu->addAction( action( ImportImageId ) );
554 case KIND_BATHYMETRY:
555 theMenu->addAction( action( ImportBathymetryId ) );
557 case KIND_ARTIFICIAL_OBJECT:
558 theMenu->addAction( action( CreateChannelId ) );
559 theMenu->addAction( action( CreateDigueId ) );
561 case KIND_NATURAL_OBJECT:
562 theMenu->addAction( action( CreateImmersibleZoneId ) );
563 theMenu->addAction( action( CreateStreamId ) );
566 theMenu->addAction( action( ImportObstacleFromFileId ) );
567 theMenu->addAction( action( CreateBoxId ) );
568 theMenu->addAction( action( CreateCylinderId ) );
570 case KIND_STRICKLER_TABLE:
571 theMenu->addAction( action( ImportStricklerTableFromFileId ) );
573 case KIND_LAND_COVER_MAP:
574 theMenu->addAction( action( CreateLandCoverMapId ) );
575 theMenu->addAction( action( ImportLandCoverMapId ) );
577 case KIND_CALCULATION:
578 theMenu->addAction( action( CreateCalculationId ) );
580 case KIND_POLYLINEXY:
581 theMenu->addAction( action( ImportPolylineId ) );
582 theMenu->addAction( action( CreatePolylineId ) );
585 theMenu->addAction( action( CreatePolyline3DId ) );
588 theMenu->addAction( action( CreateProfileId ) );
589 theMenu->addAction( action( ImportProfilesId ) );
590 theMenu->addAction( action( AllGeoreferencementId ) );
592 case KIND_VISUAL_STATE:
593 theMenu->addAction( action( SaveVisualStateId ) );
595 case KIND_BC_POLYGON:
596 theMenu->addAction( action( ImportBCPolygonId ) );
599 theMenu->addSeparator();
603 Handle(HYDROData_CalculationCase) aCalcCase;
605 HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr);
606 if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION ))
607 theMenu->addAction( action( RegenerateRegionColorsId ) );
611 if( anIsSelectedDataObjects )
613 if ( anIsMustObjectBeUpdated )
615 theMenu->addAction( action( UpdateObjectId ) );
616 theMenu->addSeparator();
620 theMenu->addAction( action( ForcedUpdateObjectId ) );
621 theMenu->addSeparator();
625 if( aSeq.Length() == 1 )
629 if( anIsImportedImage )
630 theMenu->addAction( action( EditImportedImageId ) );
631 else if( anIsImageHasRefs )
634 theMenu->addAction( action( EditFusedImageId ) );
635 else if( anIsCutImage )
636 theMenu->addAction( action( EditCutImageId ) );
637 else if( anIsSplitImage )
638 theMenu->addAction( action( EditSplitImageId ) );
641 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
642 theMenu->addAction( action( ExportImageId ) );
643 theMenu->addSeparator();
645 if( anIsImageHasRefs )
647 theMenu->addAction( action( RemoveImageRefsId ) );
648 theMenu->addSeparator();
651 theMenu->addAction( action( FuseImagesId ) );
652 theMenu->addAction( action( CutImagesId ) );
653 theMenu->addAction( action( SplitImageId ) );
654 theMenu->addSeparator();
655 theMenu->addAction( action( RecognizeContoursId ) );
656 theMenu->addSeparator();
658 else if( anIsBathymetry )
660 theMenu->addAction( action( EditImportedBathymetryId ) );
661 theMenu->addAction( action( BathymetryBoundsId ) );
662 theMenu->addSeparator();
664 else if( anIsPolyline )
666 theMenu->addAction( action( EditPolylineId ) );
667 theMenu->addSeparator();
668 theMenu->addAction( action( SplitPolylinesId ) );
669 theMenu->addAction( action( MergePolylinesId ) );
670 theMenu->addSeparator();
671 theMenu->addAction( action( ShowAttrPolylinesId ) );
672 theMenu->addSeparator();
674 else if( anIsPolyline3D )
676 theMenu->addAction( action( EditPolyline3DId ) );
677 theMenu->addSeparator();
679 else if( anIsProfile )
681 theMenu->addAction( action( EditProfileId ) );
682 theMenu->addAction( action( SelectedGeoreferencementId ) );
683 theMenu->addSeparator();
685 else if( anIsCalculation )
687 theMenu->addAction( action( EditCalculationId ) );
688 theMenu->addAction( action( ExportCalculationId ) );
689 theMenu->addSeparator();
691 else if( anIsImmersibleZone )
693 theMenu->addAction( action( EditImmersibleZoneId ) );
694 theMenu->addSeparator();
696 else if( anIsStream )
698 theMenu->addAction( action( EditStreamId ) );
699 if ( action( RiverBottomContextId ) )
701 theMenu->addAction( action( RiverBottomContextId ) );
702 action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
704 theMenu->addAction( action( ProfileInterpolateId ) );
705 theMenu->addSeparator();
707 else if( anIsChannel )
709 theMenu->addAction( action( EditChannelId ) );
710 theMenu->addSeparator();
714 theMenu->addAction( action( EditDigueId ) );
715 theMenu->addSeparator();
717 else if( anIsObstacle )
719 theMenu->addAction( action( TranslateObstacleId ) );
720 theMenu->addSeparator();
722 else if( anIsStricklerTable )
724 theMenu->addAction( action( EditStricklerTableId ) );
725 theMenu->addAction( action( ExportStricklerTableFromFileId ) );
726 theMenu->addAction( action( DuplicateStricklerTableId ) );
727 theMenu->addSeparator();
729 Handle(HYDROData_StricklerTable) aTable =
730 Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
731 QString aCurrentTable =
732 HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
733 bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
735 if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER_MAP ).isEmpty() ) {
736 theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
737 theMenu->addSeparator();
740 else if( anIsLandCoverMap )
742 theMenu->addAction( action( AddLandCoverId ) );
743 theMenu->addAction( action( RemoveLandCoverId ) );
744 theMenu->addSeparator();
745 theMenu->addAction( action( SplitLandCoverId ) );
746 theMenu->addAction( action( MergeLandCoverId ) );
747 theMenu->addAction( action( ChangeLandCoverTypeId ) );
748 theMenu->addSeparator();
750 theMenu->addAction( action( ExportToShapeFileID ) );
751 theMenu->addSeparator();
753 else if( anIsVisualState && anIsObjectBrowser )
755 theMenu->addAction( action( SaveVisualStateId ) );
756 theMenu->addAction( action( LoadVisualStateId ) );
757 theMenu->addSeparator();
760 theMenu->addAction( action( ZoneSetColorId ) );
761 else if (anIsBCPolygon)
762 theMenu->addAction( action( SetBoundaryTypePolygonId ) );
764 if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
766 theMenu->addAction( action( PolylineExtractionId ) );
767 theMenu->addSeparator();
770 // Add set color action for geometrical objects
771 if ( anIsObjectCanBeColored )
773 theMenu->addAction( action( SetColorId ) );
774 theMenu->addSeparator();
777 // Add transparency action for land cover map objects
778 if ( anIsLandCoverMap )
780 theMenu->addAction( action( SetTransparencyId ) );
781 theMenu->addSeparator();
784 else if ( anAllAreProfiles )
786 theMenu->addAction( action( EditProfileId ) );
787 theMenu->addAction( action( SelectedGeoreferencementId ) );
788 theMenu->addSeparator();
791 bool isPoly = anIsPolyline || anIsPolyline3D;
792 if (isPoly && !anIsLandCoverMap)
793 theMenu->addAction( action( ExportToShapeFileID ) );
796 QAction* aCopyAction = action( CopyId );
797 if( aCopyAction && aCopyAction->isEnabled() ) {
798 theMenu->addAction( action( CopyId ) );
799 theMenu->addSeparator();
803 if( !anIsDummyObject3D )
804 theMenu->addAction( action( DeleteId ) );
806 theMenu->addSeparator();
808 if( anIsImage || anIsPolyline || anIsPolyline3D ||
809 anIsImmersibleZone || anIsZone || anIsRegion ||
810 anIsBathymetry || anIsObstacle || anIsStream ||
811 anIsChannel || anIsDigue || anIsDummyObject3D ||
812 anIsValidProfile || anIsGroup || anIsLandCoverMap ||
815 if( anIsHiddenInSelection )
816 theMenu->addAction( action( ShowId ) );
817 theMenu->addAction( action( ShowOnlyId ) );
818 if( anIsVisibleInSelection )
819 theMenu->addAction( action( HideId ) );
820 theMenu->addSeparator();
826 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
827 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
828 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
829 theMenu->addAction( action( DeleteId ) );
831 theMenu->addSeparator();
832 theMenu->addAction( action( SetZLevelId ) );
833 theMenu->addSeparator();
835 if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
836 theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
837 theMenu->addSeparator();
841 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
843 theMenu->addAction( action( ShowAllId ) );
844 theMenu->addAction( action( HideAllId ) );
845 theMenu->addSeparator();
848 if ( anIsOCCView || anIsVTKView )
850 theMenu->addSeparator();
851 theMenu->addAction( action( CopyViewerPositionId ) );
855 theMenu->addAction( action( EditLocalCSId ) );
857 if( anIsObjectBrowser && anOwners.size()==1 )
859 if( aSeq.Size() > 0 )
861 Handle( HYDROData_Entity ) aFirstEnt = aSeq.First();
862 Handle(HYDROData_Object) anObject;
863 Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt);
864 Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt);
866 if (!anAObject.IsNull())
867 anObject = anAObject;
868 if (!aNObject.IsNull())
871 if( !anObject.IsNull() )
873 theMenu->addSeparator();
874 bool IsSubmersible = anObject->IsSubmersible();
877 theMenu->addAction( action( SubmersibleId ) );
878 action( SubmersibleId )->setCheckable(true);
879 action( SubmersibleId )->setChecked(true);
883 theMenu->addAction( action( UnSubmersibleId ) );
884 action( UnSubmersibleId )->setCheckable(true);
885 action( UnSubmersibleId )->setChecked(true);
891 theMenu->addSeparator();
892 QAction* a = action( ShowHideArrows );
893 a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
894 theMenu->addAction( a );
897 void HYDROGUI_Module::createPreferences()
899 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
900 int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
902 int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
903 LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
905 // Set property cursor type
906 QList<QVariant> aCursorTypeIndicesList;
907 QList<QVariant> aCursorTypeIconsList;
909 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
910 for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
911 QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
912 QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
913 aCursorTypeIndicesList << i;
914 aCursorTypeIconsList << pixmap;
917 setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
918 setPreferenceProperty( typeOfCursor, "icons", aCursorTypeIconsList );
920 int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
921 addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
922 LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
924 addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
926 addPreference( tr( "PREF_VIEWER_CHAINED_PANNING" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "chained_panning" );
928 int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
929 int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
930 LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
931 setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
932 setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
933 setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
934 setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
936 int polylinesGroup = addPreference( tr( "PREF_GROUP_POLYLINES" ), genTab );
937 int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
938 LightApp_Preferences::Selector, "polyline", "arrow_type" );
940 QList<QVariant> arrow_types;
941 arrow_types.append( tr( "No" ) );
942 arrow_types.append( tr( "Triangle" ) );
943 arrow_types.append( tr( "Cone" ) );
944 setPreferenceProperty( polylineArrow, "strings", arrow_types );
946 QList<QVariant> indices;
950 setPreferenceProperty( polylineArrow, "indexes", indices );
951 setPreferenceProperty( polylineArrow, "ids", indices );
953 int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup,
954 LightApp_Preferences::IntSpin, "polyline", "arrow_size" );
957 void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
959 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
960 if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
963 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
964 if ( resMgr && !aDoc.IsNull() )
965 aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
967 else if( theSection == "polyline" )
973 resMgr->value( "polyline", "arrow_type", aType );
974 resMgr->value( "polyline", "arrow_size", aSize );
977 ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end();
978 for( ; it!=last; it++ )
980 int aViewerId = it.key();
981 OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( it.value().first );
983 getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
986 else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
988 bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
989 setAutoZoomToAllViewManagers(!aZoomShutoff);
991 else if (theSection == "HYDRO" && thePref == "chained_panning")
993 bool aChainedPan = resMgr->booleanValue( "HYDRO", "chained_panning" );
996 ViewManagerList aViewManagers = getApp()->viewManagers();
997 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
999 OCCViewer_ViewManager* anOCCViewMgr = dynamic_cast<OCCViewer_ViewManager*>( aVMgr );
1001 anOCCViewMgr->setChainedOperations( aChainedPan );
1004 QList<QDockWidget*> docW = getApp()->desktop()->findChildren<QDockWidget*>();
1005 foreach (QDockWidget* qw, docW)
1007 HYDROGUI_ProfileDlg* pdlg = dynamic_cast<HYDROGUI_ProfileDlg*>(qw);
1009 pdlg->viewManager()->setChainedOperations(aChainedPan);
1013 LightApp_Module::preferencesChanged( theSection, thePref );
1016 QCursor HYDROGUI_Module::getPrefEditCursor() const
1018 int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
1019 if ( aCursorType >= Qt::BlankCursor)
1021 QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
1025 void HYDROGUI_Module::update( const int flags )
1027 if ( !isUpdateEnabled() )
1030 QApplication::setOverrideCursor( Qt::WaitCursor );
1032 // To prevent calling this method recursively
1033 // from one of the methods called below
1034 setUpdateEnabled( false );
1036 // store selected objects
1037 QStringList aSelectedEntries = storeSelection();
1039 bool aDoFitAll = flags & UF_FitAll;
1042 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1043 aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
1046 if( ( flags & UF_Viewer ) )
1047 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
1049 if( ( flags & UF_OCCViewer ) )
1050 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
1052 if( ( flags & UF_VTKViewer ) )
1053 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
1055 if( ( flags & UF_Model ) && getDataModel() && getApp() )
1057 getDataModel()->update( getStudyId() );
1059 // Temporary workaround to prevent breaking
1060 // the selection in the object browser.
1061 // Note: processEvents() should be called after updateGV(),
1062 // otherwise the application crashes from time to time.
1063 //RKV: qApp->processEvents();
1064 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1065 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
1066 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
1067 if ( isResizeOnExpandItem && anObjectBrowser ) {
1068 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
1070 getApp()->updateObjectBrowser( true );
1071 if ( isResizeOnExpandItem && anObjectBrowser ) {
1072 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
1076 // Object browser is currently updated by using UF_Model flag
1077 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
1078 getApp()->updateObjectBrowser( true );
1080 if( ( flags & UF_Controls ) && getApp() )
1081 getApp()->updateActions();
1083 // restore selected objects
1084 restoreSelection( aSelectedEntries );
1086 setUpdateEnabled( true );
1088 preferencesChanged( "HYDRO", "zoom_shutoff" );
1090 preferencesChanged( "HYDRO", "chained_panning" );
1092 QApplication::restoreOverrideCursor();
1095 void HYDROGUI_Module::updateCommandsStatus()
1097 LightApp_Module::updateCommandsStatus();
1099 updateUndoRedoControls();
1101 action( CopyId )->setEnabled( getDataModel()->canCopy() );
1102 action( PasteId )->setEnabled( getDataModel()->canPaste() );
1105 void HYDROGUI_Module::selectionChanged()
1107 LightApp_Module::selectionChanged();
1108 updateCommandsStatus();
1111 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
1113 return (HYDROGUI_DataModel*)dataModel();
1116 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
1121 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
1123 return myOCCDisplayer;
1126 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
1128 return myVTKDisplayer;
1131 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
1133 if( myViewManagerMap.contains( theId ) )
1135 return myViewManagerMap[ theId ].first;
1140 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
1142 if( myViewManagerMap.contains( theId ) )
1144 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1145 GraphicsView_ViewManager* aViewManager =
1146 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
1148 return aViewManager->getViewer();
1153 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
1155 if( myViewManagerMap.contains( theId ) )
1157 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1158 OCCViewer_ViewManager* aViewManager =
1159 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
1161 return aViewManager->getOCCViewer();
1166 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
1168 if( myViewManagerMap.contains( theId ) )
1170 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1171 SVTK_ViewManager* aViewManager =
1172 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
1174 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
1179 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
1181 ViewManagerMapIterator anIter( myViewManagerMap );
1182 while( anIter.hasNext() )
1184 int anId = anIter.next().key();
1185 const ViewManagerInfo& anInfo = anIter.value();
1186 if( anInfo.first == theViewManager )
1192 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
1194 int anId = getViewManagerId( theViewManager );
1197 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1198 return anInfo.second;
1203 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
1204 const ViewManagerRole theRole )
1206 int anId = getViewManagerId( theViewManager );
1209 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1210 anInfo.second = theRole;
1214 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
1215 const Handle(HYDROData_Entity)& theObject ) const
1217 if( theObject.IsNull() )
1223 foreach( int aViewId, myObjectStateMap.keys() )
1225 if( isObjectVisible( aViewId, theObject ) )
1231 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1232 if( anIter1 != myObjectStateMap.end() )
1234 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1235 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1237 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1238 if( anIter2 != aEntry2ObjectStateMap.end() )
1240 const ObjectState& anObjectState = anIter2.value();
1241 return anObjectState.Visibility;
1247 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1248 const Handle(HYDROData_Entity)& theObject,
1249 const bool theState )
1251 if( !theObject.IsNull() )
1253 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1254 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1256 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1257 anObjectState.Visibility = theState;
1259 HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1262 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1265 QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1266 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1267 if ( visState != Qtx::UnpresentableState )
1268 treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1272 if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1273 setLandCoversScalarMapModeOff( theViewId );
1274 } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) {
1275 getOCCDisplayer()->SetToUpdateColorScale();
1280 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1281 const bool theState )
1283 if( !theObject.IsNull() )
1285 // Process OCC shapes
1286 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1287 while( aShapesMapIter != myShapesMap.end() )
1289 const ListOfShapes& aShapesList = aShapesMapIter.value();
1290 foreach ( HYDROGUI_Shape* aShape, aShapesList )
1292 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1294 aShape->setIsToUpdate( theState );
1299 // Process VTK shapes
1300 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1301 while( aVTKPrsMapIter != myVTKPrsMap.end() )
1303 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1304 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1306 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1308 aShape->setIsToUpdate( theState );
1316 /////////////////// OCC SHAPES PROCESSING
1317 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
1318 ObjectKind theKind ) const
1320 QList<HYDROGUI_Shape*> aResult;
1322 if ( myShapesMap.contains( theViewId ) )
1324 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1325 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1327 if( aShape && aShape->getObject()->GetKind()==theKind )
1328 aResult.append( aShape );
1334 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
1335 const Handle(HYDROData_Entity)& theObject ) const
1337 HYDROGUI_Shape* aResShape = NULL;
1338 if( theObject.IsNull() )
1341 if ( myShapesMap.contains( theViewId ) )
1343 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1344 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1346 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1357 void HYDROGUI_Module::setObjectShape( const int theViewId,
1358 const Handle(HYDROData_Entity)& theObject,
1359 HYDROGUI_Shape* theShape )
1361 if( theObject.IsNull() )
1364 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1365 aViewShapes.append( theShape );
1368 void HYDROGUI_Module::removeObjectShape( const int theViewId,
1369 const Handle(HYDROData_Entity)& theObject )
1371 if ( !myShapesMap.contains( theViewId ) )
1374 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1375 Handle(HYDROData_Entity) anObject;
1376 for ( int i = 0; i < aViewShapes.length(); )
1378 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1379 anObject = aShape->getObject();
1380 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1383 aViewShapes.removeAt( i );
1391 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1393 if ( !myShapesMap.contains( theViewId ) )
1396 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1397 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1399 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1404 myShapesMap.remove( theViewId );
1406 /////////////////// END OF OCC SHAPES PROCESSING
1408 /////////////////// VTKPrs PROCESSING
1409 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
1410 const Handle(HYDROData_Entity)& theObject ) const
1412 HYDROGUI_VTKPrs* aResShape = NULL;
1413 if( theObject.IsNull() )
1416 if ( myVTKPrsMap.contains( theViewId ) )
1418 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1419 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1421 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1432 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1433 const Handle(HYDROData_Entity)& theObject,
1434 HYDROGUI_VTKPrs* theShape )
1436 if( theObject.IsNull() )
1439 if( theShape && theShape->needScalarBar() )
1441 // Compute the new global Z range from the added presentation and the old global Z range.
1442 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1443 double* aRange = theShape->getInternalZRange();
1444 bool anIsUpdate = false;
1445 if ( aRange[0] < aGlobalRange[0] )
1447 aGlobalRange[0] = aRange[0];
1450 if ( aRange[1] > aGlobalRange[1] )
1452 aGlobalRange[1] = aRange[1];
1458 updateVTKZRange( theViewId, aGlobalRange );
1462 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1463 aViewShapes.append( theShape );
1466 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1467 const QString& theEntry )
1469 if ( !myVTKPrsMap.contains( theViewId ) )
1472 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1473 Handle(HYDROData_Entity) anObject;
1475 for ( int i = 0; i < aViewShapes.length(); )
1477 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1478 anObject = aShape->getObject();
1479 anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1480 if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1483 aViewShapes.removeAt( i );
1490 // Invalidate global Z range
1491 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1492 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1495 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1496 const Handle(HYDROData_Entity)& theObject )
1498 if ( !myVTKPrsMap.contains( theViewId ) )
1501 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1502 Handle(HYDROData_Entity) anObject;
1503 for ( int i = 0; i < aViewShapes.length(); )
1505 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1506 anObject = aShape->getObject();
1507 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1510 aViewShapes.removeAt( i );
1517 // Invalidate global Z range
1518 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1519 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1522 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1524 if ( !myVTKPrsMap.contains( theViewId ) )
1527 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1528 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1530 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1535 myVTKPrsMap.remove( theViewId );
1538 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1540 if ( myVTKPrsMap.contains( theViewId ) )
1542 // For the given viewer id update all VTK presentations ...
1543 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1544 HYDROGUI_VTKPrs* aShape;
1545 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1547 aShape = aViewShapes.at( i );
1548 if ( aShape && aShape->needScalarBar() )
1550 aShape->setZRange( theRange );
1554 // ... and update the global color legend scalar bar.
1555 getVTKDisplayer()->SetZRange( theViewId, theRange );
1557 /////////////////// END OF VTKPrs PROCESSING
1559 void HYDROGUI_Module::clearCache()
1561 myObjectStateMap.clear();
1564 CAM_DataModel* HYDROGUI_Module::createDataModel()
1566 return new HYDROGUI_DataModel( this );
1569 void HYDROGUI_Module::customEvent( QEvent* e )
1571 int aType = e->type();
1572 if ( aType == NewViewEvent )
1574 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1575 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1577 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1579 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1580 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1582 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1584 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1585 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1587 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1588 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1589 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1591 //ouv: temporarily commented
1592 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1595 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1596 update( UF_Viewer );
1598 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1604 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1606 QEvent::Type aType = theEvent->type();
1607 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1609 if( aType == QEvent::Show )
1611 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1612 e->setData( theObj );
1613 QApplication::postEvent( this, e );
1614 theObj->removeEventFilter( this );
1617 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1619 if( aType == QEvent::Leave )
1621 SUIT_Desktop* aDesktop = getApp()->desktop();
1622 if ( aDesktop && aDesktop->statusBar() ) {
1623 aDesktop->statusBar()->clearMessage();
1627 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1629 if( aType == QEvent::Leave )
1631 SUIT_Desktop* aDesktop = getApp()->desktop();
1632 if ( aDesktop && aDesktop->statusBar() ) {
1633 aDesktop->statusBar()->clearMessage();
1638 return LightApp_Module::eventFilter( theObj, theEvent );
1641 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1643 LightApp_Module::onViewManagerAdded( theViewManager );
1645 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1647 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1648 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1650 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1652 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
1653 //mgr->setChainedOperations( true );
1655 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1656 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1657 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1658 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1659 connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
1660 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
1662 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1664 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1665 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1666 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1667 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1670 createSelector( theViewManager ); // replace the default selector
1672 ViewManagerInfo anInfo( theViewManager, VMR_General );
1673 myViewManagerMap.insert( ViewManagerId++, anInfo );
1676 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1678 LightApp_Module::onViewManagerRemoved( theViewManager );
1680 createSelector( theViewManager ); // replace the default selector
1682 int anId = getViewManagerId( theViewManager );
1685 OCCViewer_ViewManager* anOCCViewManager =
1686 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1687 if ( anOCCViewManager )
1689 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1690 if ( anOCCViewer ) {
1691 int aViewerId = (size_t)anOCCViewer;
1692 removeViewShapes( aViewerId );
1693 setLandCoversScalarMapModeOff( aViewerId );
1697 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1699 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1702 getVTKDisplayer()->EraseScalarBar( anId, true );
1703 removeViewShapes( (size_t)aVTKViewer );
1707 myViewManagerMap.remove( anId );
1711 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1713 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1715 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1717 aViewFrame->installEventFilter( this );
1719 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1720 aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
1722 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1723 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1726 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1728 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1730 aViewFrame->onTopView();
1732 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1733 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1735 aViewPort->installEventFilter( this );
1739 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1741 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1743 aViewFrame->installEventFilter( this );
1748 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1750 /* ouv: currently unused
1751 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1753 SUIT_ViewManager* aViewManager = 0;
1755 QObject* aParent = aViewPort;
1756 while( aParent = aParent->parent() )
1758 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1760 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1762 aViewManager = aViewer->getViewManager();
1771 double aMouseX = theEvent->scenePos().x();
1772 double aMouseY = theEvent->scenePos().y();
1774 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1775 if( aRole == VMR_General )
1777 int aXDeg = 0, aYDeg = 0;
1778 int aXMin = 0, aYMin = 0;
1779 double aXSec = 0, aYSec = 0;
1780 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1781 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1783 QString aDegSymbol( QChar( 0x00B0 ) );
1784 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1785 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1787 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1789 else if( aRole == VMR_TransformImage )
1790 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1795 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1796 const bool theIsInit,
1797 const bool theIsForced,
1798 const bool theDoFitAll )
1800 QList<int> aViewManagerIdList;
1802 // currently, all views are updated
1803 ViewManagerMapIterator anIter( myViewManagerMap );
1804 while( anIter.hasNext() )
1806 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1808 if ( theDisplayer->IsApplicable( aViewManager ) )
1810 int anId = anIter.key();
1811 aViewManagerIdList.append( anId );
1815 QListIterator<int> anIdIter( aViewManagerIdList );
1816 while( anIdIter.hasNext() )
1818 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1819 myOverview->setTopView();
1823 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1825 if( !theViewManager )
1828 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1829 if( !aSelectionMgr )
1832 QString aViewType = theViewManager->getType();
1833 if( aViewType != GraphicsView_Viewer::Type() &&
1834 aViewType != OCCViewer_Viewer::Type())
1837 QList<SUIT_Selector*> aSelectorList;
1838 aSelectionMgr->selectors( aViewType, aSelectorList );
1840 // disable all alien selectors
1841 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1842 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1844 SUIT_Selector* aSelector = *anIter;
1845 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1846 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1847 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1848 aSelector->setEnabled( false );
1851 if ( aViewType == GraphicsView_Viewer::Type() )
1853 GraphicsView_ViewManager* aViewManager =
1854 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1856 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1858 else if ( aViewType == OCCViewer_Viewer::Type() )
1860 OCCViewer_ViewManager* aViewManager =
1861 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1863 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1867 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1869 bool aPrevState = myIsUpdateEnabled;
1870 myIsUpdateEnabled = theState;
1874 bool HYDROGUI_Module::isUpdateEnabled() const
1876 return myIsUpdateEnabled;
1879 QStringList HYDROGUI_Module::storeSelection() const
1881 QStringList anEntryList;
1882 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1884 SUIT_DataOwnerPtrList aList( true );
1885 aSelectionMgr->selected( aList );
1887 SUIT_DataOwnerPtrList::iterator anIter;
1888 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1890 const LightApp_DataOwner* anOwner =
1891 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1893 anEntryList.append( anOwner->entry() );
1899 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1901 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1903 SUIT_DataOwnerPtrList aList( true );
1904 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1905 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1906 aSelectionMgr->setSelected( aList );
1910 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1913 bool doShow = false;
1914 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1916 aDisplayer->SaveCursorViewPosition( theViewWindow );
1917 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1921 // Show the coordinates in the status bar
1922 SUIT_Desktop* aDesktop = getApp()->desktop();
1923 if ( aDesktop && aDesktop->statusBar() )
1925 gp_Pnt aWPnt( X, Y, Z );
1926 int aStudyId = application()->activeStudy()->id();
1927 HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false );
1928 double WX = aWPnt.X(), WY = aWPnt.Y();
1930 QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1931 QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1932 QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1933 QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1934 QString aMsg = tr( "COORDINATES_INFO" );
1935 aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1936 aDesktop->statusBar()->showMessage( aMsg );
1942 * Returns stack of active operations;
1944 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
1946 return myActiveOperationMap;
1950 * Returns the module active operation. If the active operation is show/hide,
1951 * the method returns the previous operation if it is.
1953 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
1955 HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
1957 if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
1959 QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
1961 aVIt.previous(); // skip the top show/hide operation
1962 anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
1969 * \brief Virtual public slot
1971 * This method is called after the object inserted into data view to update their visibility state
1972 * This is default implementation
1974 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
1976 if ( !isActiveModule() )
1979 HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
1981 // change visibility of object
1982 if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
1985 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1987 QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
1988 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1989 if ( visState == Qtx::UnpresentableState )
1992 visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
1993 treeModel->setVisibilityState( id, visState );
1995 bool vis = visState == Qtx::ShownState;
1996 if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
1999 setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
2001 update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
2004 bool HYDROGUI_Module::isDraggable( const SUIT_DataObject* what ) const
2009 bool HYDROGUI_Module::isDropAccepted( const SUIT_DataObject* where ) const
2015 void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
2016 const int row, Qt::DropAction action )
2018 if ( action != Qt::CopyAction && action != Qt::MoveAction )
2024 if (where->level() < 2 )
2027 DataObjectList::ConstIterator it = what.constBegin();
2028 for (;it != what.constEnd();++it)
2030 if ((*it)->parent() != where)
2034 it = what.constBegin();
2037 for (;it != what.constEnd();++it)
2039 SUIT_DataObject* objWhat = *it;
2041 DataObjectList objInSect = where->children();
2043 //std::list<SUIT_DataObject*> t1 = where->children().toStdList(); //debug
2044 int ind = objInSect.indexOf(objWhat);
2047 HYDROGUI_DataModel* aModel = getDataModel();
2056 where->moveChildPos(objWhat, pos);
2057 //std::list<SUIT_DataObject*> t2 = where->children().toStdList(); //debug
2061 getApp()->updateObjectBrowser(true);
2065 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
2067 Handle(HYDROData_StricklerTable) aTable;
2069 if ( myLandCoverColoringMap.contains( theViewId ) ) {
2070 aTable = myLandCoverColoringMap.value( theViewId );
2076 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
2077 const Handle(HYDROData_StricklerTable)& theTable )
2079 if ( !theTable.IsNull() ) {
2080 myLandCoverColoringMap.insert( theViewId, theTable );
2084 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
2086 myLandCoverColoringMap.remove( theViewId );
2089 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
2091 return myLandCoverColoringMap.contains( theViewId );
2094 void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
2096 if ( theObject.IsNull() || !theObject->IsRemoved() ) {
2100 if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
2101 Handle(HYDROData_StricklerTable) aTable =
2102 Handle(HYDROData_StricklerTable)::DownCast( theObject );
2103 QList<int> aViewIds;
2104 QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
2105 while ( anIter.hasNext() ) {
2106 if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
2107 HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
2114 void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
2119 SUIT_ViewWindow* wnd = theMgr->getActiveView();
2120 OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
2124 myOverview->setMainView( occwnd );
2127 void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
2129 ViewManagerList aViewManagers = getApp()->viewManagers();
2130 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
2131 setAutoZoom(aVMgr, bAutoZoom);
2134 void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
2138 QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
2139 foreach (SUIT_ViewWindow* aView, aViews)
2143 OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
2146 anOCCViewFrame->setAutomaticZoom(bAutoZoom);
2147 for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
2149 OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
2151 aV->setAutomaticZoom(bAutoZoom);
2154 OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
2155 if (anOCCViewWindow)
2156 anOCCViewWindow->setAutomaticZoom(bAutoZoom);