00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef CURVE_VIEW_H
00023 #define CURVE_VIEW_H
00024
00025 #include "ViewItem.h"
00026 #include "Command.h"
00027
00028 #include <QTimer>
00029
00030 class Curve;
00031 class CurveNode;
00032 class CurveNodeView;
00033 class QPoint;
00034 class CurveView;
00035
00036 class DragNode : public Command
00037 {
00038 Q_OBJECT
00039 Q_CLASSINFO("move_up", tr("Move Up"));
00040 Q_CLASSINFO("move_down", tr("Move Down"));
00041
00042 public:
00043 DragNode(CurveNode* node,
00044 CurveView* curveview,
00045 qint64 scalefactor,
00046 TimeRef rangeMin,
00047 TimeRef rangeMax,
00048 const QString& des);
00049
00050 int prepare_actions();
00051 int do_action();
00052 int undo_action();
00053 int finish_hold();
00054 void cancel_action();
00055 int begin_hold();
00056 int jog();
00057 void set_cursor_shape(int useX, int useY);
00058 void set_vertical_only();
00059
00060 private :
00061 class Private {
00062 public:
00063 CurveView* curveView;
00064 qint64 scalefactor;
00065 TimeRef rangeMin;
00066 TimeRef rangeMax;
00067 QPoint mousepos;
00068 bool verticalOnly;
00069 };
00070
00071 Private* d;
00072 CurveNode* m_node;
00073 double m_origWhen;
00074 double m_origValue;
00075 double m_newWhen;
00076 double m_newValue;
00077
00078 int calculate_and_set_node_values();
00079
00080
00081 public slots:
00082 void move_up(bool autorepeat);
00083 void move_down(bool autorepeat);
00084 };
00085
00086
00087 class CurveView : public ViewItem
00088 {
00089 Q_OBJECT
00090 Q_CLASSINFO("add_node", tr("New node"))
00091 Q_CLASSINFO("remove_node", tr("Remove node"))
00092 Q_CLASSINFO("remove_all_nodes", tr("Remove all Nodes"))
00093 Q_CLASSINFO("drag_node", tr("Move node"))
00094 Q_CLASSINFO("drag_node_vertical_only", tr("Move node (vertical only)"))
00095
00096 public:
00097 CurveView(SheetView* sv, ViewItem* parentViewItem, Curve* curve);
00098 ~CurveView();
00099
00100 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
00101 int get_vector(int xstart, int pixelcount, float *arg);
00102 bool has_nodes() const;
00103 float get_default_value();
00104 void calculate_bounding_rect();
00105 void load_theme_data();
00106
00107 void set_start_offset(const TimeRef& offset);
00108 const TimeRef& get_start_offset() const {return m_startoffset;}
00109
00110
00111 protected:
00112 void hoverEnterEvent ( QGraphicsSceneHoverEvent * event );
00113 void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event );
00114 void hoverMoveEvent ( QGraphicsSceneHoverEvent * event );
00115
00116 private:
00117 Curve* m_curve;
00118 Curve* m_guicurve;
00119 QTimer m_blinkTimer;
00120 CurveNodeView* m_blinkingNode;
00121 int m_blinkDarkness;
00122 int m_blinkColorDirection;
00123 QList<CurveNodeView*> m_nodeViews;
00124 TimeRef m_startoffset;
00125
00126 void update_softselected_node(QPoint pos, bool force = false);
00127
00128 public slots:
00129 Command* add_node();
00130 Command* remove_node();
00131 Command* remove_all_nodes();
00132 Command* drag_node();
00133 Command* drag_node_vertical_only();
00134
00135 private slots:
00136 void add_curvenode_view(CurveNode* node);
00137 void remove_curvenode_view(CurveNode* node);
00138 void node_moved();
00139 void set_view_mode();
00140 void update_blink_color();
00141
00142 signals :
00143
00144
00145 void curveModified();
00146 };
00147
00148 #endif
00149
00150
00151