aAction = new QtxAction(tr("MNU_DUMP_VIEW"), aResMgr->loadPixmap( "GLViewer", tr( "ICON_GL_DUMP" ) ),
tr( "MNU_DUMP_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_DUMP_VIEW"));
- connect(aAction, SIGNAL(activated()), this, SLOT(onViewDump()));
+ connect(aAction, SIGNAL(activated()), this, SLOT(onDumpView()));
myActionsMap[ DumpId ] = aAction;
// FitAll
{
}
-void GLViewer_ViewFrame::onViewDump()
+QImage GLViewer_ViewFrame::dumpView()
{
GLViewer_Widget* aWidget = ((GLViewer_ViewPort2d*)myVP)->getGLWidget();
int width, height;
}
delete [] imageBits;
-
- SUIT_Application* app = getViewManager()->study()->application();
-
- QString aFileName = app->getFileName( false, QString::null, QString( "*.bmp;*.png" ), tr( "DUMP_VIEW_SAVE_FILE_DLG_CAPTION" ), 0 );
-
- if( aFileName.isEmpty() ) // cancelled
- return;
-
- QString aSaveOp = SUIT_Tools::extension( aFileName ).upper();
-
- if ( aSaveOp != "BMP" && aSaveOp != "PNG" ) {
- SUIT_MessageBox::error1( this,
- tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
- tr( "DUMP_VIEW_ERROR_UNSUPPORTED_FORMAT" ).arg( aSaveOp ),
- tr( "BUT_OK" ) );
- return;
- }
-
- if( !anImage.save( aFileName, aSaveOp ) )
- {
- SUIT_MessageBox::error1( this,
- tr( "DUMP_VIEW_ERROR_DLG_CAPTION" ),
- tr( "DUMP_VIEW_ERROR_DLG_TEXT" ),
- tr( "BUT_OK" ) );
- }
+ return anImage;
}
void GLViewer_ViewFrame::onViewPan()
break;
}
}
+
GLViewer_Viewer* myViewer;
GLViewer_ViewPort* myVP;
+protected:
+ QImage dumpView();
+
public:
//ViewType getTypeView() const { return VIEW_GL; };
QWidget* getViewWidget() { return ( QWidget* )getViewPort(); };
protected slots:
- void onViewDump();
void onViewPan();
void onViewZoom();
void onViewFitAll();
{
if( thePopup->count() > 0 )
thePopup->insertSeparator();
+ thePopup->insertItem( tr( "MNU_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
thePopup->insertItem( tr( "CHANGE_BGCOLOR" ), this, SLOT( onChangeBgColor() ) );
}
}
updateAll();
}
+/*!
+ Processes "Dump view..." context popup menu command
+*/
+void GLViewer_Viewer2d::onDumpView()
+{
+ if ( getActiveView() )
+ getActiveView()->onDumpView();
+}
/****************************************************************
** Class: GLViewer_View2dTransformer
}
GLViewer_ViewTransformer::onTransform( state );
}
+
protected slots:
void onMouseEvent( SUIT_ViewWindow*, QMouseEvent* );
+ void onDumpView();
private:
bool testRotation( QMouseEvent* );
msgstr "Saves the active view in the image file"
msgid "MNU_DUMP_VIEW"
-msgstr "Dump"
+msgstr "Dump view..."
msgid "GL_IMAGE_FILES"
msgstr "Images Files (*.bmp *.png)"
myViewPort->fitAll();
}
-//****************************************************************
-/*
- Dumps 3d-Viewer contents into image file
- File format is defined by file's extension; supported formats : PNG, BMP, GIF, JPG
-*/
-void OCCViewer_ViewWindow::onDumpView()
-{
- QApplication::setOverrideCursor( Qt::waitCursor );
- QPixmap px = QPixmap::grabWindow(myViewPort->winId());
- QApplication::restoreOverrideCursor();
-
- SUIT_Application* app = getViewManager()->study()->application();
-
- QString aFileName = app->getFileName( false, QString::null, tr("OCC_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 );
-
- if ( !aFileName.isNull() ) {
- QApplication::setOverrideCursor( Qt::waitCursor );
- QString fmt = SUIT_Tools::extension( aFileName ).upper();
- if (fmt.isEmpty())
- fmt = QString("BMP"); // default format
- if (fmt == "JPG")
- fmt = "JPEG";
- bool bOk = px.save(aFileName, fmt.latin1());
- QApplication::restoreOverrideCursor();
- if (!bOk) {
- SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK"));
- }
- }
-}
-
//****************************************************************
void OCCViewer_ViewWindow::onCloneView()
{
{
myModel->toggleTrihedron();
}
+
+//****************************************************************
+QImage OCCViewer_ViewWindow::dumpView()
+{
+ QPixmap px = QPixmap::grabWindow( myViewPort->winId() );
+ return px.convertToImage();
+}
void onRightView();
void onResetView();
void onFitAll();
- void onDumpView();
void activateZoom();
void activateWindowFit();
void activateRotation();
typedef QMap<int, QtxAction*> ActionsMap;
+ QImage dumpView();
/* Transformation selected but not started yet */
bool transformRequested() const { return ( myOperation != NOTHING ); }
myPlot->replot();
myPnt = event->pos();
}
-/*!
- View operations : Dump view
-*/
-void Plot2d_ViewFrame::onDump()
-{
- QApplication::setOverrideCursor( Qt::waitCursor );
- QPixmap px = QPixmap::grabWindow(winId());
- QApplication::restoreOverrideCursor();
-
- SUIT_Application* app = ((Plot2d_ViewWindow*)parent())->getViewManager()->study()->application();
-
- QString aFileName = app->getFileName( false, QString::null, tr("PLOT2D_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 );
-
- if ( !aFileName.isNull() )
- {
- QApplication::setOverrideCursor( Qt::waitCursor );
- QString fmt = SUIT_Tools::extension( aFileName ).upper();
- if (fmt.isEmpty())
- fmt = QString("BMP"); // default format
- if (fmt == "JPG")
- fmt = "JPEG";
- bool bOk = px.save(aFileName, fmt.latin1());
- QApplication::restoreOverrideCursor();
- if (!bOk) {
- SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK"));
- }
- }
-}
/*!
View operations : Pan view
*/
virtual void wheelEvent( QWheelEvent* );
public slots:
- void onDump();
void onViewPan();
void onViewZoom();
void onViewFitAll();
aView->contextMenuPopup(thePopup);
if (thePopup->count() > 0) thePopup->insertSeparator();
- thePopup->insertItem("Change background...", this, SLOT(onChangeBgColor()));
+ thePopup->insertItem( tr( "MNU_DUMP_VIEW" ), this, SLOT(onDumpView()));
+ thePopup->insertItem( tr( "MEN_PLOT2D_CHANGE_BACKGROUND" ), this, SLOT(onChangeBgColor()));
if ( aView ) {
if ( !aView->getToolBar()->isVisible() ) {
if ( aView )
aView->getToolBar()->show();
}
+
+//*********************************************************************
+void Plot2d_Viewer::onDumpView()
+{
+ Plot2d_ViewWindow* aView = (Plot2d_ViewWindow*)(myViewManager->getActiveView());
+ if ( aView )
+ aView->onDumpView();
+}
protected slots:
void onChangeBgColor();
+ void onDumpView();
void onShowToolbar();
private:
#include <qstatusbar.h>
#include <qlayout.h>
+#include <qapplication.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
myActionsMap[ LegendId ]->setOn(myViewFrame->isLegendShow());
}
-//****************************************************************
-void Plot2d_ViewWindow::onDumpView()
-{
- myViewFrame->onDump();
-}
-
//****************************************************************
void Plot2d_ViewWindow::onFitAll()
{
myViewFrame->setCurveType(2);
}
}
+
+//****************************************************************
+void Plot2d_ViewWindow::onDumpView()
+{
+ qApp->postEvent( myViewFrame, new QPaintEvent( QRect( 0, 0, myViewFrame->width(), myViewFrame->height() ), TRUE ) );
+ SUIT_ViewWindow::onDumpView();
+}
+
+//****************************************************************
+QImage Plot2d_ViewWindow::dumpView()
+{
+ QPixmap px = QPixmap::grabWindow( myViewFrame->winId() );
+ return px.convertToImage();
+}
QToolBar* getToolBar() { return myToolBar; };
void contextMenuPopup( QPopupMenu* thePopup );
+protected:
+ QImage dumpView();
+
private:
bool eventFilter(QObject* watched, QEvent* e);
void onChangeCurveMode();
void onChangeLegendMode();
- void onDumpView();
void onFitAll();
void onFitRect();
void onZoom();
void onLegend();
void onCurves();
+ void onDumpView();
+
signals:
void cloneView();
msgstr "Saves the active view in the image file"
msgid "MNU_DUMP_VIEW"
-msgstr "Dump"
+msgstr "Dump view..."
msgid "DSC_FITALL"
msgstr "Fit all objects inside the view frame"
#include "SUIT_ViewWindow.h"
#include "SUIT_Desktop.h"
+#include "SUIT_Application.h"
+#include "SUIT_Study.h"
+#include "SUIT_ViewManager.h"
+#include "SUIT_Tools.h"
+#include "SUIT_MessageBox.h"
#include "qhbox.h"
#include "qpopupmenu.h"
+#include "qapplication.h"
+
+// Dump view custom event
+const int DUMP_EVENT = QEvent::User + 123;
+
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
if ( e->reason() != QContextMenuEvent::Mouse )
emit contextMenuRequested( e );
}
+
+//****************************************************************
+void SUIT_ViewWindow::onDumpView()
+{
+ qApp->postEvent( this, new QPaintEvent( QRect( 0, 0, width(), height() ), TRUE ) );
+ qApp->postEvent( this, new QCustomEvent( DUMP_EVENT ) );
+}
+
+//****************************************************************
+bool SUIT_ViewWindow::event( QEvent* e )
+{
+ if ( e->type() == DUMP_EVENT ) {
+ bool bOk = false;
+ if ( myManager && myManager->study() && myManager->study()->application() ) {
+ // first create an image (this is small trick to avoid dialog box overlapping)
+ QImage img = dumpView();
+ if ( !img.isNull() ) {
+ // get file name
+ QString fileName = myManager->study()->application()->getFileName( false, QString::null, tr( "TLT_IMAGE_FILES" ), tr( "TLT_DUMP_VIEW" ), 0 );
+ if ( fileName ) {
+ QString fmt = SUIT_Tools::extension( fileName ).upper();
+ if ( fmt.isEmpty() ) fmt = QString( "BMP" ); // default format
+ if ( fmt == "JPG" ) fmt = "JPEG";
+ QApplication::setOverrideCursor( Qt::waitCursor );
+ bOk = img.save( fileName, fmt.latin1() );
+ QApplication::restoreOverrideCursor();
+ }
+ else {
+ bOk = true; // cancelled
+ }
+ }
+ }
+ if ( !bOk ) {
+ SUIT_MessageBox::error1( this, tr( "ERROR" ), tr( "ERR_CANT_DUMP_VIEW" ), tr( "BUT_OK" ) );
+ }
+ return TRUE;
+ }
+ return QMainWindow::event( e );
+}
+
+//****************************************************************
#include "SUIT.h"
#include <qmainwindow.h>
+#include <qimage.h>
class SUIT_Desktop;
class SUIT_ViewManager;
void setViewManager(SUIT_ViewManager* theManager) { myManager = theManager;}
SUIT_ViewManager* getViewManager() const { return myManager; }
+ bool event(QEvent*);
+
+public slots:
+ virtual void onDumpView();
+
signals:
void closing(SUIT_ViewWindow*);
void mousePressed(SUIT_ViewWindow*, QMouseEvent*);
void closeEvent(QCloseEvent* theEvent);
virtual void contextMenuEvent( QContextMenuEvent * e );
+ virtual QImage dumpView() { return QImage(); }
+
SUIT_Desktop* myDesktop;
SUIT_ViewManager* myManager;
};
msgid "QUE_FILE_EXISTS"
msgstr "The file \"%1\" already exists.\nDo you want to overwrite it?"
+msgid "TLT_DUMP_VIEW"
+msgstr "Dump View to File"
+
+msgid "TLT_IMAGE_FILES"
+msgstr "Images Files (*.bmp *.png *.jpg *.jpeg)""
+
+msgid "ERR_CANT_DUMP_VIEW"
+msgstr "Can't dump view contents to the file."
\ No newline at end of file
Repaint();
}
-//----------------------------------------------------------------------------
-void
-SVTK_ViewWindow
-::onDumpView()
-{
- QApplication::setOverrideCursor( Qt::waitCursor );
- QPixmap px = QPixmap::grabWindow(myRenderWindow->winId());
- QApplication::restoreOverrideCursor();
-
- SUIT_Application* app = getViewManager()->study()->application();
-
- QString aFileName = app->getFileName( false, QString::null, tr("VTK_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 );
-
- if ( !aFileName.isNull() ) {
- QApplication::setOverrideCursor( Qt::waitCursor );
- QString fmt = SUIT_Tools::extension( aFileName ).upper();
- if (fmt.isEmpty())
- fmt = QString("BMP"); // default format
- if (fmt == "JPG")
- fmt = "JPEG";
- bool bOk = px.save(aFileName, fmt.latin1());
- QApplication::restoreOverrideCursor();
- if (!bOk) {
- SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK"));
- }
- }
-}
-
//----------------------------------------------------------------
void
SVTK_ViewWindow
RemoveActor(theActor);
InsertActor(theActor,true);
}
+
+//----------------------------------------------------------------------------
+QImage
+SVTK_ViewWindow
+::dumpView()
+{
+ QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
+ return px.convertToImage();
+}
public slots:
void onSelectionChanged();
- signals:
+signals:
void selectionChanged();
public slots:
void onResetView();
void onFitAll();
- void onDumpView();
void onViewTrihedron();
void onAdjustTrihedron();
void activatePanning();
void activateGlobalPanning();
+protected:
+ QImage dumpView();
+
protected slots:
void onKeyPressed(QKeyEvent* event);
void onKeyReleased(QKeyEvent* event);
Repaint();
}
-//****************************************************************
-/*
- Dumps 3d-Viewer contents into image file
- File format is defined by file's extension; supported formats : PNG, BMP, GIF, JPG
-*/
-void VTKViewer_ViewWindow::onDumpView()
-{
- QApplication::setOverrideCursor( Qt::waitCursor );
- QPixmap px = QPixmap::grabWindow(myRenderWindow->winId());
- QApplication::restoreOverrideCursor();
-
- SUIT_Application* app = getViewManager()->study()->application();
-
- QString aFileName = app->getFileName( false, QString::null, tr("VTK_IMAGE_FILES"), tr("INF_APP_DUMP_VIEW"), 0 );
-
- if ( !aFileName.isNull() ) {
- QApplication::setOverrideCursor( Qt::waitCursor );
- QString fmt = SUIT_Tools::extension( aFileName ).upper();
- if (fmt.isEmpty())
- fmt = QString("BMP"); // default format
- if (fmt == "JPG")
- fmt = "JPEG";
- bool bOk = px.save(aFileName, fmt.latin1());
- QApplication::restoreOverrideCursor();
- if (!bOk) {
- SUIT_MessageBox::error1(this, tr("ERROR"), tr("ERR_DOC_CANT_SAVE_FILE"), tr("BUT_OK"));
- }
- }
-}
-
//****************************************************************
/*!
Set background of the viewport
myTrihedron->VisibilityOn();
myRenderWindow->update();
}
+
+//****************************************************************
+QImage VTKViewer_ViewWindow::dumpView()
+{
+ QPixmap px = QPixmap::grabWindow( myRenderWindow->winId() );
+ return px.convertToImage();
+}
void onRightView();
void onResetView();
void onFitAll();
- void onDumpView();
void activateZoom();
void activateWindowFit();
void activateRotation();
void activateGlobalPanning();
void onTrihedronShow();
+protected:
+ QImage dumpView();
+
protected slots:
void onKeyPressed(QKeyEvent* event);
void onKeyReleased(QKeyEvent* event);
msgstr "Saves the active view in the image file"
msgid "MNU_DUMP_VIEW"
-msgstr "Dump"
+msgstr "Dump view..."
msgid "VTK_IMAGE_FILES"
msgstr "Images Files (*.bmp *.png *.jpg *.jpeg)"