ddt  1.0.0
ddtCornergrabber.hpp
Go to the documentation of this file.
1 
19 #ifndef DDT_DATAVISUALISATION_UTILS_CORNERGRABBER_HPP
20 #define DDT_DATAVISUALISATION_UTILS_CORNERGRABBER_HPP
21 
22 #include <math.h>
23 #include <QGraphicsItem>
24 #include <QGraphicsSceneDragDropEvent>
25 #include <QPainter>
26 #include <QPen>
27 
28 const int DDT_CORNER_GRABBER_SIZE = 20;
29 
37 };
38 
42 class CornerGrabber : public QGraphicsItem {
43  public:
49  explicit CornerGrabber(QGraphicsItem *parent = nullptr, const int corner = 0);
50 
55  int GetCorner() const;
56 
61  void SetMouseState(const int state);
62 
67  int GetMouseState() const;
68 
72  qreal mouse_down_x;
73 
77  qreal mouse_down_y;
78 
79  private:
80  virtual QRectF boundingRect() const override;
81 
82  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
83  QWidget *widget) override;
84 
85  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
86  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
87 
88  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
89  virtual void mouseMoveEvent(QGraphicsSceneDragDropEvent *event);
90  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
91  virtual void mousePressEvent(QGraphicsSceneDragDropEvent *event);
92  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
93 
94  void Initialize(QGraphicsItem *parent);
95 
96  QColor outer_border_color;
97  QPen outer_border_pen;
98 
99  qreal width;
100  qreal height;
101 
102  // 0,1,2,3: starting at x=0,y=0 and moving clockwise around the box
103  int corner;
104 
105  int mouse_button_state;
106 };
107 
108 #endif // DDT_DATAVISUALISATION_UTILS_CORNERGRABBER_HPP
109 
Definition: ddtCornergrabber.hpp:42
qreal mouse_down_x
Definition: ddtCornergrabber.hpp:72
int GetCorner() const
Definition: ddtCornergrabber.cpp:50
CornerGrabber(QGraphicsItem *parent=nullptr, const int corner=0)
Definition: ddtCornergrabber.cpp:21
qreal mouse_down_y
Definition: ddtCornergrabber.hpp:77
int GetMouseState() const
Definition: ddtCornergrabber.cpp:48
void SetMouseState(const int state)
Definition: ddtCornergrabber.cpp:46
MouseStates
Definition: ddtCornergrabber.hpp:33
@ CG_MOUSE_MOVING
Definition: ddtCornergrabber.hpp:36
@ CG_MOUSE_DOWN
Definition: ddtCornergrabber.hpp:35
@ CG_MOUSE_RELEASED
Definition: ddtCornergrabber.hpp:34
const int DDT_CORNER_GRABBER_SIZE
Definition: ddtCornergrabber.hpp:28