};
+ 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;
};
- class TCreate3DViewEvent: public TCreateViewEvent{
+ template<class TViewFrame>
+ 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<VISU::View3D_i>(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<VISU::XYPlot_i>(myStudyDocument));
}
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);
return (VISU::Scaling)myView->getHorScaleMode();
}
+
void XYPlot_i::SetVerScaling(VISU::Scaling theScaling){
ProcessVoidEvent(new TSetScaleModeEvent(myView,&Plot2d_ViewFrame::setVerScaleMode,
theScaling == VISU::LOGARITHMIC));
return CORBA::string_dup(myView->getXTitle());
}
+
void XYPlot_i::SetYTitle(const char* theTitle){
ProcessVoidEvent(new TSetTitleEvent(myView,&Plot2d_ViewFrame::setYTitle,theTitle));
}
return CORBA::string_dup(myView->getYTitle());
}
+
void XYPlot_i::ShowLegend(CORBA::Boolean theShowing){
ProcessVoidEvent(new TMemFun2ArgEvent<Plot2d_ViewFrame,bool,bool>
(myView,&Plot2d_ViewFrame::showLegend,theShowing,true));
}
+
void XYPlot_i::SetBackground(const SALOMEDS::Color& theColor){
ProcessVoidEvent(new TSetBackgroundEvent<Plot2d_ViewFrame>(myView,theColor));
}
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);
}
}
}
+
+
void XYPlot_i::Erase(PrsObject_ptr thePrsObj) {
if(MYDEBUG) MESSAGE("XYPlot_i::Erase");
Mutex mt(myMutex,qApp,MYDELAY);
}
}
}
+
void XYPlot_i::EraseAll() {
- if(MYDEBUG) MESSAGE("XYPlot_i::EraseAll");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->EraseAll();
+ ProcessVoidEvent(new TMemFunEvent<Plot2d_ViewFrame>(myView,&Plot2d_ViewFrame::EraseAll));
}
+
+
void XYPlot_i::DisplayOnly(PrsObject_ptr thePrsObj) {
if(MYDEBUG) MESSAGE("XYPlot_i::DisplayOnly");
Mutex mt(myMutex,qApp,MYDELAY);
}
}
}
+
+
void XYPlot_i::FitAll() {
- if(MYDEBUG) MESSAGE("XYPlot_i::FitAll");
- Mutex mt(myMutex,qApp,MYDELAY);
- myView->fitAll();
+ ProcessVoidEvent(new TMemFunEvent<Plot2d_ViewFrame>(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){
if(MYDEBUG) MESSAGE("TableView_i::~TableView_i");
delete myView;
}
+
+
//===========================================================================
int View3D_i::myNbViewParams = 0;
const string View3D_i::myComment = "VIEW3D";
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;
}
}
//-------------------- View3D interface --------------------
- typedef TMemFunEvent<VTKViewer_ViewFrame> TViewActionEvent;
-
-
void View3D_i::FitAll() {
- if(MYDEBUG) MESSAGE("View3D_i::FitAll");
- ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFitAll));
+ ProcessVoidEvent(new TMemFunEvent<VTKViewer_ViewFrame>(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<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewFront));
break;
case VISU::View3D::BACK :
- ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack));
+ ProcessVoidEvent(new TMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBack));
break;
case VISU::View3D::LEFT :
- ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft));
+ ProcessVoidEvent(new TMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewLeft));
break;
case VISU::View3D::RIGHT :
- ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight));
+ ProcessVoidEvent(new TMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewRight));
break;
case VISU::View3D::TOP :
- ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop));
+ ProcessVoidEvent(new TMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewTop));
break;
case VISU::View3D::BOTTOM :
- ProcessVoidEvent(new TViewActionEvent(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom));
+ ProcessVoidEvent(new TMemFunEvent<VTKViewer_ViewFrame>(GetViewFrame(myStudyFrame),&VTKViewer_ViewFrame::onViewBottom));
break;
}
Update();