summaryrefslogtreecommitdiff
path: root/src/GudhUI/view
diff options
context:
space:
mode:
Diffstat (limited to 'src/GudhUI/view')
-rw-r--r--src/GudhUI/view/Color.h22
-rw-r--r--src/GudhUI/view/FirstCoordProjector.h31
-rw-r--r--src/GudhUI/view/Projector3D.h26
-rw-r--r--src/GudhUI/view/View_parameter.h138
-rw-r--r--src/GudhUI/view/Viewer.cpp173
-rw-r--r--src/GudhUI/view/Viewer.h104
-rw-r--r--src/GudhUI/view/Viewer_instructor.cpp179
-rw-r--r--src/GudhUI/view/Viewer_instructor.h101
8 files changed, 774 insertions, 0 deletions
diff --git a/src/GudhUI/view/Color.h b/src/GudhUI/view/Color.h
new file mode 100644
index 00000000..791cca51
--- /dev/null
+++ b/src/GudhUI/view/Color.h
@@ -0,0 +1,22 @@
+/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#ifndef VIEW_COLOR_H_
+#define VIEW_COLOR_H_
+
+struct Color {
+ double r;
+ double g;
+ double b;
+
+ Color(double r_, double g_, double b_) : r(r_), g(g_), b(b_) { }
+};
+
+#endif // VIEW_COLOR_H_
diff --git a/src/GudhUI/view/FirstCoordProjector.h b/src/GudhUI/view/FirstCoordProjector.h
new file mode 100644
index 00000000..673485e3
--- /dev/null
+++ b/src/GudhUI/view/FirstCoordProjector.h
@@ -0,0 +1,31 @@
+/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#ifndef VIEW_FIRSTCOORDPROJECTOR_H_
+#define VIEW_FIRSTCOORDPROJECTOR_H_
+
+#include "utils/UI_utils.h"
+#include "Projector3D.h"
+
+class FirstCoordProjector3D : public Projector3D {
+ typedef Projector3D::Point Point;
+ typedef Projector3D::Point_3 Point_3;
+
+ Point_3 operator()(const Point& p) const {
+ if (p.dimension() >= 3)
+ return Point_3(p.x(), p.y(), p.z());
+ else if (p.dimension() >= 2)
+ return Point_3(p.x(), p.y(), 0.0);
+ else
+ return Point_3(0.0, 0.0, 0.0);
+ }
+};
+
+#endif // VIEW_FIRSTCOORDPROJECTOR_H_
diff --git a/src/GudhUI/view/Projector3D.h b/src/GudhUI/view/Projector3D.h
new file mode 100644
index 00000000..574756fd
--- /dev/null
+++ b/src/GudhUI/view/Projector3D.h
@@ -0,0 +1,26 @@
+/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#ifndef VIEW_PROJECTOR3D_H_
+#define VIEW_PROJECTOR3D_H_
+
+#include "model/Complex_typedefs.h"
+
+class Projector3D {
+ public:
+ typedef Geometry_trait::Point Point;
+ typedef Geometry_trait::Point_3 Point_3;
+
+ virtual Point_3 operator()(const Point&) const = 0;
+
+ virtual ~Projector3D() { }
+};
+
+#endif // VIEW_PROJECTOR3D_H_
diff --git a/src/GudhUI/view/View_parameter.h b/src/GudhUI/view/View_parameter.h
new file mode 100644
index 00000000..dfd3aa41
--- /dev/null
+++ b/src/GudhUI/view/View_parameter.h
@@ -0,0 +1,138 @@
+/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#ifndef VIEW_VIEW_PARAMETER_H_
+#define VIEW_VIEW_PARAMETER_H_
+
+#include <iostream>
+
+/**
+ * Different parameters for the view such as the camera angle,
+ * the light, options for vertices/edges/triangles.
+ */
+class View_parameter {
+ public:
+ bool light;
+ bool relative_light;
+
+ double size_vertices;
+ double size_edges;
+ double light_edges; // in 0-1
+ double light_triangles; // in 0-1
+
+ /**
+ * light angle
+ */
+ double theta;
+ double phi;
+
+ enum VERTEX_MODE {
+ V_NONE, V_SIMPLE, V_COUNT
+ };
+
+ enum EDGE_MODE {
+ E_NONE, E_SIMPLE, E_COUNT
+ };
+
+ enum TRIANGLE_MODE {
+ T_NONE, T_SIMPLE, T_COUNT
+ };
+
+ VERTEX_MODE vertex_mode;
+ EDGE_MODE edge_mode;
+ TRIANGLE_MODE triangle_mode;
+
+ void change_vertex_mode() {
+ int current_value = vertex_mode;
+ vertex_mode = static_cast<VERTEX_MODE> (++current_value % V_COUNT);
+ std::cout << "Vertex mode : ";
+ switch (vertex_mode) {
+ case V_NONE:
+ std::cout << "empty\n";
+ break;
+ case V_SIMPLE:
+ std::cout << "simple\n";
+ break;
+ default:
+ break;
+ }
+ }
+
+ void change_vertex_mode(int new_mode) {
+ vertex_mode = static_cast<VERTEX_MODE> (new_mode % V_COUNT);
+ }
+
+ void change_edge_mode() {
+ int current_value = edge_mode;
+ edge_mode = static_cast<EDGE_MODE> (++current_value % E_COUNT);
+ }
+
+ void change_edge_mode(int new_mode) {
+ edge_mode = static_cast<EDGE_MODE> (new_mode % E_COUNT);
+ }
+
+ void change_triangle_mode() {
+ int current_value = triangle_mode;
+ triangle_mode = static_cast<TRIANGLE_MODE> (++current_value % T_COUNT);
+ }
+
+ View_parameter() {
+ light = true;
+ relative_light = true;
+ vertex_mode = V_SIMPLE;
+ edge_mode = E_SIMPLE;
+ triangle_mode = T_NONE;
+
+ size_vertices = 3;
+ size_edges = 2;
+
+ light_edges = 0.3;
+ light_triangles = 0.85;
+ theta = 0;
+ phi = 0;
+ }
+
+ friend std::ostream& operator<<(std::ostream& stream, const View_parameter& param) {
+ stream << param.light << " ";
+ stream << param.relative_light << " ";
+ stream << param.vertex_mode << " ";
+ stream << param.edge_mode << " ";
+ stream << param.triangle_mode << " ";
+ stream << param.size_vertices << " ";
+ stream << param.size_edges << " ";
+ stream << param.light_edges << " ";
+ stream << param.light_triangles << " ";
+ stream << param.theta << " ";
+ stream << param.phi << " ";
+ return stream;
+ }
+
+ friend std::istream& operator>>(std::istream& stream, View_parameter& param) {
+ stream >> param.light;
+ stream >> param.relative_light;
+ int a;
+ stream >> a;
+ param.vertex_mode = static_cast<VERTEX_MODE> (a % V_COUNT);
+ stream >> a;
+ param.edge_mode = static_cast<EDGE_MODE> (a % E_COUNT);
+ stream >> a;
+ param.triangle_mode = static_cast<TRIANGLE_MODE> (a % T_COUNT);
+ stream >> a;
+ stream >> param.size_vertices;
+ stream >> param.size_edges;
+ stream >> param.light_edges;
+ stream >> param.light_triangles;
+ stream >> param.theta;
+ stream >> param.phi;
+ return stream;
+ }
+};
+
+#endif // VIEW_VIEW_PARAMETER_H_
diff --git a/src/GudhUI/view/Viewer.cpp b/src/GudhUI/view/Viewer.cpp
new file mode 100644
index 00000000..6b17c833
--- /dev/null
+++ b/src/GudhUI/view/Viewer.cpp
@@ -0,0 +1,173 @@
+/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#include "Viewer.h"
+#include "utils/UI_utils.h"
+
+Viewer::Viewer(QWidget* parent) : QGLViewer(QGLFormat(QGL::SampleBuffers), parent), instructor(0), theta(0), phi(0) { }
+
+void Viewer::set_instructor(Viewer_instructor* instructor_) {
+ instructor = instructor_;
+}
+
+void Viewer::show_entire_scene() {
+ this->showEntireScene();
+}
+
+void Viewer::draw() {
+ instructor->give_instructions();
+}
+
+void Viewer::set_bounding_box(const Point_3 & lower_left, const Point_3 & upper_right) {
+ this->camera()->setSceneBoundingBox(qglviewer::Vec(lower_left[0], lower_left[1], lower_left[2]),
+ qglviewer::Vec(upper_right[0], upper_right[1], upper_right[2]));
+}
+
+void Viewer::update_GL() {
+ this->updateGL();
+}
+
+void Viewer::init_scene() {
+ this->setBackgroundColor(Qt::white);
+ ::glEnable(GL_LINE_SMOOTH);
+ init_light();
+}
+
+void Viewer::init_light() {
+ ::glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
+}
+
+void Viewer::set_light() {
+ if (theta >= 0 && phi >= 0) {
+ const GLfloat pos[4] = {static_cast<float> (sin(phi) * cos(theta)),
+ static_cast<float> (sin(phi) * sin(theta)),
+ static_cast<float> (cos(phi)), 0.};
+ glLightfv(GL_LIGHT0, GL_POSITION, pos);
+ }
+}
+
+void Viewer::set_light_direction(double theta_, double phi_) {
+ theta = theta_;
+ phi = phi_;
+}
+
+/**
+ * set the light in the direction of the observer
+ */
+void Viewer::set_light_direction() {
+ theta = -1;
+ phi = -1;
+}
+
+void Viewer::postSelection(const QPoint& point) {
+ bool found;
+
+ auto vec = this->camera()->pointUnderPixel(point, found);
+
+ if (found) {
+ Point_3 position(vec[0], vec[1], vec[2]);
+ emit(click(position));
+ }
+}
+
+////////////////////////
+// draw
+////////////////////////
+
+void Viewer::set_size_point(double size_points) {
+ ::glPointSize(size_points);
+}
+
+void Viewer::draw_point(const Point_3& p, const Color& color, double size_points) {
+ ::glColor3f(color.r, color.g, color.b);
+ ::glDisable(GL_LIGHTING);
+ ::glEnable(GL_POINT_SMOOTH);
+ ::glPointSize(size_points);
+ ::glBegin(GL_POINTS);
+ ::glVertex3d(p.x(), p.y(), p.z());
+ ::glEnd();
+ ::glDisable(GL_POINT_SMOOTH);
+}
+
+void Viewer::begin_draw_points(double size, bool light) {
+ light ? glEnable(GL_LIGHTING) : glDisable(GL_LIGHTING);
+ ::glEnable(GL_POINT_SMOOTH);
+ ::glPointSize(size);
+ ::glBegin(GL_POINTS);
+}
+
+void Viewer::set_color(const Color& color) {
+ ::glColor3f(color.r, color.g, color.b);
+}
+
+void Viewer::draw_points(const Point_3 & point) {
+ ::glVertex3d(point.x(), point.y(), point.z());
+}
+
+void Viewer::end_draw_points() {
+ ::glEnd();
+ ::glDisable(GL_POINT_SMOOTH);
+}
+
+void Viewer::draw_edge(const Point_3 &a, const Point_3 &b, const Color& color, double size) {
+ ::glColor3f(color.r, color.g, color.b);
+ ::glPointSize(3.0);
+ ::glLineWidth(size);
+ ::glBegin(GL_LINES);
+ ::glVertex3f(a.x(), a.y(), a.z());
+ ::glVertex3f(b.x(), b.y(), b.z());
+ ::glEnd();
+}
+
+void Viewer::begin_draw_edges(double size, bool light) {
+ ::glLineWidth(size);
+ ::glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ ::glEnable(GL_POLYGON_OFFSET_LINE);
+ ::glPolygonOffset(3.0f, -3.0f);
+ light ? glEnable(GL_LIGHTING) : glDisable(GL_LIGHTING);
+ ::glBegin(GL_LINES);
+}
+
+void Viewer::draw_edges(const Point_3 &a, const Point_3 &b) {
+ ::glVertex3f(a.x(), a.y(), a.z());
+ ::glVertex3f(b.x(), b.y(), b.z());
+}
+
+void Viewer::end_draw_edges() {
+ ::glEnd();
+}
+
+void Viewer::begin_draw_triangles(double size, bool light, bool transparent) {
+ if (transparent) {
+ ::glEnable(GL_BLEND);
+ ::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ ::glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ ::glEnable(GL_POLYGON_OFFSET_FILL);
+ ::glPolygonOffset(3.0f, -3.0f);
+ light ? glEnable(GL_LIGHTING) : glDisable(GL_LIGHTING);
+ ::glBegin(GL_TRIANGLES);
+}
+
+void Viewer::draw_triangles(const Point_3& p1, const Point_3& p2, const Point_3& p3) {
+ if (!CGAL::collinear(p1, p2, p3)) {
+ auto triangle_normal = CGAL::unit_normal(p1, p2, p3);
+ ::glNormal3d(triangle_normal.x(), triangle_normal.y(), triangle_normal.z());
+ ::glVertex3d(p1.x(), p1.y(), p1.z());
+ ::glVertex3d(p2.x(), p2.y(), p2.z());
+ ::glVertex3d(p3.x(), p3.y(), p3.z());
+ }
+}
+
+void Viewer::end_draw_triangles() {
+ ::glEnd();
+}
+
+#include "Viewer.moc"
diff --git a/src/GudhUI/view/Viewer.h b/src/GudhUI/view/Viewer.h
new file mode 100644
index 00000000..ec165031
--- /dev/null
+++ b/src/GudhUI/view/Viewer.h
@@ -0,0 +1,104 @@
+/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#ifndef VIEW_VIEWER_H_
+#define VIEW_VIEWER_H_
+
+#include <QGLViewer/qglviewer.h>
+
+#include <vector>
+
+#include "View_parameter.h"
+#include "model/Complex_typedefs.h"
+#include "Color.h"
+#include "Viewer_instructor.h"
+
+class Viewer_instructor;
+
+class Viewer : public QGLViewer {
+ Q_OBJECT
+
+ Viewer_instructor * instructor;
+
+ /**
+ * light angles
+ */
+ double theta, phi;
+ typedef Complex::GT Gudhi_kernel;
+ typedef Gudhi_kernel::Point_3 Point_3;
+
+ public:
+ Viewer(QWidget* parent);
+
+ void set_instructor(Viewer_instructor* instructor_);
+
+ void show_entire_scene();
+
+ void draw();
+
+ void set_bounding_box(const Point_3 & lower_left, const Point_3 & upper_right);
+
+ void update_GL();
+
+ void init_scene();
+
+ void init_light();
+
+ void set_light();
+
+ void set_light_direction(double theta, double phi);
+
+ /**
+ * set the light in the direction of the observer
+ */
+ void set_light_direction();
+
+ protected:
+ virtual void postSelection(const QPoint& point);
+
+ public:
+ ////////////////////////
+ // draw
+ ////////////////////////
+ void set_size_point(double size_points);
+
+ void set_color(const Color& color);
+
+ void draw_point(const Point_3& p, const Color& color, double size_points);
+
+ void begin_draw_points(double size, bool light = false);
+
+ void draw_points(const Point_3 & point);
+
+ void end_draw_points();
+
+ void draw_edge(const Point_3 &a, const Point_3 &b, const Color& color, double size);
+
+ void begin_draw_edges(double size, bool light = false);
+
+ void draw_edges(const Point_3 &a, const Point_3 &b);
+
+ void end_draw_edges();
+
+ void begin_draw_triangles(double size, bool light, bool transparent = false);
+
+ void draw_triangles(const Point_3& p1, const Point_3& p2, const Point_3& p3);
+
+ // todo remove
+ void draw_triangles(const std::vector<Point_3*>& points);
+
+ void end_draw_triangles();
+
+
+ signals:
+ void click(const Point_3& position);
+};
+
+#endif // VIEW_VIEWER_H_
diff --git a/src/GudhUI/view/Viewer_instructor.cpp b/src/GudhUI/view/Viewer_instructor.cpp
new file mode 100644
index 00000000..9a0f1cd3
--- /dev/null
+++ b/src/GudhUI/view/Viewer_instructor.cpp
@@ -0,0 +1,179 @@
+/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#include <utility>
+
+#include "Viewer_instructor.h"
+#include "utils/UI_utils.h"
+#include "FirstCoordProjector.h"
+
+Viewer_instructor::Viewer_instructor(QWidget* parent,
+ Viewer* viewer,
+ const Complex& mesh
+ )
+ : viewer_(viewer), mesh_(mesh), projector_(new FirstCoordProjector3D()) {
+ viewer_->set_instructor(this);
+}
+
+void Viewer_instructor::initialize_bounding_box() {
+ auto pair_bounding_box = compute_bounding_box_corners();
+ viewer_->set_bounding_box(proj(pair_bounding_box.first), proj(pair_bounding_box.second));
+ viewer_->init_scene();
+}
+
+std::pair<Complex::Point, Complex::Point> Viewer_instructor::compute_bounding_box_corners() {
+ if (mesh_.empty()) {
+ return std::make_pair(Point(-1, -1, -1, 1), Point(1, 1, 1, 1));
+ } else {
+ double x_min = 1e10;
+ double y_min = 1e10;
+ double z_min = 1e10;
+ double x_max = -1e10;
+ double y_max = -1e10;
+ double z_max = -1e10;
+ for (auto vi : mesh_.vertex_range()) {
+ auto pt = proj(mesh_.point(vi));
+ x_min = (std::min)(x_min, pt.x());
+ y_min = (std::min)(y_min, pt.y());
+ z_min = (std::min)(z_min, pt.z());
+
+ x_max = (std::max)(x_max, pt.x());
+ y_max = (std::max)(y_max, pt.y());
+ z_max = (std::max)(z_max, pt.z());
+ }
+ return std::make_pair(Point(x_min, y_min, z_min, 1.),
+ Point(x_max, y_max, z_max, 1.));
+ }
+}
+
+void Viewer_instructor::show_entire_scene() {
+ viewer_->show_entire_scene();
+}
+
+const qglviewer::Camera* Viewer_instructor::camera() const {
+ return viewer_->camera();
+}
+
+int
+Viewer_instructor::width() const {
+ return viewer_->width();
+}
+
+int
+Viewer_instructor::height() const {
+ return viewer_->height();
+}
+
+/**
+ * to change display parameters
+ */
+View_parameter& Viewer_instructor::view_params() {
+ return view_params_;
+}
+
+void
+Viewer_instructor::give_instructions() {
+ if (view_params_.relative_light)
+ viewer_->set_light_direction();
+ else
+ viewer_->set_light_direction(view_params_.theta, view_params_.phi);
+ viewer_->set_light();
+
+ if (view_params_.edge_mode) draw_edges();
+ if (view_params_.triangle_mode) draw_triangles();
+ if (view_params_.vertex_mode) draw_points();
+}
+
+void Viewer_instructor::draw_edges() {
+ viewer_->begin_draw_edges(view_params_.size_edges, false);
+
+ for (auto edge : mesh_.edge_range()) {
+ set_color_edge(edge);
+ const Point& a = mesh_.point(mesh_.first_vertex(edge));
+ const Point& b = mesh_.point(mesh_.second_vertex(edge));
+ viewer_->draw_edges(proj(a), proj(b));
+ }
+
+ viewer_->end_draw_edges();
+}
+
+void Viewer_instructor::draw_triangles() {
+ const double size_triangles = 1.0;
+ viewer_->begin_draw_triangles(size_triangles, view_params_.light);
+
+ for (const auto& fit : mesh_.triangle_range()) {
+ set_color_triangle(fit);
+ if (view_params_.triangle_mode) {
+ auto fit_it = fit.begin();
+ const Point& p1 = mesh_.point(*fit_it);
+ const Point& p2 = mesh_.point(*(++fit_it));
+ const Point& p3 = mesh_.point(*(++fit_it));
+ viewer_->draw_triangles(proj(p1), proj(p2), proj(p3));
+ }
+ }
+ viewer_->end_draw_triangles();
+}
+
+void Viewer_instructor::draw_points() {
+ viewer_->begin_draw_points(view_params_.size_vertices);
+ for (auto vi : mesh_.vertex_range()) {
+ viewer_->set_size_point(view_params_.size_vertices);
+ set_color_vertex(vi);
+ viewer_->draw_points(proj(mesh_.point(vi)));
+ }
+ viewer_->end_draw_points();
+}
+
+void Viewer_instructor::draw_edge(const Point&, const Point&) { }
+
+void Viewer_instructor::draw_point(const Point&) { }
+
+/**
+ * set the right color of vertex/edge/triangle considering the view_params choice
+ */
+void Viewer_instructor::set_color_vertex(Vertex_handle vh) {
+ viewer_->set_color(Color(view_params_.light_edges, view_params_.light_edges, view_params_.light_edges));
+}
+
+void Viewer_instructor::set_color_edge(Edge_handle eh) {
+ viewer_->set_color(Color(view_params_.light_edges, view_params_.light_edges, view_params_.light_edges));
+}
+
+void Viewer_instructor::set_color_triangle(const Simplex& triangle) {
+ viewer_->set_color(Color(view_params_.light_triangles, view_params_.light_triangles, view_params_.light_triangles));
+}
+
+Viewer_instructor::Point_3
+Viewer_instructor::proj(const Point& p) const {
+ return (*projector_)(p);
+}
+
+void Viewer_instructor::sceneChanged() {
+ UIDBG("sceneChanged");
+ viewer_->update_GL();
+}
+
+void Viewer_instructor::change_draw_vertices() {
+ view_params_.change_vertex_mode();
+}
+
+void Viewer_instructor::change_draw_edges() {
+ view_params_.change_edge_mode();
+}
+
+void Viewer_instructor::change_draw_triangles() {
+ view_params_.change_triangle_mode();
+}
+
+void Viewer_instructor::change_light() {
+ view_params_.light = !view_params_.light;
+}
+
+#include "Viewer_instructor.moc"
diff --git a/src/GudhUI/view/Viewer_instructor.h b/src/GudhUI/view/Viewer_instructor.h
new file mode 100644
index 00000000..58cbcd31
--- /dev/null
+++ b/src/GudhUI/view/Viewer_instructor.h
@@ -0,0 +1,101 @@
+/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
+ * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
+ * Author(s): David Salinas
+ *
+ * Copyright (C) 2014 Inria
+ *
+ * Modification(s):
+ * - YYYY/MM Author: Description of the modification
+ */
+
+#ifndef VIEW_VIEWER_INSTRUCTOR_H_
+#define VIEW_VIEWER_INSTRUCTOR_H_
+
+// todo do a viewer instructor that have directely a pointer to a QGLviewer and buffer ot not triangles
+
+#include <QFileDialog>
+#include <QKeyEvent>
+#include <QGLViewer/camera.h>
+
+#include <memory>
+#include <utility> // for pair<>
+
+#include "model/Complex_typedefs.h"
+
+#include "Projector3D.h"
+#include "View_parameter.h"
+#include "Viewer.h"
+
+class Viewer;
+class Viewer_parameter;
+
+class Viewer_instructor : public QWidget {
+ Q_OBJECT
+
+ typedef Geometry_trait::Point_3 Point_3;
+ typedef Complex::Point Point;
+ typedef Complex::Vertex_handle Vertex_handle;
+ typedef Complex::Edge_handle Edge_handle;
+ typedef Complex::Simplex Simplex;
+
+ Viewer* viewer_;
+ View_parameter view_params_;
+ const Complex& mesh_;
+ std::unique_ptr<Projector3D> projector_;
+
+ public:
+ Viewer_instructor(QWidget* parent, Viewer* viewer, const Complex& mesh);
+
+ void initialize_bounding_box();
+
+ std::pair<Point, Point> compute_bounding_box_corners();
+
+ void show_entire_scene();
+
+ const qglviewer::Camera* camera() const;
+
+ int width() const;
+ int height() const;
+
+ /**
+ * to change display parameters
+ */
+ View_parameter& view_params();
+
+ public:
+ /**
+ * gives instructions to the viewer
+ */
+ void give_instructions();
+
+ void draw_edges();
+ void draw_triangles();
+ void draw_points();
+
+ void draw_edge(const Point&, const Point&);
+
+ void draw_point(const Point&);
+
+ /**
+ * set the right color of vertex/edge/triangle considering the view_params choice
+ */
+ void set_color_vertex(Vertex_handle vh);
+ void set_color_edge(Edge_handle eh);
+
+ void set_color_triangle(const Simplex& triangle);
+
+ private:
+ /**
+ * Projection to 3D needed for the viewer.
+ */
+ Point_3 proj(const Point& p) const;
+
+ public slots:
+ void sceneChanged();
+ void change_draw_vertices();
+ void change_draw_edges();
+ void change_draw_triangles();
+ void change_light();
+};
+
+#endif // VIEW_VIEWER_INSTRUCTOR_H_