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,41 @@
8th tutorial
-----------------
In this tutorial you learn how to use a button to attach and
detach a Qt_widget_tool. As in the previous tutorial we use the
generic tool Qt_widget_get_point and a toolbar button that will
control the process of attaching and detaching.
To use a toolbar, here is what you have to do in the constructor of My_Window:
QToolBar *tools_toolbar;
tools_toolbar = new QToolBar("Tools", this, QMainWindow::Top, TRUE, "Tools");
addToolBar(tools_toolbar, Top, FALSE);
To add a button in the toolbar you have to:
-declare the button in My_Window:
QToolButton *get_point_but; //the toolbar button
-add the button in the toolbar:
get_point_but = new QToolButton(QPixmap( (const char**)point_xpm ),
"Point Tool",
0,
this,
SLOT(pointtool()),
tools_toolbar,
"Point Tool");
The constructor of QToolButton needs a pointer to QMainWindow, that is
"this", and a pointer to a toolbar, that is "tools_toolbar".
To make the button a toggle button:
get_point_but->setToggleButton(TRUE);
Also in the constructor of QToolButton is needed to declare a function
that will be called every time the button is pressed. That is
pointtool(). The first parameter is the icon found in <CGAL/IO/pixmaps/point.xpm>.
@@ -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: tutorial8$(EXE_EXT)
tutorial8$(EXE_EXT): tutorial8.moc tutorial8$(OBJ_EXT)
$(CGAL_CXX) $(EXE_OPT)tutorial8 tutorial8$(OBJ_EXT) $(LDFLAGS)
clean: tutorial8.clean
#---------------------------------------------------------------------#
# suffix rules
#---------------------------------------------------------------------#
.C$(OBJ_EXT):
$(CGAL_CXX) $(CXXFLAGS) $(OBJ_OPT) $<
.C.moc:
$(QT_MOC) $< -o $@
@@ -0,0 +1,101 @@
//demo/Qt_widget/basic/tutorial8/tutorial8.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 <qtoolbar.h>
#include <qtoolbutton.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>
#include <CGAL/IO/pixmaps/point.xpm>
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");
QToolBar *layers_toolbar;
layers_toolbar = new QToolBar("Tools", this,
QMainWindow::Top, TRUE, "Tools");
get_point_button = new QToolButton(layers_toolbar, "Get Point");
get_point_button->setPixmap(QPixmap( (const char**)point_xpm ));
get_point_button->setToggleButton(true);
widget->attach(&v);
widget->attach(&get_point);
get_point_button->toggle();
connect(get_point_button, SIGNAL(stateChanged(int)),
&get_point, SLOT(stateChanged(int)));
connect(widget, SIGNAL(new_cgal_object(CGAL::Object)),
this, SLOT(get_object(CGAL::Object)));
}
~My_window(){delete widget;}
private slots:
//this function is called every time a tool creates a Cgal object
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; //the instance of Qt_widget
My_layer v; //an instance of a layer
CGAL::Qt_widget_standard_toolbar *stoolbar;
//the standard toolbar
CGAL::Qt_widget_get_point<Rep> get_point;
//the generic tool that creates Cgal points
QToolButton *get_point_button;//the toolbar button
};
#include "tutorial8.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