X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FHYDROGUI%2FHYDROGUI_Module.cxx;h=f93e0cef65fbf1955a0f5b072067ce7ca890970f;hb=ab259fb906dc491712765e98efb34cc18b9fd183;hp=cca1a2ae051bf165c0c9a25f09619296e9b1693b;hpb=e65d0d622f842ec712a1bef0b854067762f730a2;p=modules%2Fhydro.git diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index cca1a2ae..f93e0cef 100755 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -16,6 +16,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#include + #include "HYDROGUI_Module.h" #include "HYDROGUI.h" @@ -28,6 +30,7 @@ #include "HYDROGUI_OCCDisplayer.h" #include "HYDROGUI_OCCSelector.h" #include "HYDROGUI_Operations.h" +#include "HYDROGUI_Operation.h" #include "HYDROGUI_PrsImage.h" #include "HYDROGUI_Tool.h" #include "HYDROGUI_Tool2.h" @@ -109,7 +112,10 @@ #include #include -static int ViewManagerId = 0; +//#define _DEVDEBUG_ +#include "HYDRO_trace.hxx" + +static size_t ViewManagerId = 1; extern "C" HYDRO_EXPORT CAM_Module* createModule() { @@ -128,20 +134,24 @@ HYDROGUI_Module::HYDROGUI_Module() myIsUpdateEnabled( true ), myOverview( 0 ) { + DEBTRACE("HYDROGUI_Module::HYDROGUI_Module()"); } HYDROGUI_Module::~HYDROGUI_Module() { + DEBTRACE("HYDROGUI_Module::~HYDROGUI_Module()"); } int HYDROGUI_Module::getStudyId() const { + DEBTRACE("HYDROGUI_Module::getStudyId()"); LightApp_Application* anApp = getApp(); return anApp ? anApp->activeStudy()->id() : 0; } void HYDROGUI_Module::initialize( CAM_Application* theApp ) { + DEBTRACE("HYDROGUI_Module::initialize"); LightApp_Module::initialize( theApp ); createActions(); @@ -157,12 +167,13 @@ void HYDROGUI_Module::initialize( CAM_Application* theApp ) myOCCDisplayer = new HYDROGUI_OCCDisplayer( this ); myVTKDisplayer = new HYDROGUI_VTKPrsDisplayer( this ); - HYDROData_Tool::SetSIProgress( new HYDROGUI_SIProgressIndicator( theApp->desktop() ) ); - HYDROData_Tool::SetZIProgress( new HYDROGUI_ZIProgressIndicator( theApp->desktop() ) ); + //HYDROData_Tool::SetSIProgress( new HYDROGUI_SIProgressIndicator( theApp->desktop() ) ); + //HYDROData_Tool::SetZIProgress( new HYDROGUI_ZIProgressIndicator( theApp->desktop() ) ); } bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) { + DEBTRACE("HYDROGUI_Module::activateModule"); bool aRes = LightApp_Module::activateModule( theStudy ); LightApp_Application* anApp = getApp(); @@ -173,28 +184,46 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) setMenuShown( true ); setToolShown( true ); + // import Python module that manages HYDRO plugins (need to be here because SalomePyQt API uses active module) + PyGILState_STATE gstate = PyGILState_Ensure(); + PyObject* pluginsmanager = PyImport_ImportModuleNoBlock((char*)"salome_pluginsmanager"); + if ( !pluginsmanager ) { + PyErr_Print(); + } + else { + PyObject* result = + PyObject_CallMethod(pluginsmanager, (char*)"initialize", (char*)"isss", 1, "hydro", + tr("MEN_DESK_HYDRO").toUtf8().data(), + tr("Python plugins").toUtf8().data()); + if ( !result ) + PyErr_Print(); + Py_XDECREF(result); + } + PyGILState_Release(gstate); + // end of GEOM plugins loading + #ifndef DISABLE_PYCONSOLE - aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ), + aDesktop->tabifyDockWidget( HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_PyConsole ) ), HYDROGUI_Tool::WindowDock( anApp->getWindow( LightApp_Application::WT_LogWindow ) ) ); #endif // Remove defunct view managers from the map. // It's essential to do this before "update( UF_All )" call! - QList anObsoleteIds; + QList anObsoleteIds; ViewManagerList anAllViewManagers = anApp->viewManagers(); ViewManagerList aHydroViewManagers; // view managers created inside the HYDRO module ViewManagerMapIterator anIter( myViewManagerMap ); while( anIter.hasNext() ) { - int anId = anIter.next().key(); + size_t anId = anIter.next().key(); const ViewManagerInfo& anInfo = anIter.value(); - + aHydroViewManagers << anInfo.first; if ( !anAllViewManagers.contains( anInfo.first ) ) { anObsoleteIds << anId; } } - foreach ( const int anId, anObsoleteIds ) { + foreach ( const size_t anId, anObsoleteIds ) { myViewManagerMap.remove( anId ); myObjectStateMap.remove( anId ); myShapesMap.remove( anId ); @@ -223,7 +252,7 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) { connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ), this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); - connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ), + connect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ), this, SLOT( onViewActivated( SUIT_ViewManager* ) ) ); OCCViewer_ViewManager* occ_mgr = dynamic_cast( aViewManager ); @@ -247,10 +276,10 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) preferencesChanged( "HYDRO", "chained_panning" ); // Load GEOM data - SalomeApp_Study* aStudy = + SalomeApp_Study* aStudy = dynamic_cast( getApp()->activeStudy() ); if ( aStudy ) { - SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() ); + SALOMEDS::Study_var aDSStudy = GeometryGUI::getStudyServant(); GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen(); if ( !aGeomEngine->_is_nil() && !aGeomEngine->_is_nil() ) { SALOMEDS::StudyBuilder_var aStudyBuilder = aDSStudy->NewBuilder(); @@ -271,6 +300,7 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy ) bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy ) { + DEBTRACE("HYDROGUI_Module::deactivateModule"); /* Issues ## 68, 88. ViewManagerMapIterator anIter( myViewManagerMap ); while( anIter.hasNext() ) @@ -285,7 +315,7 @@ bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy ) { disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ), this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); - disconnect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ), + disconnect( aViewManager, SIGNAL( activated( SUIT_ViewManager* ) ), this, SLOT( onViewActivated( SUIT_ViewManager* ) ) ); OCCViewer_ViewManager* occ_mgr = dynamic_cast( aViewManager ); @@ -322,11 +352,22 @@ bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy ) myViewManagerMap.clear(); - return LightApp_Module::deactivateModule( theStudy ); + bool ret = LightApp_Module::deactivateModule( theStudy ); + return ret; +} + +void HYDROGUI_Module::studyClosed(SUIT_Study* theStudy) +{ + DEBTRACE("HYDROGUI_Module::studyClosed"); + HYDROGUI_Operation::myIsClear = false; // force clear of Zlayers on next study + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); + if (!aDoc.IsNull()) + aDoc->Close(); } void HYDROGUI_Module::windows( QMap& theMap ) const { + DEBTRACE("HYDROGUI_Module::windows"); static bool inWindows = false; if( inWindows ) return; @@ -343,7 +384,7 @@ void HYDROGUI_Module::windows( QMap& theMap ) const LightApp_Application* app = getApp(); if( app && app->getWindow( OverviewWindow )==0 ) { - const_cast( this )->myOverview = + const_cast( this )->myOverview = new HYDROGUI_Overview( tr( "OVERVIEW" ), 0, app->desktop() ); app->insertDockWindow( OverviewWindow, myOverview ); app->placeDockWindow( OverviewWindow, Qt::LeftDockWidgetArea ); @@ -353,6 +394,7 @@ void HYDROGUI_Module::windows( QMap& theMap ) const void HYDROGUI_Module::viewManagers( QStringList& theTypesList ) const { + DEBTRACE("HYDROGUI_Module::viewManagers"); theTypesList << GraphicsView_Viewer::Type() << OCCViewer_Viewer::Type(); } @@ -419,14 +461,14 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, // Check the selected GEOM objects (take into account the Object Browser only) if ( anIsObjectBrowser ) { - QList anObstacleTypes = + QList anObstacleTypes = HYDROGUI_ImportGeomObjectOp::getObstacleTypes(); - QList aPolylineTypes = + QList aPolylineTypes = HYDROGUI_ImportGeomObjectOp::getPolylineTypes(); - bool isCanBeImportedAsObstacle = + bool isCanBeImportedAsObstacle = !HYDROGUI_Tool::GetSelectedGeomObjects( this, anObstacleTypes ).isEmpty(); - bool isCanBeImportedAsPolyline = + bool isCanBeImportedAsPolyline = !HYDROGUI_Tool::GetSelectedGeomObjects( this, aPolylineTypes ).isEmpty(); // Add import as obstacle action @@ -495,7 +537,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, anIsProfile = true; aNbOfSelectedProfiles++; - Handle(HYDROData_Profile) aProfile = + Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( anObject ); if( !aProfile.IsNull() && aProfile->IsValid() ) { anIsValidProfile = true; @@ -524,7 +566,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, else if( anObjectKind == KIND_STREAM ) { anIsStream = true; - Handle(HYDROData_Stream) aStream = + Handle(HYDROData_Stream) aStream = Handle(HYDROData_Stream)::DownCast( anObject ); if ( !aStream.IsNull() ) isStreamHasBottom = !aStream->GetBottomPolyline().IsNull(); @@ -575,11 +617,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( CreateCylinderId ) ); break; case KIND_STRICKLER_TABLE: - theMenu->addAction( action( ImportStricklerTableFromFileId ) ); + theMenu->addAction( action( ImportStricklerTableFromFileId ) ); break; case KIND_LAND_COVER_MAP: - theMenu->addAction( action( CreateLandCoverMapId ) ); - theMenu->addAction( action( ImportLandCoverMapId ) ); + theMenu->addAction( action( CreateLandCoverMapId ) ); + theMenu->addAction( action( ImportLandCoverMapId ) ); break; case KIND_CALCULATION: theMenu->addAction( action( CreateCalculationId ) ); @@ -590,6 +632,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, break; case KIND_POLYLINE: theMenu->addAction( action( CreatePolyline3DId ) ); + theMenu->addAction( action( ImportPolylineId ) ); break; case KIND_PROFILE: theMenu->addAction( action( CreateProfileId ) ); @@ -693,6 +736,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, { theMenu->addAction( action( EditCalculationId ) ); theMenu->addAction( action( ExportCalculationId ) ); + theMenu->addAction( action( CompleteCalculationId ) ); theMenu->addSeparator(); } else if( anIsImmersibleZone ) @@ -733,9 +777,9 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( DuplicateStricklerTableId ) ); theMenu->addSeparator(); - Handle(HYDROData_StricklerTable) aTable = + Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( aSeq.First() ); - QString aCurrentTable = + QString aCurrentTable = HYDROGUI_DataObject::dataObjectEntry( getLandCoverColoringTable( anActiveViewId ) ); bool isUsed = aCurrentTable == HYDROGUI_DataObject::dataObjectEntry( aTable ); @@ -756,7 +800,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, // theMenu->addAction( action( ExportToShapeFileID ) ); theMenu->addSeparator(); - } + } else if( anIsVisualState && anIsObjectBrowser ) { theMenu->addAction( action( SaveVisualStateId ) ); @@ -787,7 +831,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addAction( action( SetTransparencyId ) ); theMenu->addSeparator(); } - } + } else if ( anAllAreProfiles ) { theMenu->addAction( action( EditProfileId ) ); @@ -812,7 +856,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, theMenu->addSeparator(); - if( anIsImage || anIsPolyline || anIsPolyline3D || + if( anIsImage || anIsPolyline || anIsPolyline3D || anIsImmersibleZone || anIsZone || anIsRegion || anIsBathymetry || anIsObstacle || anIsStream || anIsChannel || anIsDigue || anIsDummyObject3D || @@ -903,6 +947,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient, void HYDROGUI_Module::createPreferences() { + DEBTRACE("HYDROGUI_Module::createPreferences"); int genTab = addPreference( tr( "PREF_TAB_GENERAL" ) ); int CursorGroup = addPreference( tr( "PREF_GROUP_CURSOR" ), genTab ); @@ -963,11 +1008,12 @@ void HYDROGUI_Module::createPreferences() void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QString& thePref ) { + DEBTRACE("HYDROGUI_Module::preferencesChanged"); SUIT_ResourceMgr* resMgr = application()->resourceMgr(); if ( theSection == "preferences" && thePref == "default_strickler_coefficient" ) { - - Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( application()->activeStudy()->id() ); + + Handle(HYDROData_Document) aDoc = HYDROData_Document::Document(); if ( resMgr && !aDoc.IsNull() ) aDoc->SetDefaultStricklerCoefficient( resMgr->doubleValue( theSection, thePref, 0 ) ); } @@ -984,7 +1030,7 @@ void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QStri ViewManagerMap::const_iterator it = myViewManagerMap.begin(), last = myViewManagerMap.end(); for( ; it!=last; it++ ) { - int aViewerId = it.key(); + size_t aViewerId = it.key(); OCCViewer_ViewManager* aMgr = dynamic_cast( it.value().first ); if( aMgr ) getOCCDisplayer()->UpdatePolylines( aViewerId, aType, aSize ); @@ -1007,7 +1053,7 @@ void HYDROGUI_Module::preferencesChanged( const QString& theSection, const QStri if (anOCCViewMgr) anOCCViewMgr->setChainedOperations( aChainedPan ); } - + QList docW = getApp()->desktop()->findChildren(); foreach (QDockWidget* qw, docW) { @@ -1031,6 +1077,7 @@ QCursor HYDROGUI_Module::getPrefEditCursor() const void HYDROGUI_Module::update( const int flags ) { + DEBTRACE("HYDROGUI_Module::update"); if ( !isUpdateEnabled() ) return; @@ -1051,13 +1098,13 @@ void HYDROGUI_Module::update( const int flags ) } if( ( flags & UF_Viewer ) ) - updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll ); + updateViewer( getDisplayer(), flags & UF_GV_Init, flags & UF_GV_Forced, aDoFitAll ); if( ( flags & UF_OCCViewer ) ) - updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll ); + updateViewer( getOCCDisplayer(), flags & UF_OCC_Init, flags & UF_OCC_Forced, aDoFitAll ); if( ( flags & UF_VTKViewer ) ) - updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll ); + updateViewer( getVTKDisplayer(), flags & UF_VTK_Init, flags & UF_VTK_Forced, aDoFitAll ); if( ( flags & UF_Model ) && getDataModel() && getApp() ) { @@ -1072,11 +1119,11 @@ void HYDROGUI_Module::update( const int flags ) bool isResizeOnExpandItem = aResMgr->booleanValue( "ObjectBrowser", "resize_on_expand_item", false ); SUIT_DataBrowser* anObjectBrowser = getApp()->objectBrowser(); if ( isResizeOnExpandItem && anObjectBrowser ) { - anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280 + anObjectBrowser->setResizeOnExpandItem( false ); // MZN: ISSUE #280 } getApp()->updateObjectBrowser( true ); if ( isResizeOnExpandItem && anObjectBrowser ) { - anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280 + anObjectBrowser->setResizeOnExpandItem( true ); // MZN: ISSUE #280 } } @@ -1101,6 +1148,7 @@ void HYDROGUI_Module::update( const int flags ) void HYDROGUI_Module::updateCommandsStatus() { + DEBTRACE("HYDROGUI_Module::updateCommandsStatus"); LightApp_Module::updateCommandsStatus(); updateUndoRedoControls(); @@ -1111,32 +1159,38 @@ void HYDROGUI_Module::updateCommandsStatus() void HYDROGUI_Module::selectionChanged() { + DEBTRACE("HYDROGUI_Module::selectionChanged"); LightApp_Module::selectionChanged(); updateCommandsStatus(); } HYDROGUI_DataModel* HYDROGUI_Module::getDataModel() const { + //DEBTRACE("HYDROGUI_Module::getDataModel()"); return (HYDROGUI_DataModel*)dataModel(); } HYDROGUI_Displayer* HYDROGUI_Module::getDisplayer() const { + //DEBTRACE("HYDROGUI_Module::getDisplayer()"); return myDisplayer; } HYDROGUI_OCCDisplayer* HYDROGUI_Module::getOCCDisplayer() const { + DEBTRACE("HYDROGUI_Module::getOCCDisplayer"); return myOCCDisplayer; } HYDROGUI_VTKPrsDisplayer* HYDROGUI_Module::getVTKDisplayer() const { + DEBTRACE("HYDROGUI_Module::getVTKDisplayer"); return myVTKDisplayer; } -SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const +SUIT_ViewManager* HYDROGUI_Module::getViewManager( const size_t theId ) const { + DEBTRACE("HYDROGUI_Module::getViewManager " << theId); if( myViewManagerMap.contains( theId ) ) { return myViewManagerMap[ theId ].first; @@ -1144,8 +1198,9 @@ SUIT_ViewManager* HYDROGUI_Module::getViewManager( const int theId ) const return NULL; } -GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const +GraphicsView_Viewer* HYDROGUI_Module::getViewer( const size_t theId ) const { + DEBTRACE("HYDROGUI_Module::getViewer " << theId); if( myViewManagerMap.contains( theId ) ) { ViewManagerInfo anInfo = myViewManagerMap[ theId ]; @@ -1157,8 +1212,9 @@ GraphicsView_Viewer* HYDROGUI_Module::getViewer( const int theId ) const return NULL; } -OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const +OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const size_t theId ) const { + DEBTRACE("HYDROGUI_Module::getOCCViewer " << theId); if( myViewManagerMap.contains( theId ) ) { ViewManagerInfo anInfo = myViewManagerMap[ theId ]; @@ -1170,8 +1226,9 @@ OCCViewer_Viewer* HYDROGUI_Module::getOCCViewer( const int theId ) const return NULL; } -SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const +SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const size_t theId ) const { + DEBTRACE("HYDROGUI_Module::getVTKViewer " << theId); if( myViewManagerMap.contains( theId ) ) { ViewManagerInfo anInfo = myViewManagerMap[ theId ]; @@ -1183,23 +1240,25 @@ SVTK_Viewer* HYDROGUI_Module::getVTKViewer( const int theId ) const return NULL; } -int HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager ) +size_t HYDROGUI_Module::getViewManagerId( SUIT_ViewManager* theViewManager ) { + DEBTRACE("HYDROGUI_Module::getViewManagerId"); ViewManagerMapIterator anIter( myViewManagerMap ); while( anIter.hasNext() ) { - int anId = anIter.next().key(); + size_t anId = anIter.next().key(); const ViewManagerInfo& anInfo = anIter.value(); if( anInfo.first == theViewManager ) return anId; } - return -1; + return 0; } HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewManager* theViewManager ) { - int anId = getViewManagerId( theViewManager ); - if( anId != -1 ) + DEBTRACE("HYDROGUI_Module::getViewManagerRole"); + size_t anId = getViewManagerId( theViewManager ); + if( anId == 0 ) { const ViewManagerInfo& anInfo = myViewManagerMap[ anId ]; return anInfo.second; @@ -1210,24 +1269,25 @@ HYDROGUI_Module::ViewManagerRole HYDROGUI_Module::getViewManagerRole( SUIT_ViewM void HYDROGUI_Module::setViewManagerRole( SUIT_ViewManager* theViewManager, const ViewManagerRole theRole ) { - int anId = getViewManagerId( theViewManager ); - if( anId != -1 ) + DEBTRACE("HYDROGUI_Module::setViewManagerRole"); + size_t anId = getViewManagerId( theViewManager ); + if( anId != 0 ) { ViewManagerInfo& anInfo = myViewManagerMap[ anId ]; anInfo.second = theRole; } } -bool HYDROGUI_Module::isObjectVisible( const int theViewId, +bool HYDROGUI_Module::isObjectVisible( const size_t theViewId, const Handle(HYDROData_Entity)& theObject ) const { if( theObject.IsNull() ) return false; - if( theViewId < 0 ) + if( theViewId == 0 ) { //search in all - foreach( int aViewId, myObjectStateMap.keys() ) + foreach( size_t aViewId, myObjectStateMap.keys() ) { if( isObjectVisible( aViewId, theObject ) ) return true; @@ -1251,26 +1311,40 @@ bool HYDROGUI_Module::isObjectVisible( const int theViewId, return false; } -void HYDROGUI_Module::setObjectVisible( const int theViewId, +void HYDROGUI_Module::setObjectVisible( const size_t theViewId, const Handle(HYDROData_Entity)& theObject, const bool theState ) { + DEBTRACE("setObjectVisible, theViewId: " << theViewId << " " << theState); if( !theObject.IsNull() ) { - Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ]; - QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject ); + DEBTRACE("myObjectStateMap.size: " << myObjectStateMap.size()); + QString anEntry = HYDROGUI_DataObject::dataObjectEntry( theObject ); + DEBTRACE("anEntry: " << anEntry.toStdString()); + if (myObjectStateMap.find(theViewId) == myObjectStateMap.end()) + { + DEBTRACE("theViewId is not a valid key for myObjectStateMap"); + } + if (theViewId) + { + Entry2ObjectStateMap& aEntry2ObjectStateMap = myObjectStateMap[ theViewId ]; // created OK if it does not exist + DEBTRACE("myObjectStateMap key created"); - ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ]; - anObjectState.Visibility = theState; + ObjectState& anObjectState = aEntry2ObjectStateMap[ anEntry ]; + anObjectState.Visibility = theState; + } HYDROGUI_DataObject* hydroObject = getDataModel()->getDataObject( theObject ); if ( hydroObject ) { + DEBTRACE("hydroObject " << hydroObject); SUIT_AbstractModel* treeModel = dynamic_cast( getApp()->objectBrowser()->model() ); if ( treeModel ) { + DEBTRACE("treeModel " << treeModel); QString id = hydroObject->text( hydroObject->customData( Qtx::IdType ).toInt() ); Qtx::VisibilityState visState = treeModel->visibilityState( id ); + DEBTRACE("id " << id << " visState "<< visState); if ( visState != Qtx::UnpresentableState ) treeModel->setVisibilityState( id, theState ? Qtx::ShownState : Qtx::HiddenState ); } @@ -1287,6 +1361,7 @@ void HYDROGUI_Module::setObjectVisible( const int theViewId, void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject, const bool theState ) { + DEBTRACE("HYDROGUI_Module::setIsToUpdate"); if( !theObject.IsNull() ) { // Process OCC shapes @@ -1321,7 +1396,7 @@ void HYDROGUI_Module::setIsToUpdate( const Handle(HYDROData_Entity)& theObject, } /////////////////// OCC SHAPES PROCESSING -QList HYDROGUI_Module::getObjectShapes( const int theViewId, +QList HYDROGUI_Module::getObjectShapes( const size_t theViewId, ObjectKind theKind ) const { QList aResult; @@ -1338,7 +1413,7 @@ QList HYDROGUI_Module::getObjectShapes( const int theViewId, return aResult; } -HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int theViewId, +HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const size_t theViewId, const Handle(HYDROData_Entity)& theObject ) const { HYDROGUI_Shape* aResShape = NULL; @@ -1361,7 +1436,7 @@ HYDROGUI_Shape* HYDROGUI_Module::getObjectShape( const int return aResShape; } -void HYDROGUI_Module::setObjectShape( const int theViewId, +void HYDROGUI_Module::setObjectShape( const size_t theViewId, const Handle(HYDROData_Entity)& theObject, HYDROGUI_Shape* theShape ) { @@ -1372,7 +1447,7 @@ void HYDROGUI_Module::setObjectShape( const int theViewId, aViewShapes.append( theShape ); } -void HYDROGUI_Module::removeObjectShape( const int theViewId, +void HYDROGUI_Module::removeObjectShape( const size_t theViewId, const Handle(HYDROData_Entity)& theObject ) { if ( !myShapesMap.contains( theViewId ) ) @@ -1386,6 +1461,7 @@ void HYDROGUI_Module::removeObjectShape( const int theView anObject = aShape->getObject(); if ( aShape && (!anObject.IsNull()) && IsEqual( anObject, theObject ) ) { + DEBTRACE("delete shape :" << aShape->getObject()->GetName().toStdString()); delete aShape; aViewShapes.removeAt( i ); continue; @@ -1395,7 +1471,7 @@ void HYDROGUI_Module::removeObjectShape( const int theView } } -void HYDROGUI_Module::removeViewShapes( const int theViewId ) +void HYDROGUI_Module::removeViewShapes( const size_t theViewId ) { if ( !myShapesMap.contains( theViewId ) ) return; @@ -1413,7 +1489,7 @@ void HYDROGUI_Module::removeViewShapes( const int theViewId ) /////////////////// END OF OCC SHAPES PROCESSING /////////////////// VTKPrs PROCESSING -HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int theViewId, +HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const size_t theViewId, const Handle(HYDROData_Entity)& theObject ) const { HYDROGUI_VTKPrs* aResShape = NULL; @@ -1436,7 +1512,7 @@ HYDROGUI_VTKPrs* HYDROGUI_Module::getObjectVTKPrs( const int return aResShape; } -void HYDROGUI_Module::setObjectVTKPrs( const int theViewId, +void HYDROGUI_Module::setObjectVTKPrs( const size_t theViewId, const Handle(HYDROData_Entity)& theObject, HYDROGUI_VTKPrs* theShape ) { @@ -1470,7 +1546,7 @@ void HYDROGUI_Module::setObjectVTKPrs( const int theViewId aViewShapes.append( theShape ); } -void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId, +void HYDROGUI_Module::removeObjectVTKPrs( const size_t theViewId, const QString& theEntry ) { if ( !myVTKPrsMap.contains( theViewId ) ) @@ -1499,7 +1575,7 @@ void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId, getVTKDisplayer()->SetZRange( theViewId, anInvalidRange ); } -void HYDROGUI_Module::removeObjectVTKPrs( const int theViewId, +void HYDROGUI_Module::removeObjectVTKPrs( const size_t theViewId, const Handle(HYDROData_Entity)& theObject ) { if ( !myVTKPrsMap.contains( theViewId ) ) @@ -1526,7 +1602,7 @@ void HYDROGUI_Module::removeObjectVTKPrs( const int theVie getVTKDisplayer()->SetZRange( theViewId, anInvalidRange ); } -void HYDROGUI_Module::removeViewVTKPrs( const int theViewId ) +void HYDROGUI_Module::removeViewVTKPrs( const size_t theViewId ) { if ( !myVTKPrsMap.contains( theViewId ) ) return; @@ -1542,7 +1618,7 @@ void HYDROGUI_Module::removeViewVTKPrs( const int theViewId ) myVTKPrsMap.remove( theViewId ); } -void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] ) +void HYDROGUI_Module::updateVTKZRange( const size_t theViewId, double theRange[] ) { if ( myVTKPrsMap.contains( theViewId ) ) { @@ -1565,11 +1641,13 @@ void HYDROGUI_Module::updateVTKZRange( const int theViewId, double theRange[] ) void HYDROGUI_Module::clearCache() { + DEBTRACE("HYDROGUI_Module::clearCache"); myObjectStateMap.clear(); } CAM_DataModel* HYDROGUI_Module::createDataModel() { + DEBTRACE("HYDROGUI_Module::createDataModel"); return new HYDROGUI_DataModel( this ); } @@ -1647,10 +1725,11 @@ bool HYDROGUI_Module::eventFilter( QObject* theObj, QEvent* theEvent ) void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager ) { + DEBTRACE("HYDROGUI_Module::onViewManagerAdded"); LightApp_Module::onViewManagerAdded( theViewManager ); if( theViewManager->getType() == GraphicsView_Viewer::Type() ) - { + { connect( theViewManager, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) ); } @@ -1663,7 +1742,7 @@ void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager ) this, SLOT( onViewCreated( SUIT_ViewWindow* ) ) ); connect( theViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ), this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) ); - connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ), + connect( theViewManager, SIGNAL( activated( SUIT_ViewManager* ) ), this, SLOT( onViewActivated( SUIT_ViewManager* ) ) ); } else if( theViewManager->getType() == SVTK_Viewer::Type() ) @@ -1680,22 +1759,23 @@ void HYDROGUI_Module::onViewManagerAdded( SUIT_ViewManager* theViewManager ) myViewManagerMap.insert( ViewManagerId++, anInfo ); } -void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager ) +void HYDROGUI_Module::removeViewManager( SUIT_ViewManager* theViewManager) { - LightApp_Module::onViewManagerRemoved( theViewManager ); + DEBTRACE("removeViewManager") - createSelector( theViewManager ); // replace the default selector - - int anId = getViewManagerId( theViewManager ); - if( anId != -1 ) + size_t anId = getViewManagerId( theViewManager ); + if( anId != 0 ) { + bool isDisableGVSelector = theViewManager->getType() == GraphicsView_Viewer::Type(); + createSelector( theViewManager, isDisableGVSelector ); // replace the default selector + OCCViewer_ViewManager* anOCCViewManager = ::qobject_cast( myViewManagerMap[ anId ].first ); if ( anOCCViewManager ) { OCCViewer_Viewer* anOCCViewer = anOCCViewManager->getOCCViewer(); if ( anOCCViewer ) { - int aViewerId = (size_t)anOCCViewer; + size_t aViewerId = (size_t)anOCCViewer; removeViewShapes( aViewerId ); setLandCoversScalarMapModeOff( aViewerId ); } @@ -1715,12 +1795,23 @@ void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager ) } } +void HYDROGUI_Module::onViewManagerRemoved( SUIT_ViewManager* theViewManager ) +{ + DEBTRACE("HYDROGUI_Module::onViewManagerRemoved"); + removeViewManager(theViewManager); + LightApp_Module::onViewManagerRemoved( theViewManager ); + +} + void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow ) { + DEBTRACE("HYDROGUI_Module::onViewCreated"); if( theViewWindow && theViewWindow->inherits( "GraphicsView_ViewFrame" ) ) { + DEBTRACE("theViewWindow->inherits( 'GraphicsView_ViewFrame' )"); if( GraphicsView_ViewFrame* aViewFrame = dynamic_cast( theViewWindow ) ) { + DEBTRACE("---"); aViewFrame->installEventFilter( this ); GraphicsView_ViewPort* aViewPort = aViewFrame->getViewPort(); @@ -1732,8 +1823,10 @@ void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow ) } else if( theViewWindow && theViewWindow->inherits( "OCCViewer_ViewFrame" ) ) { + DEBTRACE("theViewWindow->inherits( 'OCCViewer_ViewFrame' )"); if( OCCViewer_ViewFrame* aViewFrame = dynamic_cast( theViewWindow ) ) { + DEBTRACE("---"); aViewFrame->onTopView(); HYDROGUI_Tool::setOCCActionShown( aViewFrame, OCCViewer_ViewWindow::MaximizedId, false ); @@ -1745,8 +1838,10 @@ void HYDROGUI_Module::onViewCreated( SUIT_ViewWindow* theViewWindow ) } else if( theViewWindow && theViewWindow->inherits( "SVTK_ViewWindow" ) ) { + DEBTRACE("theViewWindow->inherits( 'SVTK_ViewWindow' )"); if( SVTK_ViewWindow* aViewFrame = dynamic_cast( theViewWindow ) ) { + DEBTRACE("---"); aViewFrame->installEventFilter( this ); } } @@ -1799,17 +1894,18 @@ void HYDROGUI_Module::onViewPortMouseEvent( QGraphicsSceneMouseEvent* theEvent ) */ } -void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, - const bool theIsInit, - const bool theIsForced, +void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, + const bool theIsInit, + const bool theIsForced, const bool theDoFitAll ) { - QList aViewManagerIdList; + DEBTRACE("HYDROGUI_Module::updateViewer"); + QList aViewManagerIdList; // currently, all views are updated ViewManagerMapIterator anIter( myViewManagerMap ); while( anIter.hasNext() ) - { + { SUIT_ViewManager* aViewManager = anIter.next().value().first; if ( theDisplayer->IsApplicable( aViewManager ) ) @@ -1819,7 +1915,7 @@ void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, } } - QListIterator anIdIter( aViewManagerIdList ); + QListIterator anIdIter( aViewManagerIdList ); while( anIdIter.hasNext() ) { theDisplayer->UpdateAll( anIdIter.next(), theIsInit, theIsForced, theDoFitAll ); @@ -1827,8 +1923,9 @@ void HYDROGUI_Module::updateViewer( HYDROGUI_AbstractDisplayer* theDisplayer, } } -void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager ) +void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager, bool isDisableGV ) { + DEBTRACE("HYDROGUI_Module::createSelector " << isDisableGV); if( !theViewManager ) return; @@ -1837,6 +1934,7 @@ void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager ) return; QString aViewType = theViewManager->getType(); + DEBTRACE("aViewType " << aViewType.toStdString()); if( aViewType != GraphicsView_Viewer::Type() && aViewType != OCCViewer_Viewer::Type()) return; @@ -1845,14 +1943,44 @@ void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager ) aSelectionMgr->selectors( aViewType, aSelectorList ); // disable all alien selectors + bool isGV = false; + bool isOCC = false; QList::iterator anIter, anIterEnd = aSelectorList.end(); for( anIter = aSelectorList.begin(); anIter != anIterEnd; anIter++ ) { SUIT_Selector* aSelector = *anIter; - if( aSelector && ( !dynamic_cast( aSelector ) && - !dynamic_cast( aSelector ) && - !dynamic_cast( aSelector ) ) ) - aSelector->setEnabled( false ); + bool isOk = false; + if (aSelector) + { + DEBTRACE("Selector " << aSelector->type().toStdString()); + if (dynamic_cast( aSelector )) + { + isOk = !isDisableGV; + isGV = true; + DEBTRACE("HYDROGUI_GVSelector " << isOk); + } + else if (dynamic_cast( aSelector )) + { + isOk = true; + DEBTRACE("SVTK_Selector"); + } + else if (dynamic_cast( aSelector )) + { + isOk = true; + isOCC = true; + DEBTRACE("HYDROGUI_OCCSelector"); + } + if (isOk) + { + DEBTRACE("Selector enabled " << aSelector->type().toStdString()); + aSelector->setEnabled( true ); + } + else + { + DEBTRACE("Selector disabled " << aSelector->type().toStdString()); + aSelector->setEnabled( false ); + } + } } if ( aViewType == GraphicsView_Viewer::Type() ) @@ -1860,19 +1988,28 @@ void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager ) GraphicsView_ViewManager* aViewManager = ::qobject_cast( theViewManager ); if( aViewManager ) - new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr ); + { + HYDROGUI_GVSelector* sel = new HYDROGUI_GVSelector( this, aViewManager->getViewer(), aSelectionMgr ); + DEBTRACE("new HYDROGUI_GVSelector " << sel << " " << sel->type().toStdString()); + sel->setEnabled( true ); + } } else if ( aViewType == OCCViewer_Viewer::Type() ) { OCCViewer_ViewManager* aViewManager = ::qobject_cast( theViewManager ); if( aViewManager ) - new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr ); + { + HYDROGUI_OCCSelector* sel = new HYDROGUI_OCCSelector( this, aViewManager->getOCCViewer(), aSelectionMgr ); + DEBTRACE("new HYDROGUI_OCCSelector " << sel << " " << sel->type().toStdString()); + sel->setEnabled( true ); + } } } bool HYDROGUI_Module::setUpdateEnabled( const bool theState ) { + DEBTRACE("HYDROGUI_Module::setUpdateEnabled"); bool aPrevState = myIsUpdateEnabled; myIsUpdateEnabled = theState; return aPrevState; @@ -1885,6 +2022,7 @@ bool HYDROGUI_Module::isUpdateEnabled() const QStringList HYDROGUI_Module::storeSelection() const { + DEBTRACE("HYDROGUI_Module::storeSelection"); QStringList anEntryList; if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() ) { @@ -1894,7 +2032,7 @@ QStringList HYDROGUI_Module::storeSelection() const SUIT_DataOwnerPtrList::iterator anIter; for( anIter = aList.begin(); anIter != aList.end(); anIter++ ) { - const LightApp_DataOwner* anOwner = + const LightApp_DataOwner* anOwner = dynamic_cast( (*anIter).operator->() ); if( anOwner ) anEntryList.append( anOwner->entry() ); @@ -1905,6 +2043,7 @@ QStringList HYDROGUI_Module::storeSelection() const void HYDROGUI_Module::restoreSelection( const QStringList& theEntryList ) { + DEBTRACE("HYDROGUI_Module::restoreSelection"); if( LightApp_SelectionMgr* aSelectionMgr = getApp()->selectionMgr() ) { SUIT_DataOwnerPtrList aList( true ); @@ -1930,8 +2069,7 @@ void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* if ( aDesktop && aDesktop->statusBar() ) { gp_Pnt aWPnt( X, Y, Z ); - int aStudyId = application()->activeStudy()->id(); - HYDROData_Document::Document( aStudyId )->Transform( aWPnt, false ); + HYDROData_Document::Document()->Transform( aWPnt, false ); double WX = aWPnt.X(), WY = aWPnt.Y(); QString aXStr = HYDROGUI_Tool::GetCoordinateString( X, true ); @@ -1950,6 +2088,7 @@ void HYDROGUI_Module::onMouseMove( SUIT_ViewWindow* theViewWindow, QMouseEvent* */ QStack& HYDROGUI_Module::getActiveOperations() { + DEBTRACE("HYDROGUI_Module::getActiveOperations"); return myActiveOperationMap; } @@ -2023,16 +2162,16 @@ void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* const int row, Qt::DropAction action ) { if ( action != Qt::CopyAction && action != Qt::MoveAction ) - return; + return; if (row == -1) return; if (where->level() < 2 ) - return; + return; DataObjectList::ConstIterator it = what.constBegin(); - for (;it != what.constEnd();++it) + for (;it != what.constEnd();++it) { if ((*it)->parent() != where) return; @@ -2041,7 +2180,7 @@ void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* it = what.constBegin(); int i=0; - for (;it != what.constEnd();++it) + for (;it != what.constEnd();++it) { SUIT_DataObject* objWhat = *it; @@ -2062,14 +2201,14 @@ void HYDROGUI_Module::dropObjects( const DataObjectList& what, SUIT_DataObject* pos = row - 1; where->moveChildPos(objWhat, pos); //std::list t2 = where->children().toStdList(); //debug - } + } } getApp()->updateObjectBrowser(true); - + } -Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const int theViewId ) const +Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( const size_t theViewId ) const { Handle(HYDROData_StricklerTable) aTable; @@ -2080,20 +2219,20 @@ Handle(HYDROData_StricklerTable) HYDROGUI_Module::getLandCoverColoringTable( con return aTable; } -void HYDROGUI_Module::setLandCoverColoringTable( const int theViewId, +void HYDROGUI_Module::setLandCoverColoringTable( const size_t theViewId, const Handle(HYDROData_StricklerTable)& theTable ) { - if ( !theTable.IsNull() ) { + if ( !theTable.IsNull() && theViewId ) { myLandCoverColoringMap.insert( theViewId, theTable ); } } -void HYDROGUI_Module::setLandCoversScalarMapModeOff( const int theViewId ) +void HYDROGUI_Module::setLandCoversScalarMapModeOff( const size_t theViewId ) { myLandCoverColoringMap.remove( theViewId ); } -bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const int theViewId ) const +bool HYDROGUI_Module::isLandCoversScalarMapModeOn( const size_t theViewId ) const { return myLandCoverColoringMap.contains( theViewId ); } @@ -2105,12 +2244,11 @@ void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObjec } if ( theObject->GetKind() == KIND_STRICKLER_TABLE ) { - Handle(HYDROData_StricklerTable) aTable = + Handle(HYDROData_StricklerTable) aTable = Handle(HYDROData_StricklerTable)::DownCast( theObject ); - QList aViewIds; - QMutableMapIterator anIter( myLandCoverColoringMap ); + QMutableMapIterator anIter( myLandCoverColoringMap ); while ( anIter.hasNext() ) { - if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) == + if ( HYDROGUI_DataObject::dataObjectEntry( anIter.next().value() ) == HYDROGUI_DataObject::dataObjectEntry( aTable ) ) { anIter.remove(); } @@ -2120,6 +2258,7 @@ void HYDROGUI_Module::setObjectRemoved( const Handle(HYDROData_Entity)& theObjec void HYDROGUI_Module::onViewActivated( SUIT_ViewManager* theMgr ) { + DEBTRACE("HYDROGUI_Module::onViewActivated"); if( !theMgr ) return;