summaryrefslogtreecommitdiff
path: root/openscad.h
diff options
context:
space:
mode:
authorclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-06-23 19:56:46 (GMT)
committerclifford <clifford@b57f626f-c46c-0410-a088-ec61d464b74c>2009-06-23 19:56:46 (GMT)
commit4daae374011de97aafa999f2353e2c7d17511046 (patch)
treebc51daf75fb7d4be3d17ed4fd3206f08bf7d0aee /openscad.h
parent0fcdcb6bd6117e8e8ccaff15b0a083c2f76266a6 (diff)
Clifford Wolf:
Added GUI git-svn-id: http://svn.clifford.at/openscad/trunk@13 b57f626f-c46c-0410-a088-ec61d464b74c
Diffstat (limited to 'openscad.h')
-rw-r--r--openscad.h95
1 files changed, 93 insertions, 2 deletions
diff --git a/openscad.h b/openscad.h
index f0b1e33..9ca09d9 100644
--- a/openscad.h
+++ b/openscad.h
@@ -23,8 +23,15 @@
#include <QHash>
#include <QVector>
+#include <QMainWindow>
+#include <QSplitter>
+#include <QTextEdit>
+#include <QGLWidget>
+
#include <stdio.h>
+#include <errno.h>
#include <stdlib.h>
+#include <string.h>
#include <math.h>
#include <fstream>
@@ -222,7 +229,7 @@ public:
const QHash<QString, AbstractFunction*> *functions_p;
const QHash<QString, AbstractModule*> *modules_p;
- Context(const Context *parent) : parent(parent) { }
+ Context(const Context *parent = NULL) : parent(parent) { }
void args(const QVector<QString> &argnames, const QVector<Expression*> &argexpr, const QVector<QString> &call_argnames, const QVector<Value> &call_argvalues);
Value lookup_variable(QString name) const;
@@ -234,6 +241,8 @@ public:
// So we only include the declaration of AbstractNode where it is needed...
#ifdef INCLUDE_ABSTRACT_NODE_DETAILS
+#ifdef ENABLE_CGAL
+
#include <CGAL/Gmpq.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Polyhedron_3.h>
@@ -250,6 +259,8 @@ typedef CGAL_Nef_polyhedron::Vector_3 CGAL_Vector;
typedef CGAL_Nef_polyhedron::Plane_3 CGAL_Plane;
typedef CGAL_Nef_polyhedron::Point_3 CGAL_Point;
+#endif /* ENABLE_CGAL */
+
class AbstractNode
{
public:
@@ -260,7 +271,9 @@ public:
void progress_report() const;
virtual ~AbstractNode();
+#ifdef ENABLE_CGAL
virtual CGAL_Nef_polyhedron render_cgal_nef_polyhedron() const;
+#endif
virtual QString dump(QString indent) const;
};
@@ -271,9 +284,87 @@ extern void *progress_report_vp;
void progress_report_prep(AbstractNode *root, void (*f)(const class AbstractNode *node, void *vp, int mark), void *vp);
void progress_report_fin();
+#else
+
+// this is a bit hackish - but a pointer is a pointer..
+struct CGAL_Nef_polyhedron;
+
#endif /* HIDE_ABSTRACT_NODE_DETAILS */
-extern AbstractModule *parse(FILE *f, int debug);
+class GLView : public QGLWidget
+{
+ Q_OBJECT
+
+public:
+ struct Point {
+ double x, y, z;
+ Point() : x(0), y(0), z(0) { }
+ Point(double x, double y, double z) : x(x), y(y), z(z) { }
+ };
+ typedef QVector<Point> Polygon;
+ QVector<Polygon> polygons;
+
+ void (*renderfunc)(void*);
+ void *renderfunc_vp;
+
+ double viewer_distance;
+ double object_rot_y;
+ double object_rot_z;
+
+ GLView(QWidget *parent = NULL);
+
+protected:
+ bool mouse_drag_active;
+ int last_mouse_x;
+ int last_mouse_y;
+
+ void wheelEvent(QWheelEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+ void mouseReleaseEvent(QMouseEvent *event);
+
+ void initializeGL();
+ void resizeGL(int w, int h);
+ void paintGL();
+};
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+
+public:
+ QString filename;
+ QSplitter *s1, *s2;
+ QTextEdit *editor;
+ GLView *screen;
+ QTextEdit *console;
+
+ Context root_ctx;
+ AbstractModule *root_module;
+ AbstractNode *root_node;
+#ifdef ENABLE_CGAL
+ CGAL_Nef_polyhedron *root_N;
+#endif
+
+ MainWindow(const char *filename = 0);
+ ~MainWindow();
+
+private slots:
+ void actionNew();
+ void actionOpen();
+ void actionSave();
+ void actionSaveAs();
+ void actionCompile();
+#ifdef ENABLE_CGAL
+ void actionRenderCGAL();
+#endif
+ void actionDisplayAST();
+ void actionDisplayCSG();
+ void actionExportSTL();
+ void actionExportOFF();
+};
+
+extern AbstractModule *parse(const char *text, int debug);
#endif
contact: Jan Huwald // Impressum