diff options
author | Marius Kintel <marius@kintel.net> | 2011-10-19 15:35:14 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-10-19 15:35:14 (GMT) |
commit | 038767f6a601399d2e6792019f2ae2c326e04bec (patch) | |
tree | 638f73e342cb14f1834f6704a3e2736536a28ee4 /src/mainwin.cc | |
parent | 5dd4decc9106fe27f088358f8326bb15d367af35 (diff) |
Experimental support for exporting the compiled CSG tree as a text file
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(); |