ddt  0.1
ddtCornergrabber.hpp
Go to the documentation of this file.
1 // @copyright
2 // (c) Copyright ESO 2020
3 // All Rights Reserved
4 // ESO (eso.org) is an Intergovernmental Organization, and therefore special
5 // legal conditions apply.
6 //
7 // @file ddtCornergrabber.hpp
8 // @brief Corner grabber for resizable graphical elements
9 //
10 // Class for the corners of resizable graphical elements
11 //
12 // @author Carsten Mannel, CGI
13 // @since 2021/03/16
14 //
15 
16 #ifndef DDT_DATAVISUALISATION_UTILS_CORNERGRABBER_HPP
17 #define DDT_DATAVISUALISATION_UTILS_CORNERGRABBER_HPP
18 
19 #include <QGraphicsItem>
20 #include <QPen>
21 
23 
24 class CornerGrabber : public QGraphicsItem {
25  public:
29  explicit CornerGrabber(QGraphicsItem *parent = nullptr, const int corner = 0);
30 
34  int GetCorner() const;
35 
39  void SetMouseState(const int state);
40 
44  int GetMouseState() const;
45 
49  qreal mouse_down_x;
50 
54  qreal mouse_down_y;
55 
60 
61  private:
62  virtual QRectF boundingRect() const;
63 
64  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
65  QWidget *widget);
66 
67  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
68 
69  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
70 
71  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
72  virtual void mouseMoveEvent(QGraphicsSceneDragDropEvent *event);
73  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
74  virtual void mousePressEvent(QGraphicsSceneDragDropEvent *event);
75  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
76 
77  QColor outter_border_color;
78  QPen outter_border_pen;
79 
80  qreal width;
81  qreal height;
82 
83  int corner; // 0,1,2,3 - starting at x=0,y=0 and moving clockwise around
84  // the box
85 
86  int mouse_button_state;
87 };
88 
89 #endif // DDT_DATAVISUALISATION_UTILS_CORNERGRABBER_HPP
CornerGrabber::CornerGrabber
CornerGrabber(QGraphicsItem *parent=nullptr, const int corner=0)
Definition: ddtCornergrabber.cpp:23
CornerGrabber::GetCorner
int GetCorner() const
Definition: ddtCornergrabber.cpp:50
CornerGrabber::mouse_down_y
qreal mouse_down_y
Definition: ddtCornergrabber.hpp:54
CornerGrabber::CG_MOUSE_RELEASED
@ CG_MOUSE_RELEASED
Definition: ddtCornergrabber.hpp:59
CornerGrabber
Definition: ddtCornergrabber.hpp:24
CornerGrabber::CG_MOUSE_MOVING
@ CG_MOUSE_MOVING
Definition: ddtCornergrabber.hpp:59
CornerGrabber::SetMouseState
void SetMouseState(const int state)
Definition: ddtCornergrabber.cpp:46
CornerGrabber::mouse_down_x
qreal mouse_down_x
Definition: ddtCornergrabber.hpp:49
CornerGrabber::CG_MOUSE_DOWN
@ CG_MOUSE_DOWN
Definition: ddtCornergrabber.hpp:59
CornerGrabber::GetMouseState
int GetMouseState() const
Definition: ddtCornergrabber.cpp:48
DDT_CORNER_GRABBER_SIZE
const int DDT_CORNER_GRABBER_SIZE
Definition: ddtCornergrabber.hpp:22