37 |
37 |
#include <QSettings>
|
38 |
38 |
#include <QIcon>
|
39 |
39 |
#include <QPixmap>
|
40 |
|
#include <Q3Picture>
|
|
40 |
#include <QSvgGenerator>
|
41 |
41 |
#include <QToolBar>
|
42 |
42 |
#include <QImageWriter>
|
43 |
43 |
#include <QCheckBox>
|
... | ... | |
773 |
773 |
void QgsComposer::on_mActionExportAsSVG_activated(void)
|
774 |
774 |
{
|
775 |
775 |
|
776 |
|
// QT 4 QPicture does not support export to SVG, so we're still using Q3Picture.
|
777 |
|
// When QGIS moves to Qt 4.3, we can use QSvgGenerator instead.
|
778 |
|
|
779 |
776 |
QString myQSettingsLabel = "/UI/displaySVGWarning";
|
780 |
777 |
QSettings myQSettings;
|
781 |
778 |
|
... | ... | |
791 |
788 |
m->setCheckBoxQSettingsLabel(myQSettingsLabel);
|
792 |
789 |
m->setMessageAsHtml(tr("<p>The SVG export function in Qgis has several "
|
793 |
790 |
"problems due to bugs and deficiencies in the "
|
794 |
|
"Qt4 svg code. Of note, text does not "
|
795 |
|
"appear in the SVG file and there are problems "
|
796 |
|
"with the map bounding box clipping other items "
|
797 |
|
"such as the legend or scale bar.</p>"
|
|
791 |
"Qt4 svg code. In particular, there are problems "
|
|
792 |
"with layers not being clipped to the map"
|
|
793 |
"bounding box.</p>"
|
798 |
794 |
"If you require a vector-based output file from "
|
799 |
795 |
"Qgis it is suggested that you try printing "
|
800 |
796 |
"to PostScript if the SVG output is not "
|
... | ... | |
822 |
818 |
mView->setScene(0);//don't redraw the scene on the display while we render
|
823 |
819 |
mComposition->setPlotStyle ( QgsComposition::Print );
|
824 |
820 |
|
825 |
|
Q3Picture pic;
|
826 |
|
QPainter p(&pic);
|
827 |
|
QRectF renderArea(0,0, (mComposition->paperWidth() * mComposition->scale()), (mComposition->paperHeight() * mComposition->scale()) );
|
|
821 |
QSvgGenerator generator;
|
|
822 |
generator.setFileName(myOutputFileNameQString);
|
|
823 |
generator.setSize(QSize( (int)mComposition->paperWidth(), (int)mComposition->paperHeight() ));
|
|
824 |
generator.setResolution((int)(mComposition->resolution() / 25.4)); //because the rendering is done in mm, convert the dpi
|
828 |
825 |
|
|
826 |
QPainter p(&generator);
|
|
827 |
QRectF renderArea(0,0, mComposition->paperWidth(), mComposition->paperHeight());
|
829 |
828 |
mComposition->canvas()->render(&p, renderArea);
|
830 |
829 |
p.end();
|
831 |
830 |
|
832 |
831 |
mComposition->setPlotStyle ( QgsComposition::Preview );
|
833 |
832 |
mView->setScene(mComposition->canvas()); //now that we're done, set the view to show the scene again
|
834 |
833 |
|
835 |
|
QRect br = pic.boundingRect();
|
836 |
|
|
837 |
|
pic.save ( myOutputFileNameQString, "svg" );
|
838 |
|
|
839 |
834 |
}
|
840 |
835 |
|
841 |
836 |
|