measurement.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 #pragma once
4 
5 #include "rendering.h"
6 #include "model-views.h"
7 
8 #include <vector>
9 #include <functional>
10 #include <string>
11 #include <set>
12 
13 namespace rs2
14 {
16  {
19 
20  bool operator==(const interest_point& other) const
21  {
22  return (pos - other.pos).length() < 0.001f;
23  }
24  };
25 
27  {
28  std::vector<interest_point> points;
29  std::vector<std::pair<int, int>> edges;
30  std::vector<std::vector<int>> polygons;
31 
32  bool operator==(const measurement_state& other) const
33  {
34  return points == other.points && edges == other.edges && polygons == other.polygons;
35  }
36 
37  std::vector<int> find_path(int from, int to);
38  };
39 
41  {
42  public:
43  void enable();
44  void disable();
45  bool is_enabled() const;
46 
47  bool display_mouse_picked_tooltip() const;
48  bool manipulating() const;
49 
50  void add_point(interest_point p);
51 
52  void commit_state();
53  void restore_state();
54 
55  float calculate_area(std::vector<float3> points);
56 
57  std::string length_to_string(float distance);
58  std::string area_to_string(float area);
59  rs2::float2 project_to_2d(rs2::float3 pos);
60  void draw_label(ux_window& win, float3 pos, float distance, int height, bool is_area = false);
61  void draw_ruler(ux_window& win, float3 from, float3 to, float height, int selected);
62  void draw(ux_window& win);
63 
64  void show_tooltip(ux_window& win);
65  void mouse_pick(ux_window& win, float3 picked, float3 normal);
66  void update_input(ux_window& win, const rs2::rect& viewer_rect);
67 
68  std::function<void(std::string)> log_function = [](std::string) {};
69  std::function<bool()> is_metric = [](){ return true; };
70 
71  private:
72  int point_hovered(ux_window& win);
73  int edge_hovered(ux_window& win);
74 
76 
78  std::deque<measurement_state> state_history;
79 
80  bool dragging_measurement_point = false;
81  int dragging_point_index = -1;
82  bool measurement_point_hovered = false;
83  bool measurement_active = false;
84  int hovered_edge_id = -1;
85  int last_hovered_point = -1;
86  int current_hovered_point = -1;
87 
88  temporal_event mouse_picked_event { std::chrono::milliseconds(1000) };
89  float3 _normal, _picked;
90 
92  {
93  bool mouse_down = false;
94  bool prev_mouse_down = false;
95  bool click = false;
96  double selection_started = 0.0;
97  float2 down_pos { 0.f, 0.f };
98  int mouse_wheel = 0;
99  float click_time = 0.f;
100  float click_period() { return clamp(float(glfwGetTime() - click_time) * 10, 0.f, 1.f); }
101  };
103  int id = 0;
104  };
105 }
std::vector< std::pair< int, int > > edges
Definition: measurement.h:29
std::deque< measurement_state > state_history
Definition: measurement.h:78
GLfloat GLfloat p
Definition: glext.h:12687
std::vector< interest_point > points
Definition: measurement.h:28
mouse_control input_ctrl
Definition: measurement.h:102
Definition: cah-model.h:10
GLsizei const GLchar *const * string
GLsizei GLsizei GLfloat distance
Definition: glext.h:10563
interest_point selection_point
Definition: measurement.h:75
GLdouble f
std::vector< std::vector< int > > polygons
Definition: measurement.h:30
bool operator==(const measurement_state &other) const
Definition: measurement.h:32
GLint GLsizei GLsizei height
bool operator==(const interest_point &other) const
Definition: measurement.h:20
static void draw(void)
Definition: gears.c:173
measurement_state state
Definition: measurement.h:77
GLFWAPI double glfwGetTime(void)
Returns the value of the GLFW timer.
Definition: input.c:1275
GLboolean enable
Definition: glext.h:5688
float clamp(float x, float min, float max)
Definition: rendering.h:103
float rs2_vector::* pos


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:21