00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef CURVE_H
00031 #define CURVE_H
00032
00033 #include "ContextItem.h"
00034 #include <QString>
00035 #include <QList>
00036 #include <QDomDocument>
00037
00038 #include "CurveNode.h"
00039 #include "defines.h"
00040
00041
00042 class Sheet;
00043
00044 class Curve : public ContextItem
00045 {
00046 Q_OBJECT
00047
00048 public:
00049 Curve(ContextItem* parent);
00050 Curve(ContextItem* parent, const QDomNode node);
00051 ~Curve();
00052
00053 QDomNode get_state(QDomDocument doc, const QString& name);
00054 virtual int set_state( const QDomNode& node );
00055 int process(audio_sample_t** buffer, const TimeRef& startlocation, const TimeRef& endlocation, nframes_t nframes, uint channels, float makeupgain=1.0f);
00056
00057 Command* add_node(CurveNode* node, bool historable=true);
00058 Command* remove_node(CurveNode* node, bool historable=true);
00059
00060
00061 double get_range() const;
00062 void get_vector (double x0, double x1, float *arg, int32_t veclen);
00063 APILinkedList& get_nodes() {return m_nodes;}
00064 Sheet* get_sheet() const {return m_sheet;}
00065
00066
00067 virtual void set_range(double when);
00068 void set_sheet(Sheet* sheet);
00069
00070 static bool smallerNode(const CurveNode* left, const CurveNode* right ) {
00071 return left->get_when() < right->get_when();
00072 }
00073
00074 void clear_curve() {m_nodes.clear();}
00075
00076 protected:
00077 Sheet* m_sheet;
00078
00079 private :
00080 APILinkedList m_nodes;
00081 struct LookupCache {
00082 double left;
00083 std::pair<CurveNode*, CurveNode*> range;
00084
00085 };
00086 LookupCache m_lookup_cache;
00087 bool m_changed;
00088 double m_defaultValue;
00089
00090
00091 double multipoint_eval (double x);
00092 void x_scale(double factor);
00093 void solve ();
00094 void init();
00095
00096 friend class CurveNode;
00097
00098 protected slots:
00099 void set_changed();
00100
00101 private slots:
00102 void private_add_node(CurveNode* node);
00103 void private_remove_node(CurveNode* node);
00104
00105
00106
00107 signals :
00108 void stateChanged();
00109 void nodeAdded(CurveNode*);
00110 void nodeRemoved(CurveNode*);
00111 void nodePositionChanged();
00112 };
00113
00114
00115 inline double Curve::get_range( ) const
00116 {
00117 if (m_nodes.size()) {
00118 return ((CurveNode*)m_nodes.last())->when;
00119 }
00120
00121 return 0;
00122 }
00123
00124 #endif