#include <QMouseEvent>
#include <QContextMenuEvent>
#include <QPrinter>
+#include <QPrintDialog>
#include <QPalette>
#include <qwt_math.h>
*/
bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const
{
+ // if the method is called with default (empty) arguments,
+ // send contents of the plot directly to printer
+ if( file.isEmpty() && format.isEmpty() )
+ {
+ SUIT_Application* anApp = SUIT_Session::session()->activeApplication();
+
+ QPrinter aPrinter( QPrinter::HighResolution );
+ aPrinter.setPageSize( QPrinter::A4 );
+
+ if( anApp )
+ aPrinter.setPrinterName( anApp->getLastUsedPrinter() );
+
+ QPrintDialog aDlg( &aPrinter );
+ int aStatus = aDlg.exec();
+ if( aStatus )
+ myPlot->print( aPrinter );
+
+ if( anApp )
+ anApp->setLastUsedPrinter( aPrinter.printerName() );
+
+ return aStatus;
+ }
+
#ifdef WIN32
return false;
{
Q_OBJECT
- enum { NoOpId, FitAreaId, ZoomId, PanId, GlPanId, DumpId,
+ enum { NoOpId, FitAreaId, ZoomId, PanId, GlPanId, DumpId, PrintId,
ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId,
LegendId, CurvePointsId, CurveLinesId, CurveSplinesId };
public:
bool isXLogEnabled() const;
bool isYLogEnabled() const;
- virtual bool print( const QString& file, const QString& format ) const;
+ virtual bool print( const QString& file = QString::null,
+ const QString& format = QString::null ) const;
QString getVisualParameters();
void setVisualParameters( const QString& parameters );
QtxAction* aAction;
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- // 1. Dump View
+ // 1. Dump and Print
+
+ // 1.1. Dump View
aAction = new QtxAction( tr( "MNU_DUMP_VIEW" ),
aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_DUMP" ) ),
tr( "MNU_DUMP_VIEW" ),
connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onDumpView() ) );
mgr->registerAction( aAction, DumpId );
+ // 1.2. Print View
+ aAction = new QtxAction( tr( "MNU_PRINT_VIEW" ),
+ aResMgr->loadPixmap( "Plot2d", tr( "ICON_PLOT2D_PRINT" ) ),
+ tr( "MNU_PRINT_VIEW" ),
+ 0, this);
+ aAction->setStatusTip( tr( "DSC_PRINT_VIEW" ) );
+ connect( aAction, SIGNAL( triggered( bool ) ), this, SLOT( onPrintView() ) );
+ mgr->registerAction( aAction, PrintId );
+
// 2. Scaling operations
// 2.1. Fit All
QtxActionToolMgr* mgr = toolMgr();
myToolBar = mgr->createToolBar( tr( "LBL_TOOLBAR_LABEL" ) );
mgr->append( DumpId, myToolBar );
+ mgr->append( PrintId, myToolBar );
mgr->append( ScaleOpId, myToolBar );
mgr->append( MoveOpId, myToolBar );
mgr->append( toolMgr()->separator(), myToolBar );
SUIT_ViewWindow::onDumpView();
}
+/*!
+ \brief Called when the "Print view" action is activated.
+*/
+void Plot2d_ViewWindow::onPrintView()
+{
+ myViewFrame->print();
+}
+
/*!
\brief Dump the contents of the view window to the image.
\return image, containing all scene rendered in the window
Q_OBJECT
public:
- enum { DumpId,
+ enum { DumpId, PrintId,
ScaleOpId, FitAllId, FitRectId, ZoomId,
MoveOpId, PanId, GlobalPanId,
PModeXLinearId, PModeXLogarithmicId,
void onCurves();
void onDumpView();
+ void onPrintView();
protected:
virtual QImage dumpView();
<source>ICON_PLOT2D_DUMP</source>
<translation>plot2d_camera_dump.png</translation>
</message>
+ <message>
+ <source>ICON_PLOT2D_PRINT</source>
+ <translation>plot2d_print.png</translation>
+ </message>
<message>
<source>ICON_PLOT2D_ZOOM</source>
<translation>plot2d_zoom.png</translation>
<source>MNU_DUMP_VIEW</source>
<translation>Dump view...</translation>
</message>
+ <message>
+ <source>MNU_PRINT_VIEW</source>
+ <translation>Print view...</translation>
+ </message>
<message>
<source>PLOT2D_SCALE_MODE_HOR</source>
<translation>Horizontal axis:</translation>
<source>DSC_DUMP_VIEW</source>
<translation>Saves the active view in the image file</translation>
</message>
+ <message>
+ <source>DSC_PRINT_VIEW</source>
+ <translation>Print the active view</translation>
+ </message>
<message>
<source>WARNING</source>
<translation>Warning</translation>