diff options
author | salinasd <salinasd@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-01-27 10:20:13 +0000 |
---|---|---|
committer | salinasd <salinasd@636b058d-ea47-450e-bf9e-a15bfbe3eedb> | 2015-01-27 10:20:13 +0000 |
commit | f527cde6342c5b8109a20f0a6b483327c6569844 (patch) | |
tree | 1c0464b56b21ef7767f814b9a35a6e5c68aa7613 /src/GudhUI/gui | |
parent | df6c26bdcb28805e8949d08dad5acd012e91ecb8 (diff) |
Merge GudhUI, a UI for gudhi based on Qt
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/trunk@427 636b058d-ea47-450e-bf9e-a15bfbe3eedb
Former-commit-id: 17fedd974f14a8225b27d94361e835964eeb5cba
Diffstat (limited to 'src/GudhUI/gui')
-rw-r--r-- | src/GudhUI/gui/KNearestNeighborsMenu.ui | 150 | ||||
-rw-r--r-- | src/GudhUI/gui/MainWindow.cpp | 283 | ||||
-rw-r--r-- | src/GudhUI/gui/MainWindow.h | 97 | ||||
-rw-r--r-- | src/GudhUI/gui/MenuEdgeContraction.ui | 118 | ||||
-rw-r--r-- | src/GudhUI/gui/Menu_edge_contraction.cpp | 91 | ||||
-rw-r--r-- | src/GudhUI/gui/Menu_edge_contraction.h | 52 | ||||
-rw-r--r-- | src/GudhUI/gui/Menu_k_nearest_neighbors.cpp | 55 | ||||
-rw-r--r-- | src/GudhUI/gui/Menu_k_nearest_neighbors.h | 39 | ||||
-rw-r--r-- | src/GudhUI/gui/Menu_persistence.cpp | 60 | ||||
-rw-r--r-- | src/GudhUI/gui/Menu_persistence.h | 59 | ||||
-rw-r--r-- | src/GudhUI/gui/Menu_uniform_neighbors.cpp | 59 | ||||
-rw-r--r-- | src/GudhUI/gui/Menu_uniform_neighbors.h | 36 | ||||
-rw-r--r-- | src/GudhUI/gui/PersistenceMenu.ui | 139 | ||||
-rw-r--r-- | src/GudhUI/gui/UniformNeighborsMenu.ui | 150 | ||||
-rw-r--r-- | src/GudhUI/gui/Viewer.cpp | 0 | ||||
-rw-r--r-- | src/GudhUI/gui/Viewer_instructor.cpp | 0 | ||||
-rw-r--r-- | src/GudhUI/gui/gudhui.cpp | 17 | ||||
-rw-r--r-- | src/GudhUI/gui/main_window.ui | 231 |
18 files changed, 1636 insertions, 0 deletions
diff --git a/src/GudhUI/gui/KNearestNeighborsMenu.ui b/src/GudhUI/gui/KNearestNeighborsMenu.ui new file mode 100644 index 00000000..472db48b --- /dev/null +++ b/src/GudhUI/gui/KNearestNeighborsMenu.ui @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>KNearestNeighborsMenu</class> + <widget class="QDialog" name="KNearestNeighborsMenu"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>298</width> + <height>209</height> + </rect> + </property> + <property name="windowTitle"> + <string>k-nearest neighbors</string> + </property> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="geometry"> + <rect> + <x>50</x> + <y>160</y> + <width>171</width> + <height>32</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + <widget class="QWidget" name="formLayoutWidget"> + <property name="geometry"> + <rect> + <x>30</x> + <y>10</y> + <width>229</width> + <height>84</height> + </rect> + </property> + <layout class="QFormLayout" name="formLayout_2"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>k </string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QSpinBox" name="spinBoxK"> + <property name="maximum"> + <number>10000000</number> + </property> + <property name="value"> + <number>0</number> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Metric</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="comboBoxMetric"> + <item> + <property name="text"> + <string>Ambient</string> + </property> + </item> + <item> + <property name="text"> + <string>Reduced Space</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="gridLayoutWidget"> + <property name="geometry"> + <rect> + <x>30</x> + <y>110</y> + <width>250</width> + <height>40</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QPushButton" name="pushButtonCompute"> + <property name="text"> + <string>Compute</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QCheckBox" name="checkBoxAutoUpdate"> + <property name="text"> + <string>auto update</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>KNearestNeighborsMenu</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>KNearestNeighborsMenu</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/GudhUI/gui/MainWindow.cpp b/src/GudhUI/gui/MainWindow.cpp new file mode 100644 index 00000000..85745e93 --- /dev/null +++ b/src/GudhUI/gui/MainWindow.cpp @@ -0,0 +1,283 @@ +#include "MainWindow.h" + +#include <QWidget> +#include <QInputDialog> +#include <QFileDialog> + +#include <fenv.h> + + +#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 + + setupUi(this); + + viewer_instructor_ = new Viewer_instructor( + this, + this->viewer, + model_.complex_ + ); + + connectActions(); + + update_view(); +} + +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, SIGNAL(sceneChanged()), this->viewer_instructor_, + SLOT(sceneChanged())); + +} + +void +MainWindow::init_view() const{ + viewer_instructor_->initialize_bounding_box(); + viewer_instructor_->show_entire_scene(); + update_view(); +} + + +void +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_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()); + } +} + +/** + * 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()); + } +} + + +void +MainWindow::show_graph_stats(){ + model_.show_graph_stats(); +} + +void +MainWindow::show_complex_stats(){ + model_.show_complex_stats(); +} + +void +MainWindow::show_complex_dimension(){ + model_.show_complex_dimension(); +} + + +void +MainWindow::build_rips_menu(){ + menu_uniform_neighbors_->show(); +} + +void +MainWindow::build_rips(double alpha){ + model_.build_rips(alpha); + update_view(); +} + +void +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(); +} + +void +MainWindow::contract_edge_menu(){ + menu_edge_contraction_->show(); +} + +void +MainWindow::contract_edges(unsigned num_collapses){ + std::cerr <<"Collapse "<<num_collapses<< " vertices\n"; + model_.contract_edges(num_collapses); + update_view(); +} + + +void +MainWindow::collapse_edges(){ + std::cerr <<"Collapse "<<100<< " edges\n"; + model_.collapse_edges(100); + update_view(); +} + + + +void +MainWindow::collapse_vertices(){ + std::cerr <<"Collapse vertices edges\n"; + model_.collapse_vertices(0); + update_view(); +} + + +void +MainWindow::uniform_noise(){ + bool ok; + double amplitude = QInputDialog::getDouble(this, tr("Uniform noise"), + tr("Amplitude:"), 0, 0, 10000, 3, &ok); + srand(time(NULL)); + if (ok) + model_.uniform_noise(amplitude); +} + + +void +MainWindow::lloyd(){ + //todo 1 ask lloyd parameters + model_.lloyd(0,0); + update_view(); +} + +void +MainWindow::show_homology_group(){ + model_.show_homology_group(); +} + +void +MainWindow::show_euler_characteristic(){ + model_.show_euler_characteristic(); +} + + + +void +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); +} + + + +#include "MainWindow.moc" diff --git a/src/GudhUI/gui/MainWindow.h b/src/GudhUI/gui/MainWindow.h new file mode 100644 index 00000000..0eef29ed --- /dev/null +++ b/src/GudhUI/gui/MainWindow.h @@ -0,0 +1,97 @@ +#ifndef MAIN_WINDOW_H +#define MAIN_WINDOW_H + + +#include <QMainWindow> +#include "ui_main_window.h" +#include "model/Model.h" +#include "view/Viewer_instructor.h" + + +class Menu_k_nearest_neighbors; +class Menu_uniform_neighbors; +class Menu_edge_contraction; +class Menu_persistence; + +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_; + +public: + MainWindow(QWidget* parent = 0); + void connectActions(); + + /** + * 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){} + +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 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 contract_edge_menu(); + void contract_edges(unsigned num_collapses); + + + 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); + + + +public: + signals: + void sceneChanged() const; + + +}; + + +#endif diff --git a/src/GudhUI/gui/MenuEdgeContraction.ui b/src/GudhUI/gui/MenuEdgeContraction.ui new file mode 100644 index 00000000..da2e5c82 --- /dev/null +++ b/src/GudhUI/gui/MenuEdgeContraction.ui @@ -0,0 +1,118 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MenuEdgeContraction</class>
+ <widget class="QDialog" name="MenuEdgeContraction">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>362</width>
+ <height>209</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Edge contraction</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="5" column="2">
+ <widget class="QSpinBox" name="spinBox_nb_remaining_vertices">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>999999999</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="2">
+ <widget class="QCheckBox" name="checkBox_link_condition">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Link condition</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2" alignment="Qt::AlignRight">
+ <widget class="QLabel" name="txt_nb_collapses">
+ <property name="text">
+ <string>1</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Policy</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="2">
+ <widget class="QComboBox" name="m_simplificationMethod">
+ <item>
+ <property name="text">
+ <string>Length_midpoint</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="2" alignment="Qt::AlignRight">
+ <widget class="QLabel" name="txt_nb_vertices">
+ <property name="text">
+ <string>0</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Number of vertices</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="2">
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Number of contractions</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" colspan="2">
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Number of vertices after </string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QSlider" name="horizontalSlider">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QPushButton" name="pushButton_collapse">
+ <property name="text">
+ <string>Perform collapse</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/src/GudhUI/gui/Menu_edge_contraction.cpp b/src/GudhUI/gui/Menu_edge_contraction.cpp new file mode 100644 index 00000000..dd2621be --- /dev/null +++ b/src/GudhUI/gui/Menu_edge_contraction.cpp @@ -0,0 +1,91 @@ +/* + * Menu_edge_contraction.cpp + * + * Created on: Sep 11, 2014 + * Author: dsalinas + */ + +#ifndef MENU_EDGE_CONTRACTION_CPP_ +#define 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_); +} + +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())); + +} + +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::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); +} + + +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); +} + +void +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(); +} + +unsigned +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 ; +} + + +#include "Menu_edge_contraction.moc" + +#endif /* MENU_EDGE_CONTRACTION_CPP_ */ diff --git a/src/GudhUI/gui/Menu_edge_contraction.h b/src/GudhUI/gui/Menu_edge_contraction.h new file mode 100644 index 00000000..e497a90f --- /dev/null +++ b/src/GudhUI/gui/Menu_edge_contraction.h @@ -0,0 +1,52 @@ +/* + * Menu_edge_contraction.h + * + * Created on: Sep 11, 2014 + * Author: dsalinas + */ + +#ifndef MENU_EDGE_CONTRACTION_H_ +#define MENU_EDGE_CONTRACTION_H_ + + +#include "gui/MainWindow.h" +#include "gui/ui_MenuEdgeContraction.h" + +#include "model/Model.h" + + +class Menu_edge_contraction : public QDialog,public Ui::MenuEdgeContraction{ + Q_OBJECT +private: + MainWindow* parent_; + const Model& model_; + + + void update_slider_value(); +public: + + Menu_edge_contraction(MainWindow* parent,const Model& model); + + void connectActions(MainWindow* parent); + + +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); + + void send_contract_edges(); + signals: + + void contract_edges(unsigned num_collapses); + +}; + + + +#endif /* MENU_EDGE_CONTRACTION_H_ */ diff --git a/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp b/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp new file mode 100644 index 00000000..21c67b2a --- /dev/null +++ b/src/GudhUI/gui/Menu_k_nearest_neighbors.cpp @@ -0,0 +1,55 @@ +/* + * Menu_k_nearest_neighbors.cpp + * + * Created on: Sep 11, 2014 + * Author: dsalinas + */ + + +#include "Menu_k_nearest_neighbors.h" + +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::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::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 new file mode 100644 index 00000000..d72b0074 --- /dev/null +++ b/src/GudhUI/gui/Menu_k_nearest_neighbors.h @@ -0,0 +1,39 @@ +/* + * Menu_k_nearest_neighbors.h + * + * Created on: Sep 11, 2014 + * Author: dsalinas + */ + +#ifndef MENU_K_NEAREST_NEIGHBORS_H_ +#define MENU_K_NEAREST_NEIGHBORS_H_ + +#include <QMainWindow> +#include "gui/ui_KNearestNeighborsMenu.h" + +class QWidget; + + +class Menu_k_nearest_neighbors : public QDialog,public Ui::KNearestNeighborsMenu{ + Q_OBJECT +private: + QMainWindow* parent; + +public: + + Menu_k_nearest_neighbors(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); + +}; + + +#endif /* MENU_K_NEAREST_NEIGHBORS_H_ */ diff --git a/src/GudhUI/gui/Menu_persistence.cpp b/src/GudhUI/gui/Menu_persistence.cpp new file mode 100644 index 00000000..fae3a0e6 --- /dev/null +++ b/src/GudhUI/gui/Menu_persistence.cpp @@ -0,0 +1,60 @@ +/* + * Menu_persistence.cpp + * Created on: Jan 27, 2015 + * 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) + * + * 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 <http://www.gnu.org/licenses/>. + * + */ + + +#include "Menu_persistence.h" + +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::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::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 new file mode 100644 index 00000000..67b64afa --- /dev/null +++ b/src/GudhUI/gui/Menu_persistence.h @@ -0,0 +1,59 @@ +/* + * Menu_persistence.h + * Created on: Jan 27, 2015 + * 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) + * + * 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 <http://www.gnu.org/licenses/>. + * + */ + + +#ifndef MENU_PERSISTENCE_H_ +#define MENU_PERSISTENCE_H_ + + +#include <QMainWindow> +#include "gui/ui_PersistenceMenu.h" + +class QWidget; + + +class Menu_persistence : public QDialog,public Ui::PersistenceMenu{ + Q_OBJECT +private: + QMainWindow* parent; + +public: + + Menu_persistence(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); + +}; + + + +#endif /* MENU_PERSISTENCE_H_ */ diff --git a/src/GudhUI/gui/Menu_uniform_neighbors.cpp b/src/GudhUI/gui/Menu_uniform_neighbors.cpp new file mode 100644 index 00000000..86e2593e --- /dev/null +++ b/src/GudhUI/gui/Menu_uniform_neighbors.cpp @@ -0,0 +1,59 @@ +/* + * Menu_uniform_neighbors.cpp + * + * Created on: Sep 11, 2014 + * Author: dsalinas + */ + + + + + +#include "Menu_uniform_neighbors.h" + +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::send_compute_uniform_neighbors(){ + emit(compute_uniform_neighbors(doubleSpinBoxAlpha->value())); +} + +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())); +} + + + +#include "Menu_uniform_neighbors.moc" diff --git a/src/GudhUI/gui/Menu_uniform_neighbors.h b/src/GudhUI/gui/Menu_uniform_neighbors.h new file mode 100644 index 00000000..cb90cc88 --- /dev/null +++ b/src/GudhUI/gui/Menu_uniform_neighbors.h @@ -0,0 +1,36 @@ +/* + * Menu_uniform_neighbors.h + * + * Created on: Sep 11, 2014 + * Author: dsalinas + */ + +#ifndef MENU_UNIFORM_NEIGHBORS_H_ +#define MENU_UNIFORM_NEIGHBORS_H_ + +#include <QMainWindow> +#include "gui/ui_UniformNeighborsMenu.h" + +class Menu_uniform_neighbors : public QDialog,public Ui::UniformMenu { + Q_OBJECT +private: + QMainWindow* parent; + +public: + + Menu_uniform_neighbors(QMainWindow* parent_); + + void connectActions(QMainWindow* parent); + + public slots: + void send_compute_uniform_neighbors(); + void update_alpha(double); + void accept(); + + signals: + void compute_uniform_neighbors(double alpha); + +}; + + +#endif /* MENU_UNIFORM_NEIGHBORS_H_ */ diff --git a/src/GudhUI/gui/PersistenceMenu.ui b/src/GudhUI/gui/PersistenceMenu.ui new file mode 100644 index 00000000..29327db2 --- /dev/null +++ b/src/GudhUI/gui/PersistenceMenu.ui @@ -0,0 +1,139 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>PersistenceMenu</class> + <widget class="QDialog" name="PersistenceMenu"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>354</width> + <height>275</height> + </rect> + </property> + <property name="windowTitle"> + <string>Point cloud persistence</string> + </property> + <widget class="QWidget" name=""> + <property name="geometry"> + <rect> + <x>20</x> + <y>23</y> + <width>318</width> + <height>226</height> + </rect> + </property> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="0"> + <widget class="QSpinBox" name="p_spinBox"> + <property name="minimum"> + <number>2</number> + </property> + <property name="value"> + <number>2</number> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Coefficient Z/pZ</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QSpinBox" name="maxdimension_spinBox"> + <property name="maximum"> + <number>9999</number> + </property> + <property name="value"> + <number>10</number> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="label_4"> + <property name="text"> + <string>Max dimension</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QDoubleSpinBox" name="threshold_doubleSpinBox"> + <property name="maximum"> + <double>9999.000000000000000</double> + </property> + <property name="value"> + <double>1.000000000000000</double> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Max Rips offset</string> + </property> + </widget> + </item> + <item row="3" column="0"> + <widget class="QDoubleSpinBox" name="minpersistence_doubleSpinBox"/> + </item> + <item row="3" column="1"> + <widget class="QLabel" name="label_3"> + <property name="text"> + <string>Minimum Persistence</string> + </property> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>PersistenceMenu</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>PersistenceMenu</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/GudhUI/gui/UniformNeighborsMenu.ui b/src/GudhUI/gui/UniformNeighborsMenu.ui new file mode 100644 index 00000000..1f7cf980 --- /dev/null +++ b/src/GudhUI/gui/UniformNeighborsMenu.ui @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>UniformMenu</class> + <widget class="QDialog" name="UniformMenu"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>292</width> + <height>209</height> + </rect> + </property> + <property name="windowTitle"> + <string>Uniform neighbors (Rips)</string> + </property> + <widget class="QDialogButtonBox" name="buttonBox"> + <property name="geometry"> + <rect> + <x>50</x> + <y>160</y> + <width>171</width> + <height>32</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="standardButtons"> + <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> + </property> + </widget> + <widget class="QWidget" name="formLayoutWidget"> + <property name="geometry"> + <rect> + <x>30</x> + <y>10</y> + <width>249</width> + <height>84</height> + </rect> + </property> + <layout class="QFormLayout" name="formLayout_2"> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="label"> + <property name="text"> + <string>alpha</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Metric</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QComboBox" name="comboBoxMetric"> + <item> + <property name="text"> + <string>Ambient</string> + </property> + </item> + <item> + <property name="text"> + <string>Reduced Space</string> + </property> + </item> + </widget> + </item> + <item row="0" column="1"> + <widget class="QDoubleSpinBox" name="doubleSpinBoxAlpha"> + <property name="maximum"> + <double>100000000.000000000000000</double> + </property> + <property name="singleStep"> + <double>0.100000000000000</double> + </property> + </widget> + </item> + </layout> + </widget> + <widget class="QWidget" name="gridLayoutWidget"> + <property name="geometry"> + <rect> + <x>30</x> + <y>110</y> + <width>250</width> + <height>40</height> + </rect> + </property> + <layout class="QGridLayout" name="gridLayout"> + <item row="0" column="1"> + <widget class="QPushButton" name="pushButtonCompute"> + <property name="text"> + <string>Compute</string> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QCheckBox" name="checkBoxAutoUpdate"> + <property name="text"> + <string>auto update</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + <resources/> + <connections> + <connection> + <sender>buttonBox</sender> + <signal>accepted()</signal> + <receiver>UniformMenu</receiver> + <slot>accept()</slot> + <hints> + <hint type="sourcelabel"> + <x>248</x> + <y>254</y> + </hint> + <hint type="destinationlabel"> + <x>157</x> + <y>274</y> + </hint> + </hints> + </connection> + <connection> + <sender>buttonBox</sender> + <signal>rejected()</signal> + <receiver>UniformMenu</receiver> + <slot>reject()</slot> + <hints> + <hint type="sourcelabel"> + <x>316</x> + <y>260</y> + </hint> + <hint type="destinationlabel"> + <x>286</x> + <y>274</y> + </hint> + </hints> + </connection> + </connections> +</ui> diff --git a/src/GudhUI/gui/Viewer.cpp b/src/GudhUI/gui/Viewer.cpp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/GudhUI/gui/Viewer.cpp diff --git a/src/GudhUI/gui/Viewer_instructor.cpp b/src/GudhUI/gui/Viewer_instructor.cpp new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/src/GudhUI/gui/Viewer_instructor.cpp diff --git a/src/GudhUI/gui/gudhui.cpp b/src/GudhUI/gui/gudhui.cpp new file mode 100644 index 00000000..8d90270f --- /dev/null +++ b/src/GudhUI/gui/gudhui.cpp @@ -0,0 +1,17 @@ +#include "MainWindow.h"
+#include <QApplication>
+#include <CGAL/Qt/resources.h>
+
+
+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();
+ return application.exec();
+}
diff --git a/src/GudhUI/gui/main_window.ui b/src/GudhUI/gui/main_window.ui new file mode 100644 index 00000000..ac3caf41 --- /dev/null +++ b/src/GudhUI/gui/main_window.ui @@ -0,0 +1,231 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>861</width> + <height>880</height> + </rect> + </property> + <property name="windowTitle"> + <string>GudhUI</string> + </property> + <property name="tabShape"> + <enum>QTabWidget::Rounded</enum> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="Viewer" name="viewer" native="true"> + <property name="autoFillBackground"> + <bool>false</bool> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>861</width> + <height>34</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <addaction name="actionLoad_points"/> + <addaction name="actionLoad_complex"/> + <addaction name="actionSave_points"/> + <addaction name="actionSave_complex"/> + </widget> + <widget class="QMenu" name="menuPoints"> + <property name="title"> + <string>Points</string> + </property> + <addaction name="actionNoise"/> + </widget> + <widget class="QMenu" name="menuGraph"> + <property name="title"> + <string>Graph</string> + </property> + <addaction name="actionK_nearest_neighbors_graph"/> + <addaction name="actionUniform_proximity_graph"/> + <addaction name="actionShow_graph_stats"/> + </widget> + <widget class="QMenu" name="menuComplex"> + <property name="title"> + <string>Complex</string> + </property> + <addaction name="actionContract_edges"/> + <addaction name="actionCollapse_vertices"/> + <addaction name="actionCollapse_edges"/> + <addaction name="actionShow_complex_stats"/> + <addaction name="actionShow_complex_dimension"/> + </widget> + <widget class="QMenu" name="menuView"> + <property name="title"> + <string>View</string> + </property> + <addaction name="actionPoints"/> + <addaction name="actionEdges"/> + <addaction name="actionTriangles"/> + <addaction name="actionChange_projection"/> + </widget> + <widget class="QMenu" name="menuTopology"> + <property name="title"> + <string>Topology</string> + </property> + <addaction name="actionEuler_characteristic"/> + <addaction name="actionShow_homology_group"/> + <addaction name="actionPersistence"/> + </widget> + <addaction name="menuFile"/> + <addaction name="menuPoints"/> + <addaction name="menuGraph"/> + <addaction name="menuComplex"/> + <addaction name="menuTopology"/> + <addaction name="menuView"/> + </widget> + <widget class="QStatusBar" name="statusbar"/> + <action name="actionLoad_points"> + <property name="text"> + <string>Load points</string> + </property> + </action> + <action name="actionLoad_complex"> + <property name="text"> + <string>Load complex</string> + </property> + </action> + <action name="actionSave_points"> + <property name="text"> + <string>Save points</string> + </property> + </action> + <action name="actionSave_complex"> + <property name="text"> + <string>Save complex</string> + </property> + </action> + <action name="actionNoise"> + <property name="text"> + <string>Noise</string> + </property> + </action> + <action name="actionLloyd"> + <property name="text"> + <string>Lloyd</string> + </property> + </action> + <action name="actionUniform_proximity_graph"> + <property name="text"> + <string>Uniform proximity graph</string> + </property> + </action> + <action name="actionK_nearest_neighbors_graph"> + <property name="text"> + <string>k-nearest neighbors graph</string> + </property> + </action> + <action name="actionShow_graph_stats"> + <property name="text"> + <string>Show graph stats</string> + </property> + </action> + <action name="actionBuild_complex_from_graph"> + <property name="text"> + <string>Graph expansion</string> + </property> + </action> + <action name="actionBuild_Delaunay_from_points"> + <property name="text"> + <string>Delaunay from points</string> + </property> + </action> + <action name="actionContract_edges"> + <property name="text"> + <string>Contract edges</string> + </property> + </action> + <action name="actionCollapse_vertices"> + <property name="text"> + <string>Collapse vertices</string> + </property> + </action> + <action name="actionCollapse_edges"> + <property name="text"> + <string>Collapse edges</string> + </property> + </action> + <action name="actionPoints"> + <property name="text"> + <string>Points</string> + </property> + </action> + <action name="actionEdges"> + <property name="text"> + <string>Edges</string> + </property> + </action> + <action name="actionTriangles"> + <property name="text"> + <string>Triangles</string> + </property> + </action> + <action name="actionChange_projection"> + <property name="text"> + <string>Change projection</string> + </property> + </action> + <action name="actionShow_complex_stats"> + <property name="text"> + <string>Show complex stats</string> + </property> + </action> + <action name="actionShow_complex_dimension"> + <property name="text"> + <string>Show complex dimension</string> + </property> + </action> + <action name="actionShow_homology_group"> + <property name="text"> + <string>Homology groups</string> + </property> + </action> + <action name="actionPersistence"> + <property name="text"> + <string>Point cloud persistence</string> + </property> + </action> + <action name="actionEuler_characteristic"> + <property name="text"> + <string>Euler characteristic</string> + </property> + </action> + <action name="actionHomology_groups"> + <property name="text"> + <string>Homology groups</string> + </property> + </action> + </widget> + <customwidgets> + <customwidget> + <class>Viewer</class> + <extends>QWidget</extends> + <header>view/Viewer.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> |