From: Paul RASCLE Date: Tue, 20 Oct 2020 14:02:57 +0000 (+0200) Subject: fix abort on import image X-Git-Tag: SH_V2_2_0~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f54908a23753222055c143132de495940d141c57;p=modules%2Fhydro.git fix abort on import image --- diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index bb8854fb..265fa1b6 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -981,8 +982,11 @@ void HYDROGUI_ImportImageOp::closeView( GraphicsView_ViewManager* &aViewMgr ) } // Delete the view + module()->removeViewManager(aViewMgr); // clean HYDROGUI module structure + aViewMgr->getActiveView()->hide(); module()->getApp()->removeViewManager( aViewMgr ); // aViewMgr is deleted here aViewMgr = 0; + DEBTRACE("end of closeView"); } } diff --git a/src/HYDROGUI/HYDROGUI_Module.cxx b/src/HYDROGUI/HYDROGUI_Module.cxx index de275959..5a01500a 100755 --- a/src/HYDROGUI/HYDROGUI_Module.cxx +++ b/src/HYDROGUI/HYDROGUI_Module.cxx @@ -1753,16 +1753,16 @@ 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) { - DEBTRACE("HYDROGUI_Module::onViewManagerRemoved"); - LightApp_Module::onViewManagerRemoved( theViewManager ); - - createSelector( theViewManager ); // replace the default selector + DEBTRACE("removeViewManager") 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 ) @@ -1789,6 +1789,14 @@ 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"); @@ -1909,9 +1917,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"); + DEBTRACE("HYDROGUI_Module::createSelector " << isDisableGV); if( !theViewManager ) return; @@ -1941,9 +1949,9 @@ void HYDROGUI_Module::createSelector( SUIT_ViewManager* theViewManager ) DEBTRACE("Selector " << aSelector->type().toStdString()); if (dynamic_cast( aSelector )) { - isOk = true; + isOk = !isDisableGV; isGV = true; - DEBTRACE("HYDROGUI_GVSelector"); + DEBTRACE("HYDROGUI_GVSelector " << isOk); } else if (dynamic_cast( aSelector )) { diff --git a/src/HYDROGUI/HYDROGUI_Module.h b/src/HYDROGUI/HYDROGUI_Module.h index fead3a71..2cf1ed5b 100644 --- a/src/HYDROGUI/HYDROGUI_Module.h +++ b/src/HYDROGUI/HYDROGUI_Module.h @@ -197,6 +197,7 @@ public: void removeObjectVTKPrs( const size_t theViewId, const QString& theEntry ); + void removeViewManager( SUIT_ViewManager* ); /** * Update global imposed range of Z values for the given VTK viewer id @@ -314,7 +315,7 @@ private: const bool theIsForced = false, const bool theDoFitAll = false ); - void createSelector( SUIT_ViewManager* viewMgr ); + void createSelector( SUIT_ViewManager* viewMgr , bool isDisableGV = false); bool setUpdateEnabled( const bool theState ); bool isUpdateEnabled() const; diff --git a/src/HYDROGUI/HYDROGUI_Overview.cxx b/src/HYDROGUI/HYDROGUI_Overview.cxx index f1075782..f9379e46 100644 --- a/src/HYDROGUI/HYDROGUI_Overview.cxx +++ b/src/HYDROGUI/HYDROGUI_Overview.cxx @@ -27,7 +27,7 @@ #include #include -//#define _DEVDEBUG_ +#define _DEVDEBUG_ #include "HYDRO_trace.hxx" class HYDROGUI_OverviewBand : public QtxPolyRubberBand @@ -339,6 +339,7 @@ void HYDROGUI_Overview::setMainView( OCCViewer_ViewFrame* theMainView ) myMainView = theMainView; if( !myMainView ) return; + DEBTRACE("setMainView"); OCCViewer_ViewWindow* aMainView = myMainView->getView( OCCViewer_ViewFrame::MAIN_VIEW ); connect( aMainView, SIGNAL( vpTransformationFinished( OCCViewer_ViewWindow::OperationType ) ), @@ -368,9 +369,9 @@ void HYDROGUI_Overview::setMainView( OCCViewer_ViewFrame* theMainView ) } } -#if defined(TEST_MODE) || defined(_DEBUG) - //qApp->installEventFilter( this ); -#endif +//#if defined(TEST_MODE) || defined(_DEBUG) +//qApp->installEventFilter( this ); +//#endif qApp->processEvents(); @@ -479,20 +480,25 @@ void HYDROGUI_Overview::OnMouseEvent( QMouseEvent* theEvent ) bool HYDROGUI_Overview::eventFilter( QObject* theObject, QEvent* theEvent ) { -#if defined(TEST_MODE) || defined(_DEBUG) - /*switch( theEvent->type() ) +//#if defined(TEST_MODE) || defined(_DEBUG) + if (theEvent->type() == 12) // paint { - case QEvent::MouseMove: - { - QPoint mp = ((QMouseEvent*)theEvent)->pos(); - //mp = getViewPort(false)->mapFromGlobal(mp); - QString coords = QString( "(%0, %1)" ).arg( mp.x() ).arg( mp.y() ); - std::string scoords = coords.toStdString(); - qDebug( scoords.c_str() ); - } - break; - }*/ -#endif + DEBTRACE("eventFilter " << theEvent->type() << " object " << theObject << " " << theObject->objectName().toStdString()); + } + +// switch( theEvent->type() ) +// { +// case QEvent::MouseMove: +// { +// QPoint mp = ((QMouseEvent*)theEvent)->pos(); +// //mp = getViewPort(false)->mapFromGlobal(mp); +// QString coords = QString( "(%0, %1)" ).arg( mp.x() ).arg( mp.y() ); +// std::string scoords = coords.toStdString(); +// qDebug( scoords.c_str() ); +// } +// break; +// } +//#endif return QFrame::eventFilter( theObject, theEvent ); }