Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
ViewProfileDivider.h
1 #ifndef VIEW_PROFILE_DIVIDER_H
2 #define VIEW_PROFILE_DIVIDER_H
3 
4 #include <QGraphicsRectItem>
5 #include <QObject>
6 
7 class QGraphicsLineItem;
8 class QGraphicsScene;
9 class QGraphicsPolygonItem;
10 class QGraphicsView;
11 
17 class ViewProfileDivider : public QObject, public QGraphicsRectItem
18 {
19  Q_OBJECT;
20 
21 public:
23  ViewProfileDivider (QGraphicsScene &scene,
24  QGraphicsView &view,
25  int sceneWidth,
26  int sceneHeight,
27  int yCenter,
28  bool isLowerBoundary);
29 
31  virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value);
32 
34  virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
35 
37  void setX (double x,
38  double xLow,
39  double xHigh);
40 
41 private slots:
43  void slotOtherMoved(double xSceneOther);
44 
45 signals:
47  void signalMovedLow (double xSceneOther);
48 
50  void signalMovedHigh (double xSceneOther);
51 
52 private:
54 
55  void sendSignalMoved ();
56 
57  // Update geoemtries since one of the dividers (this or the other) moved
58  void updateGeometryDivider ();
59  void updateGeometryNonPaddle ();
60  void updateGeometryPaddle ();
61 
62  QGraphicsView &m_view;
63  int m_yCenter;
64  double m_xScene; // X coordinae of this divider
65  double m_xSceneOther; // X coordinate of other divider. Used when the two dividers have moved past each other so there
66  // are two unshaded areas
67  QGraphicsLineItem *m_divider;
68  QGraphicsRectItem *m_shadedArea;
69  QGraphicsPolygonItem *m_arrow;
70  int m_sceneWidth;
71  int m_sceneHeight;
72  bool m_isLowerBoundary;
73 
74  QPointF m_startDragPos;
75 };
76 
77 #endif // VIEW_PROFILE_DIVIDER_H
void signalMovedHigh(double xSceneOther)
Signal used when divider is dragged and m_isLowerBoundary is false.
void setX(double x, double xLow, double xHigh)
Set the position by specifying the new x coordinate.
void signalMovedLow(double xSceneOther)
Signal used when divider is dragged and m_isLowerBoundary is true.
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Intercept changes so divider movement can be restricted to horizontal direction only.
Divider that can be dragged, in a dialog QGraphicsView.
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Save paddle position at start of click-and-drag.