Initial revision
[lsystem3d.git] / lsystem3d / src / openglwindow.h
diff --git a/lsystem3d/src/openglwindow.h b/lsystem3d/src/openglwindow.h
new file mode 100644 (file)
index 0000000..53dbf61
--- /dev/null
@@ -0,0 +1,151 @@
+// Copyright (C) 2006 Erik Dahlberg
+// 
+// This file is part of LSystem3d.
+// 
+// LSystem3D is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+// 
+// LSystem3D is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with LSystem3D; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+
+
+#ifndef OPENGLWINDOW_H
+#define OPENGLWINDOW_H
+
+#include <string>
+#include <vector>
+
+#include <glui.h>
+
+#include "lindenmayersystem.h"
+#include "lsystemparameters.h"
+#include "model.h"
+
+using namespace std;
+
+
+
+/**
+ * OpenGL drawing context
+ */
+class OpenGLWindow
+{
+public:
+    /**
+     * Constructor
+     */
+    OpenGLWindow();
+
+    /**
+     * Destructor
+     */
+    ~OpenGLWindow();
+    
+    /**
+     * Start generation of l-system data
+     */
+    void generate();
+    
+    /**
+     * Move camera left
+     */
+    void left();
+    
+    /**
+     * Move camera right
+     */
+    void right();
+    
+    /**
+     * Move camera up
+     */
+    void up();
+    
+    /**
+     * Move camera down
+     */
+    void down();
+    
+    /**
+     * Move camera forth
+     */
+    void forth();
+    
+    /**
+     * Move camera back
+     */
+    void back();
+    
+    /**
+     * Zoom in
+     */
+    void zoomIn();
+            
+    /**
+     * Zoom out
+     */
+    void zoomOut();
+    
+    /**
+     * Rotate around y-axis
+     */
+    void rotateY();
+    
+    /**
+     * Draw l-system model to screen
+     */
+    void draw();
+    
+    /**
+     * Reset to default view
+     */
+    void defaultView();
+    
+    /**
+     * Check if live mode is activated
+     * @return true, if activated
+     */
+    bool liveActivated();
+    
+protected:
+    
+    // Model view
+    double _xModel,            // model coordinate (starting point)
+           _yModel,
+           _zModel;
+    double _scaleModel;        // model scale factor
+    double _yRotationModel;    // model rotation
+    
+    // L-system
+    LindenmayerSystem *_lsystem;                // l-system generator
+    Model *_model;                              // the generated l-system model
+    LSystemParameters _lsystemParameters;       // saves/loads l-system parameters from file
+    string lsystemParametersPath;               // where to find the l-system rules
+    
+    // Rendering window
+    int _window;                // the rendering window
+    bool _busyGenerating;       // currently generating?
+    
+    // GUI window
+    GLUI *_glui;                                // the GUI window
+    GLUI_EditText *_axiomEditText;              // axiom textbox
+    vector<GLUI_EditText *> _ruleEditTexts;     // rule textboxes
+    GLUI_Spinner *_angleSpinner;                // angle spinner
+    GLUI_Spinner *_iterationsSpinner;           // iteration spinner
+    GLUI_Checkbox *_liveCheckbox;               // live checkbox
+    int _liveUpdates;                           // status of live checkbox
+};
+
+
+
+#endif