Cleanup for unused and backup files
|
|
@ -1,37 +0,0 @@
|
|||
# Created by the script cgal_create_cmake_script
|
||||
# This is the CMake script for compiling a CGAL application.
|
||||
|
||||
project (Periodic_4_hyperbolic_triangulation_2_demo)
|
||||
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
if(POLICY CMP0043)
|
||||
cmake_policy(SET CMP0043 OLD)
|
||||
endif()
|
||||
|
||||
find_package(CGAL COMPONENTS Qt5)
|
||||
include(${CGAL_USE_FILE})
|
||||
|
||||
find_package(Qt5 QUIET COMPONENTS Widgets)
|
||||
|
||||
include_directories (BEFORE ../../../Hyperbolic_triangulation_2/include ../../include include)
|
||||
|
||||
# ui files, created with Qt Designer
|
||||
qt5_wrap_ui( uis Periodic_4_hyperbolic_triangulation_2.ui )
|
||||
|
||||
# qrc files (resources files, that contain icons, at least)
|
||||
qt5_add_resources ( RESOURCE_FILES resources/Periodic_4_hyperbolic_triangulation_2.qrc )
|
||||
|
||||
|
||||
# cpp files
|
||||
|
||||
add_executable ( Periodic_4_hyperbolic_Delaunay_triangulation_2_demo Periodic_4_hyperbolic_Delaunay_triangulation_2_demo.cpp )
|
||||
qt5_use_modules( Periodic_4_hyperbolic_Delaunay_triangulation_2_demo Widgets)
|
||||
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Periodic_4_hyperbolic_Delaunay_triangulation_2_demo )
|
||||
target_link_libraries( Periodic_4_hyperbolic_Delaunay_triangulation_2_demo ${CGAL_LIBRARIES} ${QT_LIBRARIES} ${CGAL_QT_LIBRARIES} )
|
||||
|
||||
|
|
@ -1,859 +0,0 @@
|
|||
#include <fstream>
|
||||
|
||||
// CGAL headers
|
||||
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/Periodic_4_hyperbolic_Delaunay_triangulation_2.h>
|
||||
#include <CGAL/Periodic_4_hyperbolic_Delaunay_triangulation_traits_2.h>
|
||||
#include <CGAL/point_generators_2.h>
|
||||
// unique words
|
||||
#include <CGAL/Square_root_2_field.h>
|
||||
#include <CGAL/Hyperbolic_octagon_translation_matrix.h>
|
||||
#include <CGAL/Hyperbolic_random_points_in_disc_2.h>
|
||||
// to be deleted (iiordano: why?)
|
||||
#include <CGAL/Qt/HyperbolicPainterOstream.h>
|
||||
// for viewportsBbox
|
||||
#include <CGAL/Qt/utility.h>
|
||||
|
||||
// Qt headers
|
||||
#include <QtGui>
|
||||
#include <QString>
|
||||
#include <QActionGroup>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QGraphicsEllipseItem>
|
||||
|
||||
// for filtering
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
// GraphicsView items and event filters (input classes)
|
||||
#include "CGAL/Qt/TriangulationCircumcircle.h"
|
||||
#include "CGAL/Qt/TriangulationMovingPoint.h"
|
||||
#include "CGAL/Qt/TriangulationConflictZone.h"
|
||||
#include "CGAL/Qt/TriangulationRemoveVertex.h"
|
||||
#include "CGAL/Qt/TriangulationPointInputAndConflictZone.h"
|
||||
#include <CGAL/Qt/VoronoiGraphicsItem.h>
|
||||
#include <CGAL/Qt/TriangulationGraphicsItemWithColorInfo.h> // Visualise color
|
||||
#include <CGAL/TranslationInfo.h> // Store color
|
||||
#include <CGAL/Qt/DemosMainWindow.h>
|
||||
|
||||
|
||||
#define INITIAL_RECURSION_DEPTH 4
|
||||
|
||||
// dummy points
|
||||
#include <CGAL/Periodic_4_hyperbolic_Delaunay_triangulation_dummy.h>
|
||||
|
||||
// the two base classes
|
||||
#include "ui_Periodic_4_hyperbolic_Delaunay_triangulation_2.h"
|
||||
|
||||
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel InR;
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel R;
|
||||
|
||||
typedef CGAL::Triangulation_hyperbolic_traits_2<R> THT2;
|
||||
typedef CGAL::Periodic_4_hyperbolic_Delaunay_triangulation_traits_2<R>
|
||||
K;
|
||||
typedef K::Point_2 Point;
|
||||
// keep color
|
||||
typedef TranslationInfo<std::string> Vb_info;
|
||||
typedef CGAL::Triangulation_vertex_base_with_info_2< Vb_info, K >
|
||||
Vb;
|
||||
typedef CGAL::Triangulation_face_base_with_info_2 <CGAL::Hyperbolic_face_info_2, K >
|
||||
Fb;
|
||||
typedef CGAL::Periodic_4_hyperbolic_Delaunay_triangulation_2< K, CGAL::Triangulation_data_structure_2<Vb, Fb> >
|
||||
Delaunay;
|
||||
typedef Delaunay::Vertex_handle Vertex_handle;
|
||||
typedef K::Side_of_fundamental_octagon Side_of_fundamental_octagon;
|
||||
|
||||
|
||||
struct PointsComparator {
|
||||
static double eps;
|
||||
|
||||
bool operator() (const Point& l, const Point& r) const
|
||||
{
|
||||
if(l.x() < r.x() - eps) {
|
||||
return true;
|
||||
}
|
||||
if(l.x() < r.x() + eps) {
|
||||
if(l.y() < r.y() - eps) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
double PointsComparator::eps = 0.0001;
|
||||
|
||||
string glabels[] = { "a", "\\bar{b}", "c", "\\bar{d}", "\\bar{a}", "b", "\\bar{c}", "d" };
|
||||
|
||||
|
||||
void recurr(vector<Hyperbolic_octagon_translation_matrix>& v, vector<Hyperbolic_octagon_translation_matrix> g, int depth = 1) {
|
||||
if (depth > 1) {
|
||||
|
||||
recurr(v, g, depth-1);
|
||||
|
||||
vector<Hyperbolic_octagon_translation_matrix> tmp;
|
||||
vector<string> tmpw;
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
tmp.push_back(v[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < tmp.size(); i++) {
|
||||
for (int j = 0; j < g.size(); j++) {
|
||||
v.push_back(tmp[i]*g[j]);
|
||||
}
|
||||
}
|
||||
} else if (depth == 1) {
|
||||
for (int i = 0; i < g.size(); i++) {
|
||||
v.push_back(g[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void my_unique_words(std::vector<Point>& p, Point input, int depth) {
|
||||
std::vector<Hyperbolic_octagon_translation_matrix> g;
|
||||
get_generators(g);
|
||||
std::vector<Hyperbolic_octagon_translation_matrix> v;
|
||||
recurr(v, g, depth);
|
||||
std::set<Hyperbolic_octagon_translation_matrix> s;
|
||||
|
||||
for (int i = 0; i < v.size(); i++) {
|
||||
s.insert( v[i] );
|
||||
}
|
||||
|
||||
//cout << "Original point and images: " << endl;
|
||||
//cout << input.x() << ", " << input.y() << endl;
|
||||
cout << "Translating... " << endl;
|
||||
for (set<Hyperbolic_octagon_translation_matrix>::iterator it = s.begin(); it != s.end(); it++) {
|
||||
Hyperbolic_octagon_translation_matrix m = *it;
|
||||
pair<double, double> res;
|
||||
res = m.apply(to_double(input.x()), to_double(input.y()));
|
||||
//cout << res.first << ", " << res.second << endl;
|
||||
p.push_back( Point(res.first, res.second) );
|
||||
}
|
||||
cout << "Done! Now I need to draw " << p.size() << " points..." << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void apply_unique_words(std::vector<Point>& points, Point input = Point(0, 0), double threshold = 10, int word_length = 6, double d = .998)
|
||||
{
|
||||
|
||||
cout << "apply_unique_words called with threshold = " << threshold << ", word_length = " << word_length << ", d = " << d << endl;
|
||||
|
||||
static vector<Hyperbolic_octagon_translation_matrix> unique_words;
|
||||
static bool generated = false;
|
||||
if(generated == false) {
|
||||
generate_unique_words(unique_words, threshold, word_length);
|
||||
generated = true;
|
||||
}
|
||||
|
||||
//points.resize(unique_words.size());
|
||||
pair<double, double> res;
|
||||
for(size_t i = 0; i < unique_words.size(); i++) {
|
||||
pair<double, double> res;
|
||||
res = unique_words[i].apply(to_double(input.x()), to_double(input.y()));
|
||||
|
||||
double dist = res.first*res.first + res.second*res.second;
|
||||
if(dist < d) {
|
||||
points.push_back( Point(res.first, res.second) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void apply_unique_words_G(std::vector<Point>& points, Point input = Point(0, 0), double threshold = 6/*13.5*/, int word_length = 6/*20*/)
|
||||
{
|
||||
static vector<Hyperbolic_octagon_translation_matrix> unique_words;
|
||||
static bool generated = false;
|
||||
if(generated == false) {
|
||||
generate_unique_words(unique_words, threshold, word_length);
|
||||
generated = true;
|
||||
|
||||
// to generate all words
|
||||
/*
|
||||
ofstream fwords("m_w");
|
||||
fwords << "local words;\nPrint(\"words!\\n\");\nwords := [\n";
|
||||
for(size_t i = 0; i < unique_words.size() - 1; i++) {
|
||||
fwords << unique_words[i].label << "," <<endl;
|
||||
}
|
||||
fwords << unique_words[unique_words.size() - 1].label << endl;
|
||||
fwords << "];\nreturn words;";
|
||||
fwords.close();
|
||||
*/
|
||||
//
|
||||
}
|
||||
|
||||
ifstream findices("indicesG8_1");
|
||||
long index;
|
||||
vector<long> indices;
|
||||
while(findices >> index) {
|
||||
indices.push_back(index);
|
||||
}
|
||||
cout << "indices size " << indices.size() << endl;
|
||||
|
||||
pair<double, double> res;
|
||||
for(size_t i = 0; i < indices.size(); i++) {
|
||||
pair<double, double> res;
|
||||
if(indices[i] < unique_words.size() /*&& unique_words[indices[i]].length() < 13.*/) {
|
||||
res = unique_words[indices[i]].apply(to_double(input.x()), to_double(input.y()));
|
||||
points.push_back(Point(res.first, res.second));
|
||||
}
|
||||
}
|
||||
cout << "nb of points to insert " << points.size() << endl;
|
||||
}
|
||||
|
||||
|
||||
class MainWindow :
|
||||
public CGAL::Qt::DemosMainWindow,
|
||||
public Ui::Periodic_4_hyperbolic_Delaunay_triangulation_2
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
int recursion_depth;
|
||||
int cidx;
|
||||
std::vector<int> ccol;
|
||||
bool dummy_mode;
|
||||
|
||||
Delaunay dt;
|
||||
QGraphicsEllipseItem * disk;
|
||||
QGraphicsScene scene;
|
||||
|
||||
CGAL::Qt::TriangulationGraphicsItem<Delaunay> * dgi;
|
||||
CGAL::Qt::VoronoiGraphicsItem<Delaunay> * vgi;
|
||||
|
||||
// for drawing Voronoi diagram of the orbit of the origin
|
||||
CGAL::Qt::VoronoiGraphicsItem<Delaunay> * origin_vgi;
|
||||
|
||||
CGAL::Qt::TriangulationMovingPoint<Delaunay> * mp;
|
||||
CGAL::Qt::TriangulationConflictZone<Delaunay> * cz;
|
||||
CGAL::Qt::TriangulationRemoveVertex<Delaunay> * trv;
|
||||
CGAL::Qt::TriangulationPointInputAndConflictZone<Delaunay> * pi;
|
||||
CGAL::Qt::TriangulationCircumcircle<Delaunay> * tcc;
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
public slots:
|
||||
|
||||
void processInput(CGAL::Object o);
|
||||
|
||||
void on_actionMovingPoint_toggled(bool checked);
|
||||
|
||||
void on_actionShowConflictZone_toggled(bool checked);
|
||||
|
||||
void on_actionCircumcenter_toggled(bool checked);
|
||||
|
||||
void on_actionShowDelaunay_toggled(bool checked);
|
||||
|
||||
void on_actionShowVoronoi_toggled(bool checked);
|
||||
|
||||
void on_actionInsertPoint_toggled(bool checked);
|
||||
|
||||
void on_actionInsertRandomPoints_triggered();
|
||||
|
||||
void on_actionInsertPointOnFundamentalSide_triggered();
|
||||
void on_actionInsertPointOnAxis_triggered();
|
||||
|
||||
void on_actionInsertOrigin_triggered();
|
||||
|
||||
void on_actionInsertDummyPoints_triggered();
|
||||
|
||||
void on_actionModifyDepth_triggered();
|
||||
|
||||
void on_actionLoadPoints_triggered();
|
||||
|
||||
void on_actionSavePoints_triggered();
|
||||
|
||||
void on_actionClear_triggered();
|
||||
|
||||
void on_actionRecenter_triggered();
|
||||
|
||||
virtual void open(QString fileName);
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
};
|
||||
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: DemosMainWindow(), dt(K(1))
|
||||
{
|
||||
dummy_mode = false;
|
||||
recursion_depth = INITIAL_RECURSION_DEPTH;
|
||||
cidx = 0;
|
||||
for (int i = 0; i < 14; i++)
|
||||
ccol.push_back(i);
|
||||
|
||||
setupUi(this);
|
||||
|
||||
this->graphicsView->setAcceptDrops(false);
|
||||
|
||||
// Add Poincaré disk
|
||||
qreal origin_x = 0, origin_y = 0, radius = 1, diameter = 2*radius;
|
||||
qreal left_top_corner_x = origin_x - radius;
|
||||
qreal left_top_corner_y = origin_y - radius;
|
||||
qreal width = diameter, height = diameter;
|
||||
|
||||
// set background
|
||||
qreal eps = 0.01;
|
||||
QGraphicsRectItem* rect = new QGraphicsRectItem(left_top_corner_x - eps, left_top_corner_y - eps, width + 2*eps, height + 2*eps);
|
||||
rect->setPen(Qt::NoPen);
|
||||
rect->setBrush(Qt::white);
|
||||
scene.addItem(rect);
|
||||
|
||||
// set disk
|
||||
disk = new QGraphicsEllipseItem(left_top_corner_x, left_top_corner_y, width, height);
|
||||
QPen pen; // creates a default pen
|
||||
pen.setWidth(0);
|
||||
//pen.setBrush(Qt::black);
|
||||
pen.setBrush(Qt::black);
|
||||
disk->setPen(pen);
|
||||
|
||||
scene.addItem(disk);
|
||||
|
||||
// another input point, instead of the origin
|
||||
|
||||
//double phi = CGAL_PI / 8.;
|
||||
//double psi = CGAL_PI / 3.;
|
||||
//double rho = std::sqrt(cos(psi)*cos(psi) - sin(phi)*sin(phi));
|
||||
|
||||
//Point origin = Point(0, 0);
|
||||
//const Point a(cos(phi)*cos(phi + psi)/rho, sin(phi)*cos(phi + psi)/rho);
|
||||
|
||||
|
||||
// dt to form the octagon tessellation
|
||||
//vector<Point> origin_orbit;
|
||||
//apply_unique_words(origin_orbit, origin, 10, 6);
|
||||
//origin_orbit.push_back(Point(0, 0));
|
||||
// for(long i = 0; i < origin_orbit.size(); i++) {
|
||||
// cout << origin_orbit[i] << endl;
|
||||
// }
|
||||
//cout << "nb of points on the orbit of the origin: " << origin_orbit.size() << endl;
|
||||
|
||||
//Delaunay* dtO = new Delaunay(K(1));
|
||||
//dtO->insert(origin_orbit.begin(), origin_orbit.end());
|
||||
|
||||
//origin_vgi = new CGAL::Qt::VoronoiGraphicsItem<Delaunay>(dtO);
|
||||
//origin_vgi->setVisible(true);
|
||||
|
||||
//QObject::connect(this, SIGNAL(changed()),
|
||||
// origin_vgi, SLOT(modelChanged()));
|
||||
|
||||
//QColor br(149, 179, 179);
|
||||
//origin_vgi->setEdgesPen(QPen(br, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
//scene.addItem(origin_vgi);
|
||||
|
||||
|
||||
// Add a GraphicItem for the Delaunay triangulation
|
||||
dgi = new CGAL::Qt::TriangulationGraphicsItem<Delaunay>(&dt);
|
||||
|
||||
QObject::connect(this, SIGNAL(changed()),
|
||||
dgi, SLOT(modelChanged()));
|
||||
|
||||
dgi->setVerticesPen(QPen(Qt::red, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
dgi->setEdgesPen(QPen(QColor(200, 200, 0), 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
scene.addItem(dgi);
|
||||
|
||||
// Add a GraphicItem for the Voronoi diagram
|
||||
vgi = new CGAL::Qt::VoronoiGraphicsItem<Delaunay>(&dt);
|
||||
|
||||
QObject::connect(this, SIGNAL(changed()),
|
||||
vgi, SLOT(modelChanged()));
|
||||
|
||||
QColor brown(139, 69, 19);
|
||||
vgi->setEdgesPen(QPen(Qt::blue, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
scene.addItem(vgi);
|
||||
vgi->hide();
|
||||
|
||||
// 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::Qt::TriangulationPointInputAndConflictZone<Delaunay>(&scene, &dt, this );
|
||||
|
||||
QObject::connect(pi, SIGNAL(generate(CGAL::Object)),
|
||||
this, SLOT(processInput(CGAL::Object)));
|
||||
|
||||
mp = new CGAL::Qt::TriangulationMovingPoint<Delaunay>(&dt, this);
|
||||
// TriangulationMovingPoint<Delaunay> emits a modelChanged() signal each
|
||||
// time the moving point moves.
|
||||
// The following connection is for the purpose of emitting changed().
|
||||
QObject::connect(mp, SIGNAL(modelChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
trv = new CGAL::Qt::TriangulationRemoveVertex<Delaunay>(&dt, this);
|
||||
QObject::connect(trv, SIGNAL(modelChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
tcc = new CGAL::Qt::TriangulationCircumcircle<Delaunay>(&scene, &dt, this);
|
||||
tcc->setPen(QPen(Qt::red, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
|
||||
cz = new CGAL::Qt::TriangulationConflictZone<Delaunay>(&scene, &dt, this);
|
||||
|
||||
//
|
||||
// Manual handling of actions
|
||||
//
|
||||
|
||||
QObject::connect(this->actionQuit, SIGNAL(triggered()),
|
||||
this, SLOT(close()));
|
||||
|
||||
// We put mutually exclusive actions in an QActionGroup
|
||||
QActionGroup* ag = new QActionGroup(this);
|
||||
ag->addAction(this->actionInsertPoint);
|
||||
ag->addAction(this->actionMovingPoint);
|
||||
ag->addAction(this->actionCircumcenter);
|
||||
ag->addAction(this->actionShowConflictZone);
|
||||
|
||||
// Check two actions
|
||||
this->actionInsertPoint->setChecked(true);
|
||||
this->actionShowDelaunay->setChecked(true);
|
||||
|
||||
// //
|
||||
// // Setup the scene and the view
|
||||
// //
|
||||
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
scene.setSceneRect(left_top_corner_x, left_top_corner_y, width, height);
|
||||
this->graphicsView->setScene(&scene);
|
||||
this->graphicsView->setMouseTracking(true);
|
||||
this->graphicsView->shear(230, 230);
|
||||
|
||||
// // The navigation adds zooming and translation functionality to the
|
||||
// // QGraphicsView
|
||||
this->addNavigation(this->graphicsView);
|
||||
this->setupStatusBar();
|
||||
this->setupOptionsMenu();
|
||||
this->addAboutDemo(":/cgal/help/about_Delaunay_triangulation_2.html");
|
||||
this->addAboutCGAL();
|
||||
|
||||
this->addRecentFiles(this->menuFile, this->actionQuit);
|
||||
connect(this, SIGNAL(openRecentFile(QString)),
|
||||
this, SLOT(open(QString)));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::processInput(CGAL::Object o)
|
||||
{
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel GT;
|
||||
typedef GT::Point_2 Point_2;
|
||||
Point_2 pp;
|
||||
if (CGAL::assign(pp, o)) {
|
||||
Point tmp(pp.x(), pp.y());
|
||||
o = make_object(tmp);
|
||||
}
|
||||
|
||||
Point p;
|
||||
if(CGAL::assign(p, o)){
|
||||
QPointF qp(CGAL::to_double(p.x()), CGAL::to_double(p.y()));
|
||||
|
||||
// Cheat a little to guarantee insertion of dummy points
|
||||
CGAL::Bounded_side side;
|
||||
if (dummy_mode) {
|
||||
side = CGAL::ON_BOUNDED_SIDE;
|
||||
} else {
|
||||
Side_of_fundamental_octagon check = Side_of_fundamental_octagon();
|
||||
side = check(p);
|
||||
}
|
||||
|
||||
// note that if the point is on the boundary then the disk contains the point
|
||||
//if(disk->contains(qp)){
|
||||
|
||||
if(side != CGAL::ON_UNBOUNDED_SIDE) {
|
||||
//dt.insert(p);
|
||||
|
||||
//delete
|
||||
vector<Point> points;
|
||||
//apply_unique_words(points, p, 4, 1, .998);
|
||||
my_unique_words(points, p, recursion_depth);
|
||||
|
||||
points.push_back(p);
|
||||
Vertex_handle v;
|
||||
for(size_t j = 0; j < points.size() ; j++) {
|
||||
v = dt.insert(points[j]);
|
||||
if (/*!dummy_mode*/ true) {
|
||||
v->info().setColor(ccol[cidx]);
|
||||
} else {
|
||||
v->info().setColor(-1); // This will default to gray
|
||||
}
|
||||
}
|
||||
if (/*!dummy_mode*/ true) {
|
||||
cidx = (cidx + 1) % ccol.size();
|
||||
}
|
||||
//
|
||||
}
|
||||
// delete
|
||||
/*
|
||||
else {
|
||||
static double phi = CGAL_PI / 8.;
|
||||
static double psi = CGAL_PI / 3.;
|
||||
static double rho = std::sqrt(cos(psi)*cos(psi) - sin(phi)*sin(phi));
|
||||
|
||||
static Point origin = Point(0, 0);
|
||||
static Point a(cos(phi)*cos(phi + psi)/rho, sin(phi)*cos(phi + psi)/rho);
|
||||
static Point b((cos(psi)-sin(phi))/rho, 0.);
|
||||
|
||||
static Point current_point_a = origin;
|
||||
static Point current_point_b = origin;
|
||||
static double dT = 0.05;
|
||||
|
||||
static double dx_a = dT * CGAL::to_double(a.x());
|
||||
static double dy_a = dT * CGAL::to_double(a.y());
|
||||
current_point_a = Point(current_point_a.x() + dx_a, current_point_a.y() + dy_a);
|
||||
if(current_point_a.x() > a.x()) {
|
||||
current_point_a = origin;
|
||||
}
|
||||
|
||||
static double dx_b = dT * CGAL::to_double(b.x());
|
||||
static double dy_b = dT * CGAL::to_double(b.y());
|
||||
current_point_b = Point(current_point_b.x() + dx_b, current_point_b.y() + dy_b);
|
||||
std::cout << current_point_b.x() << " : " << current_point_b.y() << std::endl;
|
||||
if(current_point_b.x() > b.x()) {
|
||||
current_point_b = origin;
|
||||
}
|
||||
|
||||
vector<Point> points;
|
||||
|
||||
// current_point_b <-> current_point_b
|
||||
Point current_point = current_point_a;
|
||||
apply_unique_words(points, current_point);
|
||||
points.push_back(current_point);
|
||||
dt.clear();
|
||||
dt.insert(points.begin(), points.end());
|
||||
|
||||
} */
|
||||
|
||||
}
|
||||
emit(changed());
|
||||
|
||||
cout << "v = " << dt.number_of_vertices() << ", f = " << dt.number_of_faces() << endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Qt Automatic Connections
|
||||
* http://doc.trolltech.com/4.4/designer-using-a-component.html#automatic-connections
|
||||
*
|
||||
* setupUi(this) generates connections to the slots named
|
||||
* "on_<action_name>_<signal_name>"
|
||||
*/
|
||||
void
|
||||
MainWindow::on_actionInsertPoint_toggled(bool checked)
|
||||
{
|
||||
if(checked){
|
||||
scene.installEventFilter(pi);
|
||||
scene.installEventFilter(trv);
|
||||
} else {
|
||||
scene.removeEventFilter(pi);
|
||||
scene.removeEventFilter(trv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionMovingPoint_toggled(bool checked)
|
||||
{
|
||||
|
||||
if(checked){
|
||||
scene.installEventFilter(mp);
|
||||
} else {
|
||||
scene.removeEventFilter(mp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionShowConflictZone_toggled(bool checked)
|
||||
{
|
||||
|
||||
if(checked){
|
||||
scene.installEventFilter(cz);
|
||||
} else {
|
||||
scene.removeEventFilter(cz);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::on_actionCircumcenter_toggled(bool checked)
|
||||
{
|
||||
if(checked){
|
||||
scene.installEventFilter(tcc);
|
||||
tcc->show();
|
||||
} else {
|
||||
scene.removeEventFilter(tcc);
|
||||
tcc->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionShowDelaunay_toggled(bool checked)
|
||||
{
|
||||
dgi->setVisibleEdges(checked);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionShowVoronoi_toggled(bool checked)
|
||||
{
|
||||
vgi->setVisible(checked);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionClear_triggered()
|
||||
{
|
||||
dt.clear();
|
||||
emit(changed());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionInsertRandomPoints_triggered()
|
||||
{
|
||||
bool ok = false;
|
||||
const int number_of_points =
|
||||
QInputDialog::getInt(this,
|
||||
tr("Number of random points"),
|
||||
tr("Enter number of random points"),
|
||||
100,
|
||||
0,
|
||||
std::numeric_limits<int>::max(),
|
||||
1,
|
||||
&ok);
|
||||
|
||||
if(!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
// wait cursor
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel GT;
|
||||
typedef GT::Point_2 Point_2;
|
||||
typedef GT::FT FT;
|
||||
|
||||
vector<Point_2> pts;
|
||||
Hyperbolic_random_points_in_disc_2<GT>(pts, number_of_points);
|
||||
|
||||
for(int i = 0; i < number_of_points; ++i){
|
||||
processInput(make_object(pts[i]));
|
||||
}
|
||||
QApplication::restoreOverrideCursor();
|
||||
emit(changed());
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionInsertOrigin_triggered()
|
||||
{
|
||||
|
||||
std::vector<Point> pts;
|
||||
cout << "Inserting Origin now! " << endl;
|
||||
|
||||
cidx = 0;
|
||||
processInput(make_object(Point(0, 0)));
|
||||
|
||||
cout << "Origin inserted! " << endl;
|
||||
emit(changed());
|
||||
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionInsertPointOnAxis_triggered()
|
||||
{
|
||||
|
||||
std::vector<Point> pts;
|
||||
cout << "Inserting point on axis now! " << endl;
|
||||
|
||||
cidx = 0;
|
||||
processInput(make_object(Point(0, 0.29)));
|
||||
|
||||
cout << "Point on axis inserted! " << endl;
|
||||
emit(changed());
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::on_actionInsertPointOnFundamentalSide_triggered()
|
||||
{
|
||||
|
||||
std::vector<Point> pts;
|
||||
cout << "Inserting point on side of fundamental octagon now! " << endl;
|
||||
|
||||
cidx = 0;
|
||||
processInput(make_object(Point(0, sqrt(sqrt(2.)-1.))));
|
||||
|
||||
cout << "Point on side of fundamental octagon inserted! " << endl;
|
||||
emit(changed());
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::on_actionInsertDummyPoints_triggered()
|
||||
{
|
||||
|
||||
std::vector<Point> pts;
|
||||
cout << "Inserting dummy points now! " << endl;
|
||||
|
||||
dummy_mode = true;
|
||||
|
||||
dt.insert_dummy_points(pts);
|
||||
for (int i = 0; i < pts.size(); i++) {
|
||||
processInput(make_object(pts[i]));
|
||||
}
|
||||
|
||||
dummy_mode = false;
|
||||
|
||||
cout << "Dummy points inserted! " << endl;
|
||||
emit(changed());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionModifyDepth_triggered()
|
||||
{
|
||||
bool ok = false;
|
||||
const int result =
|
||||
QInputDialog::getInt(this,
|
||||
tr("Modify recursion depth"),
|
||||
tr("Enter new recursion depth"),
|
||||
recursion_depth,
|
||||
0,
|
||||
10,
|
||||
1,
|
||||
&ok);
|
||||
|
||||
if(!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
recursion_depth = result;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionLoadPoints_triggered()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Open Points file"),
|
||||
".");
|
||||
if(! fileName.isEmpty()){
|
||||
open(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::open(QString fileName)
|
||||
{
|
||||
// wait cursor
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
std::ifstream ifs(qPrintable(fileName));
|
||||
|
||||
K::Point p;
|
||||
std::vector<K::Point> points;
|
||||
while(ifs >> p) {
|
||||
points.push_back(p);
|
||||
}
|
||||
dt.insert(points.begin(), points.end());
|
||||
|
||||
// default cursor
|
||||
QApplication::restoreOverrideCursor();
|
||||
this->addToRecentFiles(fileName);
|
||||
actionRecenter->trigger();
|
||||
emit(changed());
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::on_actionSavePoints_triggered()
|
||||
{
|
||||
/* // dump points
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save points"),
|
||||
".");
|
||||
if(! fileName.isEmpty()){
|
||||
std::ofstream ofs(qPrintable(fileName));
|
||||
for(Delaunay::Finite_vertices_iterator
|
||||
vit = dt.finite_vertices_begin(),
|
||||
end = dt.finite_vertices_end();
|
||||
vit!= end; ++vit)
|
||||
{
|
||||
ofs << vit->point() << std::endl;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// take a snapshot
|
||||
std::cout << "snapshot...";
|
||||
|
||||
const QRect viewerRect = graphicsView->mapFromScene(scene.sceneRect()).boundingRect();
|
||||
const QRect imageRect = QRect(QPoint(0, 0), viewerRect.size());
|
||||
|
||||
QImage snapshot(imageRect.size(), QImage::Format_ARGB32);//QImage::Format_ARGB32_Premultiplied
|
||||
|
||||
QPainter painter(&snapshot);
|
||||
painter.setRenderHint(QPainter::Antialiasing);
|
||||
//painter.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
|
||||
graphicsView->render(&painter, imageRect, viewerRect);
|
||||
bool saved = snapshot.save("mysnap.png", "PNG", 100);
|
||||
assert(saved == true);
|
||||
|
||||
std::cout << "done" << std::endl;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionRecenter_triggered()
|
||||
{
|
||||
this->graphicsView->setSceneRect(dgi->boundingRect());
|
||||
this->graphicsView->fitInView(dgi->boundingRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
#include "Periodic_4_hyperbolic_Delaunay_triangulation_2_demo.moc"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
app.setOrganizationDomain("geometryfactory.com");
|
||||
app.setOrganizationName("GeometryFactory");
|
||||
app.setApplicationName("Periodic_4_hyperbolic_Delaunay_triangulation_2 demo");
|
||||
|
||||
// Import resources from libCGALQt4.
|
||||
// See http://doc.trolltech.com/4.4/qdir.html#Q_INIT_RESOURCE
|
||||
//Q_INIT_RESOURCE(File);
|
||||
//Q_INIT_RESOURCE(Triangulation_2);
|
||||
//Q_INIT_RESOURCE(Input);
|
||||
//Q_INIT_RESOURCE(CGAL);
|
||||
|
||||
MainWindow mainWindow;
|
||||
mainWindow.show();
|
||||
|
||||
QStringList args = app.arguments();
|
||||
args.removeAt(0);
|
||||
Q_FOREACH(QString filename, args) {
|
||||
mainWindow.open(filename);
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/help" >
|
||||
<file>about_CGAL.html</file>
|
||||
</qresource>
|
||||
<qresource prefix="/cgal/logos">
|
||||
<file alias="CGAL.gif" >cgal_logo_ipe_2013.png</file>
|
||||
<file alias="CGAL.png" >cgal_logo_ipe_2013.png</file>
|
||||
<file alias="cgal_icon" >cgal_logo.xpm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 3.9 KiB |
|
|
@ -1,12 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/Actions" >
|
||||
<file>conflict_zone.png</file>
|
||||
<file>moving_point.png</file>
|
||||
<file>triangulation.png</file>
|
||||
<file>circumcenter.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/cgal/help" >
|
||||
<file alias="about_CGAL.html">about_CGAL.html</file>
|
||||
<file>about_Delaunay_triangulation_2.html</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/fileToolbar" >
|
||||
<file>fileNew.png</file>
|
||||
<file>fileOpen.png</file>
|
||||
<file>fileSave.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
|
@ -1,7 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/Input" >
|
||||
<file>inputPoint.png</file>
|
||||
<file alias="zoom-best-fit" >fit-page-32.png</file>
|
||||
<file>inputPolyline.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/Actions">
|
||||
<file>G2.png</file>
|
||||
<file>G4.png</file>
|
||||
<file>G8.png</file>
|
||||
<file>G16.png</file>
|
||||
<file>G.png</file>
|
||||
<file>a.png</file>
|
||||
<file>b.png</file>
|
||||
<file>c.png</file>
|
||||
<file>d.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/Triangulation_2" >
|
||||
<file>Delaunay_triangulation_2.png</file>
|
||||
<file>Voronoi_diagram_2.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
|
@ -1,8 +0,0 @@
|
|||
<html>
|
||||
<body>
|
||||
<p><img src=":/cgal/logos/CGAL.png"></p>
|
||||
<h2>Computational Geometry Algorithms Library<!--CGAL_VERSION--></h2>
|
||||
<p>CGAL provides efficient and reliable geometric algorithms in the form of a C++ library.</p>
|
||||
<p>For more information visit <a href="http://www.cgal.org/">www.cgal.org</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
|
@ -1,24 +0,0 @@
|
|||
/* XPM */
|
||||
const char * demoicon_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 16 3 1",
|
||||
" c None",
|
||||
". c #FFFF00",
|
||||
"+ c #000000",
|
||||
/* pixels */
|
||||
"................",
|
||||
"...++++...++++..",
|
||||
"..+....+.+....+.",
|
||||
"..+......+......",
|
||||
"..+......+..+++.",
|
||||
"..+......+....+.",
|
||||
"..+....+.+....+.",
|
||||
"...++++...++++..",
|
||||
"................",
|
||||
"...++++...+.....",
|
||||
"..+....+..+.....",
|
||||
"..+....+..+.....",
|
||||
"..++++++..+.....",
|
||||
"..+....+..+.....",
|
||||
"..+....+..+++++.",
|
||||
"................"};
|
||||
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 768 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
|
@ -1,5 +0,0 @@
|
|||
The following files have been copied from Qt Free Edition version 4.4:
|
||||
fileNew.png
|
||||
fileOpen.png
|
||||
fileSave.png,
|
||||
fit-page-32.png
|
||||
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |
|
|
@ -1,38 +0,0 @@
|
|||
# Created by the script cgal_create_cmake_script
|
||||
# This is the CMake script for compiling a CGAL application.
|
||||
|
||||
project (Periodic_4_hyperbolic_triangulation_2_demo)
|
||||
|
||||
# Find includes in corresponding build directories
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# Instruct CMake to run moc automatically when needed.
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
SET(CMAKE_AUTOUIC ON)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.11)
|
||||
if(POLICY CMP0043)
|
||||
cmake_policy(SET CMP0043 OLD)
|
||||
endif()
|
||||
|
||||
find_package(CGAL COMPONENTS Qt5)
|
||||
include(${CGAL_USE_FILE})
|
||||
|
||||
find_package(Qt5 QUIET COMPONENTS Widgets)
|
||||
|
||||
include_directories (BEFORE ../../include include ../../../Hyperbolic_triangulation_2/include)
|
||||
|
||||
# ui files, created with Qt Designer
|
||||
qt5_wrap_ui( uis Periodic_4_hyperbolic_triangulation_2.ui )
|
||||
|
||||
# qrc files (resources files, that contain icons, at least)
|
||||
qt5_add_resources ( RESOURCE_FILES resources/Periodic_4_hyperbolic_triangulation_2.qrc )
|
||||
|
||||
|
||||
# cpp files
|
||||
add_executable ( Periodic_4_hyperbolic_triangulation_2_demo Periodic_4_hyperbolic_triangulation_2_demo.cpp )
|
||||
qt5_use_modules( Periodic_4_hyperbolic_triangulation_2_demo Widgets)
|
||||
add_to_cached_list( CGAL_EXECUTABLE_TARGETS Periodic_4_hyperbolic_triangulation_2_demo )
|
||||
target_link_libraries( Periodic_4_hyperbolic_triangulation_2_demo ${CGAL_LIBRARIES} ${QT_LIBRARIES} ${CGAL_QT_LIBRARIES} )
|
||||
|
||||
|
||||
|
|
@ -1,438 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<author>GeometryFactory</author>
|
||||
<class>Periodic_4_hyperbolic_triangulationo_2_demo</class>
|
||||
<widget class="QMainWindow" name="Periodic_4_hyperbolic_triangulationo_2_demo">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>600</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Periodic hyperbolic Delaunay triangulation</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="icons/CGAL.qrc">
|
||||
<normaloff>:/cgal/logos/cgal_icon</normaloff>:/cgal/logos/cgal_icon</iconset>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<layout class="QGridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGraphicsView" name="graphicsView">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::StrongFocus</enum>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOn</enum>
|
||||
</property>
|
||||
<property name="transformationAnchor">
|
||||
<enum>QGraphicsView::NoAnchor</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusbar"/>
|
||||
<widget class="QToolBar" name="fileToolBar">
|
||||
<property name="windowTitle">
|
||||
<string>File Tools</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionClear"/>
|
||||
<addaction name="actionLoadPoints"/>
|
||||
<addaction name="actionSavePoints"/>
|
||||
</widget>
|
||||
<widget class="QToolBar" name="toolBar">
|
||||
<property name="windowTitle">
|
||||
<string>Visualization Tools</string>
|
||||
</property>
|
||||
<attribute name="toolBarArea">
|
||||
<enum>TopToolBarArea</enum>
|
||||
</attribute>
|
||||
<attribute name="toolBarBreak">
|
||||
<bool>false</bool>
|
||||
</attribute>
|
||||
<addaction name="actionInsertPoint"/>
|
||||
<addaction name="actionDo_translation_a"/>
|
||||
<addaction name="actionDo_translation_b"/>
|
||||
<addaction name="actionDo_translation_c"/>
|
||||
<addaction name="actionDo_translation_d"/>
|
||||
<addaction name="actionMovingPoint"/>
|
||||
<addaction name="actionCircumcenter"/>
|
||||
<addaction name="actionShowConflictZone"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionShowDelaunay"/>
|
||||
<addaction name="actionShowVoronoi"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRecenter"/>
|
||||
</widget>
|
||||
<widget class="QMenuBar" name="menubar">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>800</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
<property name="title">
|
||||
<string>&File</string>
|
||||
</property>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionClear"/>
|
||||
<addaction name="actionLoadPoints"/>
|
||||
<addaction name="actionSavePoints"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionQuit"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuEdit">
|
||||
<property name="title">
|
||||
<string>&Edit</string>
|
||||
</property>
|
||||
<addaction name="actionInsertRandomPoints"/>
|
||||
<addaction name="actionModify_recursion_depth"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuTools">
|
||||
<property name="title">
|
||||
<string>&Tools</string>
|
||||
</property>
|
||||
<addaction name="actionInsertPoint"/>
|
||||
<addaction name="actionDo_translation_a"/>
|
||||
<addaction name="actionDo_translation_b"/>
|
||||
<addaction name="actionDo_translation_c"/>
|
||||
<addaction name="actionDo_translation_d"/>
|
||||
<addaction name="actionG"/>
|
||||
<addaction name="actionG2"/>
|
||||
<addaction name="actionG4"/>
|
||||
<addaction name="actionG8"/>
|
||||
<addaction name="actionG16"/>
|
||||
<addaction name="actionMovingPoint"/>
|
||||
<addaction name="actionCircumcenter"/>
|
||||
<addaction name="actionShowConflictZone"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionShowDelaunay"/>
|
||||
<addaction name="actionShowVoronoi"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionRecenter"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuEdit"/>
|
||||
<addaction name="menuTools"/>
|
||||
</widget>
|
||||
<action name="actionAbout">
|
||||
<property name="text">
|
||||
<string>&About</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionAboutCGAL">
|
||||
<property name="text">
|
||||
<string>About &CGAL</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionQuit">
|
||||
<property name="text">
|
||||
<string>&Quit</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+Q</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInsertRandomPoints">
|
||||
<property name="text">
|
||||
<string>&Insert random points</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+I</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionChangeRecursionDepth">
|
||||
<property name="text">
|
||||
<string>&Change recursion depth</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMovingPoint">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Delaunay_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/moving_point.png</normaloff>:/cgal/Actions/moving_point.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Simulate insertion</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string comment="The comment">Simulate Insertion</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string comment="and its comment">Move mouse with left button pressed to see where point would be inserted</string>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string comment="what">whats this</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionInsertPoint">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Input.qrc">
|
||||
<normaloff>:/cgal/Input/inputPoint.png</normaloff>:/cgal/Input/inputPoint.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Insert Point</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Insert Point</string>
|
||||
</property>
|
||||
<property name="statusTip">
|
||||
<string>Left: Insert vtx</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionClear">
|
||||
<property name="icon">
|
||||
<iconset resource="icons/File.qrc">
|
||||
<normaloff>:/cgal/fileToolbar/fileNew.png</normaloff>:/cgal/fileToolbar/fileNew.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Clear</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+C</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShowVoronoi">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<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>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show &Voronoi Diagram</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+V</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShowDelaunay">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Delaunay_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/triangulation.png</normaloff>:/cgal/Actions/triangulation.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show &Delaunay Triangulation</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+D</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionLoadPoints">
|
||||
<property name="icon">
|
||||
<iconset resource="icons/File.qrc">
|
||||
<normaloff>:/cgal/fileToolbar/fileOpen.png</normaloff>:/cgal/fileToolbar/fileOpen.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Load Points...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+L</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionSavePoints">
|
||||
<property name="icon">
|
||||
<iconset resource="icons/File.qrc">
|
||||
<normaloff>:/cgal/fileToolbar/fileSave.png</normaloff>:/cgal/fileToolbar/fileSave.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Save Points...</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+S</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionCircumcenter">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/cgal/Actions/icons/circumcenter.png</normaloff>:/cgal/Actions/icons/circumcenter.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Circumcenter</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Draw circumcenter</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionRecenter">
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Input.qrc">
|
||||
<normaloff>:/cgal/Input/zoom-best-fit</normaloff>:/cgal/Input/zoom-best-fit</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Re&center the viewport</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+R</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionShowConflictZone">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/cgal/Actions/icons/conflict_zone.png</normaloff>:/cgal/Actions/icons/conflict_zone.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Show Conflict Zone</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDo_translation_a">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/a.png</normaloff>:/cgal/Actions/a.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Do translation "a"</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDo_translation_b">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/b.png</normaloff>:/cgal/Actions/b.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Do translation "b"</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDo_translation_c">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/c.png</normaloff>:/cgal/Actions/c.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Do translation "c"</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionDo_translation_d">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/d.png</normaloff>:/cgal/Actions/d.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Do translation "d"</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionG">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/G.png</normaloff>:/cgal/Actions/G.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>G</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionG2">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/G2.png</normaloff>:/cgal/Actions/G2.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>G2</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionG4">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/G4.png</normaloff>:/cgal/Actions/G4.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>G4</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionG8">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/G8.png</normaloff>:/cgal/Actions/G8.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>G8</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionG16">
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/Periodic_4_hyperbolic_triangulation_2.qrc">
|
||||
<normaloff>:/cgal/Actions/G16.png</normaloff>:/cgal/Actions/G16.png</iconset>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>G16</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionModify_recursion_depth">
|
||||
<property name="text">
|
||||
<string>Modify recursion depth</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="icons/Periodic_4_hyperbolic_triangulation_2.qrc"/>
|
||||
<include location="icons/Delaunay_triangulation_2.qrc"/>
|
||||
<include location="icons/Triangulation_2.qrc"/>
|
||||
<include location="icons/Input.qrc"/>
|
||||
<include location="icons/File.qrc"/>
|
||||
<include location="icons/CGAL.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
@ -1,461 +0,0 @@
|
|||
#include <fstream>
|
||||
|
||||
// CGAL headers
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
|
||||
#include <CGAL/Delaunay_hyperbolic_triangulation_2.h>
|
||||
//#include <CGAL/Periodic_4_Delaunay_hyperbolic_triangulation_2.h>
|
||||
#include <CGAL/Triangulation_hyperbolic_traits_2.h>
|
||||
|
||||
// to be deleted
|
||||
#include <CGAL/Qt/HyperbolicPainterOstream.h>
|
||||
//
|
||||
|
||||
#include <CGAL/point_generators_2.h>
|
||||
|
||||
// Qt headers
|
||||
#include <QtGui>
|
||||
#include <QString>
|
||||
#include <QActionGroup>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QGraphicsEllipseItem>
|
||||
|
||||
// GraphicsView items and event filters (input classes)
|
||||
#include <CGAL/Qt/TriangulationCircumcircle.h>
|
||||
#include <CGAL/Qt/TriangulationMovingPoint.h>
|
||||
#include <CGAL/Qt/TriangulationConflictZone.h>
|
||||
#include <CGAL/Qt/TriangulationRemoveVertex.h>
|
||||
#include <CGAL/Qt/TriangulationPointInputAndConflictZone.h>
|
||||
#include <CGAL/Qt/TriangulationGraphicsItem.h>
|
||||
#include <CGAL/Qt/VoronoiGraphicsItem.h>
|
||||
|
||||
// for viewportsBbox
|
||||
#include <CGAL/Qt/utility.h>
|
||||
|
||||
// the two base classes
|
||||
#include "ui_Periodic_4_hyperbolic_triangulation_2.h"
|
||||
#include <CGAL/Qt/DemosMainWindow.h>
|
||||
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel R;
|
||||
typedef CGAL::Triangulation_hyperbolic_traits_2<R> K;
|
||||
|
||||
typedef K::Point_2 Point_2;
|
||||
typedef K::Iso_rectangle_2 Iso_rectangle_2;
|
||||
|
||||
//typedef CGAL::Periodic_4_Delaunay_hyperbolic_triangulation_2<K> Delaunay;
|
||||
typedef CGAL::Delaunay_hyperbolic_triangulation_2<K> Delaunay;
|
||||
|
||||
class MainWindow :
|
||||
public CGAL::Qt::DemosMainWindow,
|
||||
public Ui::Periodic_4_hyperbolic_triangulationo_2_demo
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
Delaunay dt;
|
||||
QGraphicsEllipseItem* disk;
|
||||
QGraphicsScene scene;
|
||||
|
||||
CGAL::Qt::TriangulationGraphicsItem<Delaunay> * dgi;
|
||||
CGAL::Qt::VoronoiGraphicsItem<Delaunay> * vgi;
|
||||
|
||||
CGAL::Qt::TriangulationMovingPoint<Delaunay> * mp;
|
||||
CGAL::Qt::TriangulationConflictZone<Delaunay> * cz;
|
||||
CGAL::Qt::TriangulationRemoveVertex<Delaunay> * trv;
|
||||
CGAL::Qt::TriangulationPointInputAndConflictZone<Delaunay> * pi;
|
||||
CGAL::Qt::TriangulationCircumcircle<Delaunay> *tcc;
|
||||
public:
|
||||
MainWindow();
|
||||
|
||||
public slots:
|
||||
|
||||
void processInput(CGAL::Object o);
|
||||
|
||||
void on_actionMovingPoint_toggled(bool checked);
|
||||
|
||||
void on_actionShowConflictZone_toggled(bool checked);
|
||||
|
||||
void on_actionCircumcenter_toggled(bool checked);
|
||||
|
||||
void on_actionShowDelaunay_toggled(bool checked);
|
||||
|
||||
void on_actionShowVoronoi_toggled(bool checked);
|
||||
|
||||
void on_actionInsertPoint_toggled(bool checked);
|
||||
|
||||
void on_actionInsertRandomPoints_triggered();
|
||||
|
||||
void on_actionModify_recursion_depth_triggered();
|
||||
|
||||
void on_actionLoadPoints_triggered();
|
||||
|
||||
void on_actionSavePoints_triggered();
|
||||
|
||||
void on_actionClear_triggered();
|
||||
|
||||
void on_actionRecenter_triggered();
|
||||
|
||||
virtual void open(QString fileName);
|
||||
|
||||
signals:
|
||||
void changed();
|
||||
};
|
||||
|
||||
MainWindow::MainWindow()
|
||||
: DemosMainWindow(), dt(K(1))
|
||||
{
|
||||
setupUi(this);
|
||||
|
||||
this->graphicsView->setAcceptDrops(false);
|
||||
|
||||
// Add Poincaré disk
|
||||
qreal origin_x = 0, origin_y = 0, radius = 1, diameter = 2*radius;
|
||||
qreal left_top_corner_x = origin_x - radius;
|
||||
qreal left_top_corner_y = origin_y - radius;
|
||||
qreal width = diameter, height = diameter;
|
||||
|
||||
disk = new QGraphicsEllipseItem(left_top_corner_x, left_top_corner_y, width, height);
|
||||
|
||||
QPen pen; // creates a default pen
|
||||
pen.setWidth(0);
|
||||
pen.setBrush(Qt::black);
|
||||
disk->setPen(pen);
|
||||
|
||||
scene.addItem(disk);
|
||||
|
||||
// delete:
|
||||
//
|
||||
|
||||
// Add a GraphicItem for the Delaunay triangulation
|
||||
dgi = new CGAL::Qt::TriangulationGraphicsItem<Delaunay>(&dt);
|
||||
|
||||
QObject::connect(this, SIGNAL(changed()),
|
||||
dgi, SLOT(modelChanged()));
|
||||
|
||||
dgi->setVerticesPen(QPen(Qt::red, 3, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
scene.addItem(dgi);
|
||||
|
||||
// Add a GraphicItem for the Voronoi diagram
|
||||
vgi = new CGAL::Qt::VoronoiGraphicsItem<Delaunay>(&dt);
|
||||
|
||||
QObject::connect(this, SIGNAL(changed()),
|
||||
vgi, SLOT(modelChanged()));
|
||||
|
||||
vgi->setEdgesPen(QPen(Qt::blue, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
scene.addItem(vgi);
|
||||
vgi->hide();
|
||||
|
||||
// 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::Qt::TriangulationPointInputAndConflictZone<Delaunay>(&scene, &dt, this );
|
||||
|
||||
QObject::connect(pi, SIGNAL(generate(CGAL::Object)),
|
||||
this, SLOT(processInput(CGAL::Object)));
|
||||
|
||||
mp = new CGAL::Qt::TriangulationMovingPoint<Delaunay>(&dt, this);
|
||||
// TriangulationMovingPoint<Delaunay> emits a modelChanged() signal each
|
||||
// time the moving point moves.
|
||||
// The following connection is for the purpose of emitting changed().
|
||||
QObject::connect(mp, SIGNAL(modelChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
trv = new CGAL::Qt::TriangulationRemoveVertex<Delaunay>(&dt, this);
|
||||
QObject::connect(trv, SIGNAL(modelChanged()),
|
||||
this, SIGNAL(changed()));
|
||||
|
||||
tcc = new CGAL::Qt::TriangulationCircumcircle<Delaunay>(&scene, &dt, this);
|
||||
tcc->setPen(QPen(Qt::red, 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
|
||||
|
||||
cz = new CGAL::Qt::TriangulationConflictZone<Delaunay>(&scene, &dt, this);
|
||||
|
||||
//
|
||||
// Manual handling of actions
|
||||
//
|
||||
|
||||
QObject::connect(this->actionQuit, SIGNAL(triggered()),
|
||||
this, SLOT(close()));
|
||||
|
||||
// We put mutually exclusive actions in an QActionGroup
|
||||
QActionGroup* ag = new QActionGroup(this);
|
||||
ag->addAction(this->actionInsertPoint);
|
||||
ag->addAction(this->actionMovingPoint);
|
||||
ag->addAction(this->actionCircumcenter);
|
||||
ag->addAction(this->actionShowConflictZone);
|
||||
|
||||
// Check two actions
|
||||
this->actionInsertPoint->setChecked(true);
|
||||
this->actionShowDelaunay->setChecked(true);
|
||||
|
||||
//
|
||||
// Setup the scene and the view
|
||||
//
|
||||
scene.setItemIndexMethod(QGraphicsScene::NoIndex);
|
||||
scene.setSceneRect(left_top_corner_x, left_top_corner_y, width, height);
|
||||
this->graphicsView->setScene(&scene);
|
||||
this->graphicsView->setMouseTracking(true);
|
||||
|
||||
// we want to adjust the coordinates of QGraphicsView to the coordinates of QGraphicsScene
|
||||
// the following line must do this:
|
||||
// this->graphicsView->fitInView( scene.sceneRect(), Qt::KeepAspectRatio);
|
||||
// It does not do this sufficiently well.
|
||||
// Current solution:
|
||||
this->graphicsView->shear(230, 230);
|
||||
|
||||
// adjust the coordinate system
|
||||
this->graphicsView->rotate(90);
|
||||
|
||||
// The navigation adds zooming and translation functionality to the
|
||||
// QGraphicsView
|
||||
this->addNavigation(this->graphicsView);
|
||||
|
||||
this->setupStatusBar();
|
||||
this->setupOptionsMenu();
|
||||
this->addAboutDemo(":/cgal/help/about_Delaunay_triangulation_2.html");
|
||||
this->addAboutCGAL();
|
||||
|
||||
this->addRecentFiles(this->menuFile, this->actionQuit);
|
||||
connect(this, SIGNAL(openRecentFile(QString)),
|
||||
this, SLOT(open(QString)));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::processInput(CGAL::Object o)
|
||||
{
|
||||
Point_2 p;
|
||||
if(CGAL::assign(p, o)){
|
||||
QPointF qp(CGAL::to_double(p.x()), CGAL::to_double(p.y()));
|
||||
|
||||
// note that if the point is on the boundary then the disk contains the point
|
||||
if(disk->contains(qp)){
|
||||
dt.insert(p);
|
||||
}
|
||||
}
|
||||
emit(changed());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Qt Automatic Connections
|
||||
* http://doc.trolltech.com/4.4/designer-using-a-component.html#automatic-connections
|
||||
*
|
||||
* setupUi(this) generates connections to the slots named
|
||||
* "on_<action_name>_<signal_name>"
|
||||
*/
|
||||
void
|
||||
MainWindow::on_actionInsertPoint_toggled(bool checked)
|
||||
{
|
||||
if(checked){
|
||||
scene.installEventFilter(pi);
|
||||
scene.installEventFilter(trv);
|
||||
} else {
|
||||
scene.removeEventFilter(pi);
|
||||
scene.removeEventFilter(trv);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionMovingPoint_toggled(bool checked)
|
||||
{
|
||||
|
||||
if(checked){
|
||||
scene.installEventFilter(mp);
|
||||
} else {
|
||||
scene.removeEventFilter(mp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionShowConflictZone_toggled(bool checked)
|
||||
{
|
||||
|
||||
if(checked){
|
||||
scene.installEventFilter(cz);
|
||||
} else {
|
||||
scene.removeEventFilter(cz);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::on_actionCircumcenter_toggled(bool checked)
|
||||
{
|
||||
if(checked){
|
||||
scene.installEventFilter(tcc);
|
||||
tcc->show();
|
||||
} else {
|
||||
scene.removeEventFilter(tcc);
|
||||
tcc->hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionShowDelaunay_toggled(bool checked)
|
||||
{
|
||||
dgi->setVisibleEdges(checked);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionShowVoronoi_toggled(bool checked)
|
||||
{
|
||||
vgi->setVisible(checked);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionClear_triggered()
|
||||
{
|
||||
dt.clear();
|
||||
emit(changed());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionModify_recursion_depth_triggered()
|
||||
{
|
||||
bool ok = false;
|
||||
const int depth =
|
||||
QInputDialog::getInt(this,
|
||||
tr("Recursion depth"),
|
||||
tr("Enter new value for recursion depth"),
|
||||
0,
|
||||
0,
|
||||
std::numeric_limits<int>::max(),
|
||||
1,
|
||||
&ok);
|
||||
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
//dt.Set_recursion_depth(depth);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionInsertRandomPoints_triggered()
|
||||
{
|
||||
CGAL::Random_points_in_disc_2<Point_2, CGAL::Creator_uniform_2<int, Point_2> > pg(1.0);
|
||||
bool ok = false;
|
||||
const int number_of_points =
|
||||
QInputDialog::getInt(this,
|
||||
tr("Number of random points"),
|
||||
tr("Enter number of random points"),
|
||||
100,
|
||||
0,
|
||||
std::numeric_limits<int>::max(),
|
||||
1,
|
||||
&ok);
|
||||
|
||||
if(!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
// wait cursor
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
std::vector<Point_2> points;
|
||||
points.reserve(number_of_points);
|
||||
for(int i = 0; i < number_of_points; ++i){
|
||||
points.push_back(*pg++);
|
||||
}
|
||||
dt.insert(points.begin(), points.end());
|
||||
// default cursor
|
||||
QApplication::restoreOverrideCursor();
|
||||
emit(changed());
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionLoadPoints_triggered()
|
||||
{
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
tr("Open Points file"),
|
||||
".");
|
||||
if(! fileName.isEmpty()){
|
||||
open(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::open(QString fileName)
|
||||
{
|
||||
// wait cursor
|
||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||
std::ifstream ifs(qPrintable(fileName));
|
||||
|
||||
K::Point_2 p;
|
||||
std::vector<K::Point_2> points;
|
||||
while(ifs >> p) {
|
||||
points.push_back(p);
|
||||
}
|
||||
dt.insert(points.begin(), points.end());
|
||||
|
||||
// default cursor
|
||||
QApplication::restoreOverrideCursor();
|
||||
this->addToRecentFiles(fileName);
|
||||
actionRecenter->trigger();
|
||||
emit(changed());
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::on_actionSavePoints_triggered()
|
||||
{
|
||||
QString fileName = QFileDialog::getSaveFileName(this,
|
||||
tr("Save points"),
|
||||
".");
|
||||
if(! fileName.isEmpty()){
|
||||
std::ofstream ofs(qPrintable(fileName));
|
||||
for(Delaunay::Finite_vertices_iterator
|
||||
vit = dt.finite_vertices_begin(),
|
||||
end = dt.finite_vertices_end();
|
||||
vit!= end; ++vit)
|
||||
{
|
||||
ofs << vit->point() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWindow::on_actionRecenter_triggered()
|
||||
{
|
||||
this->graphicsView->setSceneRect(dgi->boundingRect());
|
||||
this->graphicsView->fitInView(dgi->boundingRect(), Qt::KeepAspectRatio);
|
||||
}
|
||||
|
||||
|
||||
#include "Periodic_4_hyperbolic_triangulation_2_demo.moc"
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
|
||||
app.setOrganizationDomain("geometryfactory.com");
|
||||
app.setOrganizationName("GeometryFactory");
|
||||
app.setApplicationName("Delaunay_triangulation_2 demo");
|
||||
|
||||
// Import resources from libCGALQt4.
|
||||
// See http://doc.trolltech.com/4.4/qdir.html#Q_INIT_RESOURCE
|
||||
Q_INIT_RESOURCE(File);
|
||||
Q_INIT_RESOURCE(Triangulation_2);
|
||||
Q_INIT_RESOURCE(Input);
|
||||
Q_INIT_RESOURCE(CGAL);
|
||||
|
||||
MainWindow mainWindow;
|
||||
mainWindow.show();
|
||||
|
||||
QStringList args = app.arguments();
|
||||
args.removeAt(0);
|
||||
Q_FOREACH(QString filename, args) {
|
||||
mainWindow.open(filename);
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
}
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/help" >
|
||||
<file>about_CGAL.html</file>
|
||||
</qresource>
|
||||
<qresource prefix="/cgal/logos">
|
||||
<file alias="CGAL.gif" >cgal_logo_ipe_2013.png</file>
|
||||
<file alias="CGAL.png" >cgal_logo_ipe_2013.png</file>
|
||||
<file alias="cgal_icon" >cgal_logo.xpm</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 3.9 KiB |
|
|
@ -1,12 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/Actions" >
|
||||
<file>conflict_zone.png</file>
|
||||
<file>moving_point.png</file>
|
||||
<file>triangulation.png</file>
|
||||
<file>circumcenter.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/cgal/help" >
|
||||
<file alias="about_CGAL.html">about_CGAL.html</file>
|
||||
<file>about_Delaunay_triangulation_2.html</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/fileToolbar" >
|
||||
<file>fileNew.png</file>
|
||||
<file>fileOpen.png</file>
|
||||
<file>fileSave.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 2.1 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
|
|
@ -1,7 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/Input" >
|
||||
<file>inputPoint.png</file>
|
||||
<file alias="zoom-best-fit" >fit-page-32.png</file>
|
||||
<file>inputPolyline.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/Actions">
|
||||
<file>G2.png</file>
|
||||
<file>G4.png</file>
|
||||
<file>G8.png</file>
|
||||
<file>G16.png</file>
|
||||
<file>G.png</file>
|
||||
<file>a.png</file>
|
||||
<file>b.png</file>
|
||||
<file>c.png</file>
|
||||
<file>d.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<RCC>
|
||||
<qresource prefix="/cgal/Triangulation_2" >
|
||||
<file>Delaunay_triangulation_2.png</file>
|
||||
<file>Voronoi_diagram_2.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Before Width: | Height: | Size: 3.0 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
|
@ -1,8 +0,0 @@
|
|||
<html>
|
||||
<body>
|
||||
<p><img src=":/cgal/logos/CGAL.png"></p>
|
||||
<h2>Computational Geometry Algorithms Library<!--CGAL_VERSION--></h2>
|
||||
<p>CGAL provides efficient and reliable geometric algorithms in the form of a C++ library.</p>
|
||||
<p>For more information visit <a href="http://www.cgal.org/">www.cgal.org</a></p>
|
||||
</body>
|
||||
</html>
|
||||
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
|
@ -1,24 +0,0 @@
|
|||
/* XPM */
|
||||
const char * demoicon_xpm[] = {
|
||||
/* columns rows colors chars-per-pixel */
|
||||
"16 16 3 1",
|
||||
" c None",
|
||||
". c #FFFF00",
|
||||
"+ c #000000",
|
||||
/* pixels */
|
||||
"................",
|
||||
"...++++...++++..",
|
||||
"..+....+.+....+.",
|
||||
"..+......+......",
|
||||
"..+......+..+++.",
|
||||
"..+......+....+.",
|
||||
"..+....+.+....+.",
|
||||
"...++++...++++..",
|
||||
"................",
|
||||
"...++++...+.....",
|
||||
"..+....+..+.....",
|
||||
"..+....+..+.....",
|
||||
"..++++++..+.....",
|
||||
"..+....+..+.....",
|
||||
"..+....+..+++++.",
|
||||
"................"};
|
||||
|
Before Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 3.8 KiB |
|
Before Width: | Height: | Size: 7.5 KiB |
|
Before Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 1.4 KiB |
|
Before Width: | Height: | Size: 768 B |
|
Before Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 1.2 KiB |
|
Before Width: | Height: | Size: 1.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
|
@ -1,5 +0,0 @@
|
|||
The following files have been copied from Qt Free Edition version 4.4:
|
||||
fileNew.png
|
||||
fileOpen.png
|
||||
fileSave.png,
|
||||
fit-page-32.png
|
||||
|
Before Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 3.2 KiB |