From e43b1aa09d2e3ae2fa2d6005d23e901c4e026dca Mon Sep 17 00:00:00 2001 From: Radu Ursu Date: Tue, 26 Feb 2002 10:43:10 +0000 Subject: [PATCH] Radu Ursu stack -> heap --- .../demo/Qt_widget/Examples/hellosegment.C | 18 ++++++------- .../Qt_widget/Examples/standard_toolbar.C | 16 +++++++----- .../Qt_widget/demo/Qt_widget/Examples/tool.C | 8 +++--- .../demo/Qt_widget/basic/tutorial6/README.txt | 6 ++--- .../demo/Qt_widget/basic/tutorial6/demo.dsp | 16 ++++++------ .../Qt_widget/basic/tutorial6/tutorial6.C | 22 +++++++++------- .../demo/Qt_widget/basic/tutorial7/README.txt | 2 +- .../demo/Qt_widget/basic/tutorial7/demo.dsp | 18 ++++++------- .../Qt_widget/basic/tutorial7/tutorial7.C | 24 +++++++++-------- .../demo/Qt_widget/basic/tutorial8/demo.dsp | 16 ++++++------ .../Qt_widget/basic/tutorial8/tutorial8.C | 26 ++++++++++--------- 11 files changed, 90 insertions(+), 82 deletions(-) diff --git a/Packages/Qt_widget/demo/Qt_widget/Examples/hellosegment.C b/Packages/Qt_widget/demo/Qt_widget/Examples/hellosegment.C index 9ac9a3bf660..b5c4271ad60 100644 --- a/Packages/Qt_widget/demo/Qt_widget/Examples/hellosegment.C +++ b/Packages/Qt_widget/demo/Qt_widget/Examples/hellosegment.C @@ -10,14 +10,14 @@ typedef CGAL::Segment_2 Segment; int main( int argc, char **argv ) { QApplication app( argc, argv ); - CGAL::Qt_widget W; - app.setMainWidget( &W ); - W.resize(600, 600); - W.set_window(0, 600, 0, 600); - W.show(); - W.lock(); - W << BackgroundColor(ORANGE) << RED; - W << Segment(Point(100,100), Point(400,400)); - W.unlock(); + CGAL::Qt_widget *W = new CGAL::Qt_widget(); + app.setMainWidget( W ); + W->resize(600, 600); + W->set_window(0, 600, 0, 600); + W->show(); + W->lock(); + *W << BackgroundColor(ORANGE) << RED; + *W << Segment(Point(100,100), Point(400,400)); + W->unlock(); return app.exec(); } \ No newline at end of file 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 712e46dee4c..51d1243f34e 100644 --- a/Packages/Qt_widget/demo/Qt_widget/Examples/standard_toolbar.C +++ b/Packages/Qt_widget/demo/Qt_widget/Examples/standard_toolbar.C @@ -14,12 +14,13 @@ Delaunay dt; class My_window : public QMainWindow{ public: - My_window(int x, int y) : win(this) + My_window(int x, int y) { - setCentralWidget(&win); + win = new CGAL::Qt_widget(this); + setCentralWidget(win); resize(x,y); - win.show(); - win.set_window(0, x, 0, y); + win->show(); + win->set_window(0, x, 0, y); CGAL::Random_points_in_disc_2 g(500); for(int count=0; count<100; count++) { @@ -27,11 +28,12 @@ public: } //How to attach the standard toolbar - stoolbar = new CGAL::Standard_toolbar(&win, this); + stoolbar = new CGAL::Standard_toolbar(win, this); this->addToolBar(stoolbar->toolbar(), Top, FALSE); - win.redraw(); + win->redraw(); } + ~My_Window(){delete win;} private: //functions void redraw() { @@ -40,7 +42,7 @@ private: //functions } private: //members - CGAL::Qt_widget win; + CGAL::Qt_widget *win; CGAL::Standard_toolbar *stoolbar; }; diff --git a/Packages/Qt_widget/demo/Qt_widget/Examples/tool.C b/Packages/Qt_widget/demo/Qt_widget/Examples/tool.C index 08ad3e7a848..53413297438 100644 --- a/Packages/Qt_widget/demo/Qt_widget/Examples/tool.C +++ b/Packages/Qt_widget/demo/Qt_widget/Examples/tool.C @@ -42,9 +42,9 @@ private slots: int main( int argc, char **argv ) { QApplication app( argc, argv ); - My_Window W(600,600); - app.setMainWidget( &W ); - W.set_window(0, 600, 0, 600); - W.show(); + My_Window *W = new My_Window(600,600); + app.setMainWidget( W ); + W->set_window(0, 600, 0, 600); + W->show(); return app.exec(); } \ No newline at end of file diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/README.txt b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/README.txt index 92d59f77ead..4a28dbdfeb7 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/README.txt +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/README.txt @@ -30,12 +30,12 @@ In My_Window class an instance of My_Tool is created : In the constructor of My_Window we attach the tool: - win.attach(t); + win->attach(t); To receive the object that the tool creates, in the constructor of My_Window, we connect: - connect(&win, SIGNAL(new_cgal_object(CGAL::Object)), + connect(win, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_object(CGAL::Object))); In My_Window class it is declared the private slot get_object(CGAL::Object obj). @@ -44,7 +44,7 @@ tool calls the new_object() member function from Qt_widget, that emits a signal new_cgal_object(CGAL::Object). To receive this signal, in the constructor of My_Window a connect is declared: - connect(&win, SIGNAL(new_cgal_object(CGAL::Object)), + connect(win, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_object(CGAL::Object))); This connect tells the application that every time Qt_widget emits the diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/demo.dsp b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/demo.dsp index cd84626af52..bbba030abd9 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/demo.dsp +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/demo.dsp @@ -91,19 +91,19 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=..\..\..\..\src\Qt_Widget.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_widget_standard_toolbar.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_layer.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_Widget_tool.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_standard_toolbar.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_widget_layer.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_tool.C # End Source File # Begin Source File @@ -119,16 +119,16 @@ SOURCE=..\..\..\..\include\CGAL\IO\Qt_Widget.h # End Source File # Begin Source File +SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_layer.h +# End Source File +# Begin Source File + SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_standard_toolbar.h # End Source File # Begin Source File SOURCE=..\..\..\..\include\CGAL\IO\Qt_Widget_tool.h # End Source File -# Begin Source File - -SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_layer.h -# End Source File # End Group # Begin Group "Resource Files" 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 1bcda40cc7b..9bbcd224aa7 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/tutorial6.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial6/tutorial6.C @@ -42,22 +42,24 @@ private: class My_Window : public QMainWindow{ Q_OBJECT public: - My_Window(int x, int y) : win(this) + My_Window(int x, int y) { - setCentralWidget(&win); + win = new CGAL::Qt_widget(this); + setCentralWidget(win); resize(x,y); - win.show(); - win.set_window(0, x, 0, y); + win->show(); + win->set_window(0, x, 0, y); //How to attach the standard toolbar - stoolbar = new CGAL::Standard_toolbar(&win, this); + stoolbar = new CGAL::Standard_toolbar(win, this); this->addToolBar(stoolbar->toolbar(), Top, FALSE); - win.attach(&v); + win->attach(&v); - connect(&win, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_object(CGAL::Object))); - win.attach(t); + connect(win, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_object(CGAL::Object))); + win->attach(t); } + ~My_Window(){delete win;} private slots: void get_object(CGAL::Object obj) { @@ -65,11 +67,11 @@ private slots: if(CGAL::assign(p, obj)) { dt.insert(p); - win.redraw(); + win->redraw(); } } private: - CGAL::Qt_widget win; + CGAL::Qt_widget *win; My_Layer v; My_Tool t; CGAL::Standard_toolbar *stoolbar; diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/README.txt b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/README.txt index ee21eeceff6..368033c0e34 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/README.txt +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/README.txt @@ -24,7 +24,7 @@ In the class My_Window, it is declared as a private member: CGAL::Qt_widget_get_point get_point; In the constructor of My_Window also we attached this generic tool: - win.attach(get_point); + win->attach(get_point); The connect is still there in the constructor, the good news is that no matter how many tools you use, you will have to connect only once diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/demo.dsp b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/demo.dsp index abf3b88476a..63f35026dc8 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/demo.dsp +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/demo.dsp @@ -91,23 +91,23 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=..\..\..\..\src\Qt_Widget.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_widget_standard_toolbar.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_layer.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_Widget_tool.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_standard_toolbar.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_widget_layer.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_tool.C # End Source File # Begin Source File -SOURCE=.\seventh.C +SOURCE=.\tutorial7.C # End Source File # End Group # Begin Group "Header Files" @@ -119,16 +119,16 @@ SOURCE=..\..\..\..\include\CGAL\IO\Qt_Widget.h # End Source File # Begin Source File +SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_layer.h +# End Source File +# Begin Source File + SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_standard_toolbar.h # End Source File # Begin Source File SOURCE=..\..\..\..\include\CGAL\IO\Qt_Widget_tool.h # End Source File -# Begin Source File - -SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_layer.h -# End Source File # End Group # Begin Group "Resource Files" 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 1eae8a1ddd3..6662b38a916 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/tutorial7.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial7/tutorial7.C @@ -27,22 +27,24 @@ class My_Layer : public CGAL::Qt_widget_layer{ class My_Window : public QMainWindow{ Q_OBJECT public: - My_Window(int x, int y) : win(this) + My_Window(int x, int y) { - setCentralWidget(&win); + win = new CGAL::Qt_widget(this); + setCentralWidget(win); resize(x,y); - win.show(); - win.set_window(0, x, 0, y); + win->show(); + win->set_window(0, x, 0, y); //How to attach the standard toolbar - stoolbar = new CGAL::Standard_toolbar(&win, this); + stoolbar = new CGAL::Standard_toolbar(win, this); this->addToolBar(stoolbar->toolbar(), Top, FALSE); - win.attach(&v); + win->attach(&v); - connect(&win, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_object(CGAL::Object))); - win.attach(get_point); + connect(win, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_object(CGAL::Object))); + win->attach(get_point); } + ~My_Window(){delete win;} private slots: void get_object(CGAL::Object obj) { @@ -50,12 +52,12 @@ private slots: if(CGAL::assign(p, obj)) { dt.insert(p); - win.redraw(); - win << CGAL::RED << p; + win->redraw(); + *win << CGAL::RED << p; } } private: - CGAL::Qt_widget win; + CGAL::Qt_widget *win; My_Layer v; CGAL::Standard_toolbar *stoolbar; CGAL::Qt_widget_get_point get_point; diff --git a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/demo.dsp b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/demo.dsp index 7177a93de2a..ef67607da21 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/demo.dsp +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/demo.dsp @@ -91,19 +91,19 @@ LINK32=link.exe # PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" # Begin Source File -SOURCE=..\..\..\..\src\Qt_widget\Qt_widget.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_widget\Qt_widget_standard_toolbar.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_layer.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_widget\Qt_widget_tool.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_standard_toolbar.C # End Source File # Begin Source File -SOURCE=..\..\..\..\src\Qt_widget\Qt_widget_layer.C +SOURCE=..\..\..\..\src\CGALQt\Qt_widget_tool.C # End Source File # Begin Source File @@ -119,6 +119,10 @@ SOURCE=..\..\..\..\include\CGAL\IO\Qt_Widget.h # End Source File # Begin Source File +SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_layer.h +# End Source File +# Begin Source File + SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_standard_toolbar.h !IF "$(CFG)" == "demo - Win32 Release" @@ -140,10 +144,6 @@ InputPath=..\..\..\..\include\CGAL\IO\Qt_widget_standard_toolbar.h SOURCE=..\..\..\..\include\CGAL\IO\Qt_Widget_tool.h # End Source File -# Begin Source File - -SOURCE=..\..\..\..\include\CGAL\IO\Qt_widget_layer.h -# End Source File # End Group # Begin Group "Resource Files" 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 88d999c9d18..8be3b55f3f1 100644 --- a/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/tutorial8.C +++ b/Packages/Qt_widget/demo/Qt_widget/basic/tutorial8/tutorial8.C @@ -29,15 +29,16 @@ class My_Layer : public CGAL::Qt_widget_layer{ class My_Window : public QMainWindow{ Q_OBJECT public: - My_Window(int x, int y) : win(this) + My_Window(int x, int y) { - setCentralWidget(&win); + win = new CGAL::Qt_widget(this); + setCentralWidget(win); resize(x,y); - win.show(); - win.set_window(0, x, 0, y); + win->show(); + win->set_window(0, x, 0, y); //How to attach the standard toolbar - stoolbar = new CGAL::Standard_toolbar(&win, this); + stoolbar = new CGAL::Standard_toolbar(win, this); this->addToolBar(stoolbar->toolbar(), Top, FALSE); QToolBar *tools_toolbar; @@ -51,17 +52,18 @@ public: tools_toolbar, "Point Tool"); get_point_but->setToggleButton(TRUE); - win.attach(&v); + win->attach(&v); - connect(&win, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_object(CGAL::Object))); + connect(win, SIGNAL(new_cgal_object(CGAL::Object)), this, SLOT(get_object(CGAL::Object))); } + ~My_Window(){delete win;} private slots: //this function is called every time the toolbar button is pressed void pointtool(){ if (get_point_but->isOn()) - win.attach(get_point); + win->attach(get_point); else - win.detach_current_tool(); + win->detach_current_tool(); } //this function is called every time a tool creates a Cgal object @@ -71,12 +73,12 @@ private slots: if(CGAL::assign(p, obj)) { dt.insert(p); - win.redraw(); - win << CGAL::RED << p; + win->redraw(); + *win << CGAL::RED << p; } } private: - CGAL::Qt_widget win; //the instance of Qt_widget + CGAL::Qt_widget *win; //the instance of Qt_widget My_Layer v; //an instance of a layer CGAL::Standard_toolbar *stoolbar; //the standard toolbar CGAL::Qt_widget_get_point get_point; //the generic tool that creates Cgal points