diff options
Diffstat (limited to 'src/mainwin.cc')
-rw-r--r-- | src/mainwin.cc | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc index 238bd10..9944f67 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -218,8 +218,12 @@ MainWindow::MainWindow(const QString &filename) connect(this->fileActionReload, SIGNAL(triggered()), this, SLOT(actionReload())); connect(this->fileActionQuit, SIGNAL(triggered()), this, SLOT(quit())); #ifndef __APPLE__ - this->fileActionSave->setShortcut(QKeySequence(Qt::Key_F2)); - this->fileActionReload->setShortcut(QKeySequence(Qt::Key_F3)); + QList<QKeySequence> shortcuts = this->fileActionSave->shortcuts(); + shortcuts.push_back(QKeySequence(Qt::Key_F2)); + this->fileActionSave->setShortcuts(shortcuts); + shortcuts = this->fileActionReload->shortcuts(); + shortcuts.push_back(QKeySequence(Qt::Key_F3)); + this->fileActionReload->setShortcuts(shortcuts); #endif // Open Recent for (int i = 0;i<maxRecentFiles; i++) { @@ -283,6 +287,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())); @@ -871,7 +876,6 @@ void MainWindow::compileCSG(bool procevents) this->thrownTogetherRenderer = new ThrownTogetherRenderer(this->root_chain, this->highlights_chain, this->background_chain); - PRINT("CSG generation finished."); int s = t.elapsed() / 1000; PRINTF("Total rendering time: %d hours, %d minutes, %d seconds", s / (60*60), (s / 60) % 60, s % 60); @@ -1474,6 +1478,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(); |