summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/builtin.h2
-rw-r--r--src/context.cc20
-rw-r--r--src/mainwin.cc17
-rw-r--r--src/openscad.cc16
4 files changed, 24 insertions, 31 deletions
diff --git a/src/builtin.h b/src/builtin.h
index ae526f2..643966b 100644
--- a/src/builtin.h
+++ b/src/builtin.h
@@ -26,4 +26,6 @@ extern void register_builtin_dxf_linear_extrude();
extern void register_builtin_dxf_rotate_extrude();
extern void initialize_builtin_dxf_dim();
+extern void register_builtin(class Context &ctx);
+
#endif
diff --git a/src/context.cc b/src/context.cc
index b4983f6..47b8a78 100644
--- a/src/context.cc
+++ b/src/context.cc
@@ -193,3 +193,23 @@ std::string Context::getAbsolutePath(const std::string &filename) const
return filename;
}
}
+
+void register_builtin(Context &ctx)
+{
+ ctx.functions_p = &builtin_functions;
+ ctx.modules_p = &builtin_modules;
+ ctx.set_variable("$fn", Value(0.0));
+ ctx.set_variable("$fs", Value(1.0));
+ ctx.set_variable("$fa", Value(12.0));
+ ctx.set_variable("$t", Value(0.0));
+
+ Value zero3;
+ zero3.type = Value::VECTOR;
+ zero3.append(new Value(0.0));
+ zero3.append(new Value(0.0));
+ zero3.append(new Value(0.0));
+ ctx.set_variable("$vpt", zero3);
+ ctx.set_variable("$vpr", zero3);
+
+ ctx.set_constant("PI",Value(M_PI));
+}
diff --git a/src/mainwin.cc b/src/mainwin.cc
index 9944f67..a6f5be6 100644
--- a/src/mainwin.cc
+++ b/src/mainwin.cc
@@ -143,22 +143,7 @@ MainWindow::MainWindow(const QString &filename)
{
setupUi(this);
- root_ctx.functions_p = &builtin_functions;
- root_ctx.modules_p = &builtin_modules;
- root_ctx.set_variable("$fn", Value(0.0));
- root_ctx.set_variable("$fs", Value(1.0));
- root_ctx.set_variable("$fa", Value(12.0));
- root_ctx.set_variable("$t", Value(0.0));
-
- root_ctx.set_constant("PI",Value(M_PI));
-
- Value zero3;
- zero3.type = Value::VECTOR;
- zero3.append(new Value(0.0));
- zero3.append(new Value(0.0));
- zero3.append(new Value(0.0));
- root_ctx.set_variable("$vpt", zero3);
- root_ctx.set_variable("$vpr", zero3);
+ register_builtin(root_ctx);
root_module = NULL;
absolute_root_node = NULL;
diff --git a/src/openscad.cc b/src/openscad.cc
index 9b45d21..84d6263 100644
--- a/src/openscad.cc
+++ b/src/openscad.cc
@@ -260,21 +260,7 @@ int main(int argc, char **argv)
#ifdef ENABLE_CGAL
Context root_ctx;
- root_ctx.functions_p = &builtin_functions;
- root_ctx.modules_p = &builtin_modules;
- root_ctx.set_variable("$fn", Value(0.0));
- root_ctx.set_variable("$fs", Value(1.0));
- root_ctx.set_variable("$fa", Value(12.0));
- root_ctx.set_variable("$t", Value(0.0));
-
- Value zero3;
- zero3.type = Value::VECTOR;
- zero3.append(new Value(0.0));
- zero3.append(new Value(0.0));
- zero3.append(new Value(0.0));
- root_ctx.set_variable("$vpt", zero3);
- root_ctx.set_variable("$vpr", zero3);
-
+ register_builtin(root_ctx);
AbstractModule *root_module;
ModuleInstantiation root_inst;
contact: Jan Huwald // Impressum