mirror of https://github.com/CGAL/cgal
after presentation at Inria
This commit is contained in:
parent
132153d513
commit
2d3816ec73
|
|
@ -27,7 +27,7 @@ link_directories(../../src/CGALQt4)
|
|||
qt4_wrap_ui( UI_FILES MainWindow.ui )
|
||||
|
||||
# qrc files (resources files, that contain icons, at least)
|
||||
qt4_add_resources ( RESOURCE_FILES ./MainWindow.qrc )
|
||||
qt4_add_resources ( RESOURCE_FILES ./MainWindow.qrc ../icons/Input.qrc ../icons/File.qrc ../icons/Triangulation_2.qrc )
|
||||
|
||||
# use the Qt MOC preprocessor on classes that derives from QObject
|
||||
qt4_automoc( MainWindow.cpp )
|
||||
|
|
@ -39,8 +39,9 @@ add_executable ( delaunay main.cpp MainWindow.cpp ${UI_FILES} ${RESOURCE_FILES}
|
|||
target_link_libraries( delaunay ${QT_LIBRARIES} )
|
||||
if ( NOT AUTO_LINK_ENABLED )
|
||||
# If auto-link is not enabled (on Linux for example), link with libCGAL explicitly.
|
||||
target_link_libraries( delaunay CGAL CGAL-Qt4 )
|
||||
target_link_libraries( delaunay CGAL )
|
||||
endif()
|
||||
target_link_libraries( delaunay CGAL-Qt4 )
|
||||
|
||||
#----------------------------------------
|
||||
# minimal graphics view executable: min
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@
|
|||
#include <CGAL/Constrained_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
#include "QTriangulationCircumcenter_2.h"
|
||||
#include "QTriangulationMovingPoint_2.h"
|
||||
#include <CGAL/IO/QtPolylineInput.h>
|
||||
#include <CGAL/IO/QtTriangulationGraphicsItem.h>
|
||||
#include <CGAL/IO/QtConstrainedTriangulationGraphicsItem.h>
|
||||
#include "TriangulationCircumcircle.h"
|
||||
#include "TriangulationMovingPoint_2.h"
|
||||
#include <CGAL/Qt/GraphicsViewPolylineInput.h>
|
||||
#include <CGAL/Qt/TriangulationGraphicsItem.h>
|
||||
#include <CGAL/Qt/ConstrainedTriangulationGraphicsItem.h>
|
||||
|
||||
#include <CGAL/IO/QtNavigation.h>
|
||||
#include <CGAL/Qt/GraphicsViewNavigation.h>
|
||||
|
||||
#include <QGLWidget>
|
||||
|
||||
|
|
@ -30,7 +30,7 @@ MainWindow::MainWindow()
|
|||
setupStatusBar();
|
||||
|
||||
// Add a GraphicItem for the Delaunay triangulation
|
||||
dgi = new CGAL::QtConstrainedTriangulationGraphicsItem<Delaunay>(&dt);
|
||||
dgi = new CGAL::Qt::ConstrainedTriangulationGraphicsItem<Delaunay>(&dt);
|
||||
|
||||
QObject::connect(this, SIGNAL(changed()),
|
||||
dgi, SLOT(modelChanged()));
|
||||
|
|
@ -41,19 +41,19 @@ MainWindow::MainWindow()
|
|||
// Setup input handlers. They get events before the scene gets them
|
||||
// and the input they generate is passed to the triangulation with
|
||||
// the signal/slot mechanism
|
||||
pi = new CGAL::QtPolylineInput<K>(this, &scene, 0, false); // inputs polylines which are not closed
|
||||
pi = new CGAL::Qt::GraphicsViewPolylineInput<K>(this, &scene, 0, false); // inputs polylines which are not closed
|
||||
|
||||
QObject::connect(pi, SIGNAL(generate(CGAL::Object)),
|
||||
this, SLOT(process(CGAL::Object)));
|
||||
this, SLOT(processInput(CGAL::Object)));
|
||||
|
||||
mp = new CGAL::QTriangulationMovingPoint_2<Delaunay>(&dt, this);
|
||||
// QTriangulationMovingPoint_2<Delaunay> generates an empty Object() each
|
||||
mp = new CGAL::Qt::TriangulationMovingPoint<Delaunay>(&dt, this);
|
||||
// TriangulationMovingPoint<Delaunay> generates an empty Object() each
|
||||
// time the moving point moves.
|
||||
// The following connection is for the purpose of emitting changed().
|
||||
QObject::connect(mp, SIGNAL(generate(CGAL::Object)),
|
||||
this, SLOT(process(CGAL::Object)));
|
||||
this, SLOT(processInput(CGAL::Object)));
|
||||
|
||||
tcc = new CGAL::QTriangulationCircumcenter_2<Delaunay>(&scene, &dt, this);
|
||||
tcc = new CGAL::Qt::TriangulationCircumcircle<Delaunay>(&scene, &dt, this);
|
||||
tcc->setPen(QPen(Qt::red, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ MainWindow::MainWindow()
|
|||
|
||||
// The navigation adds zooming and translation functionality to the
|
||||
// QGraphicsView
|
||||
navigation = new CGAL::QtNavigation(this->graphicsView);
|
||||
navigation = new CGAL::Qt::GraphicsViewNavigation(this->graphicsView);
|
||||
this->graphicsView->viewport()->installEventFilter(navigation);
|
||||
this->graphicsView->installEventFilter(navigation);
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ MainWindow::MainWindow()
|
|||
}
|
||||
|
||||
void
|
||||
MainWindow::process(CGAL::Object o)
|
||||
MainWindow::processInput(CGAL::Object o)
|
||||
{
|
||||
std::list<Point_2> points;
|
||||
if(CGAL::assign(points, o)){
|
||||
|
|
|
|||
|
|
@ -12,13 +12,15 @@
|
|||
#include "ui_MainWindow.h"
|
||||
|
||||
namespace CGAL {
|
||||
class QtNavigation;
|
||||
template <class Delaunay> class QtTriangulationGraphicsItem;
|
||||
template <class Delaunay> class QtConstrainedTriangulationGraphicsItem;
|
||||
template <class Delaunay> class QTriangulationMovingPoint_2;
|
||||
template <class Delaunay> class QTriangulationCircumcenter_2;
|
||||
template <class K> class QtPolylineInput;
|
||||
} // end namespace CGAL
|
||||
namespace Qt {
|
||||
class GraphicsViewNavigation;
|
||||
template <class Delaunay> class TriangulationGraphicsItem;
|
||||
template <class Delaunay> class ConstrainedTriangulationGraphicsItem;
|
||||
template <class Delaunay> class TriangulationMovingPoint;
|
||||
template <class Delaunay> class TriangulationCircumcircle;
|
||||
template <class K> class GraphicsItemPolylineInput;
|
||||
} // namespace Qt
|
||||
} // namespace CGAL
|
||||
|
||||
class QLabel;
|
||||
class QWidget;
|
||||
|
|
@ -42,15 +44,15 @@ private:
|
|||
Delaunay dt;
|
||||
QGraphicsScene scene;
|
||||
|
||||
CGAL::QtNavigation* navigation;
|
||||
CGAL::Qt::GraphicsViewNavigation* navigation;
|
||||
|
||||
CGAL::QtConstrainedTriangulationGraphicsItem<Delaunay> * dgi;
|
||||
CGAL::Qt::ConstrainedTriangulationGraphicsItem<Delaunay> * dgi;
|
||||
|
||||
QLabel* xycoord ;
|
||||
|
||||
CGAL::QTriangulationMovingPoint_2<Delaunay> * mp;
|
||||
CGAL::QtPolylineInput<K> * pi;
|
||||
CGAL::QTriangulationCircumcenter_2<Delaunay> *tcc;
|
||||
CGAL::Qt::TriangulationMovingPoint<Delaunay> * mp;
|
||||
CGAL::Qt::GraphicsViewPolylineInput<K> * pi;
|
||||
CGAL::Qt::TriangulationCircumcircle<Delaunay> *tcc;
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
|
|
@ -82,7 +84,7 @@ private:
|
|||
|
||||
public slots:
|
||||
|
||||
void process(CGAL::Object o);
|
||||
void processInput(CGAL::Object o);
|
||||
|
||||
void on_actionUse_OpenGL_toggled(bool checked);
|
||||
|
||||
|
|
|
|||
|
|
@ -13,18 +13,9 @@
|
|||
<string>CGAL Constrained Delaunay Triangulation</string>
|
||||
</property>
|
||||
<property name="windowIcon" >
|
||||
<iconset resource="../icons/Logos.qrc" >
|
||||
<normaloff>:/cgal/logos/cgal_logo.xpm</normaloff>:/cgal/logos/cgal_logo.xpm</iconset>
|
||||
<iconset resource="../icons/Logos.qrc" >:/cgal/logos/cgal_logo.xpm</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>66</y>
|
||||
<width>400</width>
|
||||
<height>209</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<item row="0" column="0" >
|
||||
<widget class="QGraphicsView" name="graphicsView" >
|
||||
|
|
@ -50,7 +41,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>29</height>
|
||||
<height>19</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile" >
|
||||
|
|
@ -63,12 +54,14 @@
|
|||
<addaction name="actionSaveConstraints" />
|
||||
<addaction name="separator" />
|
||||
<addaction name="actionExit" />
|
||||
<addaction name="actionToto" />
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdit" >
|
||||
<property name="title" >
|
||||
<string>&Edit</string>
|
||||
</property>
|
||||
<addaction name="actionInsertRandomPoints" />
|
||||
<addaction name="actionDisplay_Nearest_Neighbor" />
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools" >
|
||||
<property name="title" >
|
||||
|
|
@ -101,25 +94,8 @@
|
|||
<addaction name="menuOptions" />
|
||||
<addaction name="menuHelp" />
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>275</y>
|
||||
<width>400</width>
|
||||
<height>25</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar" />
|
||||
<widget class="QToolBar" name="fileToolBar" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>29</y>
|
||||
<width>116</width>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>File Tools</string>
|
||||
</property>
|
||||
|
|
@ -134,14 +110,6 @@
|
|||
<addaction name="actionSaveConstraints" />
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar" >
|
||||
<property name="geometry" >
|
||||
<rect>
|
||||
<x>116</x>
|
||||
<y>29</y>
|
||||
<width>284</width>
|
||||
<height>37</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<string>Visualization Tools</string>
|
||||
</property>
|
||||
|
|
@ -158,6 +126,18 @@
|
|||
<addaction name="actionCircumcenter" />
|
||||
<addaction name="actionRecenter" />
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar_2" >
|
||||
<property name="windowTitle" >
|
||||
<string>toolBar_2</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea" >
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak" >
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionDisplay_Nearest_Neighbor" />
|
||||
</widget>
|
||||
<action name="actionAbout" >
|
||||
<property name="text" >
|
||||
<string>&About</string>
|
||||
|
|
@ -189,8 +169,7 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="MainWindow.qrc" >
|
||||
<normaloff>:/cgal/Actions/icons/movingPoint.png</normaloff>:/cgal/Actions/icons/movingPoint.png</iconset>
|
||||
<iconset resource="MainWindow.qrc" >:/cgal/Actions/icons/movingPoint.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Moving Point</string>
|
||||
|
|
@ -213,8 +192,7 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons/Input.qrc" >
|
||||
<normaloff>:/cgal/Input/inputPolyline.png</normaloff>:/cgal/Input/inputPolyline.png</iconset>
|
||||
<iconset resource="../icons/Input.qrc" >:/cgal/Input/inputPolyline.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Insert Polyline</string>
|
||||
|
|
@ -228,8 +206,7 @@
|
|||
</action>
|
||||
<action name="actionClear" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons/File.qrc" >
|
||||
<normaloff>:/cgal/fileToolbar/fileNew.png</normaloff>:/cgal/fileToolbar/fileNew.png</iconset>
|
||||
<iconset resource="../icons/File.qrc" >:/cgal/fileToolbar/fileNew.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Clear</string>
|
||||
|
|
@ -246,8 +223,7 @@
|
|||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons/Triangulation_2.qrc" >
|
||||
<normaloff>:/cgal/Triangulation_2/Voronoi_diagram_2.png</normaloff>:/cgal/Triangulation_2/Voronoi_diagram_2.png</iconset>
|
||||
<iconset resource="../icons/Triangulation_2.qrc" >:/cgal/Triangulation_2/Voronoi_diagram_2.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Show &Voronoi Diagram</string>
|
||||
|
|
@ -264,8 +240,7 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons/Triangulation_2.qrc" >
|
||||
<normaloff>:/cgal/Triangulation_2/Delaunay_triangulation_2.png</normaloff>:/cgal/Triangulation_2/Delaunay_triangulation_2.png</iconset>
|
||||
<iconset resource="../icons/Triangulation_2.qrc" >:/cgal/Triangulation_2/Delaunay_triangulation_2.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Show &Delaunay Triangulation</string>
|
||||
|
|
@ -276,8 +251,7 @@
|
|||
</action>
|
||||
<action name="actionLoadConstraints" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons/File.qrc" >
|
||||
<normaloff>:/cgal/fileToolbar/fileOpen.png</normaloff>:/cgal/fileToolbar/fileOpen.png</iconset>
|
||||
<iconset resource="../icons/File.qrc" >:/cgal/fileToolbar/fileOpen.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Load Constraints</string>
|
||||
|
|
@ -288,8 +262,7 @@
|
|||
</action>
|
||||
<action name="actionSaveConstraints" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons/File.qrc" >
|
||||
<normaloff>:/cgal/fileToolbar/fileSave.png</normaloff>:/cgal/fileToolbar/fileSave.png</iconset>
|
||||
<iconset resource="../icons/File.qrc" >:/cgal/fileToolbar/fileSave.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Save Constraints</string>
|
||||
|
|
@ -303,8 +276,7 @@
|
|||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="MainWindow.qrc" >
|
||||
<normaloff>:/cgal/Actions/icons/circumcenter.png</normaloff>:/cgal/Actions/icons/circumcenter.png</iconset>
|
||||
<iconset resource="MainWindow.qrc" >:/cgal/Actions/icons/circumcenter.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>&Circumcenter</string>
|
||||
|
|
@ -329,8 +301,7 @@
|
|||
</action>
|
||||
<action name="actionRecenter" >
|
||||
<property name="icon" >
|
||||
<iconset resource="../icons/Input.qrc" >
|
||||
<normaloff>:/cgal/Input/zoom-best-fit.svg</normaloff>:/cgal/Input/zoom-best-fit.svg</iconset>
|
||||
<iconset resource="../icons/Input.qrc" >:/cgal/Input/zoom-best-fit.svg</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Re&center the viewport</string>
|
||||
|
|
@ -350,6 +321,22 @@
|
|||
<string>Ctrl+A</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionToto" >
|
||||
<property name="text" >
|
||||
<string>toto</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDisplay_Nearest_Neighbor" >
|
||||
<property name="checkable" >
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon" >
|
||||
<iconset resource="MainWindow.qrc" >:/cgal/Actions/icons/circumcenter.png</iconset>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<string>Display Nearest Neighbor</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="MainWindow.qrc" />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef CGAL_Q_TRIANGULATION_CIRCUMCENTER_2
|
||||
#define CGAL_Q_TRIANGULATION_CIRCUMCENTER_2
|
||||
#ifndef CGAL_QT_TRIANGULATION_CIRCUMCIRCLE_H
|
||||
#define CGAL_QT_TRIANGULATION_CIRCUMCIRCLE_H
|
||||
|
||||
#include <CGAL/IO/QtInput.h>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsEllipseItem>
|
||||
|
|
@ -9,16 +8,17 @@
|
|||
#include <QPen>
|
||||
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
|
||||
#include <CGAL/Qt/GraphicsViewInput.h>
|
||||
|
||||
namespace CGAL {
|
||||
namespace Qt {
|
||||
|
||||
template <typename DT>
|
||||
class QTriangulationCircumcenter_2 : public QtInput
|
||||
class TriangulationCircumcircle_2 : public GraphicsViewInput
|
||||
{
|
||||
public:
|
||||
QTriangulationCircumcenter_2(QGraphicsScene* s, DT * dt_, QObject* parent);
|
||||
~QTriangulationCircumcenter_2();
|
||||
QTriangulationCircumcircle_2(QGraphicsScene* s, DT * dt_, QObject* parent);
|
||||
~QTriangulationCircumcircle_2();
|
||||
|
||||
void setPen(const QPen& pen);
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ private:
|
|||
|
||||
|
||||
template <typename T>
|
||||
QTriangulationCircumcenter_2<T>::QTriangulationCircumcenter_2(QGraphicsScene* s,
|
||||
QTriangulationCircumcircle_2<T>::QTriangulationCircumcircle_2(QGraphicsScene* s,
|
||||
T * dt_,
|
||||
QObject* parent)
|
||||
: QtInput(parent), dt(dt_), scene_(s)
|
||||
|
|
@ -50,28 +50,32 @@ QTriangulationCircumcenter_2<T>::QTriangulationCircumcenter_2(QGraphicsScene* s,
|
|||
scene_->addItem(circle);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
QTriangulationCircumcenter_2<T>::~QTriangulationCircumcenter_2()
|
||||
QTriangulationCircumcircle_2<T>::~QTriangulationCircumcircle_2()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
QTriangulationCircumcenter_2<T>::setPen(const QPen& pen)
|
||||
QTriangulationCircumcircle_2<T>::setPen(const QPen& pen)
|
||||
{
|
||||
circle->setPen(pen);
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
QTriangulationCircumcenter_2<T>::show()
|
||||
QTriangulationCircumcircle_2<T>::show()
|
||||
{
|
||||
circle->show();
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
QTriangulationCircumcenter_2<T>::hide()
|
||||
QTriangulationCircumcircle_2<T>::hide()
|
||||
{
|
||||
circle->hide();
|
||||
}
|
||||
|
|
@ -79,7 +83,7 @@ QTriangulationCircumcenter_2<T>::hide()
|
|||
|
||||
template <typename T>
|
||||
void
|
||||
QTriangulationCircumcenter_2<T>::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
QTriangulationCircumcircle_2<T>::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(dt->dimension() != 2){
|
||||
circle->hide();
|
||||
|
|
@ -102,7 +106,7 @@ QTriangulationCircumcenter_2<T>::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
template <typename T>
|
||||
bool
|
||||
QTriangulationCircumcenter_2<T>::eventFilter(QObject *obj, QEvent *event)
|
||||
QTriangulationCircumcircle_2<T>::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::GraphicsSceneMouseMove) {
|
||||
QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
|
||||
|
|
@ -114,7 +118,7 @@ QTriangulationCircumcenter_2<T>::eventFilter(QObject *obj, QEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
} // namespace Qt
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_Q_TRIANGULATION_CIRCUMCENTER_2
|
||||
#endif // CGAL_QT_TRIANGULATION_CIRCUMCIRCLE_H
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
#ifndef CGAL_Q_TRIANGULATION_MOVING_POINT_2
|
||||
#define CGAL_Q_TRIANGULATION_MOVING_POINT_2
|
||||
#ifndef CGAL_QT_TRIANGULATION_MOVING_POINT
|
||||
#define CGAL_QT_TRIANGULATION_MOVING_POINT
|
||||
|
||||
#include <CGAL/IO/QtInput.h>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
|
|
@ -10,16 +10,17 @@
|
|||
|
||||
|
||||
namespace CGAL {
|
||||
namespace Qt {
|
||||
|
||||
template <typename DT>
|
||||
class QTriangulationMovingPoint_2 : public QtInput
|
||||
class TriangulationMovingPoint : public GraphicsViewInput
|
||||
{
|
||||
public:
|
||||
typedef typename DT::Face_handle Face_handle;
|
||||
typedef typename DT::Vertex_handle Vertex_handle;
|
||||
typedef typename DT::Point Point;
|
||||
|
||||
QTriangulationMovingPoint_2(DT * dt_, QObject* parent);
|
||||
TriangulationMovingPoint(DT * dt_, QObject* parent);
|
||||
|
||||
protected:
|
||||
void localize_and_insert_point(QPointF qt_point);
|
||||
|
|
@ -36,15 +37,15 @@ protected:
|
|||
|
||||
|
||||
template <typename T>
|
||||
QTriangulationMovingPoint_2<T>::QTriangulationMovingPoint_2(T * dt_,
|
||||
TriangulationMovingPoint_2<T>::TriangulationMovingPoint_2(T * dt_,
|
||||
QObject* parent)
|
||||
: QtInput(parent), dt(dt_), movePointToInsert(false), vh()
|
||||
: GraphicsViewInput(parent), dt(dt_), movePointToInsert(false), vh()
|
||||
{}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
QTriangulationMovingPoint_2<T>::localize_and_insert_point(QPointF qt_point)
|
||||
TriangulationMovingPoint_2<T>::localize_and_insert_point(QPointF qt_point)
|
||||
{
|
||||
Point p(qt_point.x(), qt_point.y());
|
||||
typename T::Locate_type lt;
|
||||
|
|
@ -59,7 +60,7 @@ QTriangulationMovingPoint_2<T>::localize_and_insert_point(QPointF qt_point)
|
|||
|
||||
template <typename T>
|
||||
void
|
||||
QTriangulationMovingPoint_2<T>::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
TriangulationMovingPoint_2<T>::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(dt->number_of_vertices() == 0 ||
|
||||
event->modifiers() != 0 ||
|
||||
|
|
@ -73,7 +74,7 @@ QTriangulationMovingPoint_2<T>::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
template <typename T>
|
||||
void
|
||||
QTriangulationMovingPoint_2<T>::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
TriangulationMovingPoint_2<T>::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
|
||||
if(! movePointToInsert) return;
|
||||
|
|
@ -90,7 +91,7 @@ QTriangulationMovingPoint_2<T>::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
|
||||
template <typename T>
|
||||
void
|
||||
QTriangulationMovingPoint_2<T>::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
TriangulationMovingPoint_2<T>::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if(! movePointToInsert ||
|
||||
event->button() != Qt::LeftButton) {
|
||||
|
|
@ -109,7 +110,7 @@ QTriangulationMovingPoint_2<T>::mouseReleaseEvent(QGraphicsSceneMouseEvent *even
|
|||
|
||||
template <typename T>
|
||||
bool
|
||||
QTriangulationMovingPoint_2<T>::eventFilter(QObject *obj, QEvent *event)
|
||||
TriangulationMovingPoint_2<T>::eventFilter(QObject *obj, QEvent *event)
|
||||
{
|
||||
if (event->type() == QEvent::GraphicsSceneMousePress) {
|
||||
QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
|
||||
|
|
@ -130,7 +131,7 @@ QTriangulationMovingPoint_2<T>::eventFilter(QObject *obj, QEvent *event)
|
|||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Qt
|
||||
} // namespace CGAL
|
||||
|
||||
#endif // CGAL_Q_TRIANGULATION_MOVING_POINT_2
|
||||
#endif // CGAL_QT_TRIANGULATION_MOVING_POINT
|
||||
|
|
|
|||
|
|
@ -1,3 +1,80 @@
|
|||
#include <iostream> // for cout
|
||||
#include <stdlib.h> // for exit
|
||||
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Triangle_3.h>
|
||||
#include <CGAL/Polyhedron_incremental_builder_3.h>
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
|
||||
template <class HDS>
|
||||
class Build_Surface : public CGAL::Modifier_base<HDS>
|
||||
{
|
||||
public:
|
||||
Build_Surface() { }
|
||||
void operator()( HDS& hds );
|
||||
};
|
||||
|
||||
template <class HDS>
|
||||
void Build_Surface< HDS >::operator()( HDS &hds )
|
||||
{
|
||||
/// Build a simple surface made of two triangles.
|
||||
CGAL::Polyhedron_incremental_builder_3<HDS> pB(hds, true);
|
||||
pB.begin_surface( 6, 2, 0);
|
||||
|
||||
typedef typename HDS::Vertex::Point Point;
|
||||
pB.add_vertex( Point( 0.0, 0.0, 0.0));
|
||||
pB.add_vertex( Point( 1.0, 0.0, 0.0));
|
||||
pB.add_vertex( Point( 0.0, 1.0, 0.0));
|
||||
pB.add_vertex( Point( 0.0, 0.0, 1.0));
|
||||
pB.add_vertex( Point( 1.0, 1.0, 1.0));
|
||||
pB.add_vertex( Point( 1.0, 0.0, 1.0));
|
||||
|
||||
// First triangle:
|
||||
pB.begin_facet();
|
||||
pB.add_vertex_to_facet(2);
|
||||
pB.add_vertex_to_facet(4);
|
||||
pB.add_vertex_to_facet(0);
|
||||
pB.end_facet();
|
||||
|
||||
// Second triangle:
|
||||
std::vector< std::size_t> t;
|
||||
t.push_back(0); t.push_back(5); t.push_back(4);
|
||||
if( pB.test_facet(t.begin(), t.end()) == true )
|
||||
std::cout << "Test passed." << std::endl;
|
||||
else
|
||||
{
|
||||
std::cout << "Test failed." << std::endl;
|
||||
exit( 0 ) ;
|
||||
}
|
||||
|
||||
pB.begin_facet();
|
||||
pB.add_vertex_to_facet(t[0]);
|
||||
pB.add_vertex_to_facet(t[1]);
|
||||
pB.add_vertex_to_facet(t[2]);
|
||||
pB.end_facet();
|
||||
|
||||
std::cout << "before end_surface()" << std::endl;
|
||||
pB.end_surface();
|
||||
std::cout << "after end_surface()" << std::endl;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
typedef CGAL::Simple_cartesian<double> Kernel;
|
||||
typedef CGAL::Polyhedron_3<Kernel> Polyhedron;
|
||||
typedef Polyhedron::HalfedgeDS HalfedgeDS;
|
||||
|
||||
Polyhedron P;
|
||||
Build_Surface<HalfedgeDS> surface;
|
||||
P.delegate(surface);
|
||||
std::cout << "Done with surface building." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#if 0
|
||||
#include <iostream>
|
||||
#include <boost/format.hpp>
|
||||
#include <QtGui>
|
||||
|
|
@ -288,3 +365,5 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
#include "min.moc"
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue