FotoSHOCK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
QCurveWidget.h
1 /*
2  * Copyright 2011, 2012 Lukas Jirkovsky
3  *
4  * This file is part of FotoSHOCK.
5  *
6  * FotoSHOCK is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, version 3 of the License.
9  *
10  * FotoSHOCK is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with FotoSHOCK. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef QCURVEWIDGET_H
20 #define QCURVEWIDGET_H
21 
22 #include "HermiteCurve.h"
23 
24 #include <GraphNode.hpp>
25 
26 #include <QtGui/QWidget>
27 #include <QtGui/QCursor>
28 
29 class QCurveWidget : public QWidget
30 {
31 Q_OBJECT
32  public:
33  QCurveWidget(FotoSHOCKcore::GraphNode* node, const uint x, const uint y, HermiteCurve* curves, std::size_t numOfCurves, QWidget* parent = 0);
34  virtual ~QCurveWidget();
35  public slots:
36  void visibleAll(bool visibility);
37  void setActive(int active);
38  protected:
39  virtual void mousePressEvent(QMouseEvent *event);
40  virtual void mouseReleaseEvent(QMouseEvent *event);
41  virtual void mouseMoveEvent(QMouseEvent *event);
42  virtual void paintEvent (QPaintEvent * event);
43  private:
44  // draw the whole curve
45  inline void drawCurve(QPainter& p, std::size_t active);
46  inline void drawHermite(QPainter& p, const QHermiteControlPoint& x0, const QHermiteControlPoint& x1);
47 
48  HermiteCurve* curvesArray;
49  std::size_t curvesArraySize;
50  std::size_t activeCurve;
51 
52  bool m_visibleAll;
53 
54  // the point which would be moved if I press mouse button
55  // -1 if there is none
56  int movePointIndex;
57  // true if I'm moving some point right now
58  bool movingPoint;
59 
60  FotoSHOCKcore::GraphNode* m_parentNode;
61 };
62 
63 #endif // QCURVEWIDGET_H