From cd2e83819689afd2cd1bc76810282111cf5cd59d Mon Sep 17 00:00:00 2001 From: vrouvrea Date: Thu, 8 Oct 2015 21:15:51 +0000 Subject: cpplint fixes on GudhUI git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@844 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 3acf1e789f3e4bded974f324ce3161bc1d1d2433 --- src/GudhUI/gui/MainWindow.cpp | 385 ++++++++++++++-------------- src/GudhUI/gui/MainWindow.h | 140 +++++----- src/GudhUI/gui/Menu_edge_contraction.cpp | 118 +++++---- src/GudhUI/gui/Menu_edge_contraction.h | 73 +++--- src/GudhUI/gui/Menu_k_nearest_neighbors.cpp | 82 +++--- src/GudhUI/gui/Menu_k_nearest_neighbors.h | 58 +++-- src/GudhUI/gui/Menu_persistence.cpp | 45 ++-- src/GudhUI/gui/Menu_persistence.h | 42 ++- src/GudhUI/gui/Menu_uniform_neighbors.cpp | 87 +++---- src/GudhUI/gui/Menu_uniform_neighbors.h | 57 ++-- src/GudhUI/gui/Viewer.cpp | 0 src/GudhUI/gui/Viewer_instructor.cpp | 0 src/GudhUI/gui/gudhui.cpp | 35 ++- 13 files changed, 597 insertions(+), 525 deletions(-) delete mode 100644 src/GudhUI/gui/Viewer.cpp delete mode 100644 src/GudhUI/gui/Viewer_instructor.cpp (limited to 'src/GudhUI/gui') diff --git a/src/GudhUI/gui/MainWindow.cpp b/src/GudhUI/gui/MainWindow.cpp index e41b15ba..779ccd33 100644 --- a/src/GudhUI/gui/MainWindow.cpp +++ b/src/GudhUI/gui/MainWindow.cpp @@ -1,3 +1,25 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "MainWindow.h" #include @@ -6,292 +28,271 @@ #include - #include "gui/Menu_k_nearest_neighbors.h" #include "gui/Menu_uniform_neighbors.h" #include "gui/Menu_edge_contraction.h" #include "gui/Menu_persistence.h" +MainWindow::MainWindow(QWidget* parent) : + menu_k_nearest_neighbors_(new Menu_k_nearest_neighbors(this)), + menu_uniform_neighbors_(new Menu_uniform_neighbors(this)), + menu_edge_contraction_(new Menu_edge_contraction(this, model_)), + menu_persistence_(new Menu_persistence(this)) { + // #ifndef NDEBUG // catch nan + // feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); + // #endif -MainWindow::MainWindow(QWidget* parent): -menu_k_nearest_neighbors_(new Menu_k_nearest_neighbors(this)), -menu_uniform_neighbors_(new Menu_uniform_neighbors(this)), -menu_edge_contraction_(new Menu_edge_contraction(this,model_)), -menu_persistence_(new Menu_persistence(this)) -{ -//#ifndef NDEBUG // catch nan -//feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); -//#endif + setupUi(this); - setupUi(this); + viewer_instructor_ = new Viewer_instructor( + this, + this->viewer, + model_.complex_); - viewer_instructor_ = new Viewer_instructor( - this, - this->viewer, - model_.complex_ - ); + connectActions(); - connectActions(); - - update_view(); + update_view(); } -void -MainWindow::closeEvent(QCloseEvent *event){ - exit(0); +void +MainWindow::closeEvent(QCloseEvent *event) { + exit(0); } - -void -MainWindow::connectActions(){ - QObject::connect(this->actionLoad_complex, SIGNAL(triggered()), this, - SLOT(off_file_open())); - QObject::connect(this->actionLoad_points, SIGNAL(triggered()), this, - SLOT(off_points_open())); - QObject::connect(this->actionSave_complex, SIGNAL(triggered()), this, - SLOT(off_file_save())); - QObject::connect(this->actionSave_points, SIGNAL(triggered()), this, - SLOT(off_points_save())); - - QObject::connect(this->actionShow_graph_stats, SIGNAL(triggered()), this, - SLOT(show_graph_stats())); - QObject::connect(this->actionShow_complex_stats, SIGNAL(triggered()), this, - SLOT(show_complex_stats())); - QObject::connect(this->actionShow_complex_dimension, SIGNAL(triggered()), this, - SLOT(show_complex_dimension())); - - QObject::connect(this->actionUniform_proximity_graph, SIGNAL(triggered()), this, - SLOT(build_rips_menu())); - QObject::connect(this->actionK_nearest_neighbors_graph, SIGNAL(triggered()), this, - SLOT(build_k_nearest_neighbors_menu())); - - - QObject::connect(this->actionContract_edges, SIGNAL(triggered()), this, - SLOT(contract_edge_menu())); - - QObject::connect(this->actionCollapse_vertices, SIGNAL(triggered()), this, - SLOT(collapse_vertices())); - - QObject::connect(this->actionCollapse_edges, SIGNAL(triggered()), this, - SLOT(collapse_edges())); - - QObject::connect(this->actionNoise, SIGNAL(triggered()), this, - SLOT(uniform_noise())); - QObject::connect(this->actionLloyd, SIGNAL(triggered()), this, - SLOT(lloyd())); - - - //view - QObject::connect(this->actionPoints, SIGNAL(triggered()), this->viewer_instructor_, - SLOT(change_draw_vertices())); - QObject::connect(this->actionEdges, SIGNAL(triggered()), this->viewer_instructor_, - SLOT(change_draw_edges())); - QObject::connect(this->actionTriangles, SIGNAL(triggered()), this->viewer_instructor_, - SLOT(change_draw_triangles())); - - //topology - QObject::connect(this->actionShow_homology_group, SIGNAL(triggered()), this, - SLOT(show_homology_group())); - QObject::connect(this->actionEuler_characteristic, SIGNAL(triggered()), this, - SLOT(show_euler_characteristic())); - QObject::connect(this->actionPersistence, SIGNAL(triggered()), this, - SLOT(persistence_menu())); - QObject::connect(this->actionEstimate_topological_changes, SIGNAL(triggered()), this, - SLOT(critical_points_menu())); - QObject::connect(this->actionIs_manifold, SIGNAL(triggered()), this, - SLOT(is_manifold_menu())); - - - QObject::connect(this, SIGNAL(sceneChanged()), this->viewer_instructor_, - SLOT(sceneChanged())); - +void +MainWindow::connectActions() { + QObject::connect(this->actionLoad_complex, SIGNAL(triggered()), this, + SLOT(off_file_open())); + QObject::connect(this->actionLoad_points, SIGNAL(triggered()), this, + SLOT(off_points_open())); + QObject::connect(this->actionSave_complex, SIGNAL(triggered()), this, + SLOT(off_file_save())); + QObject::connect(this->actionSave_points, SIGNAL(triggered()), this, + SLOT(off_points_save())); + + QObject::connect(this->actionShow_graph_stats, SIGNAL(triggered()), this, + SLOT(show_graph_stats())); + QObject::connect(this->actionShow_complex_stats, SIGNAL(triggered()), this, + SLOT(show_complex_stats())); + QObject::connect(this->actionShow_complex_dimension, SIGNAL(triggered()), this, + SLOT(show_complex_dimension())); + + QObject::connect(this->actionUniform_proximity_graph, SIGNAL(triggered()), this, + SLOT(build_rips_menu())); + QObject::connect(this->actionK_nearest_neighbors_graph, SIGNAL(triggered()), this, + SLOT(build_k_nearest_neighbors_menu())); + + + QObject::connect(this->actionContract_edges, SIGNAL(triggered()), this, + SLOT(contract_edge_menu())); + + QObject::connect(this->actionCollapse_vertices, SIGNAL(triggered()), this, + SLOT(collapse_vertices())); + + QObject::connect(this->actionCollapse_edges, SIGNAL(triggered()), this, + SLOT(collapse_edges())); + + QObject::connect(this->actionNoise, SIGNAL(triggered()), this, + SLOT(uniform_noise())); + QObject::connect(this->actionLloyd, SIGNAL(triggered()), this, + SLOT(lloyd())); + + + // view + QObject::connect(this->actionPoints, SIGNAL(triggered()), this->viewer_instructor_, + SLOT(change_draw_vertices())); + QObject::connect(this->actionEdges, SIGNAL(triggered()), this->viewer_instructor_, + SLOT(change_draw_edges())); + QObject::connect(this->actionTriangles, SIGNAL(triggered()), this->viewer_instructor_, + SLOT(change_draw_triangles())); + + // topology + QObject::connect(this->actionShow_homology_group, SIGNAL(triggered()), this, + SLOT(show_homology_group())); + QObject::connect(this->actionEuler_characteristic, SIGNAL(triggered()), this, + SLOT(show_euler_characteristic())); + QObject::connect(this->actionPersistence, SIGNAL(triggered()), this, + SLOT(persistence_menu())); + QObject::connect(this->actionEstimate_topological_changes, SIGNAL(triggered()), this, + SLOT(critical_points_menu())); + QObject::connect(this->actionIs_manifold, SIGNAL(triggered()), this, + SLOT(is_manifold_menu())); + + + QObject::connect(this, SIGNAL(sceneChanged()), this->viewer_instructor_, + SLOT(sceneChanged())); } void -MainWindow::init_view() const{ - viewer_instructor_->initialize_bounding_box(); - viewer_instructor_->show_entire_scene(); - update_view(); +MainWindow::init_view() const { + viewer_instructor_->initialize_bounding_box(); + viewer_instructor_->show_entire_scene(); + update_view(); } - void -MainWindow::update_view() const{ - emit (sceneChanged()); +MainWindow::update_view() const { + emit(sceneChanged()); } - - /** * open a file chooser to choose an off to load */ -void -MainWindow::off_file_open(){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open off File"), - "~/", tr("off files (*.off)")); - if (!fileName.isEmpty()){ - model_.off_file_open(fileName.toStdString()); - init_view(); - } +void +MainWindow::off_file_open() { + QString fileName = QFileDialog::getOpenFileName(this, tr("Open off File"), + "~/", tr("off files (*.off)")); + if (!fileName.isEmpty()) { + model_.off_file_open(fileName.toStdString()); + init_view(); + } } void -MainWindow::off_points_open(){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Open points in a off file"), - "~/", tr("off files (*.off)")); - if (!fileName.isEmpty()){ - model_.off_points_open(fileName.toStdString()); - init_view(); - } +MainWindow::off_points_open() { + QString fileName = QFileDialog::getOpenFileName(this, tr("Open points in a off file"), + "~/", tr("off files (*.off)")); + if (!fileName.isEmpty()) { + model_.off_points_open(fileName.toStdString()); + init_view(); + } } - /** * open a file chooser to choose an off to save */ -void -MainWindow::off_file_save(){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Save to off File"), - "~/", tr("off files (*.off)")); - if (!fileName.isEmpty()) - { - model_.off_file_save(fileName.toStdString()); - } +void +MainWindow::off_file_save() { + QString fileName = QFileDialog::getOpenFileName(this, tr("Save to off File"), + "~/", tr("off files (*.off)")); + if (!fileName.isEmpty()) { + model_.off_file_save(fileName.toStdString()); + } } /** * open a file chooser to choose an off to save */ void -MainWindow::off_points_save(){ - QString fileName = QFileDialog::getOpenFileName(this, tr("Save to off File"), - "~/", tr("off files (*.off)")); - if (!fileName.isEmpty()) - { - model_.off_points_save(fileName.toStdString()); - } +MainWindow::off_points_save() { + QString fileName = QFileDialog::getOpenFileName(this, tr("Save to off File"), + "~/", tr("off files (*.off)")); + if (!fileName.isEmpty()) { + model_.off_points_save(fileName.toStdString()); + } } - void -MainWindow::show_graph_stats(){ - model_.show_graph_stats(); +MainWindow::show_graph_stats() { + model_.show_graph_stats(); } void -MainWindow::show_complex_stats(){ - model_.show_complex_stats(); +MainWindow::show_complex_stats() { + model_.show_complex_stats(); } -void -MainWindow::show_complex_dimension(){ - model_.show_complex_dimension(); +void +MainWindow::show_complex_dimension() { + model_.show_complex_dimension(); } - void -MainWindow::build_rips_menu(){ - menu_uniform_neighbors_->show(); +MainWindow::build_rips_menu() { + menu_uniform_neighbors_->show(); } void -MainWindow::build_rips(double alpha){ - model_.build_rips(alpha); - update_view(); +MainWindow::build_rips(double alpha) { + model_.build_rips(alpha); + update_view(); } void -MainWindow::build_k_nearest_neighbors_menu(){ - menu_k_nearest_neighbors_->show(); +MainWindow::build_k_nearest_neighbors_menu() { + menu_k_nearest_neighbors_->show(); } void -MainWindow::build_k_nearest_neighbors(unsigned k){ - model_.build_k_nearest_neighbors(k); - update_view(); +MainWindow::build_k_nearest_neighbors(unsigned k) { + model_.build_k_nearest_neighbors(k); + update_view(); } void -MainWindow::contract_edge_menu(){ - menu_edge_contraction_->show(); +MainWindow::contract_edge_menu() { + menu_edge_contraction_->show(); } void -MainWindow::contract_edges(unsigned num_collapses){ - std::cerr <<"Collapse "<show(); +MainWindow::persistence_menu() { + menu_persistence_->show(); } void -MainWindow::compute_persistence(int p,double threshold,int max_dim,double min_pers){ - model_.show_persistence(p,threshold,max_dim,min_pers); +MainWindow::compute_persistence(int p, double threshold, int max_dim, double min_pers) { + model_.show_persistence(p, threshold, max_dim, min_pers); } void -MainWindow::critical_points_menu(){ - bool ok; - double max_length = QInputDialog::getDouble(this, tr("Maximal edge length for the Rips"), - tr("Maximal edge length:"), 0, 0, 10000, 3, &ok); - if (ok) - model_.show_critical_points(max_length); +MainWindow::critical_points_menu() { + bool ok; + double max_length = QInputDialog::getDouble(this, tr("Maximal edge length for the Rips"), + tr("Maximal edge length:"), 0, 0, 10000, 3, &ok); + if (ok) + model_.show_critical_points(max_length); } void -MainWindow::is_manifold_menu(){ - model_.show_is_manifold(); +MainWindow::is_manifold_menu() { + model_.show_is_manifold(); } diff --git a/src/GudhUI/gui/MainWindow.h b/src/GudhUI/gui/MainWindow.h index e46b72a3..c8c3fcf6 100644 --- a/src/GudhUI/gui/MainWindow.h +++ b/src/GudhUI/gui/MainWindow.h @@ -1,5 +1,27 @@ -#ifndef MAIN_WINDOW_H -#define MAIN_WINDOW_H +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef GUI_MAINWINDOW_H_ +#define GUI_MAINWINDOW_H_ // Workaround for moc-qt4 not parsing boost headers #include @@ -15,86 +37,82 @@ class Menu_uniform_neighbors; class Menu_edge_contraction; class Menu_persistence; -class MainWindow : public QMainWindow,public Ui::MainWindow{ - Q_OBJECT +class MainWindow : public QMainWindow, public Ui::MainWindow { + Q_OBJECT -private: - Model model_; - Viewer_instructor* viewer_instructor_; - Menu_k_nearest_neighbors* menu_k_nearest_neighbors_; - Menu_uniform_neighbors* menu_uniform_neighbors_; - Menu_edge_contraction* menu_edge_contraction_; - Menu_persistence* menu_persistence_; + private: + Model model_; + Viewer_instructor* viewer_instructor_; + Menu_k_nearest_neighbors* menu_k_nearest_neighbors_; + Menu_uniform_neighbors* menu_uniform_neighbors_; + Menu_edge_contraction* menu_edge_contraction_; + Menu_persistence* menu_persistence_; -public: - MainWindow(QWidget* parent = 0); - void connectActions(); + public: + MainWindow(QWidget* parent = 0); + void connectActions(); - /** - * compute the bounding box and calls update view - */ - void init_view() const; - void update_view() const; + /** + * compute the bounding box and calls update view + */ + void init_view() const; + void update_view() const; -protected: - void closeEvent(QCloseEvent *event); - void keyPressEvent(QKeyEvent *event){} + protected: + void closeEvent(QCloseEvent *event); -public: + void keyPressEvent(QKeyEvent *event) { } - public slots: + public: + public slots: + /** + * open a file chooser to choose an off to load + */ + void off_file_open(); + void off_points_open(); - /** - * open a file chooser to choose an off to load - */ - void off_file_open(); + /** + * open a file chooser to choose an off to save + */ + void off_file_save(); + void off_points_save(); - void off_points_open(); + void show_graph_stats(); + void show_complex_stats(); + void show_complex_dimension(); - /** - * open a file chooser to choose an off to save - */ - void off_file_save(); - void off_points_save(); - void show_graph_stats(); - void show_complex_stats(); - void show_complex_dimension(); + void build_rips_menu(); + void build_rips(double alpha); + void build_k_nearest_neighbors_menu(); + void build_k_nearest_neighbors(unsigned k); - void build_rips_menu(); - void build_rips(double alpha); - void build_k_nearest_neighbors_menu(); - void build_k_nearest_neighbors(unsigned k); + void contract_edge_menu(); + void contract_edges(unsigned num_collapses); - void contract_edge_menu(); - void contract_edges(unsigned num_collapses); + void collapse_vertices(); + void collapse_edges(); - void collapse_vertices(); - void collapse_edges(); + void uniform_noise(); + void lloyd(); + void show_homology_group(); + void show_euler_characteristic(); + void persistence_menu(); + void compute_persistence(int p, double threshold, int max_dim, double min_pers); + void critical_points_menu(); + void is_manifold_menu(); - void uniform_noise(); - void lloyd(); - - void show_homology_group(); - void show_euler_characteristic(); - void persistence_menu(); - void compute_persistence(int p,double threshold,int max_dim,double min_pers); - void critical_points_menu(); - void is_manifold_menu(); - - -public: - signals: - void sceneChanged() const; - + public: + signals: + void sceneChanged() const; }; -#endif +#endif // GUI_MAINWINDOW_H_ diff --git a/src/GudhUI/gui/Menu_edge_contraction.cpp b/src/GudhUI/gui/Menu_edge_contraction.cpp index dd2621be..a679b0bf 100644 --- a/src/GudhUI/gui/Menu_edge_contraction.cpp +++ b/src/GudhUI/gui/Menu_edge_contraction.cpp @@ -1,91 +1,97 @@ -/* - * Menu_edge_contraction.cpp +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#ifndef MENU_EDGE_CONTRACTION_CPP_ -#define MENU_EDGE_CONTRACTION_CPP_ - +#ifndef GUI_MENU_EDGE_CONTRACTION_CPP_ +#define GUI_MENU_EDGE_CONTRACTION_CPP_ #include "Menu_edge_contraction.h" -Menu_edge_contraction::Menu_edge_contraction(MainWindow* parent,const Model& model): -parent_(parent),model_(model) -{ - setupUi(this); - connectActions(parent_); +Menu_edge_contraction::Menu_edge_contraction(MainWindow* parent, const Model& model) : + parent_(parent), model_(model) { + setupUi(this); + connectActions(parent_); } -void Menu_edge_contraction::connectActions(MainWindow* parent) -{ - QObject::connect( - this->horizontalSlider, - SIGNAL(valueChanged(int)), - this, - SLOT(slider_value_changed(int)) - ); +void Menu_edge_contraction::connectActions(MainWindow* parent) { + QObject::connect( + this->horizontalSlider, + SIGNAL(valueChanged(int)), + this, + SLOT(slider_value_changed(int))); - QObject::connect(this, SIGNAL(contract_edges(unsigned)), parent, SLOT(contract_edges(unsigned))); - - QObject::connect(this->pushButton_collapse, SIGNAL(clicked()), this, SLOT(send_contract_edges())); + QObject::connect(this, SIGNAL(contract_edges(unsigned)), parent, SLOT(contract_edges(unsigned))); + QObject::connect(this->pushButton_collapse, SIGNAL(clicked()), this, SLOT(send_contract_edges())); } -void Menu_edge_contraction::slider_value_changed(int new_slider_value){ - int num_collapses = - (horizontalSlider->value()==1)? 1 : horizontalSlider->value() * model_.num_vertices() / 100 ; - this->txt_nb_vertices->setNum((int)model_.num_vertices()); - this->txt_nb_collapses->setNum(num_collapses); - this->spinBox_nb_remaining_vertices->setValue(model_.num_vertices()-num_collapses); +void Menu_edge_contraction::slider_value_changed(int new_slider_value) { + int num_collapses = + (horizontalSlider->value() == 1) ? 1 : horizontalSlider->value() * model_.num_vertices() / 100; + this->txt_nb_vertices->setNum(static_cast(model_.num_vertices())); + this->txt_nb_collapses->setNum(num_collapses); + this->spinBox_nb_remaining_vertices->setValue(model_.num_vertices() - num_collapses); } - void -Menu_edge_contraction::update_slider_value(){ - int num_vertices = model_.num_vertices(); - int num_collapses = (horizontalSlider->value()==1)? 1 : horizontalSlider->value() * num_vertices / 100 ; - int horizontal_slider_position = num_vertices>0? num_collapses/(double)num_vertices * 100 : 1 ; - horizontalSlider->setValue(horizontal_slider_position); +Menu_edge_contraction::update_slider_value() { + int num_vertices = model_.num_vertices(); + int num_collapses = (horizontalSlider->value() == 1) ? 1 : horizontalSlider->value() * num_vertices / 100; + int horizontal_slider_position = num_vertices > 0 ? num_collapses / static_cast(num_vertices * 100) : 1; + horizontalSlider->setValue(horizontal_slider_position); } - void -Menu_edge_contraction::update_gui_numbers(){ - update_slider_value(); - bool ok; - int num_collapses = this->txt_nb_collapses->text().toInt(&ok,10); - if(!ok) return; - this->txt_nb_vertices->setNum((int)model_.num_vertices()); - this->txt_nb_collapses->setNum(num_collapses); - this->spinBox_nb_remaining_vertices->setValue(model_.num_vertices()-num_collapses); +Menu_edge_contraction::update_gui_numbers() { + update_slider_value(); + bool ok; + int num_collapses = this->txt_nb_collapses->text().toInt(&ok, 10); + if (!ok) return; + this->txt_nb_vertices->setNum(static_cast(model_.num_vertices())); + this->txt_nb_collapses->setNum(num_collapses); + this->spinBox_nb_remaining_vertices->setValue(model_.num_vertices() - num_collapses); } void -Menu_edge_contraction::update_gui_numbers(int new_value){ - update_gui_numbers(); +Menu_edge_contraction::update_gui_numbers(int new_value) { + update_gui_numbers(); } - void -Menu_edge_contraction::send_contract_edges(){ - emit(contract_edges(num_collapses())); - update_gui_numbers(); +Menu_edge_contraction::send_contract_edges() { + emit(contract_edges(num_collapses())); + update_gui_numbers(); } unsigned -Menu_edge_contraction::num_vertices(){ - return model_.num_vertices(); +Menu_edge_contraction::num_vertices() { + return model_.num_vertices(); } unsigned -Menu_edge_contraction::num_collapses(){ - return (horizontalSlider->value()==1)? 1 : horizontalSlider->value() * num_vertices() / 100 ; +Menu_edge_contraction::num_collapses() { + return (horizontalSlider->value() == 1) ? 1 : horizontalSlider->value() * num_vertices() / 100; } - #include "Menu_edge_contraction.moc" -#endif /* MENU_EDGE_CONTRACTION_CPP_ */ +#endif // GUI_MENU_EDGE_CONTRACTION_CPP_ diff --git a/src/GudhUI/gui/Menu_edge_contraction.h b/src/GudhUI/gui/Menu_edge_contraction.h index 81d37bd8..08f0bf67 100644 --- a/src/GudhUI/gui/Menu_edge_contraction.h +++ b/src/GudhUI/gui/Menu_edge_contraction.h @@ -1,12 +1,27 @@ -/* - * Menu_edge_contraction.h +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#ifndef MENU_EDGE_CONTRACTION_H_ -#define MENU_EDGE_CONTRACTION_H_ +#ifndef GUI_MENU_EDGE_CONTRACTION_H_ +#define GUI_MENU_EDGE_CONTRACTION_H_ // Workaround for moc-qt4 not parsing boost headers #include @@ -16,39 +31,33 @@ #include "model/Model.h" +class Menu_edge_contraction : public QDialog, public Ui::MenuEdgeContraction { + Q_OBJECT -class Menu_edge_contraction : public QDialog,public Ui::MenuEdgeContraction{ - Q_OBJECT -private: - MainWindow* parent_; - const Model& model_; - + private: + MainWindow* parent_; + const Model& model_; - void update_slider_value(); -public: + void update_slider_value(); - Menu_edge_contraction(MainWindow* parent,const Model& model); + public: + Menu_edge_contraction(MainWindow* parent, const Model& model); - void connectActions(MainWindow* parent); + void connectActions(MainWindow* parent); + private: + unsigned num_vertices(); + unsigned num_collapses(); -private: - unsigned num_vertices(); - unsigned num_collapses(); + public slots: + void slider_value_changed(int new_slider_value); + void update_gui_numbers(); + void update_gui_numbers(int gui_numbers); - public slots: - - void slider_value_changed(int new_slider_value); - void update_gui_numbers(); - void update_gui_numbers(int); - - void send_contract_edges(); - signals: - - void contract_edges(unsigned num_collapses); + void send_contract_edges(); + signals: + void contract_edges(unsigned num_collapses); }; - - -#endif /* MENU_EDGE_CONTRACTION_H_ */ +#endif // GUI_MENU_EDGE_CONTRACTION_H_ diff --git a/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp b/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp index 21c67b2a..e24865f2 100644 --- a/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp +++ b/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp @@ -1,55 +1,59 @@ -/* - * Menu_k_nearest_neighbors.cpp +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ - #include "Menu_k_nearest_neighbors.h" -Menu_k_nearest_neighbors::Menu_k_nearest_neighbors(QMainWindow* parent_): -parent(parent_) -{ - setupUi(this); - connectActions(parent_); +Menu_k_nearest_neighbors::Menu_k_nearest_neighbors(QMainWindow* parent_) + : parent(parent_) { + setupUi(this); + connectActions(parent_); } -void Menu_k_nearest_neighbors::connectActions(QMainWindow* parent){ - - QObject::connect( - this->pushButtonCompute, - SIGNAL(clicked()), - this, - SLOT(send_compute_k_nearest_neighbors()) - ); - QObject::connect( - this->spinBoxK, - SIGNAL(valueChanged(int)), - this, - SLOT(update_k(int)) - ); - QObject::connect( - this, - SIGNAL(compute_k_nearest_neighbors(unsigned)), - parent, - SLOT(build_k_nearest_neighbors(unsigned)) - ); - +void Menu_k_nearest_neighbors::connectActions(QMainWindow* parent) { + QObject::connect(this->pushButtonCompute, + SIGNAL(clicked()), + this, + SLOT(send_compute_k_nearest_neighbors())); + QObject::connect(this->spinBoxK, + SIGNAL(valueChanged(int)), + this, + SLOT(update_k(int))); + QObject::connect(this, + SIGNAL(compute_k_nearest_neighbors(unsigned)), + parent, + SLOT(build_k_nearest_neighbors(unsigned))); } -void Menu_k_nearest_neighbors::send_compute_k_nearest_neighbors(){ - emit(compute_k_nearest_neighbors((unsigned)spinBoxK->value())); +void Menu_k_nearest_neighbors::send_compute_k_nearest_neighbors() { + emit(compute_k_nearest_neighbors((unsigned) spinBoxK->value())); } -void Menu_k_nearest_neighbors::accept(){ - send_compute_k_nearest_neighbors(); +void Menu_k_nearest_neighbors::accept() { + send_compute_k_nearest_neighbors(); } -void Menu_k_nearest_neighbors::update_k(int new_k_value){ - if(checkBoxAutoUpdate->isChecked()) - emit(compute_k_nearest_neighbors((unsigned)spinBoxK->value())); +void Menu_k_nearest_neighbors::update_k(int new_k_value) { + if (checkBoxAutoUpdate->isChecked()) + emit(compute_k_nearest_neighbors((unsigned) spinBoxK->value())); } - #include "Menu_k_nearest_neighbors.moc" diff --git a/src/GudhUI/gui/Menu_k_nearest_neighbors.h b/src/GudhUI/gui/Menu_k_nearest_neighbors.h index d72b0074..8088b768 100644 --- a/src/GudhUI/gui/Menu_k_nearest_neighbors.h +++ b/src/GudhUI/gui/Menu_k_nearest_neighbors.h @@ -1,39 +1,51 @@ -/* - * Menu_k_nearest_neighbors.h +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#ifndef MENU_K_NEAREST_NEIGHBORS_H_ -#define MENU_K_NEAREST_NEIGHBORS_H_ +#ifndef GUI_MENU_K_NEAREST_NEIGHBORS_H_ +#define GUI_MENU_K_NEAREST_NEIGHBORS_H_ #include #include "gui/ui_KNearestNeighborsMenu.h" class QWidget; +class Menu_k_nearest_neighbors : public QDialog, public Ui::KNearestNeighborsMenu { + Q_OBJECT -class Menu_k_nearest_neighbors : public QDialog,public Ui::KNearestNeighborsMenu{ - Q_OBJECT -private: - QMainWindow* parent; + private: + QMainWindow* parent; -public: + public: + Menu_k_nearest_neighbors(QMainWindow* parent_); - Menu_k_nearest_neighbors(QMainWindow* parent_); + void connectActions(QMainWindow* parent); - void connectActions(QMainWindow* parent); - - public slots: - void send_compute_k_nearest_neighbors(); - void update_k(int); - void accept(); - - signals: - void compute_k_nearest_neighbors(unsigned k); + public slots: + void send_compute_k_nearest_neighbors(); + void update_k(int k); + void accept(); + signals: + void compute_k_nearest_neighbors(unsigned k); }; - -#endif /* MENU_K_NEAREST_NEIGHBORS_H_ */ +#endif // GUI_MENU_K_NEAREST_NEIGHBORS_H_ diff --git a/src/GudhUI/gui/Menu_persistence.cpp b/src/GudhUI/gui/Menu_persistence.cpp index fae3a0e6..016c076b 100644 --- a/src/GudhUI/gui/Menu_persistence.cpp +++ b/src/GudhUI/gui/Menu_persistence.cpp @@ -1,13 +1,10 @@ -/* - * Menu_persistence.cpp - * Created on: Jan 27, 2015 - * This file is part of the Gudhi Library. The Gudhi library +/* This file is part of the Gudhi Library. The Gudhi library * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,34 +24,30 @@ #include "Menu_persistence.h" -Menu_persistence::Menu_persistence(QMainWindow* parent_):parent(parent_) -{ - setupUi(this); - connectActions(parent_); +Menu_persistence::Menu_persistence(QMainWindow* parent_) : parent(parent_) { + setupUi(this); + connectActions(parent_); } -void Menu_persistence::connectActions(QMainWindow* parent){ - QObject::connect( - this, - SIGNAL(compute_persistence(int,double,int,double)), - parent, - SLOT(compute_persistence(int,double,int,double)) - ); +void Menu_persistence::connectActions(QMainWindow* parent) { + QObject::connect(this, + SIGNAL(compute_persistence(int, double, int, double)), + parent, + SLOT(compute_persistence(int, double, int, double))); } -void Menu_persistence::send_compute_persistence(){ - emit(compute_persistence(p_spinBox->value(),threshold_doubleSpinBox->value(), - maxdimension_spinBox->value(),minpersistence_doubleSpinBox->value())); +void Menu_persistence::send_compute_persistence() { + emit(compute_persistence(p_spinBox->value(), threshold_doubleSpinBox->value(), + maxdimension_spinBox->value(), minpersistence_doubleSpinBox->value())); } -void Menu_persistence::accept(){ - send_compute_persistence(); +void Menu_persistence::accept() { + send_compute_persistence(); } -//void Menu_persistence::compute_persistence(int p_fied,double threshold,int dim_max,double min_persistence){ -//// if(checkBoxAutoUpdate->isChecked()) -//// emit(compute_k_nearest_neighbors((unsigned)spinBoxK->value())); -//} - +// void Menu_persistence::compute_persistence(int p_fied,double threshold,int dim_max,double min_persistence) { +// if(checkBoxAutoUpdate->isChecked()) +// emit(compute_k_nearest_neighbors((unsigned)spinBoxK->value())); +// } #include "Menu_persistence.moc" diff --git a/src/GudhUI/gui/Menu_persistence.h b/src/GudhUI/gui/Menu_persistence.h index 67b64afa..8c4df158 100644 --- a/src/GudhUI/gui/Menu_persistence.h +++ b/src/GudhUI/gui/Menu_persistence.h @@ -1,13 +1,10 @@ -/* - * Menu_persistence.h - * Created on: Jan 27, 2015 - * This file is part of the Gudhi Library. The Gudhi library +/* This file is part of the Gudhi Library. The Gudhi library * (Geometric Understanding in Higher Dimensions) is a generic C++ * library for computational topology. * * Author(s): David Salinas * - * Copyright (C) 2014 INRIA Sophia Antipolis-Méditerranée (France) + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,36 +21,31 @@ * */ - -#ifndef MENU_PERSISTENCE_H_ -#define MENU_PERSISTENCE_H_ - +#ifndef GUI_MENU_PERSISTENCE_H_ +#define GUI_MENU_PERSISTENCE_H_ #include #include "gui/ui_PersistenceMenu.h" class QWidget; +class Menu_persistence : public QDialog, public Ui::PersistenceMenu { + Q_OBJECT -class Menu_persistence : public QDialog,public Ui::PersistenceMenu{ - Q_OBJECT -private: - QMainWindow* parent; - -public: + private: + QMainWindow* parent; - Menu_persistence(QMainWindow* parent_); + public: + Menu_persistence(QMainWindow* parent_); - void connectActions(QMainWindow* parent); + void connectActions(QMainWindow* parent); - public slots: - void send_compute_persistence(); - void accept(); - signals: - void compute_persistence(int p_fied,double threshold,int dim_max,double min_persistence); + public slots: + void send_compute_persistence(); + void accept(); + signals: + void compute_persistence(int p_fied, double threshold, int dim_max, double min_persistence); }; - - -#endif /* MENU_PERSISTENCE_H_ */ +#endif // GUI_MENU_PERSISTENCE_H_ diff --git a/src/GudhUI/gui/Menu_uniform_neighbors.cpp b/src/GudhUI/gui/Menu_uniform_neighbors.cpp index 86e2593e..20e4f98f 100644 --- a/src/GudhUI/gui/Menu_uniform_neighbors.cpp +++ b/src/GudhUI/gui/Menu_uniform_neighbors.cpp @@ -1,59 +1,60 @@ -/* - * Menu_uniform_neighbors.cpp +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * */ - - - - #include "Menu_uniform_neighbors.h" -Menu_uniform_neighbors::Menu_uniform_neighbors(QMainWindow* parent_): -parent(parent_) -{ - setupUi(this); - connectActions(parent_); +Menu_uniform_neighbors::Menu_uniform_neighbors(QMainWindow* parent_) : + parent(parent_) { + setupUi(this); + connectActions(parent_); } -void Menu_uniform_neighbors::connectActions(QMainWindow* parent){ - - QObject::connect( - this->pushButtonCompute, - SIGNAL(clicked()), - this, - SLOT(send_compute_uniform_neighbors()) - ); - QObject::connect( - this->doubleSpinBoxAlpha, - SIGNAL(valueChanged(double)), - this, - SLOT(update_alpha(double)) - ); - QObject::connect( - this, - SIGNAL(compute_uniform_neighbors(double)), - parent, - SLOT(build_rips(double)) - ); - +void Menu_uniform_neighbors::connectActions(QMainWindow* parent) { + QObject::connect(this->pushButtonCompute, + SIGNAL(clicked()), + this, + SLOT(send_compute_uniform_neighbors())); + QObject::connect(this->doubleSpinBoxAlpha, + SIGNAL(valueChanged(double)), + this, + SLOT(update_alpha(double))); + QObject::connect(this, + SIGNAL(compute_uniform_neighbors(double)), + parent, + SLOT(build_rips(double))); } -void Menu_uniform_neighbors::send_compute_uniform_neighbors(){ - emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); +void Menu_uniform_neighbors::send_compute_uniform_neighbors() { + emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); } -void Menu_uniform_neighbors::accept(){ - send_compute_uniform_neighbors(); +void Menu_uniform_neighbors::accept() { + send_compute_uniform_neighbors(); } -void Menu_uniform_neighbors::update_alpha(double alpha){ - if(checkBoxAutoUpdate->isChecked()) - emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); +void Menu_uniform_neighbors::update_alpha(double alpha) { + if (checkBoxAutoUpdate->isChecked()) + emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); } - - #include "Menu_uniform_neighbors.moc" diff --git a/src/GudhUI/gui/Menu_uniform_neighbors.h b/src/GudhUI/gui/Menu_uniform_neighbors.h index cb90cc88..0b6f65fe 100644 --- a/src/GudhUI/gui/Menu_uniform_neighbors.h +++ b/src/GudhUI/gui/Menu_uniform_neighbors.h @@ -1,36 +1,51 @@ -/* - * Menu_uniform_neighbors.h +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. * - * Created on: Sep 11, 2014 - * Author: dsalinas + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * */ -#ifndef MENU_UNIFORM_NEIGHBORS_H_ -#define MENU_UNIFORM_NEIGHBORS_H_ +#ifndef GUI_MENU_UNIFORM_NEIGHBORS_H_ +#define GUI_MENU_UNIFORM_NEIGHBORS_H_ #include #include "gui/ui_UniformNeighborsMenu.h" -class Menu_uniform_neighbors : public QDialog,public Ui::UniformMenu { - Q_OBJECT -private: - QMainWindow* parent; - -public: +class Menu_uniform_neighbors : public QDialog, public Ui::UniformMenu { + Q_OBJECT - Menu_uniform_neighbors(QMainWindow* parent_); + private: + QMainWindow* parent; - void connectActions(QMainWindow* parent); + public: + Menu_uniform_neighbors(QMainWindow* parent_); - public slots: - void send_compute_uniform_neighbors(); - void update_alpha(double); - void accept(); + void connectActions(QMainWindow* parent); - signals: - void compute_uniform_neighbors(double alpha); + public slots: + void send_compute_uniform_neighbors(); + void update_alpha(double alpha); + void accept(); + signals: + void compute_uniform_neighbors(double alpha); }; -#endif /* MENU_UNIFORM_NEIGHBORS_H_ */ +#endif // GUI_MENU_UNIFORM_NEIGHBORS_H_ diff --git a/src/GudhUI/gui/Viewer.cpp b/src/GudhUI/gui/Viewer.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/GudhUI/gui/Viewer_instructor.cpp b/src/GudhUI/gui/Viewer_instructor.cpp deleted file mode 100644 index e69de29b..00000000 diff --git a/src/GudhUI/gui/gudhui.cpp b/src/GudhUI/gui/gudhui.cpp index 8d90270f..377cd2f2 100644 --- a/src/GudhUI/gui/gudhui.cpp +++ b/src/GudhUI/gui/gudhui.cpp @@ -1,15 +1,36 @@ +/* This file is part of the Gudhi Library. The Gudhi library + * (Geometric Understanding in Higher Dimensions) is a generic C++ + * library for computational topology. + * + * Author(s): David Salinas + * + * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + #include "MainWindow.h" #include #include +int main(int argc, char** argv) { + QApplication application(argc, argv); + application.setOrganizationDomain("inria.fr"); + application.setOrganizationName("INRIA"); + application.setApplicationName("GudhUI"); -int main(int argc, char** argv) -{ - QApplication application(argc,argv); - application.setOrganizationDomain("inria.fr"); - application.setOrganizationName("INRIA"); - application.setApplicationName("GudhUI"); - MainWindow mw; application.setQuitOnLastWindowClosed(false); mw.show(); -- cgit v1.2.3