From 78eb2b6a38f7522e7bd5dc91fa3dbe97a9f280df Mon Sep 17 00:00:00 2001 From: Radu Ursu Date: Tue, 26 Feb 2002 13:41:25 +0000 Subject: [PATCH] Radu Ursu win -->> widget --- .../Qt_widget/Examples/standard_toolbar.C | 18 +-- .../Qt_widget_toolbar_layers.C | 5 +- .../Qt_widget_toolbar_layers.h | 8 +- .../Min_quadrilateral_2/min_quadrilateral_2.C | 122 +++++++++--------- 4 files changed, 77 insertions(+), 76 deletions(-) diff --git a/Packages/Qt_widget/demo/Qt_widget/Examples/standard_toolbar.C b/Packages/Qt_widget/demo/Qt_widget/Examples/standard_toolbar.C index 0c171bb8469..847507c055a 100644 --- a/Packages/Qt_widget/demo/Qt_widget/Examples/standard_toolbar.C +++ b/Packages/Qt_widget/demo/Qt_widget/Examples/standard_toolbar.C @@ -20,11 +20,11 @@ class My_window : public QMainWindow{ public: My_window(int x, int y) { - win = new CGAL::Qt_widget(this); - setCentralWidget(win); + widget = new CGAL::Qt_widget(this); + setCentralWidget(widget); resize(x,y); - win->show(); - win->set_window(0, x, 0, y); + widget->show(); + widget->set_window(0, x, 0, y); CGAL::Random_points_in_disc_2 g(500); for(int count=0; count<100; count++) { @@ -32,22 +32,22 @@ public: } //How to attach the standard toolbar - stoolbar = new CGAL::Standard_toolbar(win, this); + stoolbar = new CGAL::Standard_toolbar(widget, this); this->addToolBar(stoolbar->toolbar(), Top, FALSE); - connect(win, SIGNAL(custom_redraw()), + connect(widget, SIGNAL(custom_redraw()), this, SLOT(redraw_win()) ); } - ~My_window(){delete win;} + ~My_window(){} private slots: //functions void redraw_win() { //CGAL::Qt_widget::redraw(); - *win << dt; + *widget << dt; } private: //members - CGAL::Qt_widget *win; + CGAL::Qt_widget *widget; CGAL::Standard_toolbar *stoolbar; }; diff --git a/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/Qt_widget_toolbar_layers.C b/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/Qt_widget_toolbar_layers.C index e1e2a89986d..1116d180c3e 100644 --- a/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/Qt_widget_toolbar_layers.C +++ b/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/Qt_widget_toolbar_layers.C @@ -33,7 +33,7 @@ namespace CGAL { Layers_toolbar::Layers_toolbar(Qt_widget *w, QMainWindow *mw, std::list *l_of_p) : - nr_of_buttons(0) + nr_of_buttons(0), widget(w), window(mw) { showMC = new Qt_layer_mouse_coordinates(*mw); @@ -41,9 +41,8 @@ namespace CGAL { showP = new Qt_layer_show_points(l_of_p); showLS = new Qt_layer_show_strip(l_of_p); showR = new Qt_layer_show_rectangle(l_of_p); + //set the widget - widget = w; - window = mw; window->statusBar(); widget->attach(showMC); diff --git a/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/Qt_widget_toolbar_layers.h b/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/Qt_widget_toolbar_layers.h index d72fefb6d65..838a62f3323 100644 --- a/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/Qt_widget_toolbar_layers.h +++ b/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/Qt_widget_toolbar_layers.h @@ -44,7 +44,7 @@ class Layers_toolbar : public QObject { Q_OBJECT public: - Layers_toolbar(Qt_widget *w, QMainWindow *mw, std::list *l_of_p); + Layers_toolbar(Qt_widget *w, QMainWindow *mw, std::list *l_of_p); ~Layers_toolbar() { delete showMC; @@ -73,10 +73,10 @@ private: QMainWindow *window; int nr_of_buttons; - CGAL::Qt_layer_mouse_coordinates *showMC; - Qt_layer_show_points *showP; + CGAL::Qt_layer_mouse_coordinates *showMC; + Qt_layer_show_points *showP; Qt_layer_show_parallelogram *showPL; - Qt_layer_show_strip *showLS; + Qt_layer_show_strip *showLS; Qt_layer_show_rectangle *showR; };//end class diff --git a/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/min_quadrilateral_2.C b/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/min_quadrilateral_2.C index e11716677d9..26f5ab4fd8d 100644 --- a/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/min_quadrilateral_2.C +++ b/Packages/Qt_widget/demo/Qt_widget/Min_quadrilateral_2/min_quadrilateral_2.C @@ -23,11 +23,12 @@ int main(int, char*) #include #include #include +#include //Qt_widget -#include #include "Qt_widget_toolbar.h" #include "Qt_widget_toolbar_layers.h" +#include #include #include @@ -66,66 +67,67 @@ class MyWindow : public QMainWindow { Q_OBJECT public: - MyWindow(int w, int h): win(this) { - setCentralWidget(&win); + MyWindow(int w, int h){ + widget = new CGAL::Qt_widget(this); + setCentralWidget(widget); - //create a timer for checking if somthing changed - QTimer *timer = new QTimer( this ); - connect( timer, SIGNAL(timeout()), + //create a timer for checking if somthing changed + QTimer *timer = new QTimer( this ); + connect( timer, SIGNAL(timeout()), this, SLOT(timer_done()) ); - timer->start( 200, FALSE ); + 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( "&Close", this, SLOT(close()), CTRL+Key_X ); + file->insertItem( "&Quit", qApp, SLOT( closeAllWindows() ), CTRL+Key_Q ); - // 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( "&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 points", this, SLOT(gen_points()), 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()) ); - // drawing menu - QPopupMenu * draw = new QPopupMenu( this ); - menuBar()->insertItem( "&Draw", draw ); - draw->insertItem("&Generate points", this, SLOT(gen_points()), 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, &list_of_points); - //the layers toolbar - vtoolbar = new CGAL::Layers_toolbar(&win, this, &list_of_points); - //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); + //the new tools toolbar + setUsesBigPixmaps(TRUE); + newtoolbar = new CGAL::Tools_toolbar(widget, this, &list_of_points); + //the layers toolbar + vtoolbar = new CGAL::Layers_toolbar(widget, this, &list_of_points); + //the standard toolbar + stoolbar = new CGAL::Standard_toolbar (widget, 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); + *widget << CGAL::LineWidth(2) << CGAL::BackgroundColor (CGAL::BLACK); + resize(w,h); + widget->show(); - resize(w,h); - win.show(); - - win.setMouseTracking(TRUE); + widget->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))); + //connect the widget to the main function that receives the objects + connect(widget, SIGNAL(new_cgal_object(CGAL::Object)), + this, SLOT(get_new_object(CGAL::Object))); - //application flag stuff - old_state = 0; + //application flag stuff + old_state = 0; }; ~MyWindow() { + delete newtoolbar; + delete vtoolbar; + delete stoolbar; }; @@ -135,15 +137,15 @@ private: public slots: void set_window(double xmin, double xmax, double ymin, double ymax) { - win.set_window(xmin, xmax, ymin, ymax); + widget->set_window(xmin, xmax, ymin, ymax); } void new_instance() { - win.detach_current_tool(); - win.lock(); + widget->detach_current_tool(); + widget->lock(); list_of_points.clear(); - win.set_window(-1.1, 1.1, -1.1, 1.1); // set the Visible Area to the Interval - win.unlock(); + widget->set_window(-1.1, 1.1, -1.1, 1.1); // set the Visible Area to the Interval + widget->unlock(); something_changed(); } @@ -180,14 +182,14 @@ private slots: void timer_done() { if(old_state!=current_state){ - win.redraw(); + widget->redraw(); old_state = current_state; } } void gen_points() { - win.set_window(-1.1, 1.1, -1.1, 1.1); // set the Visible Area to the Interval + widget->set_window(-1.1, 1.1, -1.1, 1.1); // set the Visible Area to the Interval // send resizeEvent only on show. CGAL::Random_points_in_disc_2 g(0.5); @@ -200,7 +202,7 @@ private slots: private: - CGAL::Qt_widget win; + CGAL::Qt_widget *widget; CGAL::Tools_toolbar *newtoolbar; CGAL::Standard_toolbar *stoolbar; CGAL::Layers_toolbar *vtoolbar; @@ -217,13 +219,13 @@ main(int argc, char **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(); + MyWindow widget(800,800); // physical window size + app.setMainWidget(&widget); + widget.setCaption(my_title_string); + widget.setMouseTracking(TRUE); + widget.show(); // because Qt send resizeEvent only on show. - win.set_window(-1, 1, -1, 1); + widget.set_window(-1, 1, -1, 1); current_state = -1; return app.exec(); }