// 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");
}
*/
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;
}
*/
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<QAD_Study,bool>
+ (myActiveStudy,&QAD_Study::updateObjBrowser,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;
}
/*!
*/
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;
}
/*!
*/
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;
}
/*!
*/
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<SALOME_Selection,int,
+ const Handle(SALOME_InteractiveObject)&,bool,
+ Handle(SALOME_InteractiveObject)>
+ (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<SALOME_Selection,int,
+ const Handle(SALOME_InteractiveObject)&,bool,
+ Handle(SALOME_InteractiveObject)>
+ (aSel,&SALOME_Selection::RemoveIObject,anIO,true));
+ }
+ }
}
*/
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<SALOME_Selection>
+ (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<QAD_ViewFrame,
+ const Handle(SALOME_InteractiveObject)&,bool,
+ Handle(SALOME_InteractiveObject)>
+ (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<QAD_ViewFrame,
+ const Handle(SALOME_InteractiveObject)&,
+ Handle(SALOME_InteractiveObject)>
+ (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<QAD_ViewFrame,
+ const Handle(SALOME_InteractiveObject)&,bool,
+ Handle(SALOME_InteractiveObject)>
+ (aViewFrame,&QAD_ViewFrame::Erase,anIO,true));
+ }
+ }
}
/*!
*/
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<QAD_ViewFrame>
+ (aViewFrame,&QAD_ViewFrame::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<QAD_ViewFrame>
+ (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; i<nbStudyFrames; i++)
- {
- if ( myStudy->getStudyFrame(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 <nbStudyFrames))
- myRenderer = myStudy->getStudyFrame(viewId)->getRightFrame()->getViewFrame()->getRenderer();
- }
- if (myRenderer == NULL) MESSAGE("No VTK Renderer available !");
- return myRenderer;
-}
-*/
-