Move packages to trunk root
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
7th tutorial
|
||||
-----------------
|
||||
|
||||
This tutorial is very similar to the previous one. Insert new points
|
||||
in a Delaunay triangulation when you click the mouse on the widget,
|
||||
using a tool, and also let you use the standard toolbar.
|
||||
|
||||
The difference is that this example is using a generic tool, developed
|
||||
by CGAL. This tool creates new CGAL points every time you click the
|
||||
mouse. The coordinates of the point are the coordinates of the real
|
||||
world. This means that the mouse coordinates are transformed using the
|
||||
current scales to the real world coordinates.
|
||||
|
||||
The generic tools are documented in the manual. They are templetized
|
||||
by a kernel of CGAL. In this tutorial the generic tool get_point it is
|
||||
templetized by Cartesian<double>.
|
||||
|
||||
First comes the include statement:
|
||||
|
||||
#include <CGAL/IO/Qt_widget_get_point.h>
|
||||
|
||||
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:
|
||||
widget->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
|
||||
the SIGNAL with your SLOT.
|
||||
@@ -0,0 +1,53 @@
|
||||
# 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.
|
||||
|
||||
.SUFFIXES: .moc
|
||||
|
||||
# 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: tutorial7$(EXE_EXT)
|
||||
|
||||
tutorial7$(EXE_EXT): tutorial7.moc tutorial7$(OBJ_EXT)
|
||||
$(CGAL_CXX) $(EXE_OPT)tutorial7 tutorial7$(OBJ_EXT) $(LDFLAGS)
|
||||
|
||||
clean: tutorial7.clean
|
||||
|
||||
#---------------------------------------------------------------------#
|
||||
# suffix rules
|
||||
#---------------------------------------------------------------------#
|
||||
|
||||
.C$(OBJ_EXT):
|
||||
$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<
|
||||
|
||||
.C.moc:
|
||||
$(QT_MOC) $< -o $@
|
||||
@@ -0,0 +1,82 @@
|
||||
//demo/Qt_widget/basic/tutorial7/tutorial7.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/Point_2.h>
|
||||
#include <CGAL/Delaunay_triangulation_2.h>
|
||||
#include <CGAL/IO/Qt_widget_Delaunay_triangulation_2.h>
|
||||
|
||||
#include <qapplication.h>
|
||||
#include <qmainwindow.h>
|
||||
|
||||
#include <CGAL/IO/Qt_widget.h>
|
||||
#include <CGAL/IO/Qt_widget_layer.h>
|
||||
#include <CGAL/IO/Qt_widget_standard_toolbar.h>
|
||||
#include <CGAL/IO/Qt_widget_get_point.h>
|
||||
|
||||
typedef CGAL::Cartesian<double> Rep;
|
||||
typedef CGAL::Point_2<Rep> Point;
|
||||
typedef CGAL::Delaunay_triangulation_2<Rep> Delaunay;
|
||||
|
||||
Delaunay dt;
|
||||
|
||||
class My_layer : public CGAL::Qt_widget_layer{
|
||||
void draw(){
|
||||
*widget << CGAL::BLACK;
|
||||
*widget << dt;
|
||||
}
|
||||
};
|
||||
|
||||
class My_window : public QMainWindow{
|
||||
Q_OBJECT
|
||||
public:
|
||||
My_window(int x, int y)
|
||||
{
|
||||
widget = new CGAL::Qt_widget(this);
|
||||
setCentralWidget(widget);
|
||||
resize(x,y);
|
||||
widget->show();
|
||||
widget->set_window(0, x, 0, y);
|
||||
|
||||
//How to attach the standard toolbar
|
||||
stoolbar = new CGAL::Qt_widget_standard_toolbar(widget, this,
|
||||
"Standard toolbar");
|
||||
widget->attach(&v);
|
||||
connect(widget, SIGNAL(new_cgal_object(CGAL::Object)),
|
||||
this, SLOT(get_object(CGAL::Object)));
|
||||
widget->attach(&get_point);
|
||||
}
|
||||
~My_window(){}
|
||||
private slots:
|
||||
void get_object(CGAL::Object obj)
|
||||
{
|
||||
Point p;
|
||||
if(CGAL::assign(p, obj))
|
||||
{
|
||||
dt.insert(p);
|
||||
widget->redraw();
|
||||
*widget << CGAL::RED << p;
|
||||
}
|
||||
}
|
||||
private:
|
||||
CGAL::Qt_widget *widget;
|
||||
My_layer v;
|
||||
CGAL::Qt_widget_standard_toolbar *stoolbar;
|
||||
CGAL::Qt_widget_get_point<Rep> get_point;
|
||||
};
|
||||
|
||||
#include "tutorial7.moc"
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
QApplication app( argc, argv );
|
||||
My_window W(400,400);
|
||||
app.setMainWidget( &W );
|
||||
W.show();
|
||||
W.setCaption("Using the Standard Toolbar");
|
||||
return app.exec();
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user