From: vsr Date: Fri, 15 Apr 2005 05:37:29 +0000 (+0000) Subject: PAL8598: Provide an access to "Dump View" functionality from the context popup menu... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1056cf8b10e37b9be6e0a1242d3de57d05315343;p=modules%2Fkernel.git PAL8598: Provide an access to "Dump View" functionality from the context popup menu for the viewer --- diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 90645fdb2..8396a6a6c 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -189,6 +189,8 @@ void OCCViewer_ViewFrame::initViewPort() this, SIGNAL( vfKeyPress( QKeyEvent* ) ) ) ); QAD_ASSERT( connect( myViewPort, SIGNAL( vpKeyRelease( QKeyEvent* ) ), this, SIGNAL( vfKeyRelease( QKeyEvent* ) ) ) ); + QAD_ASSERT( connect( myViewPort, SIGNAL( vpDumpView() ), + this, SLOT( onProcessViewDump() ) ) ); } //======================================================================= diff --git a/src/OCCViewer/OCCViewer_ViewPort.h b/src/OCCViewer/OCCViewer_ViewPort.h index 6f80c7816..1ddf54a18 100644 --- a/src/OCCViewer/OCCViewer_ViewPort.h +++ b/src/OCCViewer/OCCViewer_ViewPort.h @@ -171,6 +171,8 @@ signals: void vpPaint (QPaintEvent*); void vpDrawExternal (QPainter* painter); + void vpDumpView(); + protected slots: virtual void onChangeBackgroundColor() = 0; diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 0ace89025..6b39a2add 100644 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -99,6 +99,8 @@ void OCCViewer_ViewPort3d::onCreatePopup() int id; myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_CHANGEBGR")) ); QAD_ASSERT ( myPopup->connectItem ( id, this, SLOT(onChangeBackgroundColor())) ); + myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_DUMPVIEW")) ); + QAD_ASSERT ( myPopup->connectItem ( id, this, SIGNAL(vpDumpView())) ); // } } } diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index cde7a3961..50626fa19 100644 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -244,6 +244,13 @@ void Plot2d_ViewFrame::createActions() fitDataAction->setStatusTip ( tr( "PRP_PLOT2D_CHANGE_BACKGROUND" ) ); myActions.insert( ChangeBackgroundId, changeBGAction ); connect( changeBGAction, SIGNAL( activated() ), this, SLOT( onChangeBackground() ) ); + + // Dump View + QActionP* dumpViewAction = new QActionP ( tr( "MEN_VP3D_DUMPVIEW"), + tr( "MEN_VP3D_DUMPVIEW" ), 0, this ); + dumpViewAction->setStatusTip ( tr( "MEN_VP3D_DUMPVIEW" ) ); + myActions.insert( DumpViewId, dumpViewAction ); + connect( dumpViewAction, SIGNAL( activated() ), this, SLOT( onProcessViewDump() ) ); } /*! Gets window's central widget @@ -288,6 +295,7 @@ void Plot2d_ViewFrame::onCreatePopup() // Change background myPopup->insertSeparator(); myActions[ ChangeBackgroundId ]->addTo( myPopup ); + myActions[ DumpViewId ]->addTo( myPopup ); } } /*! diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 275c432fb..c837cee50 100644 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -35,7 +35,7 @@ class QAD_EXPORT Plot2d_ViewFrame : public QAD_ViewFrame, public QAD_PopupClient enum { NoOpId, FitAllId, FitAreaId, ZoomId, PanId, DumpId, ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId, - LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId, ChangeBackgroundId }; + LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId, ChangeBackgroundId, DumpViewId }; public: /* Construction/destruction */ Plot2d_ViewFrame( QWidget* parent, const QString& title = "" ); diff --git a/src/SALOMEGUI/QAD_ViewFrame.cxx b/src/SALOMEGUI/QAD_ViewFrame.cxx index c22c7a4a8..ff25d5aa3 100644 --- a/src/SALOMEGUI/QAD_ViewFrame.cxx +++ b/src/SALOMEGUI/QAD_ViewFrame.cxx @@ -78,7 +78,6 @@ void QAD_ViewFrame::onViewDump() { if (!getViewWidget()) return; - QApplication::setOverrideCursor( Qt::waitCursor ); QPixmap px = QPixmap::grabWindow(getViewWidget()->winId()); QApplication::restoreOverrideCursor(); @@ -105,3 +104,29 @@ void QAD_ViewFrame::onViewDump() } } } + +#define DUMP_EVENT QEvent::User + 123 +/*! + This method is used to dump the viewer contents to the image file + from the context popup menu (uses event mechanizm to assure redrawing + the viewer contents before dumping by sending custom event) +*/ +void QAD_ViewFrame::onProcessViewDump() +{ + qApp->postEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ), TRUE ) ); + qApp->postEvent( this, new QCustomEvent( DUMP_EVENT ) ); +} + +/*! + Processes the custom event sent by onProcessViewDump() method to + call onViewDump() slot: dumping the view contents to the image file + (see desription for onProcessViewDump() method above) +*/ +bool QAD_ViewFrame::event ( QEvent* e ) +{ + if ( e->type() == DUMP_EVENT ) { + onViewDump(); + return TRUE; + } + return QMainWindow::event( e ); +} diff --git a/src/SALOMEGUI/QAD_ViewFrame.h b/src/SALOMEGUI/QAD_ViewFrame.h index 7ea86fb5f..572eccddf 100644 --- a/src/SALOMEGUI/QAD_ViewFrame.h +++ b/src/SALOMEGUI/QAD_ViewFrame.h @@ -51,6 +51,8 @@ public: QAD_ViewFrame(QWidget* parent = 0); virtual ~QAD_ViewFrame(); + bool event ( QEvent* e ); + void cleanup(); virtual ViewType getTypeView() const = 0; @@ -128,6 +130,11 @@ public slots: virtual void onRotateRight() {} virtual void onRotateUp() {} virtual void onRotateDown() {} + + /* the next slot is used for dumping viewer contents to the image file; + called from the context popup menu + */ + void onProcessViewDump(); }; #endif diff --git a/src/SALOMEGUI/QAD_msg_en.po b/src/SALOMEGUI/QAD_msg_en.po index 28a42b0a2..9e6d7c6b1 100644 --- a/src/SALOMEGUI/QAD_msg_en.po +++ b/src/SALOMEGUI/QAD_msg_en.po @@ -349,6 +349,9 @@ msgstr "Viewer" msgid "MEN_VP3D_CHANGEBGR" msgstr "Change background..." +msgid "MEN_VP3D_DUMPVIEW" +msgstr "Camera Dump..." + msgid "MEN_APP_DISPLAY" msgstr "Display" diff --git a/src/VTKViewer/VTKViewer_RenderWindow.cxx b/src/VTKViewer/VTKViewer_RenderWindow.cxx index 08dbc0eda..bd97dd202 100644 --- a/src/VTKViewer/VTKViewer_RenderWindow.cxx +++ b/src/VTKViewer/VTKViewer_RenderWindow.cxx @@ -176,6 +176,8 @@ void VTKViewer_RenderWindow::onCreatePopup() int id; myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_CHANGEBGR")) ); QAD_ASSERT ( myPopup->connectItem ( id, this, SLOT(onChangeBackgroundColor())) ); + myIDs.append ( id = myPopup->insertItem (tr ("MEN_VP3D_DUMPVIEW")) ); + QAD_ASSERT ( myPopup->connectItem ( id, this, SIGNAL(DumpView())) ); // } } } diff --git a/src/VTKViewer/VTKViewer_RenderWindow.h b/src/VTKViewer/VTKViewer_RenderWindow.h index 34fd61ff0..e19e67966 100644 --- a/src/VTKViewer/VTKViewer_RenderWindow.h +++ b/src/VTKViewer/VTKViewer_RenderWindow.h @@ -77,6 +77,7 @@ public QWidget, /*virtual public vtkRenderWindow, */ void ButtonPressed(const QMouseEvent *event) ; void ButtonReleased(const QMouseEvent *event) ; void KeyPressed(QKeyEvent *event) ; + void DumpView(); protected: vtkRenderWindow* myRW; diff --git a/src/VTKViewer/VTKViewer_ViewFrame.cxx b/src/VTKViewer/VTKViewer_ViewFrame.cxx index 067cc6aee..783b60bae 100644 --- a/src/VTKViewer/VTKViewer_ViewFrame.cxx +++ b/src/VTKViewer/VTKViewer_ViewFrame.cxx @@ -90,6 +90,7 @@ VTKViewer_ViewFrame::VTKViewer_ViewFrame(QWidget* parent, const char* name) void VTKViewer_ViewFrame::InitialSetup() { m_RW = new VTKViewer_RenderWindow(this, "RenderWindow"); m_RW->getRenderWindow()->AddRenderer(m_Renderer); + connect(m_RW, SIGNAL(DumpView()), this, SLOT(onProcessViewDump())); m_Renderer->GetActiveCamera()->ParallelProjectionOn(); m_Renderer->LightFollowCameraOn();