xvWidgets
Angle.hpp
1 #pragma once
2 
3 #include <list>
4 #include <opencv2/core.hpp>
5 #include "Widget.hpp"
6 #include "Point.hpp"
7 
8 namespace xv{
9 
10 class Image;
11 
16 class Angle : public Widget
17 {
18 public:
20  static Angle UNDEFINED;
21 
22 #pragma region constructors
23  Angle();
25 
27  Angle(gui_point_t);
28 #pragma endregion constructors
29 
31  virtual void setPosition(gui_point_t position);
32 
34  operator double() const{
35  return atan2(m_vertex.y - m_pointA.y, m_vertex.x - m_pointA.x);
36  };
37 
39  bool operator == (const Angle &b) {
40  if (this->m_undefined && b.m_undefined)
41  return true;//if both are undefined they are considered equal
42  return false;
43  };
44 
46  bool operator != (const Angle &b) {
47  if (this->m_undefined && b.m_undefined)
48  return false;//if both are undefined they are considered equal
49  return true;
50  };
51 private:
52  void paint(const cv::Mat&);
53  void onMouseMove(const gui_point_t&);
54  void onMouseDown(const gui_point_t&);
55  void onMouseUp(const gui_point_t&);
56  void setMouseOver(bool mouseOver);
57  void defineContours();
58 
59  Point m_vertex, m_pointA, m_pointB;
60  int m_radius = 0;
61 };
62 
63 }
Widget that represents a point.
Definition: Point.hpp:13
virtual void setPosition(gui_point_t position)
Moves the widget.
virtual gui_point_t position()
Get the current position.
Definition: Angle.hpp:8
bool m_undefined
Definition: Widget.hpp:138
bool operator==(const Angle &b)
Checks if 2 contours are equal.
Definition: Angle.hpp:39
Widget that represents an angle between 2 points.
Definition: Angle.hpp:16
Angle()
Default constructor. Creates an undefined angle.
bool operator!=(const Angle &b)
Checks if 2 contours are different.
Definition: Angle.hpp:46
static Angle UNDEFINED
Represents an Angle_ for which user input was not collected.
Definition: Angle.hpp:20
Base class for all Widgets.
Definition: Widget.hpp:40