xvWidgets
Point.hpp
1 #pragma once
2 
3 #include "Widget.hpp"
4 #include <opencv2/core.hpp>
5 
6 namespace xv
7 {
8 
13  class Point : public Widget, public gui_point_t
14  {
15  public:
16 
17  static const std::string CLASS_NAME;
19 #pragma region constructors
20  Point();
22 
24  Point(int _x, int _y);
25 
27  Point(const gui_point_t & pt);
28 #pragma endregion constructors
29 
30  static Point UNDEFINED;
32 #pragma region operators
33  operator cv::Point() const{ return cv::Point(m_position.x,m_position.y); };
35 
37  bool operator == (const Point &b) {
38  if (this->m_undefined && b.m_undefined)
39  return true;//if both are undefined they are considered equal
40  //compare as a cv::Point_
41  return static_cast<gui_point_t>(*this) == b;
42  };
43 
45  bool operator != (const Point &b) {
46  if (this->m_undefined && b.m_undefined)
47  return false;//if both are undefined they are considered equal
48  //compare as a cv::Point_
49  return static_cast<gui_point_t>(*this) != b;
50  };
51 #pragma endregion operators
52 
54  virtual void setPosition(gui_point_t position);
55 
57  void paint(const cv::Mat&);
58 
60  void onMouseMove(const gui_point_t&);
61 
63  void onMouseDown(const gui_point_t&);
64 
66  void onMouseUp(const gui_point_t&);
67  };
68 
69 }
Widget that represents a point.
Definition: Point.hpp:13
void onMouseUp(const gui_point_t &)
The user released the left mouse button over the widget.
Point()
Default constructor.
bool operator==(const Point &b)
Checks if 2 points are equal.
Definition: Point.hpp:37
static Point UNDEFINED
Definition: Point.hpp:30
void onMouseMove(const gui_point_t &)
The user moved the mouse pointer over the widget.
virtual gui_point_t position()
Get the current position.
virtual void setPosition(gui_point_t position)
Move point widget.
void paint(const cv::Mat &)
Overlay the point widget on an image.
bool operator!=(const Point &b)
Checks if 2 points are different.
Definition: Point.hpp:45
void onMouseDown(const gui_point_t &)
The user pressed the left mouse button over the widget.
Definition: Angle.hpp:8
bool m_undefined
Definition: Widget.hpp:138
gui_point_t m_position
Definition: Widget.hpp:142
static const std::string CLASS_NAME
Definition: Point.hpp:17
Base class for all Widgets.
Definition: Widget.hpp:40