From 9731bb9369398f67cce5d4332b01eb031947a069 Mon Sep 17 00:00:00 2001 From: smh Date: Fri, 16 Apr 2004 06:26:27 +0000 Subject: [PATCH] Minor improvements --- src/VISU_I/VISU_ViewManager_i.cc | 176 ++++++++++++++----------------- src/VISU_I/VISU_ViewManager_i.hh | 3 + 2 files changed, 80 insertions(+), 99 deletions(-) diff --git a/src/VISU_I/VISU_ViewManager_i.cc b/src/VISU_I/VISU_ViewManager_i.cc index ae4c7a52..e4e7ed2e 100644 --- a/src/VISU_I/VISU_ViewManager_i.cc +++ b/src/VISU_I/VISU_ViewManager_i.cc @@ -162,6 +162,33 @@ namespace VISU{ }; + class TSavePictureEvent: public SALOME_Event{ + QWidget* myWidget; + const char* myFileName; + public: + typedef CORBA::Boolean TResult; + TResult myResult; + TSavePictureEvent(QWidget* theWidget, const char* theFileName): + myWidget(theWidget), + myFileName(theFileName), + myResult(false) + {} + virtual bool Execute(){ + if(myWidget){ + QPixmap px = QPixmap::grabWindow(myWidget->winId()); + if (!QString(myFileName).isNull()) { + QString fmt = QAD_Tools::getFileExtensionFromPath(myFileName).upper(); + if (fmt.isEmpty()) + fmt = QString("BMP"); // default format + if (fmt == "JPG") + fmt = "JPEG"; + myResult = px.save(myFileName, fmt.latin1()); + } + } + } + }; + + void RepaintView(QAD_StudyFrame* theStudyFrame); class TRepaintViewEvent: public SALOME_Event{ QAD_StudyFrame* myStudyFrame; @@ -385,56 +412,36 @@ namespace VISU{ }; - class TCreate3DViewEvent: public TCreateViewEvent{ + template + class TCreateViewFrameEvent: public TCreateViewEvent{ public: - typedef VISU::View3D TInterface; - typedef TInterface::_ptr_type TResult; + typedef typename TViewFrame::TInterface TInterface; + typedef typename TInterface::_ptr_type TResult; TResult myResult; - TCreate3DViewEvent( SALOMEDS::Study_ptr theStudy): + TCreateViewFrameEvent(SALOMEDS::Study_ptr theStudy): TCreateViewEvent(theStudy), myResult(TInterface::_nil()) {} virtual bool Execute(){ - if ( CheckStudy( myStudyDocument ) ) { - VISU::View3D_i* pView = new View3D_i(myStudyDocument); - if(pView->Create(1) != NULL) + if(CheckStudy(myStudyDocument)){ + TViewFrame* pView = new TViewFrame(myStudyDocument); + if(pView->Create(1)) myResult = pView->_this(); } return true; } }; + + VISU::View3D_ptr ViewManager_i::Create3DView(){ if(MYDEBUG) MESSAGE("ViewManager_i::Create3DView"); - return ProcessEvent(new TCreate3DViewEvent(myStudyDocument)); + return ProcessEvent(new TCreateViewFrameEvent(myStudyDocument)); } - VISU::XYPlot_ptr ViewManager_i::CreateXYPlot(){ if(MYDEBUG) MESSAGE("ViewManager_i::CreateXYPlot"); - - class TEvent: public TCreateViewEvent{ - public: - TEvent( SALOMEDS::Study_ptr theStudy): - TCreateViewEvent(theStudy) - {} - virtual bool Execute(){ - if ( CheckStudy( myStudyDocument ) ) { - VISU::XYPlot_i* pView = new XYPlot_i(myStudyDocument); - if(pView->Create(1) != NULL) - myResult = pView->_this(); - } - return true; - } - typedef VISU::XYPlot_var TResult; - TResult myResult; - }; - - TEvent* ve = new TEvent(myStudyDocument); - ve->process(); - TEvent::TResult aResult = ve->myResult; - ve->release(); - return aResult._retn(); + return ProcessEvent(new TCreateViewFrameEvent(myStudyDocument)); } @@ -529,6 +536,7 @@ namespace VISU{ XYPlot_i::XYPlot_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) { if(MYDEBUG) MESSAGE("XYPlot_i::XYPlot_i"); } + Storable* XYPlot_i::Create(int theNew){ if(theNew) myStudyFrame = myStudy->newWindow3d("",VIEW_PLOT2D); @@ -651,6 +659,7 @@ namespace VISU{ return (VISU::Scaling)myView->getHorScaleMode(); } + void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){ ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode, theScaling == VISU::LOGARITHMIC)); @@ -684,6 +693,7 @@ namespace VISU{ return CORBA::string_dup(myView->getXTitle()); } + void XYPlot_i::SetYTitle(const char* theTitle){ ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle)); } @@ -691,11 +701,13 @@ namespace VISU{ return CORBA::string_dup(myView->getYTitle()); } + void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){ ProcessVoidEvent(new TMemFun2ArgEvent (myView,&Plot2d_ViewFrame::showLegend,theShowing,true)); } + void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){ ProcessVoidEvent(new TSetBackgroundEvent(myView,theColor)); } @@ -706,15 +718,20 @@ namespace VISU{ aColor.B = myView->backgroundColor().blue()/255.0; return aColor; } + void XYPlot_i::Minimize() { ProcessVoidEvent(new TFrameActionEvent(myStudyFrame,&QAD_StudyFrame::showMinimized)); } + void XYPlot_i::Restore() { ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showNormal)); } + void XYPlot_i::Maximize() { ProcessVoidEvent(new TFrameActionEvent(myStudyFrame, &QAD_StudyFrame::showMaximized)); } + + void XYPlot_i::Display(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("XYPlot_i::Display"); Mutex mt(myMutex,qApp,MYDELAY); @@ -751,6 +768,8 @@ namespace VISU{ } } } + + void XYPlot_i::Erase(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("XYPlot_i::Erase"); Mutex mt(myMutex,qApp,MYDELAY); @@ -787,11 +806,12 @@ namespace VISU{ } } } + void XYPlot_i::EraseAll() { - if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->EraseAll(); + ProcessVoidEvent(new TMemFunEvent(myView,&Plot2d_ViewFrame::EraseAll)); } + + void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) { if(MYDEBUG) MESSAGE("XYPlot_i::DisplayOnly"); Mutex mt(myMutex,qApp,MYDELAY); @@ -828,35 +848,22 @@ namespace VISU{ } } } + + void XYPlot_i::FitAll() { - if(MYDEBUG) MESSAGE("XYPlot_i::FitAll"); - Mutex mt(myMutex,qApp,MYDELAY); - myView->fitAll(); + ProcessVoidEvent(new TMemFunEvent(myView,&Plot2d_ViewFrame::fitAll)); } - CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) { - if(MYDEBUG) MESSAGE("XYPlot_i::SavePicture"); - Mutex mt(myMutex,qApp,MYDELAY); - if (!myView->getViewWidget()) - return false; - QApplication::setOverrideCursor( Qt::waitCursor ); - QPixmap px = QPixmap::grabWindow(myView->getViewWidget()->winId()); - QApplication::restoreOverrideCursor(); - - if (!QString(theFileName).isNull()) { - QApplication::setOverrideCursor( Qt::waitCursor ); - QString fmt = QAD_Tools::getFileExtensionFromPath(theFileName).upper(); - if (fmt.isEmpty()) - fmt = QString("BMP"); // default format - if (fmt == "JPG") - fmt = "JPEG"; - bool bOk = px.save(theFileName, fmt.latin1()); - QApplication::restoreOverrideCursor(); - return bOk; - } - return false; + + CORBA::Boolean XYPlot_i::SavePicture(const char* theFileName) { + TSavePictureEvent* ve = new TSavePictureEvent(myView->getViewWidget(),theFileName); + ve->process(); + TSavePictureEvent::TResult aResult = ve->myResult; + ve->release(); + return aResult; } + //=========================================================================== TableView_i::TableView_i(SALOMEDS::Study_ptr theStudy) : View_i(theStudy) {} Storable* TableView_i::Create(VISU::Table_ptr theTable){ @@ -892,6 +899,8 @@ namespace VISU{ if(MYDEBUG) MESSAGE("TableView_i::~TableView_i"); delete myView; } + + //=========================================================================== int View3D_i::myNbViewParams = 0; const string View3D_i::myComment = "VIEW3D"; @@ -944,35 +953,9 @@ namespace VISU{ CORBA::Boolean View3D_i::SavePicture(const char* theFileName) { - class TEvent: public SALOME_Event{ - QAD_StudyFrame* myStudyFrame; - const char* myFileName; - public: - typedef CORBA::Boolean TResult; - TResult myResult; - TEvent(QAD_StudyFrame* theStudyFrame, - const char* theFileName): - myStudyFrame(theStudyFrame), - myFileName(theFileName), - myResult(false) - {} - virtual bool Execute(){ - QPixmap px = QPixmap::grabWindow(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()->winId()); - if (!QString(myFileName).isNull()) { - QString fmt = QAD_Tools::getFileExtensionFromPath(myFileName).upper(); - if (fmt.isEmpty()) - fmt = QString("BMP"); // default format - if (fmt == "JPG") - fmt = "JPEG"; - myResult = px.save(myFileName, fmt.latin1()); - } - } - }; - if (!myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget()) - return false; - TEvent* ve = new TEvent(myStudyFrame,theFileName); + TSavePictureEvent* ve = new TSavePictureEvent(myStudyFrame->getRightFrame()->getViewFrame()->getViewWidget(),theFileName); ve->process(); - TEvent::TResult aResult = ve->myResult; + TSavePictureEvent::TResult aResult = ve->myResult; ve->release(); return aResult; } @@ -1265,36 +1248,31 @@ namespace VISU{ } //-------------------- View3D interface -------------------- - typedef TMemFunEvent TViewActionEvent; - - void View3D_i::FitAll() { - if(MYDEBUG) MESSAGE("View3D_i::FitAll"); - ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll)); + ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll)); Update(); } void View3D_i::SetView(VISU::View3D::ViewType theType) { - if(MYDEBUG) MESSAGE("View3D_i::SetView"); switch(theType){ case VISU::View3D::FRONT : - ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront)); + ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront)); break; case VISU::View3D::BACK : - ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack)); + ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack)); break; case VISU::View3D::LEFT : - ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft)); + ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft)); break; case VISU::View3D::RIGHT : - ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight)); + ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight)); break; case VISU::View3D::TOP : - ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop)); + ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop)); break; case VISU::View3D::BOTTOM : - ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom)); + ProcessVoidEvent(new TMemFunEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom)); break; } Update(); diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index c26b68ce..ca653ce0 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -96,6 +96,7 @@ namespace VISU{ public virtual View_i { public: + typedef VISU::XYPlot TInterface; XYPlot_i(SALOMEDS::Study_ptr theStudy); virtual ~XYPlot_i(); virtual VISU::VISUType GetType() { return VISU::TXYPLOT;}; @@ -158,6 +159,7 @@ namespace VISU{ public virtual View_i { public: + typedef VISU::TableView TInterface; TableView_i(SALOMEDS::Study_ptr theStudy); virtual ~TableView_i(); virtual VISU::VISUType GetType() { return VISU::TTABLEVIEW;}; @@ -177,6 +179,7 @@ namespace VISU{ public virtual View_i { public: + typedef VISU::View3D TInterface; View3D_i(SALOMEDS::Study_ptr theStudy); virtual ~View3D_i(); virtual VISU::VISUType GetType() { return VISU::TVIEW3D;}; -- 2.39.2