]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
fix abort on import image
authorPaul RASCLE <paul.rascle@openfields.fr>
Tue, 20 Oct 2020 14:02:57 +0000 (16:02 +0200)
committerYOANN AUDOUIN <B61570@dsp0851742.postes.calibre.edf.fr>
Fri, 30 Oct 2020 16:09:38 +0000 (17:09 +0100)
src/HYDROGUI/HYDROGUI_ImportImageOp.cxx
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_Overview.cxx

index bb8854fbd0ea6f236bb460862e4176740abf7ad6..265fa1b647770833fd7cb45924018477a242df3d 100644 (file)
@@ -39,6 +39,7 @@
 #include <STD_TabDesktop.h>
 #include <SUIT_Desktop.h>
 #include <SUIT_MessageBox.h>
+#include <SUIT_ViewWindow.h>
 #include <QtxWorkstack.h>
 #include <QApplication>
 #include <QFileInfo>
@@ -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");
   }
 }
 
index de2759598dbbeae50e8addd67b9ef23f7d431e5d..5a01500a9cb7b66491bae4dc2db19ff00f9aebd8 100755 (executable)
@@ -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<OCCViewer_ViewManager*>( 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<HYDROGUI_GVSelector*>( aSelector ))
        {
-               isOk = true;
+               isOk = !isDisableGV;
                isGV = true;
-               DEBTRACE("HYDROGUI_GVSelector");
+               DEBTRACE("HYDROGUI_GVSelector " << isOk);
        }
        else if (dynamic_cast<SVTK_Selector*>( aSelector ))
        {
index fead3a71afcd8e0877e9fe0bdfdc67a70ef7931f..2cf1ed5be5f003334f512278c6e5cb0593ebe349 100644 (file)
@@ -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;
index f1075782abd5986c35147eeedfb1bf45a6c55bf3..f9379e46336d6f73b652b9ff41ebbe4fb9f37754 100644 (file)
@@ -27,7 +27,7 @@
 #include <QMouseEvent>
 #include <QLayout>
 
-//#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 );
 }