/* 1d BTW sandpile animation (version 2.02 - Windows)
 * 
 * Copyright (C) 2005 N.R. Moloney 
 *
 * Distributed under the Qt Non-Commercial license version 1.0
 */

#ifndef BTW_H
#define BTW_H

#include <qlcdnumber.h>
#include <qpushbutton.h>
#include <qwidget.h>

const int L = 50;
const int l = 40;
const int H = L+2;
const int zc = 1;
const unsigned int offsetx = 194;
const unsigned int offsety = 50;
const unsigned int pixel = 12;
const int wall = 12;

const int buttonWidth = 160;
const int buttonHeight = 55;
const int comboBoxHeight = 70;
const int LCDWidth = 170;
const int LCDHeight = 100;
const int leftAlign = 10;
const int rightAlign = 820;

const int FAST = 0;
const int SLOW = 1;
const int PAUSE = 2;

const int SLOWTIME = 500;

class Sandpile : public QWidget
{
  Q_OBJECT

 public:

  Sandpile( QWidget * parent = 0, const char * name = 0 );
  
  int * h;
  int * toppling;
  int * newToppling;
  int numToppling;
  int speed;
  int hits, hTotal, s, sMax;

  QLCDNumber * hitsLCD;
  QLCDNumber * grainsLCD;
  QLCDNumber * sLCD;
  QLCDNumber * largestLCD;
  QPushButton * exitButton;
  QPushButton * startAgainButton;

  void initialiseLattice();
  void relax();

  public slots:
    
  void slotSpeed( int S ); 
  void slotStartAgain();

 protected:

  void paintEvent( QPaintEvent * );

 private slots:
   
  void drive();
  void update();

};

#endif 
