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>
113 #include "HYDRO_trace.hxx"
115 static int ViewManagerId = 0;
117 extern "C" HYDRO_EXPORT CAM_Module* createModule()
119 return new HYDROGUI_Module();
122 extern "C" HYDRO_EXPORT char* getModuleVersion()
124 return (char*)HYDRO_VERSION;
127 HYDROGUI_Module::HYDROGUI_Module()
128 : LightApp_Module( "HYDRO" ),
131 myIsUpdateEnabled( true ),
134 DEBTRACE("HYDROGUI_Module::HYDROGUI_Module()");
137 HYDROGUI_Module::~HYDROGUI_Module()
139 DEBTRACE("HYDROGUI_Module::~HYDROGUI_Module()");
142 int HYDROGUI_Module::getStudyId() const
144 DEBTRACE("HYDROGUI_Module::getStudyId()");
145 LightApp_Application* anApp = getApp();
146 return anApp ? anApp->activeStudy()->id() : 0;
149 void HYDROGUI_Module::initialize( CAM_Application* theApp )
151 DEBTRACE("HYDROGUI_Module::initialize");
152 LightApp_Module::initialize( theApp );
155 createUndoRedoActions();
160 setMenuShown( false );
161 setToolShown( false );
163 myDisplayer = new HYDROGUI_Displayer( this );
164 myOCCDisplayer = new HYDROGUI_OCCDisplayer( this );
165 myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this );
167 HYDROData_Tool::SetSIProgress( new HYDROGUI_SIProgressIndicator( theApp->desktop() ) );
168 HYDROData_Tool::SetZIProgress( new HYDROGUI_ZIProgressIndicator( theApp->desktop() ) );
171 bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
173 DEBTRACE("HYDROGUI_Module::activateModule");
174 bool aRes = LightApp_Module::activateModule( theStudy );
176 LightApp_Application* anApp = getApp();
177 SUIT_Desktop* aDesktop = anApp->desktop();
179 getApp()->setEditEnabled( false ); // hide SalomeApp copy/paste actions
181 setMenuShown( true );
182 setToolShown( true );
184 #ifndef DISABLE_PYCONSOLE
185 aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ),
186 HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) );
189 // Remove defunct view managers from the map.
190 // It's essential to do this before "update( UF_All )" call!
191 QList<int> anObsoleteIds;
192 ViewManagerList anAllViewManagers = anApp->viewManagers();
193 ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module
194 ViewManagerMapIterator anIter( myViewManagerMap );
195 while( anIter.hasNext() ) {
196 int anId = anIter.next().key();
197 const ViewManagerInfo& anInfo = anIter.value();
199 aHydroViewManagers << anInfo.first;
201 if ( !anAllViewManagers.contains( anInfo.first ) ) {
202 anObsoleteIds << anId;
205 foreach ( const int anId, anObsoleteIds ) {
206 myViewManagerMap.remove( anId );
207 myObjectStateMap.remove( anId );
208 myShapesMap.remove( anId );
209 myVTKPrsMap.remove( anId );
211 // Replace the default selector for all view managers.
212 // Add view managers created outside of HYDRO module to the map.
213 foreach ( SUIT_ViewManager* aViewManager, anAllViewManagers ) {
214 createSelector( aViewManager ); // replace the default selector
215 if ( !aHydroViewManagers.contains( aViewManager ) ) {
216 ViewManagerInfo anInfo( aViewManager, VMR_General );
217 myViewManagerMap.insert( ViewManagerId++, anInfo );
223 updateCommandsStatus();
225 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, false );
227 ViewManagerList anOCCViewManagers;
228 anApp->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
230 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
232 connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
233 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
234 connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
235 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
237 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
240 occ_mgr->setChainedOperations( true );//TODO: via preferences
243 foreach( SUIT_ViewWindow* aViewWindow, aViewManager->getViews() )
245 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aViewWindow );
246 if ( aViewFrame && aViewFrame->getViewPort() )
248 aViewFrame->getViewPort()->installEventFilter( this );
253 preferencesChanged( "HYDRO", "zoom_shutoff" );
255 preferencesChanged( "HYDRO", "chained_panning" );
258 SalomeApp_Study* aStudy =
259 dynamic_cast<SalomeApp_Study*>( getApp()->activeStudy() );
261 SALOMEDS::Study_var aDSStudy = GeometryGUI::getStudyServant();
262 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
263 if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) {
264 SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder();
265 SALOMEDS::SComponent_wrap GEOM_var = aDSStudy->FindComponent( "GEOM" );
266 if( !GEOM_var->_is_nil() ) {
267 aStudyBuilder->LoadWith( GEOM_var, aGeomEngine );
273 // SUIT_DataBrowser* ob = getApp()->objectBrowser();
274 // SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( ob->model() );
275 // treeModel->setAppropriate( SUIT_DataObject::VisibilityId, Qtx::Toggled );
280 bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
282 DEBTRACE("HYDROGUI_Module::deactivateModule");
284 ViewManagerMapIterator anIter( myViewManagerMap );
285 while( anIter.hasNext() )
286 if( SUIT_ViewManager* aViewManager = anIter.next().value().first )
287 getApp()->removeViewManager( aViewManager );
288 myViewManagerMap.clear();
291 ViewManagerList anOCCViewManagers;
292 getApp()->viewManagers( OCCViewer_Viewer::Type(), anOCCViewManagers );
293 foreach ( SUIT_ViewManager* aViewManager, anOCCViewManagers )
295 disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
296 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
297 disconnect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
298 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
300 OCCViewer_ViewManager* occ_mgr = dynamic_cast<OCCViewer_ViewManager*>( aViewManager );
303 occ_mgr->setChainedOperations( false );
304 setAutoZoom( occ_mgr, true );
309 myObjectStateMap.clear();
314 // clear the status bar
315 SUIT_Desktop* aDesktop = getApp()->desktop();
316 if ( aDesktop && aDesktop->statusBar() ) {
317 aDesktop->statusBar()->clearMessage();
320 // clear the data model's list of copying objects
321 HYDROGUI_DataModel::changeCopyingObjects( HYDROData_SequenceOfObjects() );
323 setMenuShown( false );
324 setToolShown( false );
326 getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
328 HYDROGUI_Tool::setOCCActionShown( this, OCCViewer_ViewWindow::MaximizedId, true );
330 myActiveOperationMap.clear();
332 myViewManagerMap.clear();
334 bool ret = LightApp_Module::deactivateModule( theStudy );
338 void HYDROGUI_Module::studyClosed(SUIT_Study* theStudy)
340 DEBTRACE("HYDROGUI_Module::studyClosed");
341 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
346 void HYDROGUI_Module::windows( QMap<int, int>& theMap ) const
348 DEBTRACE("HYDROGUI_Module::windows");
349 static bool inWindows = false;
354 theMap.insert( LightApp_Application::WT_LogWindow, Qt::BottomDockWidgetArea );
355 #ifndef DISABLE_PYCONSOLE
356 theMap.insert( LightApp_Application::WT_PyConsole, Qt::BottomDockWidgetArea );
358 theMap.insert( LightApp_Application::WT_ObjectBrowser, Qt::LeftDockWidgetArea );
359 theMap.insert( OverviewWindow, Qt::LeftDockWidgetArea );
362 LightApp_Application* app = getApp();
363 if( app && app->getWindow( OverviewWindow )==0 )
365 const_cast<HYDROGUI_Module*>( this )->myOverview =
366 new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() );
367 app->insertDockWindow( OverviewWindow, myOverview );
368 app->placeDockWindow( OverviewWindow, Qt::LeftDockWidgetArea );
373 void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const
375 DEBTRACE("HYDROGUI_Module::viewManagers");
376 theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type();
379 void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
383 HYDROGUI_DataModel* aModel = getDataModel();
385 bool anIsObjectBrowser = theClient == getApp()->objectBrowser()->popupClientType();
386 bool anIsGraphicsView = theClient == GraphicsView_Viewer::Type();
387 bool anIsOCCView = theClient == OCCViewer_Viewer::Type();
388 bool anIsVTKView = theClient == SVTK_Viewer::Type();
389 if( !anIsObjectBrowser && !anIsGraphicsView && !anIsOCCView && !anIsVTKView )
392 size_t anActiveViewId = HYDROGUI_Tool::GetActiveViewId( this );
394 bool anIsSelectedDataObjects = false;
395 bool anIsVisibleInSelection = false;
396 bool anIsHiddenInSelection = false;
398 bool anIsImage = false;
399 bool anIsImportedImage = false;
400 bool anIsImageHasRefs = false;
401 bool anIsFusedImage = false;
402 bool anIsCutImage = false;
403 bool anIsSplitImage = false;
404 bool anIsMustObjectBeUpdated = false;
405 bool anIsPolyline = false;
406 bool anIsPolyline3D = false;
407 bool anIsProfile = false;
408 bool anIsValidProfile = false;
409 bool anAllAreProfiles = false;
410 bool anIsBathymetry = false;
411 bool anIsCalculation = false;
412 bool anIsImmersibleZone = false;
413 bool anIsVisualState = false;
414 bool anIsRegion = false;
415 bool anIsZone = false;
416 bool anIsObstacle = false;
417 bool anIsStricklerTable = false;
418 bool anIsLandCoverMap = false;
419 bool anIsStream = false;
420 bool anIsChannel = false;
421 bool anIsDigue = false;
422 bool anIsDummyObject3D = false;
423 bool anIsGroup = false;
424 bool anIsObjectCanBeColored = false;
426 bool isStreamHasBottom = false;
427 bool anIsBCPolygon = false;
429 SUIT_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
430 SUIT_DataOwnerPtrList anOwners;
431 aSelectionMgr->selected( anOwners );
432 if( anIsObjectBrowser && anOwners.size()==1 )
434 QString anEntry = anOwners[0]->keyString();
435 LightApp_Study* aStudy = dynamic_cast<LightApp_Study*>( getApp()->activeStudy() );
437 isRoot = aStudy->isComponent( anEntry );
440 // Check the selected GEOM objects (take into account the Object Browser only)
441 if ( anIsObjectBrowser ) {
442 QList<GEOM::shape_type> anObstacleTypes =
443 HYDROGUI_ImportGeomObjectOp::getObstacleTypes();
444 QList<GEOM::shape_type> aPolylineTypes =
445 HYDROGUI_ImportGeomObjectOp::getPolylineTypes();
447 bool isCanBeImportedAsObstacle =
448 !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty();
449 bool isCanBeImportedAsPolyline =
450 !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty();
452 // Add import as obstacle action
453 if ( isCanBeImportedAsObstacle ) {
454 theMenu->addAction( action( ImportGeomObjectAsObstacleId ) );
456 // Add import as polyline action
457 if ( isCanBeImportedAsPolyline ) {
458 theMenu->addAction( action( ImportGeomObjectAsPolylineId ) );
461 if ( isCanBeImportedAsObstacle || isCanBeImportedAsPolyline ) {
462 theMenu->addSeparator();
466 // check the selected data model objects
467 HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
468 int aNbOfSelectedProfiles = 0;
469 for( Standard_Integer anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
471 Handle(HYDROData_Entity) anObject = aSeq.Value( anIndex );
472 if( !anObject.IsNull() )
474 anIsSelectedDataObjects = true;
476 bool aVisibility = isObjectVisible( anActiveViewId, anObject );
477 anIsVisibleInSelection |= aVisibility;
478 anIsHiddenInSelection |= !aVisibility;
480 if ( anObject->CanBeUpdated() && anObject->IsMustBeUpdated( HYDROData_Entity::Geom_All ) )
482 anIsMustObjectBeUpdated = true;
485 ObjectKind anObjectKind = anObject->GetKind();
486 if( anObjectKind == KIND_IMAGE )
489 Handle(HYDROData_Image) anImage = Handle(HYDROData_Image)::DownCast( anObject );
490 if( !anImage.IsNull() )
492 anIsImportedImage = anImage->HasLocalPoints();
493 anIsImageHasRefs = anImage->HasReferences();
494 if( HYDROData_OperationsFactory* aFactory = HYDROData_OperationsFactory::Factory() )
496 if( ImageComposer_Operator* anOperator = aFactory->Operator( anImage ) )
498 QString anOperatorName = anOperator->name();
499 if( anOperatorName == ImageComposer_FuseOperator::Type() )
500 anIsFusedImage = true;
501 else if( anOperatorName == ImageComposer_CutOperator::Type() )
503 else if( anOperatorName == ImageComposer_CropOperator::Type() )
504 anIsSplitImage = true;
509 else if( anObjectKind == KIND_POLYLINEXY )
511 else if( anObjectKind == KIND_POLYLINE )
512 anIsPolyline3D = true;
513 else if( anObjectKind == KIND_PROFILE )
516 aNbOfSelectedProfiles++;
518 Handle(HYDROData_Profile) aProfile =
519 Handle(HYDROData_Profile)::DownCast( anObject );
520 if( !aProfile.IsNull() && aProfile->IsValid() ) {
521 anIsValidProfile = true;
524 else if( anObjectKind == KIND_CALCULATION )
525 anIsCalculation = true;
526 else if( anObjectKind == KIND_IMMERSIBLE_ZONE )
527 anIsImmersibleZone = true;
528 else if( anObjectKind == KIND_VISUAL_STATE )
529 anIsVisualState = true;
530 else if( anObjectKind == KIND_REGION )
532 else if( anObjectKind == KIND_ZONE )
534 else if( anObjectKind == KIND_BATHYMETRY )
535 anIsBathymetry = true;
536 else if( anObjectKind == KIND_OBSTACLE )
538 else if( anObjectKind == KIND_STRICKLER_TABLE )
539 anIsStricklerTable = true;
540 else if( anObjectKind == KIND_LAND_COVER_MAP )
541 anIsLandCoverMap = true;
542 else if (anObjectKind == KIND_BC_POLYGON)
543 anIsBCPolygon = true;
544 else if( anObjectKind == KIND_STREAM )
547 Handle(HYDROData_Stream) aStream =
548 Handle(HYDROData_Stream)::DownCast( anObject );
549 if ( !aStream.IsNull() )
550 isStreamHasBottom = !aStream->GetBottomPolyline().IsNull();
552 else if( anObjectKind == KIND_CHANNEL )
554 else if( anObjectKind == KIND_DIGUE )
556 else if( anObjectKind == KIND_DUMMY_3D )
557 anIsDummyObject3D = true;
558 else if( anObjectKind == KIND_SHAPES_GROUP || anObjectKind == KIND_SPLIT_GROUP )
562 if ( !anIsObjectCanBeColored )
563 anIsObjectCanBeColored = HYDROGUI_SetColorOp::CanObjectBeColored( anObject, this );
566 // Check if all selected objects are profiles
567 anAllAreProfiles = ( aNbOfSelectedProfiles > 0 ) &&
568 ( aNbOfSelectedProfiles == aSeq.Length() );
570 // check the selected partitions
571 if( !anIsSelectedDataObjects && anIsObjectBrowser )
573 ObjectKind aSelectedPartition = HYDROGUI_Tool::GetSelectedPartition( this );
574 if( aSelectedPartition != KIND_UNKNOWN )
576 switch( aSelectedPartition )
579 theMenu->addAction( action( ImportImageId ) );
581 case KIND_BATHYMETRY:
582 theMenu->addAction( action( ImportBathymetryId ) );
584 case KIND_ARTIFICIAL_OBJECT:
585 theMenu->addAction( action( CreateChannelId ) );
586 theMenu->addAction( action( CreateDigueId ) );
588 case KIND_NATURAL_OBJECT:
589 theMenu->addAction( action( CreateImmersibleZoneId ) );
590 theMenu->addAction( action( CreateStreamId ) );
593 theMenu->addAction( action( ImportObstacleFromFileId ) );
594 theMenu->addAction( action( CreateBoxId ) );
595 theMenu->addAction( action( CreateCylinderId ) );
597 case KIND_STRICKLER_TABLE:
598 theMenu->addAction( action( ImportStricklerTableFromFileId ) );
600 case KIND_LAND_COVER_MAP:
601 theMenu->addAction( action( CreateLandCoverMapId ) );
602 theMenu->addAction( action( ImportLandCoverMapId ) );
604 case KIND_CALCULATION:
605 theMenu->addAction( action( CreateCalculationId ) );
607 case KIND_POLYLINEXY:
608 theMenu->addAction( action( ImportPolylineId ) );
609 theMenu->addAction( action( CreatePolylineId ) );
612 theMenu->addAction( action( CreatePolyline3DId ) );
613 theMenu->addAction( action( ImportPolylineId ) );
616 theMenu->addAction( action( CreateProfileId ) );
617 theMenu->addAction( action( ImportProfilesId ) );
618 theMenu->addAction( action( AllGeoreferencementId ) );
620 case KIND_VISUAL_STATE:
621 theMenu->addAction( action( SaveVisualStateId ) );
623 case KIND_BC_POLYGON:
624 theMenu->addAction( action( ImportBCPolygonId ) );
627 theMenu->addSeparator();
631 Handle(HYDROData_CalculationCase) aCalcCase;
633 HYDROGUI_Tool::IsSelectedPartOfCalcCase(this, aCalcCase, outStr);
634 if (outStr == HYDROGUI_DataModel::partitionName( KIND_REGION ))
635 theMenu->addAction( action( RegenerateRegionColorsId ) );
639 if( anIsSelectedDataObjects )
641 if ( anIsMustObjectBeUpdated )
643 theMenu->addAction( action( UpdateObjectId ) );
644 theMenu->addSeparator();
648 theMenu->addAction( action( ForcedUpdateObjectId ) );
649 theMenu->addSeparator();
653 if( aSeq.Length() == 1 )
657 if( anIsImportedImage )
658 theMenu->addAction( action( EditImportedImageId ) );
659 else if( anIsImageHasRefs )
662 theMenu->addAction( action( EditFusedImageId ) );
663 else if( anIsCutImage )
664 theMenu->addAction( action( EditCutImageId ) );
665 else if( anIsSplitImage )
666 theMenu->addAction( action( EditSplitImageId ) );
669 //RKV: BUG#98: theMenu->addAction( action( ObserveImageId ) );
670 theMenu->addAction( action( ExportImageId ) );
671 theMenu->addSeparator();
673 if( anIsImageHasRefs )
675 theMenu->addAction( action( RemoveImageRefsId ) );
676 theMenu->addSeparator();
679 theMenu->addAction( action( FuseImagesId ) );
680 theMenu->addAction( action( CutImagesId ) );
681 theMenu->addAction( action( SplitImageId ) );
682 theMenu->addSeparator();
683 theMenu->addAction( action( RecognizeContoursId ) );
684 theMenu->addSeparator();
686 else if( anIsBathymetry )
688 theMenu->addAction( action( EditImportedBathymetryId ) );
689 theMenu->addAction( action( BathymetryBoundsId ) );
690 theMenu->addSeparator();
692 else if( anIsPolyline )
694 theMenu->addAction( action( EditPolylineId ) );
695 theMenu->addSeparator();
696 theMenu->addAction( action( SplitPolylinesId ) );
697 theMenu->addAction( action( MergePolylinesId ) );
698 theMenu->addSeparator();
699 theMenu->addAction( action( ShowAttrPolylinesId ) );
700 theMenu->addSeparator();
702 else if( anIsPolyline3D )
704 theMenu->addAction( action( EditPolyline3DId ) );
705 theMenu->addSeparator();
707 else if( anIsProfile )
709 theMenu->addAction( action( EditProfileId ) );
710 theMenu->addAction( action( SelectedGeoreferencementId ) );
711 theMenu->addSeparator();
713 else if( anIsCalculation )
715 theMenu->addAction( action( EditCalculationId ) );
716 theMenu->addAction( action( ExportCalculationId ) );
717 theMenu->addAction( action( CompleteCalculationId ) );
718 theMenu->addSeparator();
720 else if( anIsImmersibleZone )
722 theMenu->addAction( action( EditImmersibleZoneId ) );
723 theMenu->addSeparator();
725 else if( anIsStream )
727 theMenu->addAction( action( EditStreamId ) );
728 if ( action( RiverBottomContextId ) )
730 theMenu->addAction( action( RiverBottomContextId ) );
731 action( RiverBottomContextId )->setEnabled( !isStreamHasBottom );
733 theMenu->addAction( action( ProfileInterpolateId ) );
734 theMenu->addSeparator();
736 else if( anIsChannel )
738 theMenu->addAction( action( EditChannelId ) );
739 theMenu->addSeparator();
743 theMenu->addAction( action( EditDigueId ) );
744 theMenu->addSeparator();
746 else if( anIsObstacle )
748 theMenu->addAction( action( TranslateObstacleId ) );
749 theMenu->addSeparator();
751 else if( anIsStricklerTable )
753 theMenu->addAction( action( EditStricklerTableId ) );
754 theMenu->addAction( action( ExportStricklerTableFromFileId ) );
755 theMenu->addAction( action( DuplicateStricklerTableId ) );
756 theMenu->addSeparator();
758 Handle(HYDROData_StricklerTable) aTable =
759 Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() );
760 QString aCurrentTable =
761 HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) );
762 bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable );
764 if ( !isUsed && !getObjectShapes( anActiveViewId, KIND_LAND_COVER_MAP ).isEmpty() ) {
765 theMenu->addAction( action( LandCoverScalarMapModeOnId ) );
766 theMenu->addSeparator();
769 else if( anIsLandCoverMap )
771 theMenu->addAction( action( AddLandCoverId ) );
772 theMenu->addAction( action( RemoveLandCoverId ) );
773 theMenu->addSeparator();
774 theMenu->addAction( action( SplitLandCoverId ) );
775 theMenu->addAction( action( MergeLandCoverId ) );
776 theMenu->addAction( action( ChangeLandCoverTypeId ) );
777 theMenu->addSeparator();
779 theMenu->addAction( action( ExportToShapeFileID ) );
780 theMenu->addSeparator();
782 else if( anIsVisualState && anIsObjectBrowser )
784 theMenu->addAction( action( SaveVisualStateId ) );
785 theMenu->addAction( action( LoadVisualStateId ) );
786 theMenu->addSeparator();
789 theMenu->addAction( action( ZoneSetColorId ) );
790 else if (anIsBCPolygon)
791 theMenu->addAction( action( SetBoundaryTypePolygonId ) );
793 if ( anIsStream || anIsChannel || anIsDigue || anIsObstacle )
795 theMenu->addAction( action( PolylineExtractionId ) );
796 theMenu->addSeparator();
799 // Add set color action for geometrical objects
800 if ( anIsObjectCanBeColored )
802 theMenu->addAction( action( SetColorId ) );
803 theMenu->addSeparator();
806 // Add transparency action for land cover map objects
807 if ( anIsLandCoverMap )
809 theMenu->addAction( action( SetTransparencyId ) );
810 theMenu->addSeparator();
813 else if ( anAllAreProfiles )
815 theMenu->addAction( action( EditProfileId ) );
816 theMenu->addAction( action( SelectedGeoreferencementId ) );
817 theMenu->addSeparator();
820 bool isPoly = anIsPolyline || anIsPolyline3D;
821 if (isPoly && !anIsLandCoverMap)
822 theMenu->addAction( action( ExportToShapeFileID ) );
825 QAction* aCopyAction = action( CopyId );
826 if( aCopyAction && aCopyAction->isEnabled() ) {
827 theMenu->addAction( action( CopyId ) );
828 theMenu->addSeparator();
832 if( !anIsDummyObject3D )
833 theMenu->addAction( action( DeleteId ) );
835 theMenu->addSeparator();
837 if( anIsImage || anIsPolyline || anIsPolyline3D ||
838 anIsImmersibleZone || anIsZone || anIsRegion ||
839 anIsBathymetry || anIsObstacle || anIsStream ||
840 anIsChannel || anIsDigue || anIsDummyObject3D ||
841 anIsValidProfile || anIsGroup || anIsLandCoverMap ||
844 if( anIsHiddenInSelection )
845 theMenu->addAction( action( ShowId ) );
846 theMenu->addAction( action( ShowOnlyId ) );
847 if( anIsVisibleInSelection )
848 theMenu->addAction( action( HideId ) );
849 theMenu->addSeparator();
855 SUIT_Operation* anOp = application()->activeStudy()->activeOperation();
856 HYDROGUI_PolylineOp* aPolylineOp = dynamic_cast<HYDROGUI_PolylineOp*>( anOp );
857 if ( aPolylineOp && aPolylineOp->deleteEnabled() )
858 theMenu->addAction( action( DeleteId ) );
860 theMenu->addSeparator();
861 theMenu->addAction( action( SetZLevelId ) );
862 theMenu->addSeparator();
864 if ( isLandCoversScalarMapModeOn( anActiveViewId ) ) {
865 theMenu->addAction( action( LandCoverScalarMapModeOffId ) );
866 theMenu->addSeparator();
870 if( anIsObjectBrowser || anIsGraphicsView || anIsOCCView || anIsVTKView )
872 theMenu->addAction( action( ShowAllId ) );
873 theMenu->addAction( action( HideAllId ) );
874 theMenu->addSeparator();
877 if ( anIsOCCView || anIsVTKView )
879 theMenu->addSeparator();
880 theMenu->addAction( action( CopyViewerPositionId ) );
884 theMenu->addAction( action( EditLocalCSId ) );
886 if( anIsObjectBrowser && anOwners.size()==1 )
888 if( aSeq.Size() > 0 )
890 Handle( HYDROData_Entity ) aFirstEnt = aSeq.First();
891 Handle(HYDROData_Object) anObject;
892 Handle(HYDROData_ArtificialObject) anAObject = Handle( HYDROData_ArtificialObject )::DownCast(aFirstEnt);
893 Handle(HYDROData_NaturalObject) aNObject = Handle( HYDROData_NaturalObject )::DownCast(aFirstEnt);
895 if (!anAObject.IsNull())
896 anObject = anAObject;
897 if (!aNObject.IsNull())
900 if( !anObject.IsNull() )
902 theMenu->addSeparator();
903 bool IsSubmersible = anObject->IsSubmersible();
906 theMenu->addAction( action( SubmersibleId ) );
907 action( SubmersibleId )->setCheckable(true);
908 action( SubmersibleId )->setChecked(true);
912 theMenu->addAction( action( UnSubmersibleId ) );
913 action( UnSubmersibleId )->setCheckable(true);
914 action( UnSubmersibleId )->setChecked(true);
920 theMenu->addSeparator();
921 QAction* a = action( ShowHideArrows );
922 a->setText( arrowsVisible() ? tr( "HIDE_ARROWS" ) : tr( "SHOW_ARROWS" ) );
923 theMenu->addAction( a );
926 void HYDROGUI_Module::createPreferences()
928 DEBTRACE("HYDROGUI_Module::createPreferences");
929 int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) );
930 int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab );
932 int typeOfCursor = addPreference( tr( "PREF_TYPE_OF_CURSOR" ), CursorGroup,
933 LightApp_Preferences::Selector, "preferences", "type_of_cursor" );
935 // Set property cursor type
936 QList<QVariant> aCursorTypeIndicesList;
937 QList<QVariant> aCursorTypeIconsList;
939 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
940 for ( int i = CT_ArrowCursor; i < CT_User; i++ ) {
941 QString icoFile = QString( "ICON_CURSOR_%1" ).arg( i+1 );
942 QPixmap pixmap = resMgr->loadPixmap( "HYDRO", tr( qPrintable( icoFile ) ) );
943 aCursorTypeIndicesList << i;
944 aCursorTypeIconsList << pixmap;
947 setPreferenceProperty( typeOfCursor, "indexes", aCursorTypeIndicesList );
948 setPreferenceProperty( typeOfCursor, "icons", aCursorTypeIconsList );
950 int viewerGroup = addPreference( tr( "PREF_GROUP_VIEWER" ), genTab );
951 addPreference( tr( "PREF_VIEWER_AUTO_FITALL" ), viewerGroup,
952 LightApp_Preferences::Bool, "HYDRO", "auto_fit_all" );
954 addPreference( tr( "PREF_VIEWER_ZOOM_SHUTOFF" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "zoom_shutoff" );
956 addPreference( tr( "PREF_VIEWER_CHAINED_PANNING" ), viewerGroup, LightApp_Preferences::Bool, "HYDRO", "chained_panning" );
958 int StricklerTableGroup = addPreference( tr( "PREF_GROUP_STRICKLER_TABLE" ), genTab );
959 int defaultStricklerCoef = addPreference( tr( "PREF_DEFAULT_STRICKLER_COEFFICIENT" ), StricklerTableGroup,
960 LightApp_Preferences::DblSpin, "preferences", "default_strickler_coefficient" );
961 setPreferenceProperty( defaultStricklerCoef, "precision", 2 );
962 setPreferenceProperty( defaultStricklerCoef, "min", 0.00 );
963 setPreferenceProperty( defaultStricklerCoef, "max", 1000000.00 );
964 setPreferenceProperty( defaultStricklerCoef, "step", 0.01 );
966 int polylinesGroup = addPreference( tr( "PREF_GROUP_POLYLINES" ), genTab );
967 int polylineArrow = addPreference( tr( "PREF_POLYLINE_ARROW" ), polylinesGroup,
968 LightApp_Preferences::Selector, "polyline", "arrow_type" );
970 QList<QVariant> arrow_types;
971 arrow_types.append( tr( "No" ) );
972 arrow_types.append( tr( "Triangle" ) );
973 arrow_types.append( tr( "Cone" ) );
974 setPreferenceProperty( polylineArrow, "strings", arrow_types );
976 QList<QVariant> indices;
980 setPreferenceProperty( polylineArrow, "indexes", indices );
981 setPreferenceProperty( polylineArrow, "ids", indices );
983 int polylineSize = addPreference( tr( "PREF_POLYLINE_ARROW_SIZE" ), polylinesGroup,
984 LightApp_Preferences::IntSpin, "polyline", "arrow_size" );
987 void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref )
989 DEBTRACE("HYDROGUI_Module::preferencesChanged");
990 SUIT_ResourceMgr* resMgr = application()->resourceMgr();
991 if ( theSection == "preferences" && thePref == "default_strickler_coefficient" )
994 Handle(HYDROData_Document) aDoc = HYDROData_Document::Document();
995 if ( resMgr && !aDoc.IsNull() )
996 aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) );
998 else if( theSection == "polyline" )
1004 resMgr->value( "polyline", "arrow_type", aType );
1005 resMgr->value( "polyline", "arrow_size", aSize );
1008 ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end();
1009 for( ; it!=last; it++ )
1011 int aViewerId = it.key();
1012 OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( it.value().first );
1014 getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize );
1017 else if (theSection == "HYDRO" && thePref == "zoom_shutoff")
1019 bool aZoomShutoff = resMgr->booleanValue( "HYDRO", "zoom_shutoff" );
1020 setAutoZoomToAllViewManagers(!aZoomShutoff);
1022 else if (theSection == "HYDRO" && thePref == "chained_panning")
1024 bool aChainedPan = resMgr->booleanValue( "HYDRO", "chained_panning" );
1027 ViewManagerList aViewManagers = getApp()->viewManagers();
1028 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
1030 OCCViewer_ViewManager* anOCCViewMgr = dynamic_cast<OCCViewer_ViewManager*>( aVMgr );
1032 anOCCViewMgr->setChainedOperations( aChainedPan );
1035 QList<QDockWidget*> docW = getApp()->desktop()->findChildren<QDockWidget*>();
1036 foreach (QDockWidget* qw, docW)
1038 HYDROGUI_ProfileDlg* pdlg = dynamic_cast<HYDROGUI_ProfileDlg*>(qw);
1040 pdlg->viewManager()->setChainedOperations(aChainedPan);
1044 LightApp_Module::preferencesChanged( theSection, thePref );
1047 QCursor HYDROGUI_Module::getPrefEditCursor() const
1049 int aCursorType = SUIT_Session::session()->resourceMgr()->integerValue("preferences", "type_of_cursor", (int)CT_CrossCursor );
1050 if ( aCursorType >= Qt::BlankCursor)
1052 QCursor aCursor = QCursor( Qt::CursorShape(aCursorType) );
1056 void HYDROGUI_Module::update( const int flags )
1058 DEBTRACE("HYDROGUI_Module::update");
1059 if ( !isUpdateEnabled() )
1062 QApplication::setOverrideCursor( Qt::WaitCursor );
1064 // To prevent calling this method recursively
1065 // from one of the methods called below
1066 setUpdateEnabled( false );
1068 // store selected objects
1069 QStringList aSelectedEntries = storeSelection();
1071 bool aDoFitAll = flags & UF_FitAll;
1074 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1075 aDoFitAll = aResMgr->booleanValue( "HYDRO", "auto_fit_all", false );
1078 if( ( flags & UF_Viewer ) )
1079 updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll );
1081 if( ( flags & UF_OCCViewer ) )
1082 updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll );
1084 if( ( flags & UF_VTKViewer ) )
1085 updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll );
1087 if( ( flags & UF_Model ) && getDataModel() && getApp() )
1089 getDataModel()->update( getStudyId() );
1091 // Temporary workaround to prevent breaking
1092 // the selection in the object browser.
1093 // Note: processEvents() should be called after updateGV(),
1094 // otherwise the application crashes from time to time.
1095 //RKV: qApp->processEvents();
1096 SUIT_ResourceMgr* aResMgr = getApp()->resourceMgr();
1097 bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false );
1098 SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser();
1099 if ( isResizeOnExpandItem && anObjectBrowser ) {
1100 anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280
1102 getApp()->updateObjectBrowser( true );
1103 if ( isResizeOnExpandItem && anObjectBrowser ) {
1104 anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280
1108 // Object browser is currently updated by using UF_Model flag
1109 if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
1110 getApp()->updateObjectBrowser( true );
1112 if( ( flags & UF_Controls ) && getApp() )
1113 getApp()->updateActions();
1115 // restore selected objects
1116 restoreSelection( aSelectedEntries );
1118 setUpdateEnabled( true );
1120 preferencesChanged( "HYDRO", "zoom_shutoff" );
1122 preferencesChanged( "HYDRO", "chained_panning" );
1124 QApplication::restoreOverrideCursor();
1127 void HYDROGUI_Module::updateCommandsStatus()
1129 DEBTRACE("HYDROGUI_Module::updateCommandsStatus");
1130 LightApp_Module::updateCommandsStatus();
1132 updateUndoRedoControls();
1134 action( CopyId )->setEnabled( getDataModel()->canCopy() );
1135 action( PasteId )->setEnabled( getDataModel()->canPaste() );
1138 void HYDROGUI_Module::selectionChanged()
1140 LightApp_Module::selectionChanged();
1141 updateCommandsStatus();
1144 HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const
1146 //DEBTRACE("HYDROGUI_Module::getDataModel()");
1147 return (HYDROGUI_DataModel*)dataModel();
1150 HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const
1152 //DEBTRACE("HYDROGUI_Module::getDisplayer()");
1156 HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const
1158 DEBTRACE("HYDROGUI_Module::getOCCDisplayer");
1159 return myOCCDisplayer;
1162 HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const
1164 DEBTRACE("HYDROGUI_Module::getVTKDisplayer");
1165 return myVTKDisplayer;
1168 SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const
1170 DEBTRACE("HYDROGUI_Module::getViewManager");
1171 if( myViewManagerMap.contains( theId ) )
1173 return myViewManagerMap[ theId ].first;
1178 GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const
1180 DEBTRACE("HYDROGUI_Module::getViewer");
1181 if( myViewManagerMap.contains( theId ) )
1183 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1184 GraphicsView_ViewManager* aViewManager =
1185 dynamic_cast<GraphicsView_ViewManager*>( anInfo.first );
1187 return aViewManager->getViewer();
1192 OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const
1194 DEBTRACE("HYDROGUI_Module::getOCCViewer");
1195 if( myViewManagerMap.contains( theId ) )
1197 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1198 OCCViewer_ViewManager* aViewManager =
1199 ::qobject_cast<OCCViewer_ViewManager*>( anInfo.first );
1201 return aViewManager->getOCCViewer();
1206 SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const
1208 DEBTRACE("HYDROGUI_Module::getVTKViewer");
1209 if( myViewManagerMap.contains( theId ) )
1211 ViewManagerInfo anInfo = myViewManagerMap[ theId ];
1212 SVTK_ViewManager* aViewManager =
1213 ::qobject_cast<SVTK_ViewManager*>( anInfo.first );
1215 return dynamic_cast<SVTK_Viewer*>( aViewManager->getViewModel() );
1220 int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager )
1222 DEBTRACE("HYDROGUI_Module::getViewManagerId");
1223 ViewManagerMapIterator anIter( myViewManagerMap );
1224 while( anIter.hasNext() )
1226 int anId = anIter.next().key();
1227 const ViewManagerInfo& anInfo = anIter.value();
1228 if( anInfo.first == theViewManager )
1234 HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager )
1236 DEBTRACE("HYDROGUI_Module::getViewManagerRole");
1237 int anId = getViewManagerId( theViewManager );
1240 const ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1241 return anInfo.second;
1246 void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager,
1247 const ViewManagerRole theRole )
1249 DEBTRACE("HYDROGUI_Module::setViewManagerRole");
1250 int anId = getViewManagerId( theViewManager );
1253 ViewManagerInfo& anInfo = myViewManagerMap[ anId ];
1254 anInfo.second = theRole;
1258 bool HYDROGUI_Module::isObjectVisible( const int theViewId,
1259 const Handle(HYDROData_Entity)& theObject ) const
1261 if( theObject.IsNull() )
1267 foreach( int aViewId, myObjectStateMap.keys() )
1269 if( isObjectVisible( aViewId, theObject ) )
1275 ViewId2Entry2ObjectStateMap::const_iterator anIter1 = myObjectStateMap.find( theViewId );
1276 if( anIter1 != myObjectStateMap.end() )
1278 const Entry2ObjectStateMap& aEntry2ObjectStateMap = anIter1.value();
1279 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1281 Entry2ObjectStateMap::const_iterator anIter2 = aEntry2ObjectStateMap.find( anEntry );
1282 if( anIter2 != aEntry2ObjectStateMap.end() )
1284 const ObjectState& anObjectState = anIter2.value();
1285 return anObjectState.Visibility;
1291 void HYDROGUI_Module::setObjectVisible( const int theViewId,
1292 const Handle(HYDROData_Entity)& theObject,
1293 const bool theState )
1295 if( !theObject.IsNull() )
1297 Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ];
1298 QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject );
1300 ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ];
1301 anObjectState.Visibility = theState;
1303 HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject );
1306 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
1309 QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() );
1310 Qtx::VisibilityState visState = treeModel->visibilityState( id );
1311 if ( visState != Qtx::UnpresentableState )
1312 treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState );
1316 if ( theObject->GetKind() == KIND_BATHYMETRY && theState ) {
1317 setLandCoversScalarMapModeOff( theViewId );
1318 } else if ( theObject->GetKind() == KIND_LAND_COVER_MAP && theState ) {
1319 getOCCDisplayer()->SetToUpdateColorScale();
1324 void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject,
1325 const bool theState )
1327 DEBTRACE("HYDROGUI_Module::setIsToUpdate");
1328 if( !theObject.IsNull() )
1330 // Process OCC shapes
1331 ViewId2ListOfShapes::const_iterator aShapesMapIter( myShapesMap.begin() );
1332 while( aShapesMapIter != myShapesMap.end() )
1334 const ListOfShapes& aShapesList = aShapesMapIter.value();
1335 foreach ( HYDROGUI_Shape* aShape, aShapesList )
1337 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1339 aShape->setIsToUpdate( theState );
1344 // Process VTK shapes
1345 ViewId2ListOfVTKPrs::const_iterator aVTKPrsMapIter( myVTKPrsMap.begin() );
1346 while( aVTKPrsMapIter != myVTKPrsMap.end() )
1348 const ListOfVTKPrs& aShapesList = aVTKPrsMapIter.value();
1349 foreach ( HYDROGUI_VTKPrs* aShape, aShapesList )
1351 if ( aShape && IsEqual( aShape->getObject(), theObject ) )
1353 aShape->setIsToUpdate( theState );
1361 /////////////////// OCC SHAPES PROCESSING
1362 QList<HYDROGUI_Shape*> HYDROGUI_Module::getObjectShapes( const int theViewId,
1363 ObjectKind theKind ) const
1365 QList<HYDROGUI_Shape*> aResult;
1367 if ( myShapesMap.contains( theViewId ) )
1369 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1370 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1372 if( aShape && aShape->getObject()->GetKind()==theKind )
1373 aResult.append( aShape );
1379 HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId,
1380 const Handle(HYDROData_Entity)& theObject ) const
1382 HYDROGUI_Shape* aResShape = NULL;
1383 if( theObject.IsNull() )
1386 if ( myShapesMap.contains( theViewId ) )
1388 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1389 foreach ( HYDROGUI_Shape* aShape, aViewShapes )
1391 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1402 void HYDROGUI_Module::setObjectShape( const int theViewId,
1403 const Handle(HYDROData_Entity)& theObject,
1404 HYDROGUI_Shape* theShape )
1406 if( theObject.IsNull() )
1409 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1410 aViewShapes.append( theShape );
1413 void HYDROGUI_Module::removeObjectShape( const int theViewId,
1414 const Handle(HYDROData_Entity)& theObject )
1416 if ( !myShapesMap.contains( theViewId ) )
1419 ListOfShapes& aViewShapes = myShapesMap[ theViewId ];
1420 Handle(HYDROData_Entity) anObject;
1421 for ( int i = 0; i < aViewShapes.length(); )
1423 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1424 anObject = aShape->getObject();
1425 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1428 aViewShapes.removeAt( i );
1436 void HYDROGUI_Module::removeViewShapes( const int theViewId )
1438 if ( !myShapesMap.contains( theViewId ) )
1441 const ListOfShapes& aViewShapes = myShapesMap.value( theViewId );
1442 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1444 HYDROGUI_Shape* aShape = aViewShapes.at( i );
1449 myShapesMap.remove( theViewId );
1451 /////////////////// END OF OCC SHAPES PROCESSING
1453 /////////////////// VTKPrs PROCESSING
1454 HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId,
1455 const Handle(HYDROData_Entity)& theObject ) const
1457 HYDROGUI_VTKPrs* aResShape = NULL;
1458 if( theObject.IsNull() )
1461 if ( myVTKPrsMap.contains( theViewId ) )
1463 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1464 foreach ( HYDROGUI_VTKPrs* aShape, aViewShapes )
1466 if ( !aShape || !IsEqual( aShape->getObject(), theObject ) )
1477 void HYDROGUI_Module::setObjectVTKPrs( const int theViewId,
1478 const Handle(HYDROData_Entity)& theObject,
1479 HYDROGUI_VTKPrs* theShape )
1481 if( theObject.IsNull() )
1484 if( theShape && theShape->needScalarBar() )
1486 // Compute the new global Z range from the added presentation and the old global Z range.
1487 double* aGlobalRange = getVTKDisplayer()->GetZRange( theViewId );
1488 double* aRange = theShape->getInternalZRange();
1489 bool anIsUpdate = false;
1490 if ( aRange[0] < aGlobalRange[0] )
1492 aGlobalRange[0] = aRange[0];
1495 if ( aRange[1] > aGlobalRange[1] )
1497 aGlobalRange[1] = aRange[1];
1503 updateVTKZRange( theViewId, aGlobalRange );
1507 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1508 aViewShapes.append( theShape );
1511 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1512 const QString& theEntry )
1514 if ( !myVTKPrsMap.contains( theViewId ) )
1517 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1518 Handle(HYDROData_Entity) anObject;
1520 for ( int i = 0; i < aViewShapes.length(); )
1522 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1523 anObject = aShape->getObject();
1524 anEntryRef = HYDROGUI_DataObject::dataObjectEntry( anObject );
1525 if ( aShape && (!anObject.IsNull()) && ( anEntryRef == theEntry ) )
1528 aViewShapes.removeAt( i );
1535 // Invalidate global Z range
1536 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1537 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1540 void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId,
1541 const Handle(HYDROData_Entity)& theObject )
1543 if ( !myVTKPrsMap.contains( theViewId ) )
1546 ListOfVTKPrs& aViewShapes = myVTKPrsMap[ theViewId ];
1547 Handle(HYDROData_Entity) anObject;
1548 for ( int i = 0; i < aViewShapes.length(); )
1550 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1551 anObject = aShape->getObject();
1552 if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) )
1555 aViewShapes.removeAt( i );
1562 // Invalidate global Z range
1563 double anInvalidRange[2] = { HYDROGUI_VTKPrs::InvalidZValue(), HYDROGUI_VTKPrs::InvalidZValue() };
1564 getVTKDisplayer()->SetZRange( theViewId, anInvalidRange );
1567 void HYDROGUI_Module::removeViewVTKPrs( const int theViewId )
1569 if ( !myVTKPrsMap.contains( theViewId ) )
1572 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1573 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1575 HYDROGUI_VTKPrs* aShape = aViewShapes.at( i );
1580 myVTKPrsMap.remove( theViewId );
1583 void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] )
1585 if ( myVTKPrsMap.contains( theViewId ) )
1587 // For the given viewer id update all VTK presentations ...
1588 const ListOfVTKPrs& aViewShapes = myVTKPrsMap.value( theViewId );
1589 HYDROGUI_VTKPrs* aShape;
1590 for ( int i = 0, n = aViewShapes.length(); i < n; ++i )
1592 aShape = aViewShapes.at( i );
1593 if ( aShape && aShape->needScalarBar() )
1595 aShape->setZRange( theRange );
1599 // ... and update the global color legend scalar bar.
1600 getVTKDisplayer()->SetZRange( theViewId, theRange );
1602 /////////////////// END OF VTKPrs PROCESSING
1604 void HYDROGUI_Module::clearCache()
1606 DEBTRACE("HYDROGUI_Module::clearCache");
1607 myObjectStateMap.clear();
1610 CAM_DataModel* HYDROGUI_Module::createDataModel()
1612 DEBTRACE("HYDROGUI_Module::createDataModel");
1613 return new HYDROGUI_DataModel( this );
1616 void HYDROGUI_Module::customEvent( QEvent* e )
1618 int aType = e->type();
1619 if ( aType == NewViewEvent )
1621 SALOME_CustomEvent* ce = ( SALOME_CustomEvent* )e;
1622 if( GraphicsView_ViewFrame* aViewFrame = ( GraphicsView_ViewFrame* )ce->data() )
1624 if( GraphicsView_Viewer* aViewer = dynamic_cast<GraphicsView_Viewer*>( aViewFrame->getViewer() ) )
1626 SUIT_ViewManager* aViewManager = aViewer->getViewManager();
1627 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1629 if( GraphicsView_ViewPort* aViewPort = aViewer->getActiveViewPort() )
1631 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1632 aViewPort->scale( 1, -1 ); // invert the Y axis direction from down to up
1634 aViewPort->setInteractionFlag( GraphicsView_ViewPort::TraceBoundingRect );
1635 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateContextMenu );
1636 aViewPort->setInteractionFlag( GraphicsView_ViewPort::ImmediateSelection );
1638 //ouv: temporarily commented
1639 //aViewPort->setViewLabelPosition( GraphicsView_ViewPort::VLP_BottomLeft, true );
1642 if( aRole != VMR_TransformImage && aRole != VMR_ReferenceImage )
1643 update( UF_Viewer );
1645 aViewer->activateTransform( GraphicsView_Viewer::FitAll );
1651 bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent )
1653 QEvent::Type aType = theEvent->type();
1654 if( theObj->inherits( "GraphicsView_ViewFrame" ) )
1656 if( aType == QEvent::Show )
1658 SALOME_CustomEvent* e = new SALOME_CustomEvent( NewViewEvent );
1659 e->setData( theObj );
1660 QApplication::postEvent( this, e );
1661 theObj->removeEventFilter( this );
1664 else if ( theObj->inherits( "OCCViewer_ViewPort" ) )
1666 if( aType == QEvent::Leave )
1668 SUIT_Desktop* aDesktop = getApp()->desktop();
1669 if ( aDesktop && aDesktop->statusBar() ) {
1670 aDesktop->statusBar()->clearMessage();
1674 else if ( theObj->inherits( "SVTK_ViewWindow" ) )
1676 if( aType == QEvent::Leave )
1678 SUIT_Desktop* aDesktop = getApp()->desktop();
1679 if ( aDesktop && aDesktop->statusBar() ) {
1680 aDesktop->statusBar()->clearMessage();
1685 return LightApp_Module::eventFilter( theObj, theEvent );
1688 void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager )
1690 DEBTRACE("HYDROGUI_Module::onViewManagerAdded");
1691 LightApp_Module::onViewManagerAdded( theViewManager );
1693 if( theViewManager->getType() == GraphicsView_Viewer::Type() )
1695 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1696 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1698 else if( theViewManager->getType() == OCCViewer_Viewer::Type() )
1700 OCCViewer_ViewManager* mgr = dynamic_cast<OCCViewer_ViewManager*>( theViewManager );
1701 //mgr->setChainedOperations( true );
1703 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1704 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1705 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1706 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1707 connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ),
1708 this, SLOT( onViewActivated( SUIT_ViewManager* ) ) );
1710 else if( theViewManager->getType() == SVTK_Viewer::Type() )
1712 connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ),
1713 this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) );
1714 connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
1715 this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
1718 createSelector( theViewManager ); // replace the default selector
1720 ViewManagerInfo anInfo( theViewManager, VMR_General );
1721 myViewManagerMap.insert( ViewManagerId++, anInfo );
1724 void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager )
1726 DEBTRACE("HYDROGUI_Module::onViewManagerRemoved");
1727 LightApp_Module::onViewManagerRemoved( theViewManager );
1729 createSelector( theViewManager ); // replace the default selector
1731 int anId = getViewManagerId( theViewManager );
1734 OCCViewer_ViewManager* anOCCViewManager =
1735 ::qobject_cast<OCCViewer_ViewManager*>( myViewManagerMap[ anId ].first );
1736 if ( anOCCViewManager )
1738 OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer();
1739 if ( anOCCViewer ) {
1740 int aViewerId = (size_t)anOCCViewer;
1741 removeViewShapes( aViewerId );
1742 setLandCoversScalarMapModeOff( aViewerId );
1746 if ( getVTKDisplayer()->IsApplicable( theViewManager ) )
1748 SVTK_Viewer* aVTKViewer = getVTKViewer( anId );
1751 getVTKDisplayer()->EraseScalarBar( anId, true );
1752 removeViewShapes( (size_t)aVTKViewer );
1756 myViewManagerMap.remove( anId );
1760 void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow )
1762 DEBTRACE("HYDROGUI_Module::onViewCreated");
1763 if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) )
1765 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( theViewWindow ) )
1767 aViewFrame->installEventFilter( this );
1769 GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort();
1770 aViewPort->setInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling );
1772 connect( aViewPort, SIGNAL( vpMouseEvent( QGraphicsSceneMouseEvent* ) ),
1773 this, SLOT( onViewPortMouseEvent( QGraphicsSceneMouseEvent* ) ) );
1776 else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) )
1778 if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theViewWindow ) )
1780 aViewFrame->onTopView();
1782 HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false );
1783 OCCViewer_ViewPort3d* aViewPort = aViewFrame->getViewPort();
1785 aViewPort->installEventFilter( this );
1789 else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) )
1791 if( SVTK_ViewWindow* aViewFrame = dynamic_cast<SVTK_ViewWindow*>( theViewWindow ) )
1793 aViewFrame->installEventFilter( this );
1798 void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent )
1800 /* ouv: currently unused
1801 if( GraphicsView_ViewPort* aViewPort = qobject_cast<GraphicsView_ViewPort*>( sender() ) )
1803 SUIT_ViewManager* aViewManager = 0;
1805 QObject* aParent = aViewPort;
1806 while( aParent = aParent->parent() )
1808 if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast<GraphicsView_ViewFrame*>( aParent ) )
1810 if( GraphicsView_Viewer* aViewer = aViewFrame->getViewer() )
1812 aViewManager = aViewer->getViewManager();
1821 double aMouseX = theEvent->scenePos().x();
1822 double aMouseY = theEvent->scenePos().y();
1824 ViewManagerRole aRole = getViewManagerRole( aViewManager );
1825 if( aRole == VMR_General )
1827 int aXDeg = 0, aYDeg = 0;
1828 int aXMin = 0, aYMin = 0;
1829 double aXSec = 0, aYSec = 0;
1830 HYDROData_Lambert93::secToDMS( aMouseX, aXDeg, aXMin, aXSec );
1831 HYDROData_Lambert93::secToDMS( aMouseY, aYDeg, aYMin, aYSec );
1833 QString aDegSymbol( QChar( 0x00B0 ) );
1834 QString aXStr = QString( "%1%2 %3' %4\"" ).arg( aXDeg ).arg( aDegSymbol ).arg( aXMin ).arg( aXSec );
1835 QString aYStr = QString( "%1%2 %3' %4\"" ).arg( aYDeg ).arg( aDegSymbol ).arg( aYMin ).arg( aYSec );
1837 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( aXStr ).arg( aYStr ) );
1839 else if( aRole == VMR_TransformImage )
1840 aViewPort->setViewLabelText( QString( "X: %1\nY: %2" ).arg( (int)aMouseX ).arg( (int)aMouseY ) );
1845 void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer,
1846 const bool theIsInit,
1847 const bool theIsForced,
1848 const bool theDoFitAll )
1850 DEBTRACE("HYDROGUI_Module::updateViewer");
1851 QList<int> aViewManagerIdList;
1853 // currently, all views are updated
1854 ViewManagerMapIterator anIter( myViewManagerMap );
1855 while( anIter.hasNext() )
1857 SUIT_ViewManager* aViewManager = anIter.next().value().first;
1859 if ( theDisplayer->IsApplicable( aViewManager ) )
1861 int anId = anIter.key();
1862 aViewManagerIdList.append( anId );
1866 QListIterator<int> anIdIter( aViewManagerIdList );
1867 while( anIdIter.hasNext() )
1869 theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll );
1870 myOverview->setTopView();
1874 void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager )
1876 DEBTRACE("HYDROGUI_Module::createSelector");
1877 if( !theViewManager )
1880 LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr();
1881 if( !aSelectionMgr )
1884 QString aViewType = theViewManager->getType();
1885 if( aViewType != GraphicsView_Viewer::Type() &&
1886 aViewType != OCCViewer_Viewer::Type())
1889 QList<SUIT_Selector*> aSelectorList;
1890 aSelectionMgr->selectors( aViewType, aSelectorList );
1892 // disable all alien selectors
1893 QList<SUIT_Selector*>::iterator anIter, anIterEnd = aSelectorList.end();
1894 for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ )
1896 SUIT_Selector* aSelector = *anIter;
1897 if( aSelector && ( !dynamic_cast<HYDROGUI_GVSelector*>( aSelector ) &&
1898 !dynamic_cast<SVTK_Selector*>( aSelector ) &&
1899 !dynamic_cast<HYDROGUI_OCCSelector*>( aSelector ) ) )
1900 aSelector->setEnabled( false );
1903 if ( aViewType == GraphicsView_Viewer::Type() )
1905 GraphicsView_ViewManager* aViewManager =
1906 ::qobject_cast<GraphicsView_ViewManager*>( theViewManager );
1908 new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr );
1910 else if ( aViewType == OCCViewer_Viewer::Type() )
1912 OCCViewer_ViewManager* aViewManager =
1913 ::qobject_cast<OCCViewer_ViewManager*>( theViewManager );
1915 new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr );
1919 bool HYDROGUI_Module::setUpdateEnabled( const bool theState )
1921 DEBTRACE("HYDROGUI_Module::setUpdateEnabled");
1922 bool aPrevState = myIsUpdateEnabled;
1923 myIsUpdateEnabled = theState;
1927 bool HYDROGUI_Module::isUpdateEnabled() const
1929 return myIsUpdateEnabled;
1932 QStringList HYDROGUI_Module::storeSelection() const
1934 DEBTRACE("HYDROGUI_Module::storeSelection");
1935 QStringList anEntryList;
1936 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1938 SUIT_DataOwnerPtrList aList( true );
1939 aSelectionMgr->selected( aList );
1941 SUIT_DataOwnerPtrList::iterator anIter;
1942 for( anIter = aList.begin(); anIter != aList.end(); anIter++ )
1944 const LightApp_DataOwner* anOwner =
1945 dynamic_cast<const LightApp_DataOwner*>( (*anIter).operator->() );
1947 anEntryList.append( anOwner->entry() );
1953 void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList )
1955 DEBTRACE("HYDROGUI_Module::restoreSelection");
1956 if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() )
1958 SUIT_DataOwnerPtrList aList( true );
1959 for( int anIndex = 0, aSize = theEntryList.size(); anIndex < aSize; anIndex++ )
1960 aList.append( SUIT_DataOwnerPtr( new LightApp_DataOwner( theEntryList[ anIndex ] ) ) );
1961 aSelectionMgr->setSelected( aList );
1965 void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* )
1968 bool doShow = false;
1969 HYDROGUI_Displayer* aDisplayer = getDisplayer();
1971 aDisplayer->SaveCursorViewPosition( theViewWindow );
1972 doShow = aDisplayer->GetCursorViewCoordinates( theViewWindow, X, Y, Z );
1976 // Show the coordinates in the status bar
1977 SUIT_Desktop* aDesktop = getApp()->desktop();
1978 if ( aDesktop && aDesktop->statusBar() )
1980 gp_Pnt aWPnt( X, Y, Z );
1981 HYDROData_Document::Document()->Transform( aWPnt, false );
1982 double WX = aWPnt.X(), WY = aWPnt.Y();
1984 QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true );
1985 QString anYStr = HYDROGUI_Tool::GetCoordinateString( Y, true );
1986 QString aWXStr = HYDROGUI_Tool::GetCoordinateString( WX, true );
1987 QString aWYStr = HYDROGUI_Tool::GetCoordinateString( WY, true );
1988 QString aMsg = tr( "COORDINATES_INFO" );
1989 aMsg = aMsg.arg( aXStr ).arg( anYStr ).arg( aWXStr ).arg( aWYStr );
1990 aDesktop->statusBar()->showMessage( aMsg );
1996 * Returns stack of active operations;
1998 QStack<HYDROGUI_Operation*>& HYDROGUI_Module::getActiveOperations()
2000 DEBTRACE("HYDROGUI_Module::getActiveOperations");
2001 return myActiveOperationMap;
2005 * Returns the module active operation. If the active operation is show/hide,
2006 * the method returns the previous operation if it is.
2008 HYDROGUI_Operation* HYDROGUI_Module::activeOperation()
2010 HYDROGUI_Operation* anOp = !myActiveOperationMap.empty() ? myActiveOperationMap.top() : 0;
2012 if ( dynamic_cast<HYDROGUI_ShowHideOp*>( anOp ) )
2014 QVectorIterator<HYDROGUI_Operation*> aVIt( myActiveOperationMap );
2016 aVIt.previous(); // skip the top show/hide operation
2017 anOp = aVIt.hasPrevious() ? aVIt.previous() : 0;
2024 * \brief Virtual public slot
2026 * This method is called after the object inserted into data view to update their visibility state
2027 * This is default implementation
2029 void HYDROGUI_Module::onObjectClicked( SUIT_DataObject* theObject, int theColumn )
2031 if ( !isActiveModule() )
2034 HYDROGUI_DataObject* hydroObject = dynamic_cast<HYDROGUI_DataObject*>( theObject );
2036 // change visibility of object
2037 if ( !hydroObject || theColumn != SUIT_DataObject::VisibilityId )
2040 SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( getApp()->objectBrowser()->model() );
2042 QString id = theObject->text( theObject->customData( Qtx::IdType ).toInt() );
2043 Qtx::VisibilityState visState = treeModel->visibilityState( id );
2044 if ( visState == Qtx::UnpresentableState )
2047 visState = visState == Qtx::ShownState ? Qtx::HiddenState : Qtx::ShownState;
2048 treeModel->setVisibilityState( id, visState );
2050 bool vis = visState == Qtx::ShownState;
2051 if ( vis == isObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject() ) )
2054 setObjectVisible( HYDROGUI_Tool::GetActiveViewId( this ), hydroObject->modelObject(), vis );
2056 update( UF_OCCViewer | UF_VTKViewer | ( visState == Qtx::ShownState ? UF_FitAll : 0 ) );
2059 bool HYDROGUI_Module::isDraggable( const SUIT_DataObject* what ) const
2064 bool HYDROGUI_Module::isDropAccepted( const SUIT_DataObject* where ) const
2070 void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* where,
2071 const int row, Qt::DropAction action )
2073 if ( action != Qt::CopyAction && action != Qt::MoveAction )
2079 if (where->level() < 2 )
2082 DataObjectList::ConstIterator it = what.constBegin();
2083 for (;it != what.constEnd();++it)
2085 if ((*it)->parent() != where)
2089 it = what.constBegin();
2092 for (;it != what.constEnd();++it)
2094 SUIT_DataObject* objWhat = *it;
2096 DataObjectList objInSect = where->children();
2098 //std::list<SUIT_DataObject*> t1 = where->children().toStdList(); //debug
2099 int ind = objInSect.indexOf(objWhat);
2102 HYDROGUI_DataModel* aModel = getDataModel();
2111 where->moveChildPos(objWhat, pos);
2112 //std::list<SUIT_DataObject*> t2 = where->children().toStdList(); //debug
2116 getApp()->updateObjectBrowser(true);
2120 Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const
2122 Handle(HYDROData_StricklerTable) aTable;
2124 if ( myLandCoverColoringMap.contains( theViewId ) ) {
2125 aTable = myLandCoverColoringMap.value( theViewId );
2131 void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId,
2132 const Handle(HYDROData_StricklerTable)& theTable )
2134 if ( !theTable.IsNull() ) {
2135 myLandCoverColoringMap.insert( theViewId, theTable );
2139 void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId )
2141 myLandCoverColoringMap.remove( theViewId );
2144 bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const
2146 return myLandCoverColoringMap.contains( theViewId );
2149 void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObject )
2151 if ( theObject.IsNull() || !theObject->IsRemoved() ) {
2155 if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) {
2156 Handle(HYDROData_StricklerTable) aTable =
2157 Handle(HYDROData_StricklerTable)::DownCast( theObject );
2158 QList<int> aViewIds;
2159 QMutableMapIterator<int, Handle(HYDROData_StricklerTable)> anIter( myLandCoverColoringMap );
2160 while ( anIter.hasNext() ) {
2161 if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) ==
2162 HYDROGUI_DataObject::dataObjectEntry( aTable ) ) {
2169 void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr )
2171 DEBTRACE("HYDROGUI_Module::onViewActivated");
2175 SUIT_ViewWindow* wnd = theMgr->getActiveView();
2176 OCCViewer_ViewFrame* occwnd = dynamic_cast<OCCViewer_ViewFrame*>( wnd );
2180 myOverview->setMainView( occwnd );
2183 void HYDROGUI_Module::setAutoZoomToAllViewManagers(bool bAutoZoom)
2185 ViewManagerList aViewManagers = getApp()->viewManagers();
2186 foreach (SUIT_ViewManager* aVMgr, aViewManagers)
2187 setAutoZoom(aVMgr, bAutoZoom);
2190 void HYDROGUI_Module::setAutoZoom(SUIT_ViewManager* aVMgr, bool bAutoZoom)
2194 QVector<SUIT_ViewWindow*> aViews = aVMgr->getViews();
2195 foreach (SUIT_ViewWindow* aView, aViews)
2199 OCCViewer_ViewFrame* anOCCViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( aView );
2202 anOCCViewFrame->setAutomaticZoom(bAutoZoom);
2203 for (int i = OCCViewer_ViewFrame::MAIN_VIEW; i<=OCCViewer_ViewFrame::TOP_RIGHT; i++)
2205 OCCViewer_ViewWindow* aV = anOCCViewFrame->getView(i);
2207 aV->setAutomaticZoom(bAutoZoom);
2210 OCCViewer_ViewWindow* anOCCViewWindow = dynamic_cast<OCCViewer_ViewWindow*>( aView );
2211 if (anOCCViewWindow)
2212 anOCCViewWindow->setAutomaticZoom(bAutoZoom);