From f121c61d5f2c2f139a6284d7ac07e1f2eaffb142 Mon Sep 17 00:00:00 2001 From: Radu Ursu Date: Thu, 28 Mar 2002 14:12:48 +0000 Subject: [PATCH] Unified layers and tools and rewritten the doc. --- .../Qt_widget/basic/tutorial2/tutorial2.C | 8 ++- .../Qt_widget/basic/tutorial3/tutorial3.C | 16 ++--- .../Qt_widget/basic/tutorial4/tutorial4.C | 24 ++++---- .../Qt_widget/basic/tutorial5/tutorial5.C | 32 +++++----- .../Qt_widget/basic/tutorial6/tutorial6.C | 40 ++++++------- .../Qt_widget/basic/tutorial7/tutorial7.C | 26 +++++---- .../Qt_widget/basic/tutorial8/tutorial8.C | 58 +++++++++---------- 7 files changed, 104 insertions(+), 100 deletions(-) diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial2/tutorial2.C b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial2/tutorial2.C index d233b53d36a..3c57ffe10c4 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial2/tutorial2.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial2/tutorial2.C @@ -1,3 +1,5 @@ +//demo/Qt_widget/basic/tutorial2.C + #include #include @@ -10,10 +12,10 @@ typedef CGAL::Delaunay_triangulation_2 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); diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial3/tutorial3.C b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial3/tutorial3.C index ad4e81e57d0..24b0ea9f57d 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial3/tutorial3.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial3/tutorial3.C @@ -1,3 +1,5 @@ +//demo/Qt_widget/basic/tutorial3/tutorial3.C + #include #include #include @@ -12,15 +14,15 @@ typedef CGAL::Delaunay_triangulation_2 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); diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial4/tutorial4.C b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial4/tutorial4.C index a365807cfa0..3ffe7ac36ec 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial4/tutorial4.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial4/tutorial4.C @@ -1,3 +1,5 @@ +//demo/Qt_widget/basic/tutorial4.C + #include #include #include @@ -15,15 +17,15 @@ typedef CGAL::Delaunay_triangulation_2 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"); diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial5/tutorial5.C b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial5/tutorial5.C index 1eaed2bc53d..25d1f5a1ed1 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial5/tutorial5.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial5/tutorial5.C @@ -1,3 +1,5 @@ +//demo/Qt_widget/basic/tutorial5/tutorial5.C + #include #include #include @@ -16,16 +18,16 @@ typedef CGAL::Delaunay_triangulation_2 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"); diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/tutorial6.C b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/tutorial6.C index a61d62fad8b..081281d6eb2 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/tutorial6.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/tutorial6.C @@ -1,3 +1,5 @@ +//demo/Qt_widget/basic/tutorial6/tutorial6.C + #include #include #include @@ -7,7 +9,6 @@ #include #include -#include #include #include @@ -17,33 +18,32 @@ typedef CGAL::Delaunay_triangulation_2 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(widget->x_real(e->x())), - y=static_cast(widget->y_real(e->y())); + double x=static_cast(widget->x_real(e->x())); + double y=static_cast(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"); diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/tutorial7.C b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/tutorial7.C index 80deebabf3e..f5699d888ef 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/tutorial7.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/tutorial7.C @@ -1,3 +1,5 @@ +//demo/Qt_widget/basic/tutorial7/tutorial7.C + #include #include #include @@ -17,17 +19,17 @@ typedef CGAL::Delaunay_triangulation_2 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 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"); diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/tutorial8.C b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/tutorial8.C index 0d56e95c67b..4f19e4abae2 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/tutorial8.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/tutorial8.C @@ -1,3 +1,5 @@ +//demo/Qt_widget/basic/tutorial8/tutorial8.C + #include #include #include @@ -19,17 +21,17 @@ typedef CGAL::Delaunay_triangulation_2 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 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");