no message

This commit is contained in:
Radu Ursu 2002-01-09 17:16:06 +00:00
parent b7285d6e1b
commit 36e28ef8dc
1 changed files with 48 additions and 10 deletions

View File

@ -36,15 +36,13 @@ private:
}//endnamespace
\end{ccExampleCode}
In order to attach a tool to Qt\_widget all you have to do is to declare and
define the tool and then use the \(>>\) operator. The Qt\_widget and the tool
mechanism is designed to use only one tool at one moment of time. You can't
use two tools at the same time. When a tool is attached, both the tool and the
Qt\_widget will receive the events from the Window System.
define the tool and then use the attach method from Qt\_widget class. The
Qt\_widget and the tool mechanism is designed to use only one tool at one moment of time. You can't use two tools at the same time. When a tool is attached, both the tool and the Qt\_widget will receive the events from the Window System.
\begin{ccExampleCode}
CGAL::Qt_widget_zoomrect zoomrectbut;
CGAL::Qt_widget *widget;
*widget >> zoomrectbut;
widget->attach(zoomrectbut);
\end{ccExampleCode}
The events are declared in the base class as virtual functions. Your tool class
has to overload this functions in order to receive the events from the main
@ -236,13 +234,30 @@ created with tools, will be catched by Qt\_widget and send to user through the
signal new\_cgal\_object(CGAL::Object). This way, the user should write only
a connect like this:
connect(Qt\_Widget,SIGNAL(new\_cgal\_object(CGAL::Object)),this,SLOT(receive\_new\_object(CGAL::Object)));
connect(Qt\_Widget,SIGNAL(new\_cgal\_object(CGAL::Object)),this,SLOT(get\_new\_object(CGAL::Object)));
Also in the user class the code should look like this:
Also in the user class the code should look like this. This should be a
template for you anytime you want to use Qt\_widget, you should follow the same
model:
\begin{ccExampleCode}
private slots:
void receive_new_object(CGAL::Object obj)
class MyWindow : public QMainWindow
{
Q_OBJECT
public:
MyWindow(int w, int h): win(this) {
setCentralWidget(&win);
resize(w, h);
connect(&win, SIGNAL(new_cgal_object(CGAL::Object)),
this, SLOT(get_new_object(CGAL::Object)));
...
}
...
private:
CGAL::Qt_widget win;
private slots:
void get_new_object(CGAL::Object obj)
{
Point p;
Segment s;
Line l;
@ -257,10 +272,33 @@ void receive_new_object(CGAL::Object obj)
...
}
...
}
};
int
main(int argc, char **argv)
{
QApplication app( argc, 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.setMouseTracking(TRUE);
win.show();
// because Qt send resizeEvent only on show.
win.set_window(-1, 1, -1, 1);
return app.exec();
}
\end{ccExampleCode}
An example of a tool that create \cgal\ points when the user click the left mouse button over the widget:
The following is an example of a tool that create \cgal\ points when the user
click the left mouse button over the widget. Combined with the previous
example, you can get \cgal\ objects. For example in the previous example all
you have to do is to declare the tool and to attach it, let's say in the
constructor, or in other member function..
\begin{ccExampleCode}
namespace CGAL {