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 
22 class CornerGrabber : public QGraphicsItem {
23  public:
27  explicit CornerGrabber(QGraphicsItem *parent = nullptr, const int corner = 0);
28 
32  int GetCorner() const;
33 
37  void SetMouseState(const int state);
38 
42  int GetMouseState() const;
43 
47  qreal mouse_down_x;
48 
52  qreal mouse_down_y;
53 
58 
59  private:
60  virtual QRectF boundingRect() const;
61 
62  virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
63  QWidget *widget);
64 
65  virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
66 
67  virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
68 
69  virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
70  virtual void mouseMoveEvent(QGraphicsSceneDragDropEvent *event);
71  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
72  virtual void mousePressEvent(QGraphicsSceneDragDropEvent *event);
73  virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
74 
75  QColor outter_border_color;
76  QPen outter_border_pen;
77 
78  qreal width;
79  qreal height;
80 
81  int corner; // 0,1,2,3 - starting at x=0,y=0 and moving clockwise around
82  // the box
83 
84  int mouse_button_state;
85 };
86 
87 #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:48
CornerGrabber::mouse_down_y
qreal mouse_down_y
Definition: ddtCornergrabber.hpp:52
CornerGrabber::CG_MOUSE_RELEASED
@ CG_MOUSE_RELEASED
Definition: ddtCornergrabber.hpp:57
CornerGrabber
Definition: ddtCornergrabber.hpp:22
CornerGrabber::CG_MOUSE_MOVING
@ CG_MOUSE_MOVING
Definition: ddtCornergrabber.hpp:57
CornerGrabber::SetMouseState
void SetMouseState(const int state)
Definition: ddtCornergrabber.cpp:44
CornerGrabber::mouse_down_x
qreal mouse_down_x
Definition: ddtCornergrabber.hpp:47
CornerGrabber::CG_MOUSE_DOWN
@ CG_MOUSE_DOWN
Definition: ddtCornergrabber.hpp:57
CornerGrabber::GetMouseState
int GetMouseState() const
Definition: ddtCornergrabber.cpp:46