diff options
author | don bright <hugh.m.bright@gmail.com> | 2013-01-26 18:31:37 (GMT) |
---|---|---|
committer | don bright <hugh.m.bright@gmail.com> | 2013-01-26 18:31:37 (GMT) |
commit | 6535b16a31cf23d65f9c4c44a2e97dfdcdd69419 (patch) | |
tree | ecca4e1f641cdd5d75716b3ef41ba5ce282b6209 | |
parent | 6bac08c33a6c5111efe1f322ae8f6628403b3467 (diff) |
enable root-modifier (! character) on gui-cmdline output. reduce duplicate code.
-rw-r--r-- | src/mainwin.cc | 4 | ||||
-rw-r--r-- | src/node.cc | 11 | ||||
-rw-r--r-- | src/node.h | 1 | ||||
-rw-r--r-- | src/openscad.cc | 7 | ||||
-rw-r--r-- | tests/cgalcachetest.cc | 4 | ||||
-rw-r--r-- | tests/cgalpngtest.cc | 4 | ||||
-rw-r--r-- | tests/cgalstlsanitytest.cc | 4 | ||||
-rw-r--r-- | tests/cgaltest.cc | 4 | ||||
-rw-r--r-- | tests/csgtestcore.cc | 4 |
9 files changed, 31 insertions, 12 deletions
diff --git a/src/mainwin.cc b/src/mainwin.cc index 251c6e1..d596186 100644 --- a/src/mainwin.cc +++ b/src/mainwin.cc @@ -576,14 +576,14 @@ void MainWindow::refreshDocument() setCurrentOutput(); } -AbstractNode *MainWindow::find_root_tag(AbstractNode *n) +/*AbstractNode *MainWindow::find_root_tag(AbstractNode *n) { BOOST_FOREACH (AbstractNode *v, n->children) { if (v->modinst->isRoot()) return v; if (AbstractNode *vroot = find_root_tag(v)) return vroot; } return NULL; -} +}*/ /*! Parse and evaluate the design => this->root_node diff --git a/src/node.cc b/src/node.cc index e61174f..4baf29a 100644 --- a/src/node.cc +++ b/src/node.cc @@ -32,6 +32,7 @@ #include <iostream> #include <algorithm> +#include <boost/foreach.hpp> size_t AbstractNode::idx_counter; @@ -101,3 +102,13 @@ std::ostream &operator<<(std::ostream &stream, const AbstractNode &node) stream << node.toString(); return stream; } + +AbstractNode *find_root_tag(AbstractNode *n) +{ + BOOST_FOREACH(AbstractNode *v, n->children) { + if (v->modinst->tag_root) return v; + if (AbstractNode *vroot = find_root_tag(v)) return vroot; + } + return NULL; +} + @@ -84,5 +84,6 @@ public: }; std::ostream &operator<<(std::ostream &stream, const AbstractNode &node); +AbstractNode *find_root_tag(AbstractNode *n); #endif diff --git a/src/openscad.cc b/src/openscad.cc index 2f1c4d8..f796136 100644 --- a/src/openscad.cc +++ b/src/openscad.cc @@ -265,6 +265,7 @@ int main(int argc, char **argv) Module *root_module; ModuleInstantiation root_inst; AbstractNode *root_node; + AbstractNode *absolute_root_node; handle_dep(filename); @@ -286,7 +287,13 @@ int main(int argc, char **argv) fs::current_path(fparent); AbstractNode::resetIndexCounter(); + absolute_root_node = root_module->evaluate(&root_ctx, &root_inst); root_node = root_module->evaluate(&root_ctx, &root_inst); + + // Do we have an explicit root node (! modifier)? + if (!(root_node = find_root_tag(absolute_root_node))) + root_node = absolute_root_node; + tree.setRoot(root_node); if (csg_output_file) { diff --git a/tests/cgalcachetest.cc b/tests/cgalcachetest.cc index 46e0e9a..7f24fc5 100644 --- a/tests/cgalcachetest.cc +++ b/tests/cgalcachetest.cc @@ -70,14 +70,14 @@ void cgalTree(Tree &tree) evaluate.execute(); } -AbstractNode *find_root_tag(AbstractNode *n) +/*AbstractNode *find_root_tag(AbstractNode *n) { foreach(AbstractNode *v, n->children) { if (v->modinst->tag_root) return v; if (AbstractNode *vroot = find_root_tag(v)) return vroot; } return NULL; -} +}*/ po::variables_map parse_options(int argc, char *argv[]) { diff --git a/tests/cgalpngtest.cc b/tests/cgalpngtest.cc index 56861c6..dd5084c 100644 --- a/tests/cgalpngtest.cc +++ b/tests/cgalpngtest.cc @@ -70,14 +70,14 @@ void cgalTree(Tree &tree) evaluate.execute(); } -AbstractNode *find_root_tag(AbstractNode *n) +/*AbstractNode *find_root_tag(AbstractNode *n) { foreach(AbstractNode *v, n->children) { if (v->modinst->tag_root) return v; if (AbstractNode *vroot = find_root_tag(v)) return vroot; } return NULL; -} +}*/ struct CsgInfo { diff --git a/tests/cgalstlsanitytest.cc b/tests/cgalstlsanitytest.cc index 52cfb41..ca44dc7 100644 --- a/tests/cgalstlsanitytest.cc +++ b/tests/cgalstlsanitytest.cc @@ -69,14 +69,14 @@ void cgalTree(Tree &tree) evaluate.execute(); } -AbstractNode *find_root_tag(AbstractNode *n) +/*AbstractNode *find_root_tag(AbstractNode *n) { foreach(AbstractNode *v, n->children) { if (v->modinst->tag_root) return v; if (AbstractNode *vroot = find_root_tag(v)) return vroot; } return NULL; -} +}*/ int main(int argc, char **argv) { diff --git a/tests/cgaltest.cc b/tests/cgaltest.cc index b546286..5131f17 100644 --- a/tests/cgaltest.cc +++ b/tests/cgaltest.cc @@ -65,14 +65,14 @@ void cgalTree(Tree &tree) evaluate.execute(); } -AbstractNode *find_root_tag(AbstractNode *n) +/*AbstractNode *find_root_tag(AbstractNode *n) { foreach(AbstractNode *v, n->children) { if (v->modinst->tag_root) return v; if (AbstractNode *vroot = find_root_tag(v)) return vroot; } return NULL; -} +}*/ int main(int argc, char **argv) { diff --git a/tests/csgtestcore.cc b/tests/csgtestcore.cc index acc7c31..7a031f3 100644 --- a/tests/csgtestcore.cc +++ b/tests/csgtestcore.cc @@ -65,14 +65,14 @@ CsgInfo::CsgInfo() { glview = NULL; } -AbstractNode *find_root_tag(AbstractNode *n) +/*AbstractNode *find_root_tag(AbstractNode *n) { foreach(AbstractNode *v, n->children) { if (v->modinst->tag_root) return v; if (AbstractNode *vroot = find_root_tag(v)) return vroot; } return NULL; -} +}*/ string info_dump(OffscreenView *glview) { |