13 if ( filename.contains(
".svg" ) )
17 QString fnamepng = QString( filename ).section(
".", 0, -2 ) +
".png";
21 else if ( filename.endsWith(
".png" ) )
39 if ( filename.contains(
".svg" ) )
41 QSvgGenerator generator;
42 QString fnsvg = QString( filename ).section(
".", 0, -2 ) +
".svg";
45 double px = (double)qApp->desktop()->width();
46 double in = (double)qApp->desktop()->widthMM() / 25.4;
47 int res = qRound( px / in );
48 int pw = plot->width() + res;
49 int ph = plot->height() + res;
52 generator.setResolution( res );
53 generator.setFileName ( fnsvg );
54 generator.setSize ( plot->size() );
55 generator.setViewBox ( QRect( QPoint( 0, 0 ), QPoint( pw, ph ) ) );
57 plot->print( generator );
78 if ( filename.endsWith(
".png" ) )
80 int pw = plot->width();
81 int ph = plot->height();
83 QPixmap pixmap = QPixmap::grabWidget( (QWidget*)plot, 0, 0, pw, ph );
84 if ( ! pixmap.save( filename ) )