diff options
author | Brad Pitcher <bradpitcher@gmail.com> | 2011-10-26 02:22:14 (GMT) |
---|---|---|
committer | Brad Pitcher <bradpitcher@gmail.com> | 2011-10-26 02:22:14 (GMT) |
commit | ea7e4988d44249946b620d5973b230cf1a0606ca (patch) | |
tree | 2e3a5c03b78479298c64510356c7b10b9598ea71 /src/mainwin.cc | |
parent | b64de29a302fa09f4e9409f57d344c602566e442 (diff) | |
parent | ff6d6cda13040e69ef15bb8989ca0f436a8020cc (diff) |
Merge branch 'master' of https://github.com/openscad/openscad into win32
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(); |