#ifndef LAYER_H
#define LAYER_H
#include <string>
#include <iostream>
//#include <fstream>
#include <qwidget.h>
#include <qpainter.h>
#include <qregion.h>
#include <qpointarray.h>
#include "Visualisation/CustomTracker/interface/TkSelectionSet.h"
#include <qobjectlist.h>
#include <qapplication.h>
//#include "Visualisation/CustomTracker/interface/TkSceneUpdate.h"
class TkSceneUpdate;
class DetUnit;

static int nmodane[]={24,24,40,56,40,56,80};
static int nmodaneb[]={18,30,42,28,38,44,56,42,48,54,60,66,74};

class TkLayerSelection : public QWidget
{
    Q_OBJECT

public:

    TkLayerSelection( TkSceneUpdate *par=0, QWidget *parent=0, const char *name=0 , int newlay = 1);
    QSizePolicy sizePolicy() const;
    TkSceneUpdate *lym; 

public slots:

signals:
    void myclicked(bool,int,int,int);

protected:
    void paintEvent( QPaintEvent * e);
    void mousePressEvent( QMouseEvent *);    

private:
    bool cliccato[2000];
     float thi,hbot,htop,hapo,hthi;
     float xa, ya, za, angle; 
     float  posx,posy,posz;
     float  vposx[2000], vposy[2000], vposz[2000];
     float  vhbot[2000], vhtop[2000], vhapo[2000];
     //QRect ri[2000];
     QRegion ri[2000];
     int vane[2000], vmod[2000];
 //   ifstream* infile; 
    int layer, anello, nmod, layer1, nlay, var, nmoduli;
    int modulo, bar_fow , numod;
    int px[4], py[4];
    double xp[4], yp[4]; 
    double xp1, yp1, r, phi;
    int x, y, nmodulo;
    double xmin, xmax, ymin, ymax;
    int xpixel(double x){
	return(int)((x-xmin)/(xmax-xmin)*width());
    }
    int ypixel(double y){
        double y1;
        y1 = (y-ymin)/(ymax-ymin);
	return height()-(int)(y1*height());
    }
    void addModule(const DetUnit* det);
};


#endif //LAYER_H




