summaryrefslogtreecommitdiff
path: root/src/GudhUI/view/Viewer_instructor.h
blob: 09ed102fe2cd6a2a85d9b67aedf17665670c61f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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 has directly 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_