mirror of https://github.com/CGAL/cgal
Added alpha_shapes_2 demo
This commit is contained in:
parent
836b6bd8c9
commit
faa8cfe6f5
|
|
@ -1410,6 +1410,7 @@ Packages/Polyhedron/examples/Polyhedron/corner.off -text
|
|||
Packages/Polyhedron/examples/Polyhedron/corner_with_hole.off -text
|
||||
Packages/Polyhedron/examples/Polyhedron/corner_with_sharp_edge.off -text
|
||||
Packages/Polyhedron/examples/Polyhedron/cross.off -text
|
||||
Packages/Qt_widget/demo/Qt_widget/Alpha_shapes_2/demo.dsp -text
|
||||
Packages/Qt_widget/demo/Qt_widget/Convex_Hull_2/demo.dsp -text
|
||||
Packages/Qt_widget/demo/Qt_widget/Partition_2/demo.dsp -text
|
||||
Packages/Qt_widget/demo/Qt_widget/Triangulation_2/demo.dsp -text
|
||||
|
|
|
|||
|
|
@ -0,0 +1,115 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1997-2000 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// file : src/Qt_Window_toolbar.C
|
||||
// package : QT_window
|
||||
// author(s) : Radu Ursu
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// coordinator : Laurent Rineau <rineau@clipper.ens.fr>
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#ifdef CGAL_USE_QT
|
||||
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include "Qt_widget_toolbar.h"
|
||||
|
||||
// icons
|
||||
#include <CGAL/IO/pixmaps/point.xpm>
|
||||
#include <CGAL/IO/pixmaps/movepoint.xpm>
|
||||
#include <CGAL/IO/pixmaps/arrow.xpm>
|
||||
#include <CGAL/IO/pixmaps/line.xpm>
|
||||
|
||||
|
||||
namespace CGAL {
|
||||
Tools_toolbar::Tools_toolbar(Qt_widget *w, QMainWindow *mw, Delaunay *t) : dt(t)
|
||||
{
|
||||
//when it is created, the toolbar has 0 buttons
|
||||
nr_of_buttons = 0;
|
||||
//set the widget
|
||||
widget = w;
|
||||
is_active = FALSE;
|
||||
|
||||
#if QT_VERSION < 300
|
||||
// for Qt 2.3 and before
|
||||
maintoolbar = new QToolBar("tools", mw, QMainWindow::Top, TRUE, "Tools");
|
||||
#else
|
||||
// from Qt 3.0
|
||||
maintoolbar = new QToolBar(mw, "Tools");
|
||||
mw->addDockWindow (maintoolbar, "tools", DockTop, TRUE );
|
||||
#endif
|
||||
|
||||
|
||||
but[0] = new QToolButton(QPixmap( (const char**)arrow_xpm ),
|
||||
"Detach current tool",
|
||||
0,
|
||||
this,
|
||||
SLOT(notool()),
|
||||
maintoolbar,
|
||||
"Detach current tool");
|
||||
|
||||
but[1] = new QToolButton(QPixmap( (const char**)point_xpm ),
|
||||
"Point Tool",
|
||||
0,
|
||||
this,
|
||||
SLOT(pointtool()),
|
||||
maintoolbar,
|
||||
"Point Tool");
|
||||
|
||||
|
||||
|
||||
but[1]->setToggleButton(TRUE);
|
||||
|
||||
|
||||
nr_of_buttons = 2;
|
||||
|
||||
connect(w, SIGNAL(detached_tool()), this, SLOT(toggle_button()));
|
||||
};
|
||||
|
||||
|
||||
|
||||
//the definition of the slots
|
||||
void Tools_toolbar::toggle_button ()
|
||||
{
|
||||
if(is_active) {
|
||||
but[activebutton]->toggle();
|
||||
is_active = false;
|
||||
}
|
||||
}
|
||||
void Tools_toolbar::pointtool()
|
||||
{
|
||||
if (but[1]->isOn())
|
||||
{
|
||||
widget->attach(pointbut);
|
||||
activebutton = 1;
|
||||
is_active = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_active = false;
|
||||
widget->detach_current_tool();
|
||||
}
|
||||
}
|
||||
void Tools_toolbar::notool()
|
||||
{
|
||||
if(is_active) {
|
||||
widget->detach_current_tool();
|
||||
is_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}//end namespace
|
||||
|
||||
#include "Qt_widget_toolbar.moc"
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1997-2000 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// file : include/CGAL/IO/Qt_Window_toolbar.h
|
||||
// package : QT_window
|
||||
// author(s) : Ursu Radu
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// coordinator : Laurent Rineau <rineau@clipper.ens.fr>
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
|
||||
#ifndef CGAL_QT_WINDOW_TOOLBAR_H
|
||||
#define CGAL_QT_WINDOW_TOOLBAR_H
|
||||
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Alpha_shape_vertex_base_2.h>
|
||||
#include <CGAL/Alpha_shape_face_base_2.h>
|
||||
#include <CGAL/Alpha_shape_euclidean_traits_2.h>
|
||||
#include <CGAL/Triangulation_face_base_2.h>
|
||||
#include <CGAL/Alpha_shape_face_base_2.h>
|
||||
#include <CGAL/Alpha_shape_2.h>
|
||||
|
||||
|
||||
|
||||
// TODO: check if some of those includes shouldn't be in the .C file
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
//#include "Qt_widget_move_point.h"
|
||||
#include <CGAL/IO/Qt_widget_get_point.h>
|
||||
|
||||
#include <qobject.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qtoolbar.h>
|
||||
#include <qmainwindow.h>
|
||||
|
||||
typedef double Coord_type;
|
||||
typedef CGAL::Cartesian<Coord_type> Rp;
|
||||
typedef CGAL::Alpha_shape_euclidean_traits_2<Rp> Gt;
|
||||
typedef CGAL::Alpha_shape_vertex_base_2<Gt> Vb;
|
||||
typedef CGAL::Triangulation_face_base_2<Gt> Df;
|
||||
typedef CGAL::Alpha_shape_face_base_2<Gt, Df> Fb;
|
||||
typedef CGAL::Triangulation_default_data_structure_2<Gt,Vb,Fb> Tds;
|
||||
typedef CGAL::Delaunay_triangulation_2<Gt,Tds> Delaunay;
|
||||
|
||||
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
class Tools_toolbar : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Tools_toolbar(Qt_widget *w, QMainWindow *mw, Delaunay *t);
|
||||
~Tools_toolbar()
|
||||
{
|
||||
delete maintoolbar;
|
||||
};
|
||||
QToolBar* toolbar(){return maintoolbar;}
|
||||
|
||||
signals:
|
||||
void new_object(CGAL::Object);
|
||||
void was_repainted();
|
||||
|
||||
private slots:
|
||||
void get_new_object(CGAL::Object obj) { emit(new_object(obj)); }
|
||||
|
||||
void pointtool();
|
||||
void notool();
|
||||
|
||||
void toggle_button();
|
||||
|
||||
private:
|
||||
QToolBar *maintoolbar;
|
||||
QToolButton *but[10];
|
||||
Qt_widget *widget;
|
||||
int activebutton;
|
||||
bool is_active;
|
||||
void setActiveButton(int i);
|
||||
void addToolButton(QToolButton *b);
|
||||
int nr_of_buttons;
|
||||
|
||||
Delaunay *dt;
|
||||
CGAL::Qt_widget_get_point<Rp> pointbut;
|
||||
};//end class
|
||||
|
||||
};//end namespace
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,147 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1997-2000 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// file : src/Qt_Window_toolbar_views.C
|
||||
// package : QT_window
|
||||
// author(s) : Ursu Radu
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// coordinator : Laurent Rineau <rineau@clipper.ens.fr>
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
|
||||
#ifdef CGAL_USE_QT
|
||||
|
||||
#include "Qt_widget_toolbar_views.h"
|
||||
|
||||
// icons
|
||||
#include <CGAL/IO/pixmaps/points.xpm>
|
||||
#include <CGAL/IO/pixmaps/nearest_vertex.xpm>
|
||||
#include <CGAL/IO/pixmaps/voronoi.xpm>
|
||||
#include <CGAL/IO/pixmaps/triangulation.xpm>
|
||||
#include <CGAL/IO/pixmaps/mouse_coord.xpm>
|
||||
|
||||
|
||||
namespace CGAL {
|
||||
Views_toolbar::Views_toolbar(Qt_widget *w, QMainWindow *mw, Delaunay *t) :
|
||||
dt(t), nr_of_buttons(0)
|
||||
{
|
||||
showT = new Qt_view_show_triangulation< Delaunay >(*t);
|
||||
showV = new Qt_view_show_voronoi< Delaunay >(*t);
|
||||
showP = new Qt_view_show_points< Delaunay >(*t);
|
||||
showMC = new Qt_view_mouse_coordinates(*mw);
|
||||
|
||||
//set the widget
|
||||
widget = w;
|
||||
window = mw;
|
||||
window->statusBar();
|
||||
|
||||
widget->attach(showT);
|
||||
widget->attach(showV);
|
||||
widget->attach(showP);
|
||||
widget->attach(showMC);
|
||||
widget->deactivate(showV);
|
||||
|
||||
maintoolbar = new QToolBar("tools", mw, QMainWindow::Top, TRUE, "Tools");
|
||||
|
||||
|
||||
but[0] = new QToolButton(QPixmap( (const char**)triangulation_xpm ),
|
||||
"Show triangulation",
|
||||
0,
|
||||
this,
|
||||
SLOT(draw_triangulation()),
|
||||
maintoolbar,
|
||||
"Show triangulation");
|
||||
|
||||
but[1] = new QToolButton(QPixmap( (const char**)voronoi_xpm ),
|
||||
"Show Voronoi Diagram",
|
||||
0,
|
||||
this,
|
||||
SLOT(draw_voronoi()),
|
||||
maintoolbar,
|
||||
"Show Voronoi Diagram");
|
||||
|
||||
but[2] = new QToolButton(QPixmap( (const char**)points_xpm ),
|
||||
"Show Triangulation Points",
|
||||
0,
|
||||
this,
|
||||
SLOT(draw_points()),
|
||||
maintoolbar,
|
||||
"Show Triangulation Points");
|
||||
|
||||
but[3] = new QToolButton(QPixmap( (const char**)mouse_coord_xpm ),
|
||||
"Show Mouse Coordinates",
|
||||
0,
|
||||
this,
|
||||
SLOT(show_coordinates()),
|
||||
maintoolbar,
|
||||
"Show Mouse Coordinates");
|
||||
|
||||
nr_of_buttons = 4;
|
||||
|
||||
for(int i =0; i<nr_of_buttons; i++)
|
||||
{
|
||||
but[i]->setToggleButton(TRUE);
|
||||
but[i]->toggle();
|
||||
}
|
||||
but[1]->toggle();
|
||||
}
|
||||
void Views_toolbar::draw_triangulation()
|
||||
{
|
||||
if (but[0]->isOn())
|
||||
{
|
||||
widget->activate(showT);
|
||||
} else {
|
||||
widget->deactivate(showT);
|
||||
}
|
||||
widget->redraw();
|
||||
}
|
||||
|
||||
void Views_toolbar::draw_voronoi()
|
||||
{
|
||||
if (but[1]->isOn())
|
||||
{
|
||||
widget->activate(showV);
|
||||
} else {
|
||||
widget->deactivate(showV);
|
||||
}
|
||||
widget->redraw();
|
||||
}
|
||||
void Views_toolbar::draw_points()
|
||||
{
|
||||
if (but[2]->isOn())
|
||||
{
|
||||
widget->activate(showP);
|
||||
} else {
|
||||
widget->deactivate(showP);
|
||||
}
|
||||
widget->redraw();
|
||||
}
|
||||
|
||||
void Views_toolbar::show_coordinates()
|
||||
{
|
||||
if (but[3]->isOn())
|
||||
{
|
||||
widget->activate(showMC);
|
||||
window->statusBar();
|
||||
} else {
|
||||
widget->deactivate(showMC);
|
||||
window->statusBar()->clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}//end namespace
|
||||
|
||||
#include "Qt_widget_toolbar_views.moc"
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
// ============================================================================
|
||||
//
|
||||
// Copyright (c) 1997-2000 The CGAL Consortium
|
||||
//
|
||||
// This software and related documentation is part of an INTERNAL release
|
||||
// of the Computational Geometry Algorithms Library (CGAL). It is not
|
||||
// intended for general use.
|
||||
//
|
||||
// ----------------------------------------------------------------------------
|
||||
//
|
||||
// file : include/CGAL/IO/Qt_Window_toolbar_views.h
|
||||
// package : QT_window
|
||||
// author(s) : Radu Ursu
|
||||
// release :
|
||||
// release_date :
|
||||
//
|
||||
// coordinator : Laurent Rineau <rineau@clipper.ens.fr>
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
#ifndef CGAL_QT_WINDOW_TOOLBAR_VIEWS_H
|
||||
#define CGAL_QT_WINDOW_TOOLBAR_VIEWS_H
|
||||
|
||||
//CGAL
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Alpha_shape_vertex_base_2.h>
|
||||
#include <CGAL/Alpha_shape_face_base_2.h>
|
||||
#include <CGAL/Alpha_shape_euclidean_traits_2.h>
|
||||
#include <CGAL/Triangulation_face_base_2.h>
|
||||
#include <CGAL/Alpha_shape_face_base_2.h>
|
||||
#include <CGAL/Alpha_shape_2.h>
|
||||
|
||||
//Qt_widget
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
|
||||
//Qt_widget_view
|
||||
#include <CGAL/IO/Qt_view_show_triangulation.h>
|
||||
#include <CGAL/IO/Qt_view_show_voronoy.h>
|
||||
#include <CGAL/IO/Qt_view_show_points.h>
|
||||
#include <CGAL/IO/Qt_view_show_mouse_coordinates.h>
|
||||
|
||||
//Qt
|
||||
#include <qobject.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qtoolbar.h>
|
||||
#include <qstatusbar.h>
|
||||
|
||||
typedef double Coord_type;
|
||||
typedef CGAL::Cartesian<Coord_type> Rp;
|
||||
typedef CGAL::Alpha_shape_euclidean_traits_2<Rp> Gt;
|
||||
typedef CGAL::Alpha_shape_vertex_base_2<Gt> Vb;
|
||||
typedef CGAL::Triangulation_face_base_2<Gt> Df;
|
||||
typedef CGAL::Alpha_shape_face_base_2<Gt, Df> Fb;
|
||||
typedef CGAL::Triangulation_default_data_structure_2<Gt,Vb,Fb> Tds;
|
||||
typedef CGAL::Delaunay_triangulation_2<Gt,Tds> Delaunay;
|
||||
|
||||
namespace CGAL {
|
||||
|
||||
class Views_toolbar : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Views_toolbar(Qt_widget *w, QMainWindow *mw, Delaunay *t);
|
||||
~Views_toolbar()
|
||||
{
|
||||
delete maintoolbar;
|
||||
};
|
||||
QToolBar* toolbar(){return maintoolbar;};
|
||||
|
||||
signals:
|
||||
void new_object(CGAL::Object);
|
||||
|
||||
|
||||
private slots:
|
||||
void draw_voronoi();
|
||||
void draw_triangulation();
|
||||
void show_coordinates();
|
||||
void draw_points();
|
||||
|
||||
|
||||
private:
|
||||
QToolBar *maintoolbar;
|
||||
QToolButton *but[10];
|
||||
Qt_widget *widget;
|
||||
QMainWindow *window;
|
||||
Delaunay *dt;
|
||||
|
||||
int nr_of_buttons;
|
||||
|
||||
|
||||
CGAL::Qt_view_show_triangulation < Delaunay > *showT;
|
||||
CGAL::Qt_view_show_voronoi < Delaunay > *showV;
|
||||
CGAL::Qt_view_show_points < Delaunay > *showP;
|
||||
CGAL::Qt_view_mouse_coordinates *showMC;
|
||||
};//end class
|
||||
|
||||
};//end namespace
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,311 @@
|
|||
// if QT is not installed, a message will be issued in runtime.
|
||||
#ifndef CGAL_USE_QT
|
||||
#include <iostream>
|
||||
|
||||
|
||||
int main(int, char*)
|
||||
{
|
||||
|
||||
std::cout << "Sorry, this demo needs QT...";
|
||||
std::cout << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
|
||||
//STL
|
||||
#include <fstream>
|
||||
#include <stack>
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
//CGAL
|
||||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/squared_distance_2.h>
|
||||
#include <CGAL/Point_2.h>
|
||||
#include <CGAL/predicates_on_points_2.h>
|
||||
#include <CGAL/Triangulation_euclidean_traits_2.h>
|
||||
#include <CGAL/Triangulation_2.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
//Qt_widget
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include "Qt_widget_toolbar.h"
|
||||
#include "Qt_widget_toolbar_views.h"
|
||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
||||
|
||||
//Qt
|
||||
#include <qplatinumstyle.h>
|
||||
#include <qapplication.h>
|
||||
#include <qmainwindow.h>
|
||||
#include <qstatusbar.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <qpopupmenu.h>
|
||||
#include <qmenubar.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qtoolbar.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
|
||||
|
||||
typedef double Coord_type;
|
||||
typedef CGAL::Cartesian<Coord_type> Rep;
|
||||
typedef CGAL::Point_2<Rep> Point;
|
||||
typedef CGAL::Segment_2<Rep> Segment;
|
||||
typedef CGAL::Line_2<Rep> Line;
|
||||
typedef CGAL::Triangle_2<Rep> Triangle;
|
||||
|
||||
typedef CGAL::Triangulation_2<Rep> Triangulation;
|
||||
typedef std::list<Point> CGALPointlist;
|
||||
|
||||
|
||||
|
||||
typedef CGAL::Alpha_shape_2<Delaunay> Alpha_shape;
|
||||
typedef Alpha_shape::Face Face;
|
||||
typedef Alpha_shape::Vertex Vertex;
|
||||
typedef Alpha_shape::Edge Edge;
|
||||
typedef Alpha_shape::Face_handle Face_handle;
|
||||
typedef Alpha_shape::Vertex_handle Vertex_handle;
|
||||
typedef Alpha_shape::Face_circulator Face_circulator;
|
||||
typedef Alpha_shape::Vertex_circulator Vertex_circulator;
|
||||
typedef Alpha_shape::Locate_type Locate_type;
|
||||
typedef Alpha_shape::Face_iterator Face_iterator;
|
||||
typedef Alpha_shape::Vertex_iterator Vertex_iterator;
|
||||
typedef Alpha_shape::Edge_iterator Edge_iterator;
|
||||
typedef Alpha_shape::Edge_circulator Edge_circulator;
|
||||
typedef Alpha_shape::Coord_type Coord_type;
|
||||
typedef Alpha_shape::Alpha_iterator Alpha_iterator;
|
||||
|
||||
|
||||
|
||||
const QString my_title_string("Alpha_shapes_2 Demo with"
|
||||
" CGAL Qt_widget");
|
||||
|
||||
Delaunay tr1;
|
||||
CGALPointlist L;
|
||||
Alpha_shape A;
|
||||
int current_state;
|
||||
|
||||
|
||||
class show_alpha_shape : public Qt_widget_view
|
||||
{
|
||||
public:
|
||||
show_alpha_shape(){};
|
||||
private:
|
||||
void draw(){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class MyWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MyWindow(int w, int h): win(this) {
|
||||
setCentralWidget(&win);
|
||||
|
||||
//create a timer for checking if somthing changed
|
||||
QTimer *timer = new QTimer( this );
|
||||
connect( timer, SIGNAL(timeout()),
|
||||
this, SLOT(timerDone()) );
|
||||
timer->start( 200, FALSE );
|
||||
|
||||
|
||||
// file menu
|
||||
QPopupMenu * file = new QPopupMenu( this );
|
||||
menuBar()->insertItem( "&File", file );
|
||||
file->insertItem("&New", this, SLOT(new_instance()), CTRL+Key_N);
|
||||
file->insertItem("New &Window", this, SLOT(new_window()), CTRL+Key_W);
|
||||
file->insertSeparator();
|
||||
file->insertItem("&Load Triangulation", this, SLOT(load_triangulation()), CTRL+Key_L);
|
||||
file->insertItem("&Save Triangulation", this, SLOT(save_triangulation()), CTRL+Key_T);
|
||||
file->insertSeparator();
|
||||
file->insertItem( "&Close", this, SLOT(close()), CTRL+Key_X );
|
||||
file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q );
|
||||
|
||||
|
||||
// drawing menu
|
||||
QPopupMenu * draw = new QPopupMenu( this );
|
||||
menuBar()->insertItem( "&Draw", draw );
|
||||
draw->insertItem("&Generate_triangulation", this, SLOT(gen_tr()), CTRL+Key_G );
|
||||
|
||||
// help menu
|
||||
QPopupMenu * help = new QPopupMenu( this );
|
||||
menuBar()->insertItem( "&Help", help );
|
||||
help->insertItem("&About", this, SLOT(about()), CTRL+Key_A );
|
||||
help->insertItem("About &Qt", this, SLOT(aboutQt()) );
|
||||
|
||||
//the new tools toolbar
|
||||
setUsesBigPixmaps(TRUE);
|
||||
newtoolbar = new CGAL::Tools_toolbar(&win, this, &tr1);
|
||||
//the new scenes toolbar
|
||||
vtoolbar = new CGAL::Views_toolbar(&win, this, &tr1);
|
||||
//the standard toolbar
|
||||
stoolbar = new CGAL::Standard_toolbar (&win, this);
|
||||
this->addToolBar(stoolbar->toolbar(), Top, FALSE);
|
||||
this->addToolBar(newtoolbar->toolbar(), Top, FALSE);
|
||||
this->addToolBar(vtoolbar->toolbar(), Top, FALSE);
|
||||
|
||||
win << CGAL::LineWidth(2) << CGAL::BackgroundColor (CGAL::BLACK);
|
||||
|
||||
resize(w,h);
|
||||
win.show();
|
||||
|
||||
win.setMouseTracking(TRUE);
|
||||
|
||||
//connect the widget to the main function that receives the objects
|
||||
connect(&win, SIGNAL(new_cgal_object(CGAL::Object)),
|
||||
this, SLOT(get_new_object(CGAL::Object)));
|
||||
|
||||
//application flag stuff
|
||||
old_state = 0;
|
||||
};
|
||||
|
||||
~MyWindow()
|
||||
{
|
||||
};
|
||||
|
||||
private:
|
||||
void something_changed(){current_state++;};
|
||||
signals:
|
||||
void was_repainted();
|
||||
|
||||
public slots:
|
||||
void set_window(double xmin, double xmax, double ymin, double ymax)
|
||||
{
|
||||
win.set_window(xmin, xmax, ymin, ymax);
|
||||
}
|
||||
void new_instance()
|
||||
{
|
||||
win.detach_current_tool();
|
||||
win.lock();
|
||||
win.clear();
|
||||
tr1.clear();
|
||||
win.set_window(-1.1, 1.1, -1.1, 1.1); // set the Visible Area to the Interval
|
||||
win.unlock();
|
||||
something_changed();
|
||||
}
|
||||
|
||||
private slots:
|
||||
void get_new_object(CGAL::Object obj)
|
||||
{
|
||||
Point p;
|
||||
if(CGAL::assign(p,obj)) {
|
||||
tr1.insert(p);
|
||||
L.push_back(p);
|
||||
something_changed();
|
||||
}
|
||||
};
|
||||
|
||||
void about()
|
||||
{
|
||||
QMessageBox::about( this, my_title_string,
|
||||
"This is a demo for Triangulation,\n"
|
||||
"Copyright CGAL @2001");
|
||||
};
|
||||
|
||||
void aboutQt()
|
||||
{
|
||||
QMessageBox::aboutQt( this, my_title_string );
|
||||
}
|
||||
|
||||
void new_window(){
|
||||
MyWindow *ed = new MyWindow(500, 500);
|
||||
ed->setCaption("View");
|
||||
ed->show();
|
||||
ed->set_window(-1.1, 1.1, -1.1, 1.1);
|
||||
something_changed();
|
||||
}
|
||||
|
||||
void timerDone()
|
||||
{
|
||||
if(old_state!=current_state){
|
||||
win.redraw();
|
||||
old_state = current_state;
|
||||
}
|
||||
}
|
||||
|
||||
void gen_tr()
|
||||
{
|
||||
tr1.clear();
|
||||
win.lock();
|
||||
win.set_window(-1.1, 1.1, -1.1, 1.1); // set the Visible Area to the Interval
|
||||
|
||||
// send resizeEvent only on show.
|
||||
win.unlock();
|
||||
CGAL::Random_points_in_disc_2<Point> g(0.5);
|
||||
for(int count=0; count<200; count++) {
|
||||
tr1.insert(*g++);
|
||||
}
|
||||
win.redraw();
|
||||
something_changed();
|
||||
}
|
||||
|
||||
void save_triangulation()
|
||||
{
|
||||
QString fileName =
|
||||
QFileDialog::getSaveFileName( "triangulation.cgal",
|
||||
"Cgal files (*.cgal)", this );
|
||||
if ( !fileName.isNull() ) { // got a file name
|
||||
std::ofstream out(fileName);
|
||||
CGAL::set_ascii_mode(out);
|
||||
out << tr1 << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void load_triangulation()
|
||||
{
|
||||
QString s( QFileDialog::getOpenFileName( QString::null,
|
||||
"CGAL files (*.cgal)", this ) );
|
||||
if ( s.isEmpty() )
|
||||
return;
|
||||
tr1.clear();
|
||||
std::ifstream in(s);
|
||||
CGAL::set_ascii_mode(in);
|
||||
in >> tr1;
|
||||
something_changed();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
CGAL::Qt_widget win;
|
||||
CGAL::Tools_toolbar *newtoolbar;
|
||||
CGAL::Views_toolbar *vtoolbar;
|
||||
CGAL::Standard_toolbar *stoolbar;
|
||||
//if a CGAL::Point is received should be true
|
||||
int old_state;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#include "alpha_shapes_2.moc"
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
app.setStyle( new QPlatinumStyle );
|
||||
QPalette p( QColor( 250, 215, 100 ) );
|
||||
app.setPalette( p, TRUE );
|
||||
MyWindow win(800,800); // physical window size
|
||||
app.setMainWidget(&win);
|
||||
win.setCaption(my_title_string);
|
||||
win.setMouseTracking(TRUE);
|
||||
win.show();
|
||||
// because Qt send resizeEvent only on show.
|
||||
win.set_window(-1, 1, -1, 1);
|
||||
current_state = -1;
|
||||
return app.exec();
|
||||
}
|
||||
|
||||
#endif // CGAL_USE_QT
|
||||
|
|
@ -0,0 +1,267 @@
|
|||
# Microsoft Developer Studio Project File - Name="demo" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=demo - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "demo.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "demo.mak" CFG="demo - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "demo - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "demo - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40c /d "NDEBUG"
|
||||
# ADD RSC /l 0x40c /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /W3 /Gm /GR /GX /ZI /Od /I "$(QTDIR)\include" /I "$(CGALROOT)\stlport" /I "$(CGALROOT)\include\cgal\config\msvc" /I "$(CGALROOT)\auxiliary\wingmp\gmp-2.0.2" /I "$(CGALROOT)\include" /I "..\..\..\\Include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "CGAL_USE_QT" /D "QT_DLL" /D "UNICODE" /D "QT_THREAD_SUPPORT" /FR /YX /FD /GZ /c /Tp
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40c /d "_DEBUG"
|
||||
# ADD RSC /l 0x40c /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib imm32.lib winmm.lib wsock32.lib imm32.lib wsock32.lib winmm.lib $(QTDIR)\lib\qt-mt230nc.lib $(QTDIR)\lib\qtmain.lib $(CGALROOT)\lib\msvc\CGAL.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /nodefaultlib:"msvcrt.lib" /nodefaultlib:"libcmtd" /pdbtype:sept
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "demo - Win32 Release"
|
||||
# Name "demo - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\CGALQt\Qt_widget.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Qt_widget_move_point.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\CGALQt\Qt_widget_standard_toolbar.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\CGALQt\Qt_widget_tool.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Qt_widget_toolbar.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Qt_widget_toolbar_views.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\src\CGALQt\Qt_widget_view.C
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\triangulationdemo.C
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\CGAL\IO\Qt_widget.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=..\..\..\include\CGAL\IO\Qt_widget.h
|
||||
|
||||
"../../../src/CGALQt/Qt_widget.moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(QTDIR)\bin\moc.exe -o "../../../src/CGALQt/Qt_widget.moc" "../../../Include/CGAL/IO/Qt_widget.h"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Qt_widget_move_point.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=.\Qt_widget_move_point.h
|
||||
|
||||
"Qt_widget_move_point.moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(QTDIR)\bin\moc.exe -o "Qt_widget_move_point.moc" "Qt_widget_move_point.h"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\CGAL\IO\Qt_widget_standard_toolbar.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=..\..\..\include\CGAL\IO\Qt_widget_standard_toolbar.h
|
||||
|
||||
"../../../src/CGALQt/Qt_widget_standard_toolbar.moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(QTDIR)\bin\moc.exe -o "../../../src/CGALQt/Qt_widget_standard_toolbar.moc" "../../../Include/CGAL/IO/Qt_widget_standard_toolbar.h"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\CGAL\IO\Qt_widget_tool.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=..\..\..\include\CGAL\IO\Qt_widget_tool.h
|
||||
|
||||
"../../../src/CGALQt/Qt_widget_tool.moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(QTDIR)\bin\moc.exe -o "../../../src/CGALQt/Qt_widget_tool.moc" "../../../Include/CGAL/IO/Qt_widget_tool.h"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Qt_widget_toolbar.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=.\Qt_widget_toolbar.h
|
||||
|
||||
"Qt_widget_toolbar.moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(QTDIR)\bin\moc.exe -o "Qt_widget_toolbar.moc" "Qt_widget_toolbar.h"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Qt_widget_toolbar_views.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=.\Qt_widget_toolbar_views.h
|
||||
|
||||
"Qt_widget_toolbar_views.moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(QTDIR)\bin\moc.exe -o "Qt_widget_toolbar_views.moc" "Qt_widget_toolbar_views.h"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\..\include\CGAL\IO\Qt_widget_view.h
|
||||
|
||||
!IF "$(CFG)" == "demo - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "demo - Win32 Debug"
|
||||
|
||||
# Begin Custom Build
|
||||
InputPath=..\..\..\include\CGAL\IO\Qt_widget_view.h
|
||||
|
||||
"../../../src/CGALQt/Qt_widget_view.moc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
|
||||
$(QTDIR)\bin\moc.exe -o "../../../src/CGALQt/Qt_widget_view.moc" "../../../Include/CGAL/IO/Qt_widget_view.h"
|
||||
|
||||
# End Custom Build
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "demo"=.\demo.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Loading…
Reference in New Issue