diff --git a/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h b/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h index 5f4fee7b156..85cd4efd9dd 100644 --- a/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h +++ b/GraphicsView/include/CGAL/Qt/DemosMainWindow_impl.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -42,6 +43,7 @@ #include #include #include +#include #include // needed to get CGAL_VERSION_STR #include @@ -156,6 +158,37 @@ DemosMainWindow::setupOptionsMenu(QMenu* menuOptions) actionUse_Antialiasing->setChecked(true); } +CGAL_INLINE_FUNCTION +void +DemosMainWindow::setupExportSVG(QAction* action, QGraphicsView* view) +{ + this->view = view; + connect(action, SIGNAL(triggered(bool)), + this, SLOT(exportSVG())); +} + +CGAL_INLINE_FUNCTION +void DemosMainWindow::exportSVG() +{ + QString fileName = QFileDialog::getSaveFileName(this, + tr("Export to SVG"), + ".", + tr("SVG (*.svg)\n")); + + QSvgGenerator svg; + svg.setFileName(fileName); + + svg.setSize(this->view->size()); + svg.setViewBox(this->view->sceneRect()); + svg.setTitle(tr("%1 drawing").arg(qApp->applicationName())); + svg.setDescription(tr("Generated using %1").arg(qApp->applicationName())); + + QPainter painter; + painter.begin(&svg); + this->view->render(&painter); + painter.end(); +} + CGAL_INLINE_FUNCTION void DemosMainWindow::setUseAntialiasing(bool checked)