From: smh Date: Tue, 20 Apr 2004 05:48:50 +0000 (+0000) Subject: Code unification by template usage X-Git-Tag: mergeto_Event_Server_20Apr04~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3ef921ff549d8d371d9116573015576d0a9585fe;p=modules%2Fvisu.git Code unification by template usage --- diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 6a3de0d8..b2964382 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -43,7 +43,7 @@ #include "VISU_ScalarBarActor.hxx" #include "VISU_Actor.h" -#include "VISU_Event.h" +#include "SALOME_Event.hxx" #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -80,68 +80,8 @@ static int MYDELAY = 1; namespace VISU{ //=========================================================================== - template - class TMemFunEvent: public SALOME_Event{ - public: - typedef TResult (TObject::* TAction)(); - TMemFunEvent(TObject* theObject, TAction theAction): - myObject(theObject), - myAction(theAction) - {} - virtual bool Execute(){ - (myObject->*myAction)(); - return true; - } - private: - TObject* myObject; - TAction myAction; - }; - typedef TMemFunEvent TFrameActionEvent; - + typedef TVoidMemFunEvent TFrameActionEvent; - template - class TMemFun1ArgEvent: public SALOME_Event{ - public: - typedef TResult (TObject::* TAction)(TArg); - TMemFun1ArgEvent(TObject* theObject, TAction theAction, TArg theArg): - myObject(theObject), - myAction(theAction), - myArg(theArg) - {} - virtual bool Execute(){ - (myObject->*myAction)(myArg); - return true; - } - private: - TObject* myObject; - TAction myAction; - TStoreArg myArg; - }; - - - template - class TMemFun2ArgEvent: public SALOME_Event{ - public: - typedef TResult (TObject::* TAction)(TArg,TArg1); - TMemFun2ArgEvent(TObject* theObject, TAction theAction, TArg theArg, TArg1 theArg1): - myObject(theObject), - myAction(theAction), - myArg(theArg), - myArg1(theArg1) - {} - virtual bool Execute(){ - (myObject->*myAction)(myArg,myArg1); - return true; - } - private: - TObject* myObject; - TAction myAction; - TStoreArg myArg; - TStoreArg1 myArg1; - }; - template class TSetBackgroundEvent: public SALOME_Event{ TObject* myView; @@ -549,7 +489,7 @@ namespace VISU{ void XYPlot_i::Update() { - ProcessVoidEvent(new TMemFunEvent(myView,&Plot2d_ViewFrame::Repaint)); + ProcessVoidEvent(new TVoidMemFunEvent(myView,&Plot2d_ViewFrame::Repaint)); } @@ -563,7 +503,7 @@ namespace VISU{ void XYPlot_i::SetTitle(const char* theTitle){ - ProcessVoidEvent(new TMemFun1ArgEvent + ProcessVoidEvent(new TVoidMemFun1ArgEvent (myStudyFrame,&QAD_StudyFrame::setCaption,QString(theTitle))); } char* XYPlot_i::GetTitle() { @@ -572,7 +512,7 @@ namespace VISU{ void XYPlot_i::SetSubTitle(const char* theTitle){ - ProcessVoidEvent(new TMemFun1ArgEvent + ProcessVoidEvent(new TVoidMemFun1ArgEvent (myView,&Plot2d_ViewFrame::setTitle,QString(theTitle))); } char* XYPlot_i::GetSubTitle() { @@ -581,7 +521,7 @@ namespace VISU{ void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){ - ProcessVoidEvent(new TMemFun2ArgEvent + ProcessVoidEvent(new TVoidMemFun2ArgEvent (myView,&Plot2d_ViewFrame::setCurveType,theType,true)); } VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){ @@ -590,7 +530,7 @@ namespace VISU{ void XYPlot_i::SetMarkerSize(CORBA::Long theSize){ - ProcessVoidEvent(new TMemFun2ArgEvent + ProcessVoidEvent(new TVoidMemFun2ArgEvent (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true)); } CORBA::Long XYPlot_i::GetMarkerSize(){ @@ -703,7 +643,7 @@ namespace VISU{ void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){ - ProcessVoidEvent(new TMemFun2ArgEvent + ProcessVoidEvent(new TVoidMemFun2ArgEvent (myView,&Plot2d_ViewFrame::showLegend,theShowing,true)); } @@ -801,12 +741,12 @@ namespace VISU{ void XYPlot_i::EraseAll() { - ProcessVoidEvent(new TMemFunEvent(myView,&Plot2d_ViewFrame::EraseAll)); + ProcessVoidEvent(new TVoidMemFunEvent(myView,&Plot2d_ViewFrame::EraseAll)); } void XYPlot_i::FitAll() { - ProcessVoidEvent(new TMemFunEvent(myView,&Plot2d_ViewFrame::fitAll)); + ProcessVoidEvent(new TVoidMemFunEvent(myView,&Plot2d_ViewFrame::fitAll)); } @@ -850,7 +790,7 @@ namespace VISU{ void TableView_i::SetTitle(const char* theTitle){ - ProcessVoidEvent(new TMemFun1ArgEvent + ProcessVoidEvent(new TVoidMemFun1ArgEvent (myView,&SALOMEGUI_TableDlg::setCaption,QString(theTitle))); } @@ -1114,7 +1054,7 @@ namespace VISU{ //-------------------- View interface -------------------- void View3D_i::SetTitle(const char* theTitle){ - ProcessVoidEvent(new TMemFun1ArgEvent + ProcessVoidEvent(new TVoidMemFun1ArgEvent (myStudyFrame,&QAD_StudyFrame::setTitle,QString(theTitle))); } char* View3D_i::GetTitle() { @@ -1213,7 +1153,7 @@ namespace VISU{ //-------------------- View3D interface -------------------- void View3D_i::FitAll() { - ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll)); + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll)); Update(); } @@ -1221,22 +1161,22 @@ namespace VISU{ void View3D_i::SetView(VISU::View3D::ViewType theType) { switch(theType){ case VISU::View3D::FRONT : - ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront)); + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront)); break; case VISU::View3D::BACK : - ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack)); + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack)); break; case VISU::View3D::LEFT : - ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft)); + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft)); break; case VISU::View3D::RIGHT : - ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight)); + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight)); break; case VISU::View3D::TOP : - ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop)); + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop)); break; case VISU::View3D::BOTTOM : - ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom)); + ProcessVoidEvent(new TVoidMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom)); break; } Update();