00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef _SeExprEdCurve_h_
00016 #define _SeExprEdCurve_h_
00017
00018
00019 #include <vector>
00020
00021 #include <QtCore/QObject>
00022 #include <QtGui/QComboBox>
00023 #include <QtGui/QGraphicsPolygonItem>
00024 #include <QtGui/QGraphicsView>
00025 #include <QtGui/QLineEdit>
00026
00027 #include <SeCurve.h>
00028
00029
00030
00031
00032 class CurveGraphicsView : public QGraphicsView
00033 {
00034 Q_OBJECT
00035 public:
00036 CurveGraphicsView() {
00037 setTransformationAnchor(QGraphicsView::NoAnchor);
00038 setResizeAnchor(QGraphicsView::NoAnchor);
00039 }
00040 ~CurveGraphicsView() {}
00041
00042 virtual void resizeEvent(QResizeEvent *event);
00043
00044 signals:
00045 void resizeSignal(int width, int height);
00046 };
00047
00048
00049
00050
00051
00052 class CurveScene : public QGraphicsScene
00053 {
00054 Q_OBJECT
00055
00056 typedef SeExpr::SeCurve<double> T_CURVE;
00057 typedef T_CURVE::InterpType T_INTERP ;
00058 public:
00059 CurveScene();
00060 ~CurveScene();
00061
00062 void addPoint(double x, double y, const T_INTERP interp, const bool select=true);
00063
00064 void removePoint(const int index);
00065 void removeAll();
00066
00067 virtual void keyPressEvent(QKeyEvent *event);
00068
00069 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
00070 virtual void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
00071 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
00072
00073 void drawRect();
00074
00075 void drawPoly();
00076
00077 void drawPoints();
00078
00079 void emitCurveChanged();
00080
00081 void rebuildCurve();
00082
00083 std::vector<T_CURVE::CV> _cvs;
00084
00085 friend class SeExprEdCurve;
00086
00087 private:
00088 T_CURVE* _curve;
00089 public slots:
00090 void interpChanged(const int interp);
00091 void selPosChanged(double pos);
00092 void selValChanged(double val);
00093 void resize(const int width, const int height);
00094
00095 signals:
00096 void cvSelected(double x, double y, T_INTERP interp);
00097 void curveChanged();
00098
00099 private:
00100
00101 int _width;
00102 int _height;
00103 T_INTERP _interp;
00104 std::vector<QGraphicsEllipseItem *> _circleObjects;
00105 int _selectedItem;
00106 QGraphicsPolygonItem *_curvePoly;
00107 QGraphicsRectItem *_baseRect;
00108 bool _lmb;
00109 };
00110
00111 class SeExprEdCurve : public QWidget
00112 {
00113 Q_OBJECT
00114
00115 typedef SeExpr::SeCurve<double> T_CURVE;
00116 typedef T_CURVE::InterpType T_INTERP ;
00117
00118 public:
00119 SeExprEdCurve(QWidget* parent = 0, QString pLabel = "", QString vLabel = "", QString iLabel = "",
00120 bool expandable=true);
00121 ~SeExprEdCurve() {}
00122
00123
00124 void addPoint(const double x, const double y, const T_INTERP interp, bool select=false);
00125
00126 CurveScene *_scene;
00127
00128 public slots:
00129 void cvSelectedSlot(double pos, double val, T_INTERP interp);
00130 void selPosChanged();
00131 void selValChanged();
00132 void openDetail();
00133
00134 signals:
00135 void selPosChangedSignal(double pos);
00136 void selValChangedSignal(double val);
00137
00138 private:
00139 QLineEdit *_selPosEdit;
00140 QLineEdit *_selValEdit;
00141 QComboBox *_interpComboBox;
00142 };
00143 #endif