diff options
author | Marius Kintel <marius@kintel.net> | 2010-04-12 00:16:36 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2010-10-31 00:42:35 (GMT) |
commit | e8e213b3c9ce0580045ea6e7e86b00ab41d4c58b (patch) | |
tree | cb32e67b6334aa1f1dc62aa4a0686a22782e7f77 /src/mainwin.cc | |
parent | 53a9953b7dc4ab4a366046c91529b32fb6652551 (diff) |
Another refactoring session:
o mk_cache_id() obsoleted by removing the node index from the dump
o node index output removed from each node and make optional in NodeDumper
o The visitors are no longer global, but associated with a tree
o Added Tree class to manage node trees and the (now implicit) dump cache
o Moved PolySet cache into PolySetRenderer
Diffstat (limited to 'src/mainwin.cc')
-rw-r--r-- | src/mainwin.cc | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc index 5eb5498..9f14aed 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -151,6 +151,7 @@ MainWindow::MainWindow(const QString &filename) root_raw_term = NULL; root_norm_term = NULL; root_chain = NULL; + this->dumper = new NodeDumper; #ifdef ENABLE_CGAL this->root_N = NULL; this->recreate_cgal_ogl_p = false; @@ -538,6 +539,13 @@ AbstractNode *MainWindow::find_root_tag(AbstractNode *n) return NULL; } +QString MainWindow::dumpCSGTree(AbstractNode *root) +{ + Traverser trav(*this->dumper, *root, Traverser::PRE_AND_POSTFIX); + trav.execute(); + return QString::fromStdString(this->dumper->getDump() + "\n"); +} + /*! Parse and evaluate the design -> this->root_node */ @@ -653,11 +661,11 @@ void MainWindow::compile(bool procevents) if (!(this->root_node = find_root_tag(absolute_root_node))) { this->root_node = absolute_root_node; } - // Dump the tree (to initialize caches). I guess we wouldn't really need to do - // this explicitly.. - root_node->dump(); + // Dump the tree (to initialize caches). + // FIXME: We shouldn't really need to do this explicitly.. + dumpCSGTree(this->root_node); - if (1) { + if (1) { PRINT("Compilation finished."); if (procevents) QApplication::processEvents(); @@ -1131,7 +1139,11 @@ void MainWindow::actionRenderCGAL() progress_report_prep(root_node, report_func, pd); try { - this->root_N = new CGAL_Nef_polyhedron(CGALRenderer::renderer()->renderCGALMesh(*root_node)); +// this->root_N = new CGAL_Nef_polyhedron(CGALRenderer::renderer()->renderCGALMesh(*root_node)); + + Tree *tree = this->tree; + CGALRenderDriver renderer(tree); + this->root_N = new CGAL_Nef_polyhedron(renderer->renderCGALMesh()); } catch (ProgressCancelException e) { PRINT("Rendering cancelled."); @@ -1234,7 +1246,7 @@ void MainWindow::actionDisplayCSGTree() e->setWindowTitle("CSG Tree Dump"); e->setReadOnly(true); if (root_node) { - e->setPlainText(root_node->dump()); + e->setPlainText(QString::fromStdString(this->dumper->getDump())); } else { e->setPlainText("No CSG to dump. Please try compiling first..."); } @@ -1359,10 +1371,10 @@ void MainWindow::actionExportDXF() void MainWindow::actionFlushCaches() { // FIXME: Polycache -> PolySetRenderer - PolySet::ps_cache.clear(); + PolySetRenderer::renderer()->clearCache(); #ifdef ENABLE_CGAL CGALRenderer::renderer()->getCache().clear(); - NodeDumper::dumper()->clearCache(); + this->dumper->clearCache(); #endif dxf_dim_cache.clear(); dxf_cross_cache.clear(); |