Move packages to trunk root

This commit is contained in:
Laurent Saboret
2006-02-14 08:58:20 +00:00
parent ee07ad352c
commit 1ba3a9542f
317 changed files with 158 additions and 158 deletions
@@ -0,0 +1,64 @@
Second tutorial
-----------------
In this tutorial you can see a different method to draw on the window,
and you'll pass over the limitations of the previous example.
This tutorials insert a point in a Delaunay triangulation every time
you press the mouse button over the widget, and calls redraw(). This
means that you'll see the results of your insertions immediately. The
advantage of this approach is that you can resize the window, the
painting will not disappear.
As you see the main entry point is the same as in the previous
tutorial, but instead of using an instance of Qt_widget class, you'll
use an instance of a class derived from Qt_widget.
In this sense, we create a new class My_Window as a child for
Qt_widget. The resize function has been moved into the constructor of
My_Window.
We define a triangulation as a global variable:
typedef CGAL::Cartesian<double> Rep;
typedef CGAL::Point_2<Rep> Point;
typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
The private member redraw() is used to output the triangulation on the screen.
private:
void redraw()
{
Qt_widget::redraw();
*this << dt;
}
There is another line in the redraw():
Qt_widget::redraw();
This line is meant to call the redraw() from the Qt_widget base class,
used to draw the attached layers as you'll see later. This function
also clears the screen. If you remove this line it's necessary to add
clear() instead.
Another private member catches the mouse press event from the Window
system (X11/Windows). The code put in this function will be executed when
you press the mouse on the widget.
private:
void mousePressEvent(QMouseEvent *e)
{
Qt_widget::mousePressEvent(e);
dt.insert(Point(x_real(e->x()), y_real(e->y())));
redraw();
}
As you see the code inserts a point in the triangulation, and calls
redraw(). You can comment redraw() to see what happens: You'll see
the results only when you'll resize the window.
Of course if you want to trigger the mouse press event in the base
class you have to put this in the code of the function:
Qt_widget::mousePressEvent(e);
@@ -0,0 +1,51 @@
# Created by the script create_makefile
# This is the makefile for compiling a CGAL application.
#---------------------------------------------------------------------#
# include platform specific settings
#---------------------------------------------------------------------#
# Choose the right include file from the <cgalroot>/make directory.
# CGAL_MAKEFILE = ENTER_YOUR_INCLUDE_MAKEFILE_HERE
include $(CGAL_MAKEFILE)
#---------------------------------------------------------------------#
# compiler flags
#---------------------------------------------------------------------#
CXXFLAGS = -I../../../../include/ \
$(CGAL_CXXFLAGS) \
$(LONG_NAME_PROBLEM_CXXFLAGS) \
$(DEBUG_OPT)
#---------------------------------------------------------------------#
# linker flags
#---------------------------------------------------------------------#
LIBPATH = \
$(CGAL_LIB_DIR)
LDFLAGS = \
$(LONG_NAME_PROBLEM_LDFLAGS) \
$(CGAL_QT_LDFLAGS)
#---------------------------------------------------------------------#
# target entries
#---------------------------------------------------------------------#
all: tutorial2$(EXE_EXT)
tutorial2.moc :
$(QT_MOC) tutorial2.C -o tutorial2.moc
tutorial2$(EXE_EXT): tutorial2.moc tutorial2$(OBJ_EXT)
$(CGAL_CXX) $(EXE_OPT)tutorial2 tutorial2$(OBJ_EXT) $(LDFLAGS)
clean: tutorial2.clean
#---------------------------------------------------------------------#
# suffix rules
#---------------------------------------------------------------------#
.C$(OBJ_EXT):
$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<
@@ -0,0 +1,54 @@
//demo/Qt_widget/basic/tutorial2.C
#ifndef CGAL_USE_QT
#include <iostream>
int main(int, char*){
std::cout << "Sorry, this demo needs QT..." << std::endl; return 0;}
#else
#include <CGAL/Cartesian.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/IO/Qt_widget_Triangulation_2.h>
#include <CGAL/IO/Qt_widget.h>
#include <qapplication.h>
typedef CGAL::Cartesian<double> Rep;
typedef CGAL::Point_2<Rep> Point;
typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
Delaunay dt;
typedef CGAL::Qt_widget Qt_widget;
class My_window : public Qt_widget {
Q_OBJECT
public:
My_window(int x, int y){
resize(x,y);
connect(this, SIGNAL(redraw_on_back()),
this, SLOT(redraw_win()));
};
private slots:
void redraw_win()
{
*this << dt;
}
private:
//this event is called only when the user presses the mouse
void mousePressEvent(QMouseEvent *e)
{
Qt_widget::mousePressEvent(e);
dt.insert(Point(x_real(e->x()), y_real(e->y())));
redraw();
}
};
//moc_source_file : tutorial2.C
#include "tutorial2.moc"
int main( int argc, char **argv )
{
QApplication app( argc, argv );
My_window *W = new My_window(400,400);
app.setMainWidget( W );
W->show();
W->set_window(0, 400, 0, 400);
return app.exec();
}
#endif