#ifndef CGAL_USE_QT
#include <iostream>
int main(int, char*){
  std::cout << "Sorry, this demo needs QT..." << std::endl; return 0;}
#else
#include <iostream>
#include <vector>
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_hierarchy_2.h>
#include <CGAL/IO/Qt_widget_Delaunay_triangulation_2.h>
#include <CGAL/IO/Qt_widget.h>
#include <CGAL/IO/Qt_widget_layer.h>
#include <CGAL/Random.h>
#include <qapplication.h>
#include <CGAL/Timer.h>


typedef float                               Number_type;
typedef CGAL::Cartesian<Number_type>        K;



typedef CGAL::Point_2<K> 		    Point;
typedef CGAL::Triangulation_vertex_base_2<K>             Vbb;
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vbb> Vb;
typedef CGAL::Triangulation_face_base_2<K>               Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb>      Tds;
typedef CGAL::Delaunay_triangulation_2<K,Tds>            Delaunay;
//typedef CGAL::Triangulation_hierarchy_2<Dt>              Delaunay;




class My_layer : public CGAL::Qt_widget_layer{
  void draw(){
    ;
  }
};

class My_window : public CGAL::Qt_widget {
public:
  My_window(int x, int y)
  {
    resize(x,y);
    attach(&layer);
  };
private:
  //this method is called when the user presses the mouse
  void mousePressEvent(QMouseEvent *e)
  {
    Qt_widget::mousePressEvent(e);

    /////////////////////////////////////////////////////////////
    //  C'EST ICI QUE CA SE PASSE QUAND ON CLIQUE !
    //
      exit(1);
    /////////////////////////////////////////////////////////////

    redraw();
  }
  My_layer layer;
};

int main( int argc, char **argv )
{
    QApplication app( argc, argv );
    My_window *W = new My_window(400,400);
    app.setMainWidget(W);
    W->show();
    W->set_window(-1, 1, -1, 1);

    int Nb_points;
    CGAL::Timer cost;cost.reset();cost.start();


    std::cout<<" Nombre de points ? "<<std::endl;
    std::cin>>Nb_points;
    CGAL::Random random(0);
    
    Delaunay dt1;
    for( int i = 0 ; i<Nb_points;++i) {
      Number_type x = random.get_double();
      Number_type y = x*x;
      dt1.insert( Point( x, y ) );
      std::cout<<"\b\b\b\b\b\b\b\b\b"<<i<<" ";
    }
    *W << CGAL::GREEN<<dt1;
    std::cout<<std::endl<<Nb_points<<" points en "
             <<cost.time()<<" secondes"<<std::endl;


    return app.exec();
}
#endif
