From: smh Date: Fri, 16 Apr 2004 05:44:29 +0000 (+0000) Subject: Evolution of wrapping of CORBA methods X-Git-Tag: mergeto_Event_Server_20Apr04~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=31e574793a84bf9c1c6f34108305178f351dbffe;p=modules%2Fvisu.git Evolution of wrapping of CORBA methods --- diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index 2ba2c030..ae4c7a52 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -96,6 +96,7 @@ namespace VISU{ TObject* myObject; TAction myAction; }; + typedef TMemFunEvent TFrameActionEvent; template @@ -118,6 +119,63 @@ namespace VISU{ }; + 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; + const SALOMEDS::Color& myColor; + public: + TSetBackgroundEvent(TObject* theView, const SALOMEDS::Color& theColor): + myView(theView), myColor(theColor) + {} + virtual bool Execute(){ + int aColor[3]; + aColor[0] = int(255.0*myColor.R); + aColor[1] = int(255.0*myColor.G); + aColor[2] = int(255.0*myColor.B); + QColor aNewColor(aColor[0],aColor[1],aColor[2]); + myView->setBackgroundColor(aNewColor); + return true; + } + }; + + + void RepaintView(QAD_StudyFrame* theStudyFrame); + class TRepaintViewEvent: public SALOME_Event{ + QAD_StudyFrame* myStudyFrame; + public: + TRepaintViewEvent(QAD_StudyFrame* theStudyFrame): + myStudyFrame(theStudyFrame) + {} + virtual bool Execute(){ + RepaintView(myStudyFrame); + return true; + } + }; + + VTKViewer_ViewFrame* GetViewFrame(QAD_StudyFrame* theStudyFrame){ return dynamic_cast(theStudyFrame->getRightFrame()->getViewFrame()); } @@ -136,19 +194,6 @@ namespace VISU{ } - class TRepaintViewEvent: public SALOME_Event{ - QAD_StudyFrame* myStudyFrame; - public: - TRepaintViewEvent(QAD_StudyFrame* theStudyFrame): - myStudyFrame(theStudyFrame) - {} - virtual bool Execute(){ - RepaintView(myStudyFrame); - return true; - } - }; - - VISU_Actor* UpdateViewer(QAD_StudyFrame* theStudyFrame, int theDisplaing, Prs3d_i* thePrs){ VTKViewer_ViewFrame* vf = GetViewFrame(theStudyFrame); if (!vf) return NULL; @@ -473,13 +518,13 @@ namespace VISU{ const char* View_i::GetComment() const { return "";} void View_i::ToStream(std::ostringstream& theStr) {} - const char* View_i::GetEntry(){ + string View_i::GetEntry(){ SALOMEDS::SObject_var aSObject = myStudy->getStudyDocument()->FindObjectIOR(GetID()); CORBA::String_var anEntry = aSObject->GetID(); - string aString(anEntry); - if(MYDEBUG) MESSAGE("Result_i::GetEntry - "<title().latin1()); } + void XYPlot_i::SetSubTitle(const char* theTitle){ - class TEvent: public SALOME_Event{ - Plot2d_ViewFrame* myView; - const char* myName; - public: - TEvent(Plot2d_ViewFrame* theView, - const char* theName): - myView(theView), - myName(theName) - {} - virtual bool Execute(){ - myView->setTitle(myName); - return true; - } - }; - ProcessVoidEvent(new TEvent(myView,theTitle)); + ProcessVoidEvent(new TMemFun1ArgEvent + (myView,&Plot2d_ViewFrame::setTitle,QString(theTitle))); } char* XYPlot_i::GetSubTitle() { return CORBA::string_dup(myView->getTitle()); } + void XYPlot_i::SetCurveType(VISU::XYPlot::CurveType theType){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetCurveType"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setCurveType(theType); + ProcessVoidEvent(new TMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::setCurveType,theType,true)); } VISU::XYPlot::CurveType XYPlot_i::GetCurveType(){ - if(MYDEBUG) MESSAGE("XYPlot_i::GetCurveType"); - Mutex mt(myMutex,qApp); return (VISU::XYPlot::CurveType)myView->getCurveType(); } + void XYPlot_i::SetMarkerSize(CORBA::Long theSize){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetMarkerSize"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setMarkerSize(theSize); + ProcessVoidEvent(new TMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::setMarkerSize,theSize,true)); } CORBA::Long XYPlot_i::GetMarkerSize(){ - if(MYDEBUG) MESSAGE("XYPlot_i::GetMarkerSize"); - Mutex mt(myMutex,qApp); return myView->getMarkerSize(); } + + class TEnbleGridEvent: public SALOME_Event{ + public: + typedef void (Plot2d_ViewFrame::* TFun)(bool, const int, bool, const int, bool = true); + TEnbleGridEvent(Plot2d_ViewFrame* theView, TFun theFun, + CORBA::Boolean theMajor, CORBA::Long theNumMajor, + CORBA::Boolean theMinor, CORBA::Long theNumMinor): + myView(theView), myFun(theFun), + myMajor(theMajor), myNumMajor(theNumMajor), + myMinor(theMinor), myNumMinor(theNumMinor) + {} + virtual bool Execute(){ + (myView->*myFun)(myMajor,myNumMajor,myMinor,myNumMinor); + return true; + } + protected: + Plot2d_ViewFrame* myView; + TFun myFun; + CORBA::Boolean myMajor, myNumMajor; + CORBA::Boolean myMinor, myNumMinor; + }; + + void XYPlot_i::EnableXGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor){ - if(MYDEBUG) MESSAGE("XYPlot_i::EnableXGrid"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setXGrid(theMajor,theNumMajor,theMinor,theNumMinor); + CORBA::Boolean theMinor, CORBA::Long theNumMinor) + { + ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setXGrid, + theMajor,theNumMajor,theMinor,theNumMinor)); } void XYPlot_i::EnableYGrid(CORBA::Boolean theMajor, CORBA::Long theNumMajor, - CORBA::Boolean theMinor, CORBA::Long theNumMinor){ - if(MYDEBUG) MESSAGE("XYPlot_i::EnableYGrid"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setYGrid(theMajor,theNumMajor,theMinor,theNumMinor); + CORBA::Boolean theMinor, CORBA::Long theNumMinor) + { + ProcessVoidEvent(new TEnbleGridEvent(myView,&Plot2d_ViewFrame::setYGrid, + theMajor,theNumMajor,theMinor,theNumMinor)); } + + class TSetScaleModeEvent: public SALOME_Event{ + public: + typedef void (Plot2d_ViewFrame::* TFun)(const int, bool = true); + TSetScaleModeEvent(Plot2d_ViewFrame* theView, TFun theFun, int theScaling): + myView(theView), myFun(theFun), myScaling(theScaling) + {} + virtual bool Execute(){ + (myView->*myFun)(myScaling); + return true; + } + protected: + Plot2d_ViewFrame* myView; + TFun myFun; + int myScaling; + }; + + void XYPlot_i::SetHorScaling(VISU::Scaling theScaling){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetHorScaling"); - Mutex mt(myMutex,qApp,MYDELAY); - if(theScaling == VISU::LOGARITHMIC) - myView->setHorScaleMode(1); - else - myView->setHorScaleMode(0); + ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setHorScaleMode, + theScaling == VISU::LOGARITHMIC)); } VISU::Scaling XYPlot_i::GetHorScaling(){ - if(MYDEBUG) MESSAGE("XYPlot_i::GetHorScaling"); - Mutex mt(myMutex,qApp,MYDELAY); return (VISU::Scaling)myView->getHorScaleMode(); } void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling"); - Mutex mt(myMutex,qApp,MYDELAY); - if(theScaling == VISU::LOGARITHMIC) - myView->setVerScaleMode(1); - else - myView->setVerScaleMode(0); + ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode, + theScaling == VISU::LOGARITHMIC)); } VISU::Scaling XYPlot_i::GetVerScaling(){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetVerScaling"); - Mutex mt(myMutex,qApp); return (VISU::Scaling)myView->getVerScaleMode(); } + + class TSetTitleEvent: public SALOME_Event{ + public: + typedef void (Plot2d_ViewFrame::* TFun)(bool, const QString&, bool = true); + TSetTitleEvent(Plot2d_ViewFrame* theView, TFun theFun, const char* theTitle): + myView(theView), myFun(theFun), myTitle(theTitle) + {} + virtual bool Execute(){ + (myView->*myFun)(true,myTitle); + return true; + } + protected: + Plot2d_ViewFrame* myView; + TFun myFun; + const char* myTitle; + }; + + void XYPlot_i::SetXTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetXTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setXTitle(true,theTitle); + ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setXTitle,theTitle)); } char* XYPlot_i::GetXTitle() { - if(MYDEBUG) MESSAGE("XYPlot_i::GetXTitle"); - Mutex mt(myMutex,qApp); return CORBA::string_dup(myView->getXTitle()); } void XYPlot_i::SetYTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetYTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->setYTitle(true,theTitle); + ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle)); } char* XYPlot_i::GetYTitle() { - if(MYDEBUG) MESSAGE("XYPlot_i::GetYTitle"); - Mutex mt(myMutex,qApp); return CORBA::string_dup(myView->getYTitle()); } void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){ - if(MYDEBUG) MESSAGE("XYPlot_i::ShowLegend"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->showLegend(theShowing); + ProcessVoidEvent(new TMemFun2ArgEvent + (myView,&Plot2d_ViewFrame::showLegend,theShowing,true)); } void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){ - if(MYDEBUG) MESSAGE("XYPlot_i::SetBackground"); - Mutex mt(myMutex,qApp,MYDELAY); - int aColor[3]; - aColor[0] = (int)(255.0*theColor.R); - aColor[1] = (int)(255.0*theColor.G); - aColor[2] = (int)(255.0*theColor.B); - QColor aNewColor(aColor[0],aColor[1],aColor[2]); - myView->setBackgroundColor(aNewColor); + ProcessVoidEvent(new TSetBackgroundEvent(myView,theColor)); } SALOMEDS::Color XYPlot_i::GetBackground() { - if(MYDEBUG) MESSAGE("XYPlot_i::GetBackground"); - Mutex mt(myMutex,qApp); SALOMEDS::Color aColor; aColor.R = myView->backgroundColor().red()/255.0; aColor.G = myView->backgroundColor().green()/255.0; @@ -649,19 +707,13 @@ namespace VISU{ return aColor; } void XYPlot_i::Minimize() { - if(MYDEBUG) MESSAGE("XYPlot_i::Minimize"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showMinimized(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized)); } void XYPlot_i::Restore() { - if(MYDEBUG) MESSAGE("XYPlot_i::Restore"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showNormal(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal)); } void XYPlot_i::Maximize() { - if(MYDEBUG) MESSAGE("XYPlot_i::Maximize"); - Mutex mt(myMutex,qApp,MYDELAY); - myStudyFrame->showMaximized(); + ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized)); } void XYPlot_i::Display(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("XYPlot_i::Display"); @@ -821,7 +873,6 @@ namespace VISU{ SALOMEGUI_TableDlg::ttAuto, Qt::Vertical); myView->show(); - myName = myView->caption().latin1(); return this; } } @@ -829,26 +880,16 @@ namespace VISU{ return NULL; } void TableView_i::SetTitle(const char* theTitle){ - if(MYDEBUG) MESSAGE("TableView_i::SetTitle"); - Mutex mt(myMutex,qApp,MYDELAY); - myName = theTitle; - myView->setCaption(myName.c_str()); + myView->setCaption(theTitle); } char* TableView_i::GetTitle() { - if(MYDEBUG) MESSAGE("TableView_i::GetTitle"); - Mutex mt(myMutex,qApp); - myName = (myView->caption()).latin1(); - return CORBA::string_dup(myName.c_str()); + return CORBA::string_dup(myView->caption().latin1()); } void TableView_i::Close(){ - if(MYDEBUG) MESSAGE("TableView_i::Close"); - Mutex mt(myMutex,qApp,MYDELAY); myView->close(); } TableView_i::~TableView_i() { if(MYDEBUG) MESSAGE("TableView_i::~TableView_i"); - Mutex mt(myMutex,qApp,MYDELAY); - Close(); delete myView; } //=========================================================================== @@ -898,8 +939,6 @@ namespace VISU{ return true; } }; - if(MYDEBUG) MESSAGE("View3D_i::Update"); - myName = myStudyFrame->title().latin1(); ProcessVoidEvent(new TEvent(myStudyFrame)); } @@ -929,7 +968,6 @@ namespace VISU{ } } }; - if(MYDEBUG) MESSAGE("View3D_i::SavePicture"); if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()) return false; TEvent* ve = new TEvent(myStudyFrame,theFileName); @@ -971,7 +1009,6 @@ namespace VISU{ return true; } CORBA::Boolean View3D_i::SaveViewParams(const char* theName){ - if(MYDEBUG) MESSAGE("View3D_i::SaveViewPoint"); return SaveViewParams(myStudyFrame,theName); } @@ -1021,7 +1058,6 @@ namespace VISU{ typedef CORBA::Boolean TResult; TResult myResult; }; - if(MYDEBUG) MESSAGE("View3D_i::RestoreViewParams - "<process(); TEvent::TResult aResult = ve->myResult; @@ -1148,22 +1184,7 @@ namespace VISU{ GetViewFrame(theStudyFrame)->setBackgroundColor(aNewColor); } void View3D_i::SetBackground(const SALOMEDS::Color& theColor) { - class TEvent: public SALOME_Event{ - QAD_StudyFrame* myStudyFrame; - const SALOMEDS::Color& myColor; - public: - TEvent(QAD_StudyFrame* theStudyFrame, - const SALOMEDS::Color& theColor): - myStudyFrame(theStudyFrame), - myColor(theColor) - {} - virtual bool Execute(){ - SetBackground(myStudyFrame,myColor); - return true; - } - }; - if(MYDEBUG) MESSAGE("View3D_i::SetBackground"); - ProcessVoidEvent(new TEvent(myStudyFrame,theColor)); + ProcessVoidEvent(new TSetBackgroundEvent(GetViewFrame(myStudyFrame),theColor)); } @@ -1175,12 +1196,10 @@ namespace VISU{ return aColor; } SALOMEDS::Color View3D_i::GetBackground() { - if(MYDEBUG) MESSAGE("View3D_i::GetBackground"); return GetBackground(myStudyFrame); } - typedef TMemFunEvent TFrameActionEvent; void View3D_i::Minimize() { ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized)); } diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index 0d4a7e70..c26b68ce 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -67,7 +67,6 @@ namespace VISU{ { protected: QAD_Study* myStudy; - string myName; public: View_i(SALOMEDS::Study_ptr theStudy); virtual ~View_i(); @@ -89,7 +88,7 @@ namespace VISU{ virtual void ToStream(std::ostringstream& theStr); virtual const char* GetComment() const; public: - virtual const char* View_i::GetEntry(); + virtual std::string View_i::GetEntry(); }; //===========================================================================