#ifndef _GRAPHICS2D_H
#define _GRAPHICS2D_H

#include "GraphicsBase.h"
#include "Projection2DData.h"
#include <qlabel.h>
#include <qpixmap.h>

class QPainter;


class Graphics2D: public QLabel, public GraphicsBase{

   public:

      
      Graphics2D(QWidget *parent = 0, const char *name = 0);
      virtual ~Graphics2D();
                 
      virtual void paintLattice();
      virtual void paintLegend( float minConcentration, float maxConcentration,std::string location,std::string type);
      virtual unsigned int legendDimension(std::string location, unsigned int &rectWidth,unsigned int & rectHeight,std::string type);
      virtual void paintConcentrationLattice();
      virtual void paintCellVectorFieldLattice();
//       virtual void fillFakeConcentration();
      virtual void doContourLines();
      virtual void produceImage(QImage & image);

      QPixmap & getPixmap();
      Projection2DData projData;
            
   private:



      ///QT graphics  methods
      void paintBordersXY(int l,int m, int n,int scaleM, int scaleN,QPainter *painter);
      void paintPixelXY(int l,int m, int n,int scaleM, int scaleN,QPainter *painter);
      
      void paintBordersXZ(int l,int m, int n,int scaleM, int scaleN,QPainter *painter);
      void paintPixelXZ(int l,int m, int n,int scaleM, int scaleN,QPainter *painter);
      
      void paintBordersYZ(int l,int m, int n,int scaleM, int scaleN,QPainter *painter);
      void paintPixelYZ(int l,int m, int n,int scaleM, int scaleN,QPainter *painter);

      void drawArrow(int x, int y ,float vX, float vY , int scaleM, int scaleN ,int arrowLength, QPainter *painter);
      
      ///Cell Border Detector

      bool rightBorderXY( int _L, int _M, int _N);
      bool leftBorderXY(  int _L, int _M, int _N);
      bool upperBorderXY(  int _L, int _M,  int _N);
      bool bottomBorderXY(  int _L, int _M, int _N);

      bool rightBorderXZ( int _L, int _M, int _N);
      bool leftBorderXZ(  int _L, int _M, int _N);
      bool upperBorderXZ(  int _L, int _M,  int _N);
      bool bottomBorderXZ(  int _L, int _M, int _N);

      bool rightBorderYZ(int _L, int _M, int _N);
      bool leftBorderYZ(int _L, int _M, int _N);
      bool upperBorderYZ(int _L, int _M,  int _N);
      bool bottomBorderYZ(int _L, int _M, int _N);
      
      QPixmap pixmap2D;
      QPainter *painterPtr;
      
       
};

inline QPixmap & Graphics2D::getPixmap(){
   return pixmap2D;
}

#endif
