//demo/Qt_widget/Examples/layer.C #ifndef CGAL_USE_QT #include int main(int, char*){ std::cout << "Sorry, this demo needs QT..." << std::endl; return 0;} #else #include #include #include #include #include #include #include #include typedef CGAL::Cartesian Rep; typedef CGAL::Point_2 Point_2; typedef CGAL::Delaunay_triangulation_2 Delaunay; Delaunay dt; class My_Layer : public CGAL::Qt_widget_layer{ void draw(){ *widget << dt; } }; class My_Window : public QMainWindow { Q_OBJECT public: My_Window(int x, int y){ widget = new CGAL::Qt_widget(this, "CGAL Qt_widget"); setCentralWidget(widget); resize(x,y); widget->attach(&get_point); widget->attach(&v); connect(widget, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_new_object(CGAL::Object))); widget->set_window(0, 600, 0, 600); }; private: //members CGAL::Qt_widget_get_point get_point; My_Layer v; CGAL::Qt_widget *widget; private slots: void get_new_object(CGAL::Object obj) { Point_2 p; if (CGAL::assign(p, obj)) { dt.insert(p); } widget->redraw(); } }; //endclass // moc_source_file : layer.C #include "layer.moc" int main( int argc, char **argv ) { QApplication app( argc, argv ); My_Window *W = new My_Window(600,600); app.setMainWidget( W ); W->show(); return app.exec(); } #endif