diff options
Diffstat (limited to 'src/mainwin.cc')
-rw-r--r-- | src/mainwin.cc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc index 238bd10..be82d26 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -283,6 +283,7 @@ MainWindow::MainWindow(const QString &filename) connect(this->designActionExportSTL, SIGNAL(triggered()), this, SLOT(actionExportSTL())); connect(this->designActionExportOFF, SIGNAL(triggered()), this, SLOT(actionExportOFF())); connect(this->designActionExportDXF, SIGNAL(triggered()), this, SLOT(actionExportDXF())); + connect(this->designActionExportCSG, SIGNAL(triggered()), this, SLOT(actionExportCSG())); connect(this->designActionExportImage, SIGNAL(triggered()), this, SLOT(actionExportImage())); connect(this->designActionFlushCaches, SIGNAL(triggered()), this, SLOT(actionFlushCaches())); @@ -1474,6 +1475,38 @@ void MainWindow::actionExportDXF() #endif /* ENABLE_CGAL */ } +void MainWindow::actionExportCSG() +{ + setCurrentOutput(); + + if (!this->root_node) { + PRINT("Nothing to export. Please try compiling first..."); + clearCurrentOutput(); + return; + } + + QString csg_filename = QFileDialog::getSaveFileName(this, "Export CSG File", + this->fileName.isEmpty() ? "Untitled.csg" : QFileInfo(this->fileName).baseName()+".csg", + "CSG Files (*.csg)"); + if (csg_filename.isEmpty()) { + PRINTF("No filename specified. CSG export aborted."); + clearCurrentOutput(); + return; + } + + std::ofstream fstream(csg_filename.toUtf8()); + if (!fstream.is_open()) { + PRINTA("Can't open file \"%s\" for export", csg_filename); + } + else { + fstream << this->tree.getString(*this->root_node) << "\n"; + fstream.close(); + PRINTF("CSG export finished."); + } + + clearCurrentOutput(); +} + void MainWindow::actionExportImage() { QImage img = this->glview->grabFrameBuffer(); |