#ifndef GL_LSYSTEM_H
#define GL_LSYSTEM_H

#include "Lstring.h"
#include "Lturtle.h"
#include "GLGraphics.h"

enum sizing_type {CENTRE_AND_SCALE, CENTRE, DO_NOTHING};
enum mutations { MUT_NONE,
       MUT_GENERAL_PARAMETER,
       MUT_GENERAL_ALGORITHM,
       MUT_RAT,
       MUT_PARAM,
       MUT_ADD_RULE,
       MUT_DEL_RULE,
       MUT_ADD_TO,
       MUT_DEL_FROM,
};

struct LightClass
{
  GLfloat position[4];
  GLfloat colour[4];

  void set_position(GLfloat a, GLfloat b, GLfloat c, GLfloat d);
  void set_colour(GLfloat a, GLfloat b, GLfloat c, GLfloat d);
};

class GL_Lsystem
{
 public:
  /* c'tor & d'tor */
  GL_Lsystem(UIClass *UserInterface,
	     vector <vect3<GLfloat> > *ColourArray,
	     vect3<GLfloat>           *BackgroundColour,
	     vector <LightClass>      *Lights,
	     MutationParameters       *mut_param);
  ~GL_Lsystem();
  
  /* operators */
  void operator>>(string& out);
  void operator<<(string p);

  void mutate(mutations mut);
  
  /* other methods */
  const string get_FinalString();
  void ProcessLstring(vect3<float> &centre, double &scale);
  bool ReparseString(int i);
  bool ReparseString();
  void Output(Lgraphics *OutputClassType);
  void set_Lstring_to(GL_Lsystem *l);
  void mut_Lstring_from(GL_Lsystem *l, mutations mut);
  void GL_draw(GLfloat &ZoomFactor, GLfloat *Centre, GLfloat *RotMatrix, GLfloat AspectRatio, sizing_type how_to_size);

 private:
  void InitGL(void);
  void InitLights(void);

  Lstring            *the_Lstring;
  Lturtle            *the_Lturtle;
  GLGraphics         *the_GLGraphics;

  vect3<GLfloat>     *the_BackgroundColour;
  vector<LightClass> *the_Lights;

  double       centre_point[3];
  double       scale_factor;
  bool         do_init, draw_buffer;
};

#endif
