Unified layers and tools and rewritten the doc.

This commit is contained in:
Radu Ursu 2002-03-28 14:12:48 +00:00
parent 2e7815ee26
commit f121c61d5f
7 changed files with 104 additions and 100 deletions

View File

@ -1,3 +1,5 @@
//demo/Qt_widget/basic/tutorial2.C
#include <CGAL/Cartesian.h>
#include <CGAL/Delaunay_triangulation_2.h>
@ -10,10 +12,10 @@ typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
class My_Window : public CGAL::Qt_widget {
class My_window : public CGAL::Qt_widget {
Q_OBJECT
public:
My_Window(int x, int y){
My_window(int x, int y){
resize(x,y);
connect(this, SIGNAL(custom_redraw()),
this, SLOT(redraw_win()));
@ -39,7 +41,7 @@ private:
int main( int argc, char **argv )
{
QApplication app( argc, argv );
My_Window *W = new My_Window(600,600);
My_window *W = new My_window(600,600);
app.setMainWidget( W );
W->show();
W->set_window(0, 600, 0, 600);

View File

@ -1,3 +1,5 @@
//demo/Qt_widget/basic/tutorial3/tutorial3.C
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Delaunay_triangulation_2.h>
@ -12,15 +14,15 @@ typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
class My_Layer : public CGAL::Qt_widget_layer{
void draw(CGAL::Qt_widget& win){
win << dt;
class My_layer : public CGAL::Qt_widget_layer{
void draw(){
*widget << dt;
}
};
class My_Window : public CGAL::Qt_widget {
class My_window : public CGAL::Qt_widget {
public:
My_Window(int x, int y)
My_window(int x, int y)
{
resize(x,y);
attach(&v);
@ -33,13 +35,13 @@ private:
dt.insert(Point(x_real(e->x()), y_real(e->y())));
redraw();
}
My_Layer v;
My_layer v;
};
int main( int argc, char **argv )
{
QApplication app( argc, argv );
My_Window *W = new My_Window(600,600);
My_window *W = new My_Window(600,600);
app.setMainWidget(W);
W->show();
W->set_window(0, 600, 0, 600);

View File

@ -1,3 +1,5 @@
//demo/Qt_widget/basic/tutorial4.C
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Delaunay_triangulation_2.h>
@ -15,15 +17,15 @@ typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
class My_Layer : public CGAL::Qt_widget_layer{
void draw(CGAL::Qt_widget& widget){
widget << dt;
class My_layer : public CGAL::Qt_widget_layer{
void draw(){
*widget << dt;
}
};
class My_Widget : public CGAL::Qt_widget {
class My_widget : public CGAL::Qt_widget {
public:
My_Widget(QMainWindow* c) : CGAL::Qt_widget(c) {};
My_widget(QMainWindow* c) : CGAL::Qt_widget(c) {};
private:
//this event is called only when the user presses the mouse
void mousePressEvent(QMouseEvent *e)
@ -34,25 +36,25 @@ private:
}
};
class My_Window : public QMainWindow{
class My_window : public QMainWindow{
public:
My_Window(int x, int y)
My_window(int x, int y)
{
widget = new My_Widget(this);
widget = new My_widget(this);
setCentralWidget(widget);
resize(x,y);
widget->set_window(0, x, 0, y);
widget->attach(&v);
}
private:
My_Widget *widget;
My_Layer v;
My_widget *widget;
My_layer v;
};
int main( int argc, char **argv )
{
QApplication app( argc, argv );
My_Window W(600,600);
My_window W(600,600);
app.setMainWidget( &W );
W.show();
W.setCaption("Using QMainWindow QT class");

View File

@ -1,3 +1,5 @@
//demo/Qt_widget/basic/tutorial5/tutorial5.C
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Delaunay_triangulation_2.h>
@ -16,16 +18,16 @@ typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
class My_Layer : public CGAL::Qt_widget_layer{
void draw(CGAL::Qt_widget& widget){
widget << CGAL::BLACK;
widget << dt;
class My_layer : public CGAL::Qt_widget_layer{
void draw(){
*widget << CGAL::BLACK;
*widget << dt;
}
};
class My_Widget : public CGAL::Qt_widget {
class My_widget : public CGAL::Qt_widget {
public:
My_Widget(QMainWindow* c) : CGAL::Qt_widget(c) {};
My_widget(QMainWindow* c) : CGAL::Qt_widget(c) {};
private:
//this event is called only when the user presses the mouse
void mousePressEvent(QMouseEvent *e)
@ -36,32 +38,32 @@ private:
}
};
class My_Window : public QMainWindow{
class My_window : public QMainWindow{
public:
My_Window(int x, int y)
My_window(int x, int y)
{
widget = new My_Widget(this);
widget = new My_widget(this);
setCentralWidget(widget);
resize(x,y);
widget->set_window(0, x, 0, y);
//How to attach the standard toolbar
stoolbar = new CGAL::Qt_widget_standard_toolbar(widget, this);
this->addToolBar(stoolbar->toolbar(), Top, FALSE);
std_toolbar = new CGAL::Qt_widget_standard_toolbar(widget, this);
this->addToolBar(std_toolbar->toolbar(), Top, FALSE);
setUsesBigPixmaps(true);
widget->attach(&v);
}
private:
My_Widget *widget;
My_Layer v;
CGAL::Qt_widget_standard_toolbar *stoolbar;
My_widget *widget;
My_layer v;
CGAL::Qt_widget_standard_toolbar *std_toolbar;
};
int main( int argc, char **argv )
{
QApplication app( argc, argv );
My_Window W(600,600);
My_window W(600,600);
app.setMainWidget( &W );
W.show();
W.setCaption("Using the Standard Toolbar");

View File

@ -1,3 +1,5 @@
//demo/Qt_widget/basic/tutorial6/tutorial6.C
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Delaunay_triangulation_2.h>
@ -7,7 +9,6 @@
#include <qmainwindow.h>
#include <CGAL/IO/Qt_widget.h>
#include <CGAL/IO/Qt_widget_tool.h>
#include <CGAL/IO/Qt_widget_layer.h>
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
@ -17,33 +18,32 @@ typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
class My_Layer : public CGAL::Qt_widget_layer{
void draw(CGAL::Qt_widget& widget){
widget << CGAL::BLACK;
widget << dt;
class My_layer : public CGAL::Qt_widget_layer{
void draw(){
*widget << CGAL::BLACK;
*widget << dt;
}
};
class My_Tool : public CGAL::Qt_widget_tool{
class My_input_layer : public CGAL::Qt_widget_layer{
public:
My_Tool(){};
My_input_layer(){};
private:
void mousePressEvent(QMouseEvent *e)
{
if(e->button() == Qt::LeftButton)
{
double
x=static_cast<double>(widget->x_real(e->x())),
y=static_cast<double>(widget->y_real(e->y()));
double x=static_cast<double>(widget->x_real(e->x()));
double y=static_cast<double>(widget->y_real(e->y()));
widget->new_object(CGAL::make_object(Point(x, y)));
}
}
};
class My_Window : public QMainWindow{
class My_window : public QMainWindow{
Q_OBJECT
public:
My_Window(int x, int y)
My_window(int x, int y)
{
widget = new CGAL::Qt_widget(this);
setCentralWidget(widget);
@ -51,16 +51,16 @@ public:
widget->set_window(0, x, 0, y);
//How to attach the standard toolbar
stoolbar = new CGAL::Qt_widget_standard_toolbar(widget, this);
this->addToolBar(stoolbar->toolbar(), Top, FALSE);
std_toolbar = new CGAL::Qt_widget_standard_toolbar(widget, this);
this->addToolBar(std_toolbar->toolbar(), Top, FALSE);
widget->attach(&v);
connect(widget, SIGNAL(new_cgal_object(CGAL::Object)),
this, SLOT(get_object(CGAL::Object)));
this, SLOT(get_object(CGAL::Object)));
widget->attach(&t);
}
~My_Window(){}
~My_window(){}
private slots:
void get_object(CGAL::Object obj)
{
@ -73,9 +73,9 @@ private slots:
}
private:
CGAL::Qt_widget *widget;
My_Layer v;
My_Tool t;
CGAL::Qt_widget_standard_toolbar *stoolbar;
My_layer v;
My_input_layer t;
CGAL::Qt_widget_standard_toolbar *std_toolbar;
};
#include "tutorial6.moc"
@ -83,7 +83,7 @@ private:
int main( int argc, char **argv )
{
QApplication app( argc, argv );
My_Window W(600,600);
My_window W(600,600);
app.setMainWidget( &W );
W.show();
W.setCaption("Using the Standard Toolbar");

View File

@ -1,3 +1,5 @@
//demo/Qt_widget/basic/tutorial7/tutorial7.C
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Delaunay_triangulation_2.h>
@ -17,17 +19,17 @@ typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
class My_Layer : public CGAL::Qt_widget_layer{
void draw(CGAL::Qt_widget& widget){
widget << CGAL::BLACK;
widget << dt;
class My_layer : public CGAL::Qt_widget_layer{
void draw(){
*widget << CGAL::BLACK;
*widget << dt;
}
};
class My_Window : public QMainWindow{
class My_window : public QMainWindow{
Q_OBJECT
public:
My_Window(int x, int y)
My_window(int x, int y)
{
widget = new CGAL::Qt_widget(this);
setCentralWidget(widget);
@ -36,8 +38,8 @@ public:
widget->set_window(0, x, 0, y);
//How to attach the standard toolbar
stoolbar = new CGAL::Qt_widget_standard_toolbar(widget, this);
this->addToolBar(stoolbar->toolbar(), Top, FALSE);
std_toolbar = new CGAL::Qt_widget_standard_toolbar(widget, this);
this->addToolBar(std_toolbar->toolbar(), Top, FALSE);
widget->attach(&v);
@ -45,7 +47,7 @@ public:
this, SLOT(get_object(CGAL::Object)));
widget->attach(&get_point);
}
~My_Window(){}
~My_window(){}
private slots:
void get_object(CGAL::Object obj)
{
@ -59,8 +61,8 @@ private slots:
}
private:
CGAL::Qt_widget *widget;
My_Layer v;
CGAL::Qt_widget_standard_toolbar *stoolbar;
My_layer v;
CGAL::Qt_widget_standard_toolbar *std_toolbar;
CGAL::Qt_widget_get_point<Rep> get_point;
};
@ -69,7 +71,7 @@ private:
int main( int argc, char **argv )
{
QApplication app( argc, argv );
My_Window W(600,600);
My_window W(600,600);
app.setMainWidget( &W );
W.show();
W.setCaption("Using the Standard Toolbar");

View File

@ -1,3 +1,5 @@
//demo/Qt_widget/basic/tutorial8/tutorial8.C
#include <CGAL/Cartesian.h>
#include <CGAL/Point_2.h>
#include <CGAL/Delaunay_triangulation_2.h>
@ -19,17 +21,17 @@ typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
class My_Layer : public CGAL::Qt_widget_layer{
void draw(CGAL::Qt_widget& widget){
widget << CGAL::BLACK;
widget << dt;
class My_layer : public CGAL::Qt_widget_layer{
void draw(){
*widget << CGAL::BLACK;
*widget << dt;
}
};
class My_Window : public QMainWindow{
class My_window : public QMainWindow{
Q_OBJECT
public:
My_Window(int x, int y)
My_window(int x, int y)
{
widget = new CGAL::Qt_widget(this);
setCentralWidget(widget);
@ -38,35 +40,26 @@ public:
widget->set_window(0, x, 0, y);
//How to attach the standard toolbar
stoolbar = new CGAL::Qt_widget_standard_toolbar(widget, this);
this->addToolBar(stoolbar->toolbar(), Top, FALSE);
std_toolbar = new CGAL::Qt_widget_standard_toolbar(widget, this);
this->addToolBar(std_toolbar->toolbar(), Top, FALSE);
QToolBar *tools_toolbar;
tools_toolbar = new QToolBar("Tools", this,
layers_toolbar = new QToolBar("Tools", this,
QMainWindow::Top, TRUE, "Tools");
addToolBar(tools_toolbar, Top, FALSE);
get_point_but = new QToolButton(QPixmap( (const char**)point_xpm ),
"Point Tool",
0,
this,
SLOT(pointtool()),
tools_toolbar,
"Point Tool");
get_point_but->setToggleButton(TRUE);
addToolBar(layers_toolbar, Top, FALSE);
get_point_button->setToggleButton(TRUE);
widget->attach(&v);
widget->attach(&get_point);
connect(get_point_button, SIGNAL(stateChanged(int)),
&get_point, SLOT(stateChanged(int)));
connect(widget, SIGNAL(new_cgal_object(CGAL::Object)),
this, SLOT(get_object(CGAL::Object)));
this, SLOT(get_object(CGAL::Object)));
}
~My_Window(){delete widget;}
~My_window(){delete widget;}
private slots:
//this function is called every time the toolbar button is pressed
void pointtool(){
if (get_point_but->isOn())
widget->attach(&get_point);
else
widget->detach_current_tool();
}
//this function is called every time a tool creates a Cgal object
void get_object(CGAL::Object obj)
@ -81,11 +74,12 @@ private slots:
}
private:
CGAL::Qt_widget *widget; //the instance of Qt_widget
My_Layer v; //an instance of a layer
CGAL::Qt_widget_standard_toolbar *stoolbar; //the standard toolbar
My_layer v; //an instance of a layer
CGAL::Qt_widget_standard_toolbar *std_toolbar;
//the standard toolbar
CGAL::Qt_widget_get_point<Rep> get_point;
//the generic tool that creates Cgal points
QToolButton *get_point_but; //the toolbar button
//the generic tool that creates Cgal points
QToolButton *get_point_button;//the toolbar button
};
#include "tutorial8.moc"
@ -93,7 +87,7 @@ private:
int main( int argc, char **argv )
{
QApplication app( argc, argv );
My_Window W(600,600);
My_window W(600,600);
app.setMainWidget( &W );
W.show();
W.setCaption("Using the Standard Toolbar");