| ------------------------------------------------------------------------ | r58172 | lrineau | 2010-08-20 11:21:30 +0200 (Fri, 20 Aug 2010) | 3 lines | Changed paths: | M /branches/CGAL-3.7-branch/Arithmetic_kernel/test/Arithmetic_kernel/CMakeLists.txt | | Fix buggy CMake logic: the GMP_arithmetic_kernel.cpp must me configured | only once. | | ------------------------------------------------------------------------ | r58173 | lrineau | 2010-08-20 11:25:35 +0200 (Fri, 20 Aug 2010) | 2 lines | Changed paths: | M /branches/CGAL-3.7-branch/BGL/examples/BGL_arrangement_2 | M /branches/CGAL-3.7-branch/BGL/examples/BGL_arrangement_2/dual.cpp | M /branches/CGAL-3.7-branch/BGL/examples/BGL_arrangement_2/primal.cpp | | Fix warning about deprecated included headers. | | ------------------------------------------------------------------------ | r58174 | lrineau | 2010-08-20 11:39:25 +0200 (Fri, 20 Aug 2010) | 3 lines | Changed paths: | M /branches/CGAL-3.7-branch/Boolean_set_operations_2/test/Boolean_set_operations_2/test_polygon_validation.cpp | | Modify the test file so that the check function do not display warnings | that result in a 'w' in the testsuite. | | ------------------------------------------------------------------------ | r58175 | lrineau | 2010-08-20 11:45:26 +0200 (Fri, 20 Aug 2010) | 9 lines | Changed paths: | M /branches/CGAL-3.7-branch/GraphicsView/demo/Bounding_volumes/Bounding_volumes.cpp | | Fix warnings: | | test/Bounding_volumes_Demo/Bounding_volumes.cpp: In constructor `MainWindow::MainWindow()': | test/Bounding_volumes_Demo/Bounding_volumes.cpp:71: warning: `MainWindow::P' will be initialized after | test/Bounding_volumes_Demo/Bounding_volumes.cpp:120: warning: base `CGAL::Qt::DemosMainWindow' | test/Bounding_volumes_Demo/Bounding_volumes.cpp:120: warning: when initialized here | test/Bounding_volumes_Demo/Bounding_volumes.cpp: In member function `void MainWindow::update()': | test/Bounding_volumes_Demo/Bounding_volumes.cpp:247: warning: comparison between signed and unsigned integer expressions | | ------------------------------------------------------------------------ | r58177 | lrineau | 2010-08-20 11:47:06 +0200 (Fri, 20 Aug 2010) | 3 lines | Changed paths: | M /branches/CGAL-3.7-branch/Min_circle_2/include/CGAL/Min_circle_2.h | | Fix warning: | include/CGAL/Min_circle_2.h:197: warning: comparison between signed and unsigned integer expressions | | ------------------------------------------------------------------------ | r58178 | lrineau | 2010-08-20 11:49:09 +0200 (Fri, 20 Aug 2010) | 4 lines | Changed paths: | M /branches/CGAL-3.7-branch/STL_Extension/include/CGAL/assertions.h | | Avoid a warning if NDEBUG and CGAL_NDEBUG are both defined: | | include/CGAL/assertions.h:59:1: warning: "CGAL_NDEBUG" redefined | | ------------------------------------------------------------------------ | r58179 | lrineau | 2010-08-20 11:50:54 +0200 (Fri, 20 Aug 2010) | 8 lines | Changed paths: | M /branches/CGAL-3.7-branch/GraphicsView/include/CGAL/Qt/GraphicsViewCircularArcInput.h | | Fix a warning: | | include/CGAL/Qt/GraphicsViewCircularArcInput.h: In constructor 'CGAL::Qt::GraphicsViewCircularArcInput<K>::GraphicsViewCircularArcInput(QObject*, QGraphicsScene*) [with K = CGAL::Circular_kernel_2<CGAL::Cartesian<CGAL::Quotient<CGAL::MP_Float> >, CGAL::Algebraic_kernel_for_circles_2_2<CGAL::Quotient<CGAL::MP_Float> > >]': | cmake/platforms/i686_Linux-2.6_g++-4.1.2_CentOS-5.1/test/Circular_kernel_2_Demo/Circular_kernel_2.cpp:107: instantiated from here | include/CGAL/Qt/GraphicsViewCircularArcInput.h:73: warning: 'CGAL::Qt::GraphicsViewCircularArcInput<CGAL::Circular_kernel_2<CGAL::Cartesian<CGAL::Quotient<CGAL::MP_Float> >, CGAL::Algebraic_kernel_for_circles_2_2<CGAL::Quotient<CGAL::MP_Float> > > >::scene_' will be initialized after | include/CGAL/Qt/GraphicsViewCircularArcInput.h:68: warning: 'int CGAL::Qt::GraphicsViewCircularArcInput<CGAL::Circular_kernel_2<CGAL::Cartesian<CGAL::Quotient<CGAL::MP_Float> >, CGAL::Algebraic_kernel_for_circles_2_2<CGAL::Quotient<CGAL::MP_Float> > > >::count' | include/CGAL/Qt/GraphicsViewCircularArcInput.h:79: warning: when initialized here | | ------------------------------------------------------------------------ | r58180 | lrineau | 2010-08-20 11:56:19 +0200 (Fri, 20 Aug 2010) | 21 lines | Changed paths: | M /branches/CGAL-3.7-branch/Convex_hull_d/include/CGAL/Delaunay_d.h | | Fix warnings: | | include/CGAL/Delaunay_d.h: In member function 'CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_iterator& CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_iterator::operator++() [with R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >, Lifted_R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >]': | include/CGAL/Delaunay_d.h:1011: instantiated from 'std::list<typename CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_handle, std::allocator<typename CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_handle> > CGAL::Delaunay_d<R_, Lifted_R_>::all_simplices(CGAL::Delaunay_d<R_, Lifted_R_>::Delaunay_voronoi_kind) const [with R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >, Lifted_R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >]' | cmake/platforms/i686_Linux-2.6_g++-4.3.3_CentOS-5.1-O2/test/Convex_hull_d/delaunay_d-test.cpp:74: instantiated from here | include/CGAL/Delaunay_d.h:229: warning: suggest parentheses around && within || | include/CGAL/Delaunay_d.h: In member function 'CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_iterator& CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_iterator::operator++() [with R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >, Lifted_R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >]': | include/CGAL/Delaunay_d.h:1011: instantiated from 'std::list<typename CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_handle, std::allocator<typename CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_handle> > CGAL::Delaunay_d<R_, Lifted_R_>::all_simplices(CGAL::Delaunay_d<R_, Lifted_R_>::Delaunay_voronoi_kind) const [with R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >, Lifted_R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >]' | cmake/platforms/i686_Linux-2.6_g++-4.3.3_CentOS-5.1-O2/test/Convex_hull_d/delaunay_d-test.cpp:162: instantiated from here | include/CGAL/Delaunay_d.h:229: warning: suggest parentheses around && within || | include/CGAL/Delaunay_d.h: In constructor 'CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_iterator::Simplex_iterator(CGAL::Delaunay_d<R_, Lifted_R_>*, typename CGAL::Convex_hull_d<Lifted_R_>::Simplex_iterator, CGAL::Delaunay_d<R_, Lifted_R_>::Delaunay_voronoi_kind) [with R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >, Lifted_R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >]': | include/CGAL/Delaunay_d.h:575: instantiated from 'CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_iterator CGAL::Delaunay_d<R_, Lifted_R_>::simplices_begin(CGAL::Delaunay_d<R_, Lifted_R_>::Delaunay_voronoi_kind) [with R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >, Lifted_R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >]' | include/CGAL/Delaunay_d.h:1011: instantiated from 'std::list<typename CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_handle, std::allocator<typename CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_handle> > CGAL::Delaunay_d<R_, Lifted_R_>::all_simplices(CGAL::Delaunay_d<R_, Lifted_R_>::Delaunay_voronoi_kind) const [with R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >, Lifted_R_ = CGAL::Cartesian_d<double, CGAL::Linear_algebraCd<double, std::allocator<double> > >]' | cmake/platforms/i686_Linux-2.6_g++-4.3.3_CentOS-5.1-O2/test/Convex_hull_d/delaunay_d-test.cpp:74: instantiated from here | include/CGAL/Delaunay_d.h:213: warning: suggest parentheses around && within || | include/CGAL/Delaunay_d.h: In constructor 'CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_iterator::Simplex_iterator(CGAL::Delaunay_d<R_, Lifted_R_>*, typename CGAL::Convex_hull_d<Lifted_R_>::Simplex_iterator, CGAL::Delaunay_d<R_, Lifted_R_>::Delaunay_voronoi_kind) [with R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >, Lifted_R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >]': | include/CGAL/Delaunay_d.h:575: instantiated from 'CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_iterator CGAL::Delaunay_d<R_, Lifted_R_>::simplices_begin(CGAL::Delaunay_d<R_, Lifted_R_>::Delaunay_voronoi_kind) [with R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >, Lifted_R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >]' | include/CGAL/Delaunay_d.h:1011: instantiated from 'std::list<typename CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_handle, std::allocator<typename CGAL::Delaunay_d<R_, Lifted_R_>::Simplex_handle> > CGAL::Delaunay_d<R_, Lifted_R_>::all_simplices(CGAL::Delaunay_d<R_, Lifted_R_>::Delaunay_voronoi_kind) const [with R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >, Lifted_R_ = CGAL::Homogeneous_d<CGAL::Gmpz, CGAL::Linear_algebraHd<CGAL::Gmpz, std::allocator<CGAL::Gmpz> > >]' | cmake/platforms/i686_Linux-2.6_g++-4.3.3_CentOS-5.1-O2/test/Convex_hull_d/delaunay_d-test.cpp:162: instantiated from here | include/CGAL/Delaunay_d.h:213: warning: suggest parentheses around && within || | | ------------------------------------------------------------------------ | r58181 | lrineau | 2010-08-20 12:11:35 +0200 (Fri, 20 Aug 2010) | 3 lines | Changed paths: | M /branches/CGAL-3.7-branch/Installation/test/Installation/link_to_CGAL_Qt4.cpp | | Fix a warning: | test/Installation/link_to_CGAL_Qt4.cpp:11: warning: the address of 'f' will never be NULL | | ------------------------------------------------------------------------ | r58182 | lrineau | 2010-08-20 12:15:14 +0200 (Fri, 20 Aug 2010) | 3 lines | Changed paths: | M /branches/CGAL-3.7-branch/Jet_fitting_3/include/CGAL/Monge_via_jet_fitting.h | | Fix a warning: | include/CGAL/Monge_via_jet_fitting.h:425: warning: comparison between signed and unsigned integer expressions | | ------------------------------------------------------------------------ | r58183 | lrineau | 2010-08-20 12:19:36 +0200 (Fri, 20 Aug 2010) | 4 lines | Changed paths: | M /branches/CGAL-3.7-branch/Min_circle_2/include/CGAL/Min_circle_2.h | M /branches/CGAL-3.7-branch/Min_circle_2/test/Min_circle_2/test_Min_circle.cpp | | Fix warnings: | "comparison between signed and unsigned integer expressions" | and "unsigned is always >= 0" | | ------------------------------------------------------------------------ | r58184 | lrineau | 2010-08-20 12:22:35 +0200 (Fri, 20 Aug 2010) | 2 lines | Changed paths: | M /branches/CGAL-3.7-branch/Min_ellipse_2/test/Min_ellipse_2/test_Min_ellipse_2.cpp | | Fix warnings about comparison between signed and unsigned. | | ------------------------------------------------------------------------
214 lines
5.2 KiB
C++
214 lines
5.2 KiB
C++
// Copyright (c) 2008 GeometryFactory Sarl (France).
|
|
// All rights reserved.
|
|
//
|
|
// This file is part of CGAL (www.cgal.org); you may redistribute it under
|
|
// the terms of the Q Public License version 1.0.
|
|
// See the file LICENSE.QPL distributed with CGAL.
|
|
//
|
|
// Licensees holding a valid commercial license may use this file in
|
|
// accordance with the commercial license agreement provided with the software.
|
|
//
|
|
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|
//
|
|
// $URL$
|
|
// $Id$
|
|
//
|
|
//
|
|
// Author(s) : Andreas Fabri <Andreas.Fabri@geometryfactory.com>
|
|
// Laurent Rineau <Laurent.Rineau@geometryfactory.com>
|
|
|
|
#ifndef CGAL_QT_GRAPHICS_VIEW_CIRCULAR_ARC_INPUT_H
|
|
#define CGAL_QT_GRAPHICS_VIEW_CIRCULAR_ARC_INPUT_H
|
|
|
|
#include <QGraphicsView>
|
|
#include <QRectF>
|
|
#include <QPointF>
|
|
#include <QGraphicsItem>
|
|
#include <QGraphicsEllipseItem>
|
|
#include <QGraphicsLineItem>
|
|
#include <QGraphicsScene>
|
|
#include <QGraphicsSceneMouseEvent>
|
|
#include <QPainter>
|
|
#include <QStyleOption>
|
|
|
|
#include <CGAL/Qt/Converter.h>
|
|
#include <CGAL/Qt/GraphicsViewInput.h>
|
|
#include <CGAL/Qt/CircularArcGraphicsItem.h>
|
|
|
|
#include <CGAL/array.h>
|
|
|
|
namespace CGAL {
|
|
namespace Qt {
|
|
|
|
template <typename K>
|
|
class GraphicsViewCircularArcInput : public GraphicsViewInput
|
|
{
|
|
public:
|
|
GraphicsViewCircularArcInput(QObject *parent, QGraphicsScene* s);
|
|
~GraphicsViewCircularArcInput();
|
|
|
|
protected:
|
|
|
|
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
|
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
|
virtual void keyPressEvent(QKeyEvent *event);
|
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
|
|
|
|
|
|
|
|
|
private:
|
|
typedef typename K::Circular_arc_2 Circular_arc_2;
|
|
typedef typename K::Line_arc_2 Line_arc_2;
|
|
typedef typename K::Point_2 Point_2;
|
|
typedef typename K::Segment_2 Segment_2;
|
|
|
|
int count;
|
|
QGraphicsLineItem *qline;
|
|
CircularArcGraphicsItem<K> *qcarc;
|
|
QPointF qp, qq, qr;
|
|
Point_2 p, q, r, ap, aq, ar;
|
|
QGraphicsScene *scene_;
|
|
Converter<K> convert;
|
|
};
|
|
|
|
|
|
template <typename K>
|
|
GraphicsViewCircularArcInput<K>::GraphicsViewCircularArcInput(QObject *parent, QGraphicsScene* s)
|
|
: GraphicsViewInput(parent), count(0), scene_(s)
|
|
{
|
|
qline = new QGraphicsLineItem();
|
|
qcarc = new CircularArcGraphicsItem<K>();
|
|
qline->hide();
|
|
qcarc->hide();
|
|
s->addItem(qline);
|
|
s->addItem(qcarc);
|
|
}
|
|
|
|
|
|
template <typename K>
|
|
GraphicsViewCircularArcInput<K>::~GraphicsViewCircularArcInput()
|
|
{
|
|
// do not delete qline and qcarc, because 's' owns them and will delete them.
|
|
}
|
|
|
|
|
|
template <typename K>
|
|
void
|
|
GraphicsViewCircularArcInput<K>::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|
{
|
|
if(event->modifiers() & ::Qt::ShiftModifier){
|
|
return;
|
|
}
|
|
if(count == 0){
|
|
qp = event->scenePos();
|
|
p = convert(qp);
|
|
qline->setLine(QLineF(qp, qp));
|
|
qline->show();
|
|
count = 1;
|
|
} else if(count == 1){
|
|
qq = event->scenePos();
|
|
qline->setLine(QLineF(qp, qq));
|
|
q = convert(qq);
|
|
if( (event->button() == ::Qt::RightButton) && (p != q) ){
|
|
qline->hide();
|
|
emit generate(CGAL::make_object(Line_arc_2(Segment_2(p,q))));
|
|
count = 0;
|
|
} else {
|
|
count = 2;
|
|
}
|
|
} else if(count == 2){
|
|
qr = event->scenePos();
|
|
r = convert(qr);
|
|
typename K::Collinear_2 collinear;
|
|
if(! collinear(p,q,r)){
|
|
qcarc->hide();
|
|
emit generate(make_object(qcarc->arc()));
|
|
count = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
template <typename K>
|
|
void
|
|
GraphicsViewCircularArcInput<K>::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|
{
|
|
if(count == 0){
|
|
qcarc->hide();
|
|
qline->hide();
|
|
return;
|
|
} else if(count == 1) {
|
|
qcarc->hide();
|
|
qq = event->scenePos();
|
|
q = convert(qq);
|
|
qline->setLine(QLineF(qp, qq));
|
|
qline->show();
|
|
} else if(count == 2){
|
|
qline->hide();
|
|
qr = event->scenePos();
|
|
r = convert(qr);
|
|
typename K::Collinear_2 collinear;
|
|
if(collinear(p,q,r)){
|
|
qcarc->hide();
|
|
return;
|
|
} else {
|
|
if(CGAL::orientation(p, q, r) == CGAL::RIGHT_TURN) {
|
|
ap = p; ar = r; aq = q;
|
|
qcarc->setArc(Circular_arc_2(p,r,q));
|
|
} else {
|
|
ap = q; ar = r; aq = p;
|
|
qcarc->setArc(Circular_arc_2(q,r,p));
|
|
}
|
|
qcarc->show();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
template <typename K>
|
|
void
|
|
GraphicsViewCircularArcInput<K>::keyPressEvent ( QKeyEvent * event )
|
|
{
|
|
if(event->key() == ::Qt::Key_Delete){
|
|
if(count>0){
|
|
--count;
|
|
}
|
|
}
|
|
|
|
if(event->key() == ::Qt::Key_Escape){
|
|
count = 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
template <typename K>
|
|
bool
|
|
GraphicsViewCircularArcInput<K>::eventFilter(QObject *obj, QEvent *event)
|
|
{
|
|
if (event->type() == QEvent::GraphicsSceneMousePress) {
|
|
QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
|
|
mousePressEvent(mouseEvent);
|
|
return true;
|
|
} else if (event->type() == QEvent::GraphicsSceneMouseMove) {
|
|
QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
|
|
mouseMoveEvent(mouseEvent);
|
|
return true;
|
|
} else if (event->type() == QEvent::KeyPress) {
|
|
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
|
keyPressEvent(keyEvent);
|
|
return true;
|
|
} else{
|
|
// standard event processing
|
|
return QObject::eventFilter(obj, event);
|
|
}
|
|
}
|
|
|
|
} // namespace Qt
|
|
} // namespace CGAL
|
|
|
|
#endif // CGAL_QT_GRAPHICS_VIEW_CIRCULAR_ARC_INPUT_H
|