From d862463d781da74689d2b25e50f95d85aafc7c79 Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 6 Oct 2005 06:53:51 +0000 Subject: [PATCH] PAL9807 - some dialogs in VISU must be non-modal --- src/VISUGUI/Makefile.in | 6 ++- src/VISUGUI/VisuGUI.cxx | 18 ++++---- src/VISUGUI/VisuGUI_DialogRunner.cxx | 66 ++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_DialogRunner.h | 30 +++++++++++++ src/VISUGUI/VisuGUI_Prs3dTools.h | 10 ++++- 5 files changed, 118 insertions(+), 12 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_DialogRunner.cxx create mode 100644 src/VISUGUI/VisuGUI_DialogRunner.h diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index b0c97a00..88fccafa 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -69,7 +69,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_CutLinesDlg.cxx \ VisuGUI_CutPlanesDlg.cxx \ VisuGUI_StreamLinesDlg.cxx \ - VisuGUI_VectorsDlg.cxx + VisuGUI_VectorsDlg.cxx \ + VisuGUI_DialogRunner.cxx LIB_MOC = VisuGUI.h \ VisuGUI_Selection.h \ @@ -90,7 +91,8 @@ LIB_MOC = VisuGUI.h \ VisuGUI_CutLinesDlg.h \ VisuGUI_CutPlanesDlg.h \ VisuGUI_StreamLinesDlg.h \ - VisuGUI_VectorsDlg.h + VisuGUI_VectorsDlg.h \ + VisuGUI_DialogRunner.h LIB_CLIENT_IDL = SALOME_Exception.idl \ VISU_Gen.idl \ diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index b33dcf47..4583e339 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -583,7 +583,7 @@ void VisuGUI:: OnCreatePlot3D() { - CreatePrs3d(this); + CreatePrs3d(this); } void @@ -697,7 +697,7 @@ OnEditScalarMap() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -711,7 +711,7 @@ OnEditDeformedShape() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -725,7 +725,7 @@ OnEditCutPlanes() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -739,7 +739,7 @@ OnEditCutLines() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -753,7 +753,7 @@ OnEditIsoSurfaces() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -767,7 +767,7 @@ OnEditVectors() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -781,7 +781,7 @@ OnEditStreamLines() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } @@ -795,7 +795,7 @@ OnEditPlot3D() { Handle(SALOME_InteractiveObject) anIO; if(VISU::Prs3d_i* aPrs3d = GetPrsToModify(this,&anIO)){ - EditPrs3d(this, aPrs3d); + EditPrs3d(this, aPrs3d); if(SVTK_ViewWindow* aViewWindow = GetViewWindow()){ aViewWindow->highlight(anIO, 1); } diff --git a/src/VISUGUI/VisuGUI_DialogRunner.cxx b/src/VISUGUI/VisuGUI_DialogRunner.cxx new file mode 100644 index 00000000..f8e15e86 --- /dev/null +++ b/src/VISUGUI/VisuGUI_DialogRunner.cxx @@ -0,0 +1,66 @@ +// File: VisuGUI_DialogRunner.cxx +// Created: Thu Oct 6 10:17:39 2005 +// Author: Alexander SOLOVYOV +// + +#include "VisuGUI_DialogRunner.h" + +#include +#include + +VisuGUI_DialogRunner::VisuGUI_DialogRunner( QDialog* dlg ) +: QObject(), + myDlg( dlg ), + myInLoop( false ) +{ + if( myDlg ) + { + connect( myDlg, SIGNAL( destroyed() ), this, SLOT( onDialogDelete() ) ); + myDlg->installEventFilter( this ); + } +} + +VisuGUI_DialogRunner::~VisuGUI_DialogRunner() +{ +} + +int VisuGUI_DialogRunner::run( const bool modal ) +{ + if( myInLoop || !myDlg ) + return -1; + + qDebug( "start" ); + if( modal ) + return myDlg->exec(); + + myInLoop = true; + myDlg->show(); + qDebug( "enter loop" ); + qApp->enter_loop(); + qDebug( "after loop" ); + return myDlg->result(); +} + +void VisuGUI_DialogRunner::onDialogDelete() +{ + if( myInLoop ) + qApp->exit_loop(); + + myDlg = 0; + myInLoop = false; +} + +bool VisuGUI_DialogRunner::eventFilter( QObject* o, QEvent* e ) +{ + if( o==myDlg && e && ( e->type()==QEvent::Close || e->type()==QEvent::Hide ) ) + { + if( myInLoop && !myDlg->isMinimized() ) + { + myInLoop = false; + qApp->exit_loop(); + } + return false; + } + else + return QObject::eventFilter( o, e ); +} diff --git a/src/VISUGUI/VisuGUI_DialogRunner.h b/src/VISUGUI/VisuGUI_DialogRunner.h new file mode 100644 index 00000000..8fb16ec9 --- /dev/null +++ b/src/VISUGUI/VisuGUI_DialogRunner.h @@ -0,0 +1,30 @@ + + +#ifndef DIALOG_RUNNER_HEADER +#define DIALOG_RUNNER_HEADER + +#include + +class QDialog; + +class VisuGUI_DialogRunner : public QObject +{ + Q_OBJECT + +public: + VisuGUI_DialogRunner( QDialog* ); + virtual ~VisuGUI_DialogRunner(); + + int run( const bool ); + + virtual bool eventFilter( QObject*, QEvent* ); + +private slots: + void onDialogDelete(); + +private: + QDialog* myDlg; + bool myInLoop; +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index 2e970245..c2fb731e 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -30,17 +30,25 @@ #define VisuGUI_Prs3dTools_HeaderFile #include "VisuGUI_Tools.h" +#include "VisuGUI_DialogRunner.h" int runAndWait( QDialog* dlg, const bool modal ) { + VisuGUI_DialogRunner r( dlg ); + return r.run( modal ); +/* if( modal ) return dlg->exec(); dlg->show(); + qDebug( "enter loop" ); qApp->enter_loop(); + qDebug( "end of loop" ); - return dlg->result(); + int res = dlg->result(); + qDebug( QString( "Result : %1" ).arg( res ) ); + return dlg->result();*/ } namespace VISU -- 2.39.2