Engauge Digitizer 2
Loading...
Searching...
No Matches
ViewProfileDivider.h
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#ifndef VIEW_PROFILE_DIVIDER_H
8#define VIEW_PROFILE_DIVIDER_H
9
10#include <QGraphicsRectItem>
11#include <QObject>
12
13class QGraphicsLineItem;
14class QGraphicsScene;
15class QGraphicsPolygonItem;
16class QGraphicsView;
17
23class ViewProfileDivider : public QObject, public QGraphicsRectItem
24{
25 Q_OBJECT;
26
27public:
29 ViewProfileDivider (QGraphicsScene &scene,
30 QGraphicsView &view,
31 int sceneWidth,
32 int sceneHeight,
33 int yCenter,
34 bool isLowerBoundary);
35
37 virtual QVariant itemChange (GraphicsItemChange change, const QVariant &value);
38
40 virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
41
43 void setX (double x,
44 double xLow,
45 double xHigh);
46
47private slots:
49 void slotOtherMoved(double xSceneOther);
50
51signals:
53 void signalMovedLow (double xSceneOther);
54
56 void signalMovedHigh (double xSceneOther);
57
58private:
60
61 void sendSignalMoved ();
62
63 // Update geoemtries since one of the dividers (this or the other) moved
64 void updateGeometryDivider ();
65 void updateGeometryNonPaddle ();
66 void updateGeometryPaddle ();
67
68 QGraphicsView &m_view;
69 int m_yCenter;
70 double m_xScene; // X coordinae of this divider
71 double m_xSceneOther; // X coordinate of other divider. Used when the two dividers have moved past each other so there
72 // are two unshaded areas
73 QGraphicsLineItem *m_divider;
74 QGraphicsRectItem *m_shadedArea;
75 QGraphicsPolygonItem *m_arrow;
76 int m_sceneWidth;
77 int m_sceneHeight;
78 bool m_isLowerBoundary;
79
80 QPointF m_startDragPos;
81};
82
83#endif // VIEW_PROFILE_DIVIDER_H
void signalMovedHigh(double xSceneOther)
Signal used when divider is dragged and m_isLowerBoundary is false.
void signalMovedLow(double xSceneOther)
Signal used when divider is dragged and m_isLowerBoundary is true.
void setX(double x, double xLow, double xHigh)
Set the position by specifying the new x coordinate.
ViewProfileDivider(QGraphicsScene &scene, QGraphicsView &view, int sceneWidth, int sceneHeight, int yCenter, bool isLowerBoundary)
Single constructor.
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event)
Save paddle position at start of click-and-drag.
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Intercept changes so divider movement can be restricted to horizontal direction only.