From: smh Date: Mon, 7 Jun 2004 10:53:08 +0000 (+0000) Subject: Fix on Bug GEOM6047 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ba51e4e1c494ca49620d20b9456651effc575a57;p=modules%2Fkernel.git Fix on Bug GEOM6047 Script GEOM_example3.py freeze IAPP --- diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.cxx b/src/SALOMEGUI/SALOMEGUI_Swig.cxx index 00f6efb08..9edbd3bb1 100644 --- a/src/SALOMEGUI/SALOMEGUI_Swig.cxx +++ b/src/SALOMEGUI/SALOMEGUI_Swig.cxx @@ -26,25 +26,40 @@ // Module : SALOME // $Header$ -using namespace std; +#include "SALOMEGUI_Swig.hxx" + #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Study.h" #include "QAD_RightFrame.h" #include "QAD_StudyFrame.h" -#include "SALOMEGUI_Swig.hxx" -#include "utilities.h" + +#include "SALOME_Event.hxx" #include "SALOME_Selection.h" #include "SALOME_InteractiveObject.hxx" #include "SALOME_ListIteratorOfListIO.hxx" +#include "utilities.h" + +using namespace std; + +namespace SALOME{ + QAD_ViewFrame* GetViewFrame(QAD_Study* theStudy){ + return theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + } + + Handle(SALOME_InteractiveObject) FindIObject(QAD_Study* theStudy, const char *theEntry) + { + return GetViewFrame(theStudy)->FindIObject(theEntry); + } +} + /*! Constructor */ SALOMEGUI_Swig::SALOMEGUI_Swig() -// VSR 06-05-03 : _studyId(0) { // MESSAGE("Constructeur"); } @@ -62,8 +77,8 @@ SALOMEGUI_Swig::~SALOMEGUI_Swig() */ QAD_Study* SALOMEGUI_Swig::getActiveStudy() { - QAD_Application* app = QAD_Application::getDesktop()->getActiveApp(); - if ( app ) return app->getActiveStudy(); + if(QAD_Application* app = QAD_Application::getDesktop()->getActiveApp()) + return app->getActiveStudy(); return 0; } @@ -72,12 +87,9 @@ QAD_Study* SALOMEGUI_Swig::getActiveStudy() */ void SALOMEGUI_Swig::updateObjBrowser( bool updateSelection ) { - // VSR 06-05-03 ============================================================ - //QAD_Study* myActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myActiveStudy = getActiveStudy(); - if ( !myActiveStudy) return; - // end of VSR 06-05-03 ===================================================== - myActiveStudy->updateObjBrowser( updateSelection ); + if(QAD_Study* myActiveStudy = getActiveStudy()) + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (myActiveStudy,&QAD_Study::updateObjBrowser,updateSelection)); } /*! @@ -85,21 +97,9 @@ void SALOMEGUI_Swig::updateObjBrowser( bool updateSelection ) */ int SALOMEGUI_Swig::getActiveStudyId() { - // NRI 24-02-03 : - // if (_studyId ==0) - // { - // QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - // _name = myStudy->getTitle(); - - // VSR 06-05-03 ============================================================ - // _studyId = QAD_Application::getDesktop()->getActiveStudy()->getStudyId(); - int _studyId = 0; - QAD_Study* myActiveStudy = getActiveStudy(); - if ( myActiveStudy) _studyId = myActiveStudy->getStudyId(); - // SCRUTE(_studyId); - // end of VSR 06-05-03 ===================================================== - // } - return _studyId; + if(QAD_Study* myActiveStudy = getActiveStudy()) + return myActiveStudy->getStudyId(); + return 0; } /*! @@ -107,18 +107,9 @@ int SALOMEGUI_Swig::getActiveStudyId() */ const char *SALOMEGUI_Swig::getActiveStudyName() { - // VSR 06-05-03 ============================================================ - // QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - // _name = myStudy->getTitle(); - QString _name = QString::null; - QAD_Study* myActiveStudy = getActiveStudy(); - if ( myActiveStudy) _name = myActiveStudy->getTitle(); - // end of VSR 06-05-03 ===================================================== - - // NRI 24-02-03 : - //if (_studyId ==0) - // getActiveStudyId(); - return _name.latin1(); + if(QAD_Study* myActiveStudy = getActiveStudy()) + return myActiveStudy->getTitle().latin1(); + return QString::null; } /*! @@ -141,14 +132,11 @@ const char* SALOMEGUI_Swig::getComponentUserName( const char* ComponentName ) */ int SALOMEGUI_Swig::SelectedCount() { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return 0; - // end of VSR 06-05-03 ===================================================== - SALOME_Selection* Sel - = SALOME_Selection::Selection( myStudy->getSelection() ); - return Sel->IObjectCount(); + if(QAD_Study* myStudy = getActiveStudy()){ + SALOME_Selection* Sel = SALOME_Selection::Selection(myStudy->getSelection()); + return Sel->IObjectCount(); + } + return 0; } /*! @@ -156,68 +144,56 @@ int SALOMEGUI_Swig::SelectedCount() */ const char* SALOMEGUI_Swig::getSelected(int i) { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return ""; - // end of VSR 06-05-03 ===================================================== - SALOME_Selection* Sel - = SALOME_Selection::Selection( myStudy->getSelection() ); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - int index = 0; - for(;It.More();It.Next()) - { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - if ( i == index++ ) - { + if(QAD_Study* myStudy = getActiveStudy()){ + SALOME_Selection* Sel = SALOME_Selection::Selection( myStudy->getSelection() ); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + int index = 0; + for(;It.More();It.Next()){ + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if( i == index++ ){ if ( IObject->hasEntry() ) return IObject->getEntry(); } } + } return ""; } /*! Add object with Entry into selection. */ -void SALOMEGUI_Swig::AddIObject(const char *Entry) +void SALOMEGUI_Swig::AddIObject(const char *theEntry) { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return; - // end of VSR 06-05-03 ===================================================== - SALOME_Selection* Sel - = SALOME_Selection::Selection( myStudy->getSelection() ); - - if ( !IsInCurrentView( Entry ) ) - return; - - Handle(SALOME_InteractiveObject) IO = - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); - Sel->AddIObject( IO ); + if(QAD_Study* myStudy = getActiveStudy()){ + SALOME_Selection* aSel = SALOME_Selection::Selection( myStudy->getSelection() ); + if(IsInCurrentView(theEntry)){ + Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry); + if(anIO.IsNull()) return; + ProcessEvent(new TMemFun2ArgEvent + (aSel,&SALOME_Selection::AddIObject,anIO,true)); + } + } } /*! Removes object with Entry into selection. */ -void SALOMEGUI_Swig::RemoveIObject(const char *Entry) +void SALOMEGUI_Swig::RemoveIObject(const char *theEntry) { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return; - // end of VSR 06-05-03 ===================================================== - SALOME_Selection* Sel - = SALOME_Selection::Selection( myStudy->getSelection() ); - - if ( !IsInCurrentView( Entry ) ) - return; - - Handle(SALOME_InteractiveObject) IO = - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); - Sel->RemoveIObject( IO ); + if(QAD_Study* myStudy = getActiveStudy()){ + SALOME_Selection* aSel = SALOME_Selection::Selection( myStudy->getSelection() ); + if(IsInCurrentView(theEntry)){ + Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry); + if(anIO.IsNull()) return; + ProcessEvent(new TMemFun2ArgEvent + (aSel,&SALOME_Selection::RemoveIObject,anIO,true)); + } + } } @@ -226,76 +202,65 @@ void SALOMEGUI_Swig::RemoveIObject(const char *Entry) */ void SALOMEGUI_Swig::ClearIObjects() { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return; - // end of VSR 06-05-03 ===================================================== - SALOME_Selection* Sel - = SALOME_Selection::Selection( myStudy->getSelection() ); - Sel->ClearIObjects(); + if(QAD_Study* myStudy = getActiveStudy()){ + SALOME_Selection* aSel = SALOME_Selection::Selection( myStudy->getSelection() ); + ProcessVoidEvent(new TVoidMemFunEvent + (aSel,&SALOME_Selection::ClearIObjects)); + } } /*! Display */ -void SALOMEGUI_Swig::Display(const char *Entry) +void SALOMEGUI_Swig::Display(const char *theEntry) { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return; - // end of VSR 06-05-03 ===================================================== - - if ( !IsInCurrentView( Entry ) ) - return; - - Handle(SALOME_InteractiveObject) IO = - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); - - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Display(IO); + if(QAD_Study* myStudy = getActiveStudy()){ + if(IsInCurrentView(theEntry)){ + Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry); + if(anIO.IsNull()) return; + QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy); + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (aViewFrame,&QAD_ViewFrame::Display,anIO,true)); + } + } } /*! Display only */ -void SALOMEGUI_Swig::DisplayOnly(const char *Entry) +void SALOMEGUI_Swig::DisplayOnly(const char *theEntry) { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return; - // end of VSR 06-05-03 ===================================================== - - if ( !IsInCurrentView( Entry ) ) - return; - - Handle(SALOME_InteractiveObject) IO = - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); - - if ( !IO.IsNull() ) { - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->DisplayOnly(IO); + if(QAD_Study* myStudy = getActiveStudy()){ + if(IsInCurrentView(theEntry)){ + Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry); + if(anIO.IsNull()) return; + QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy); + ProcessVoidEvent(new TVoidMemFun1ArgEvent + (aViewFrame,&QAD_ViewFrame::DisplayOnly,anIO)); + } } } /*! Erase */ -void SALOMEGUI_Swig::Erase(const char *Entry) +void SALOMEGUI_Swig::Erase(const char *theEntry) { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return; - // end of VSR 06-05-03 ===================================================== - - if ( !IsInCurrentView( Entry ) ) - return; - - Handle(SALOME_InteractiveObject) IO = - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry ); - - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->Erase(IO); + if(QAD_Study* myStudy = getActiveStudy()){ + if(IsInCurrentView(theEntry)){ + Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(myStudy,theEntry); + if(anIO.IsNull()) return; + QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy); + ProcessVoidEvent(new TVoidMemFun2ArgEvent + (aViewFrame,&QAD_ViewFrame::Erase,anIO,true)); + } + } } /*! @@ -303,12 +268,11 @@ void SALOMEGUI_Swig::Erase(const char *Entry) */ void SALOMEGUI_Swig::DisplayAll() { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return; - // end of VSR 06-05-03 ===================================================== - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->DisplayAll(); + if(QAD_Study* myStudy = getActiveStudy()){ + QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy); + ProcessVoidEvent(new TVoidMemFunEvent + (aViewFrame,&QAD_ViewFrame::DisplayAll)); + } } /*! @@ -316,66 +280,20 @@ void SALOMEGUI_Swig::DisplayAll() */ void SALOMEGUI_Swig::EraseAll() { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return; - // end of VSR 06-05-03 ===================================================== - SALOME_Selection* Sel - = SALOME_Selection::Selection( myStudy->getSelection() ); - - Sel->ClearIObjects(); - myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->EraseAll(); + ClearIObjects(); + if(QAD_Study* myStudy = getActiveStudy()){ + QAD_ViewFrame* aViewFrame = SALOME::GetViewFrame(myStudy); + ProcessVoidEvent(new TVoidMemFunEvent + (aViewFrame,&QAD_ViewFrame::EraseAll)); + } } /*! Checks if object is displayed in current viewer */ -bool SALOMEGUI_Swig::IsInCurrentView(const char *Entry) +bool SALOMEGUI_Swig::IsInCurrentView(const char *theEntry) { - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Study* myStudy = getActiveStudy(); - if ( !myStudy) return false; - // end of VSR 06-05-03 ===================================================== - return myStudy->isInViewer( Entry, myStudy->getActiveStudyFrame()->entry() ); + if(QAD_Study* myStudy = getActiveStudy()) + return myStudy->isInViewer( theEntry, myStudy->getActiveStudyFrame()->entry() ); + return false; } - -/*! - Gets VTK renderer if available -*/ -//san:T3.13 - move getRenderer() implementation from here to SalomePy.cxx -/*vtkRenderer *SALOMEGUI_Swig::getRenderer(int viewId) -{ - // VSR 06-05-03 ============================================================ - //QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy(); - QAD_Application* app = QAD_Application::getDesktop()->getActiveApp(); - if ( !app ) return NULL; - QAD_Study* myStudy = app->getActiveStudy(); - if ( !myStudy) return NULL; - // end of VSR 06-05-03 ===================================================== - int nbStudyFrames = myStudy->getStudyFramesCount(); - vtkRenderer *myRenderer = NULL; - if (viewId == -1) // find the first frame with VTK viewer & get renderer - { - int i=0; - for(i=0; igetStudyFrame(i)->getTypeView() == VIEW_VTK ) - { - myRenderer = myStudy->getStudyFrame(i)->getRightFrame()->getViewFrame()->getRenderer(); - break; - } - } - } - else // get the VTK renderer of a given frame - { - SCRUTE(viewId); - if ((viewId >=0) && (viewId getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer(); - } - if (myRenderer == NULL) MESSAGE("No VTK Renderer available !"); - return myRenderer; -} -*/ - diff --git a/src/SALOMEGUI/SALOMEGUI_Swig.hxx b/src/SALOMEGUI/SALOMEGUI_Swig.hxx index 0af5330a1..f61d26fd0 100644 --- a/src/SALOMEGUI/SALOMEGUI_Swig.hxx +++ b/src/SALOMEGUI/SALOMEGUI_Swig.hxx @@ -34,8 +34,16 @@ #include -class vtkRenderer; +#include "SALOME_InteractiveObject.hxx" + class QAD_Study; +class QAD_ViewFrame; + +namespace SALOME{ + QAD_ViewFrame* GetViewFrame(QAD_Study* theStudy); + Handle(SALOME_InteractiveObject) FindIObject(QAD_Study* theStudy, const char *theEntry); +} + class SALOMEGUI_Swig { @@ -43,9 +51,6 @@ public: SALOMEGUI_Swig(); ~SALOMEGUI_Swig(); - //san:T3.13 - move getRenderer() implementation from here to SalomePy.cxx - //static vtkRenderer* getRenderer(int viewId = -1); - void updateObjBrowser( bool updateSelection ); QAD_Study* getActiveStudy(); int getActiveStudyId();