mirror of https://github.com/CGAL/cgal
parent
91583bedb9
commit
e43b1aa09d
|
|
@ -10,14 +10,14 @@ typedef CGAL::Segment_2<Rep> 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();
|
||||
}
|
||||
|
|
@ -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<Point> 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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ In the class My_Window, it is declared as a private member:
|
|||
CGAL::Qt_widget_get_point<Rep> 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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Rep> get_point;
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Rep> get_point; //the generic tool that creates Cgal points
|
||||
|
|
|
|||
Loading…
Reference in New Issue