mirror of https://github.com/CGAL/cgal
parent
b271ff8af5
commit
78eb2b6a38
|
|
@ -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<Point> 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;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
namespace CGAL {
|
||||
Layers_toolbar::Layers_toolbar(Qt_widget *w, QMainWindow *mw, std::list<Point> *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<Rp>(l_of_p);
|
||||
showLS = new Qt_layer_show_strip<Rp>(l_of_p);
|
||||
showR = new Qt_layer_show_rectangle<Rp>(l_of_p);
|
||||
|
||||
//set the widget
|
||||
widget = w;
|
||||
window = mw;
|
||||
window->statusBar();
|
||||
|
||||
widget->attach(showMC);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class Layers_toolbar : public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
Layers_toolbar(Qt_widget *w, QMainWindow *mw, std::list<Point> *l_of_p);
|
||||
Layers_toolbar(Qt_widget *w, QMainWindow *mw, std::list<Point> *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<Rp> *showP;
|
||||
CGAL::Qt_layer_mouse_coordinates *showMC;
|
||||
Qt_layer_show_points<Rp> *showP;
|
||||
Qt_layer_show_parallelogram<Rp> *showPL;
|
||||
Qt_layer_show_strip<Rp> *showLS;
|
||||
Qt_layer_show_strip<Rp> *showLS;
|
||||
Qt_layer_show_rectangle<Rp> *showR;
|
||||
};//end class
|
||||
|
||||
|
|
|
|||
|
|
@ -23,11 +23,12 @@ int main(int, char*)
|
|||
#include <CGAL/basic.h>
|
||||
#include <CGAL/Cartesian.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
#include <CGAL/Polygon_2.h>
|
||||
|
||||
//Qt_widget
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include "Qt_widget_toolbar.h"
|
||||
#include "Qt_widget_toolbar_layers.h"
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
||||
#include <CGAL/IO/Qt_widget_layer.h>
|
||||
|
||||
|
|
@ -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<Point> 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();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue