Add bezier progression type to automation tracks

This commit is contained in:
codythecoder
2016-04-19 09:59:26 +10:00
committed by Hyunjin Song
parent d3cd704396
commit 0dfdbc956a
7 changed files with 489 additions and 10 deletions

View File

@@ -56,6 +56,7 @@ class AutomationEditor : public QWidget, public JournallingObject
Q_PROPERTY(QColor beatLineColor READ beatLineColor WRITE setBeatLineColor)
Q_PROPERTY(QColor lineColor READ lineColor WRITE setLineColor)
Q_PROPERTY(QColor vertexColor READ vertexColor WRITE setVertexColor)
Q_PROPERTY(QColor controlPointColor READ controlPointColor WRITE setControlPointColor)
Q_PROPERTY(QBrush scaleColor READ scaleColor WRITE setScaleColor)
Q_PROPERTY(QBrush graphColor READ graphColor WRITE setGraphColor)
Q_PROPERTY(QColor crossColor READ crossColor WRITE setCrossColor)
@@ -91,6 +92,8 @@ public:
void setGraphColor(const QBrush & c);
QColor vertexColor() const;
void setVertexColor(const QColor & c);
QColor controlPointColor() const;
void setControlPointColor(const QColor& c);
QBrush scaleColor() const;
void setScaleColor(const QBrush & c);
QColor crossColor() const;
@@ -113,6 +116,7 @@ public slots:
protected:
typedef AutomationPattern::timeMap timeMap;
typedef AutomationPattern::controlPointTimeMap controlPointTimeMap;
void keyPressEvent(QKeyEvent * ke) override;
void leaveEvent(QEvent * e) override;
@@ -167,6 +171,7 @@ private:
{
NONE,
MOVE_VALUE,
MOVE_CONTROL_POINT,
SELECT_VALUES,
MOVE_SELECTION
} ;
@@ -249,6 +254,7 @@ private:
void drawCross(QPainter & p );
void drawAutomationPoint( QPainter & p, timeMap::iterator it );
void drawControlPoint( QPainter & p, controlPointTimeMap::iterator it, float key_y );
bool inBBEditor();
QColor m_barLineColor;
@@ -256,6 +262,7 @@ private:
QColor m_lineColor;
QBrush m_graphColor;
QColor m_vertexColor;
QColor m_controlPointColor;
QBrush m_scaleColor;
QColor m_crossColor;
QColor m_backgroundShade;
@@ -313,6 +320,7 @@ private:
QAction* m_discreteAction;
QAction* m_linearAction;
QAction* m_cubicHermiteAction;
QAction* m_bezierAction;
QAction* m_flipYAction;
QAction* m_flipXAction;

View File

@@ -46,10 +46,12 @@ public:
{
DiscreteProgression,
LinearProgression,
CubicHermiteProgression
CubicHermiteProgression,
BezierProgression
} ;
typedef QMap<int, float> timeMap;
typedef QMap<int, QVector<float> > controlPointTimeMap;
typedef QVector<QPointer<AutomatableModel> > objectVector;
AutomationPattern( AutomationTrack * _auto_track );
@@ -82,6 +84,15 @@ public:
const bool quantPos = true,
const bool ignoreSurroundingPoints = true );
TimePos putControlPoint( timeMap::const_iterator it,
const float _value);
TimePos putControlPoint(timeMap::const_iterator it,
const int time, const float _value);
TimePos putControlPoint(timeMap::const_iterator it,
const int time, const float _value, const bool flip);
void removeValue( const TimePos & time );
void recordValue(TimePos time, float value);
@@ -91,8 +102,13 @@ public:
const bool quantPos = true,
const bool controlKey = false );
TimePos setControlPointDragValue( const TimePos & _time, const float _value, const int _x,
const bool _quant_pos = true );
void applyDragValue();
void flipControlPoint(bool flip);
bool isDragging() const
{
@@ -119,6 +135,27 @@ public:
return m_tangents;
}
inline const controlPointTimeMap & getControlPoints() const
{
return m_controlPoints;
}
inline controlPointTimeMap & getControlPoints()
{
return m_controlPoints;
}
// This is for getting the node of the control point that is being dragged
inline const timeMap::ConstIterator & getControlPointNode() const
{
return m_oldControlPointNode;
}
inline timeMap::ConstIterator & getControlPointNode()
{
return m_oldControlPointNode;
}
inline float getMin() const
{
return firstObject()->minValue<float>();
@@ -160,6 +197,8 @@ public:
static int quantization() { return s_quantization; }
static void setQuantization(int q) { s_quantization = q; }
void clampControlPoints(bool clampVertical=true);
public slots:
void clear();
void objectDestroyed( jo_id_t );
@@ -169,6 +208,7 @@ public slots:
private:
void cleanObjects();
void cleanControlPoints();
void generateTangents();
void generateTangents( timeMap::const_iterator it, int numToGenerate );
float valueAt( timeMap::const_iterator v, int offset ) const;
@@ -179,12 +219,20 @@ private:
timeMap m_timeMap; // actual values
timeMap m_oldTimeMap; // old values for storing the values before setDragValue() is called.
timeMap m_tangents; // slope at each point for calculating spline
controlPointTimeMap m_controlPoints; // control points for calculating the bezier curve
controlPointTimeMap m_oldControlPoints; // old values for storing the values before setDragValue() is called.
// m_oldControlPoints is similar to m_oldTimeMap, since the control points need to be dragged as well or something
timeMap::const_iterator m_oldControlPointNode; // Which automation point was the control point connected to?
bool m_controlFlip; // If the lefthand control point is grabbed, the value must be flipped around the automation point
float m_controlPointDragOffset[2];
float m_tension;
bool m_hasAutomation;
ProgressionTypes m_progressionType;
bool m_dragging;
bool m_isRecording;
float m_lastRecordedValue;