00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef _TIME_VALUE_LAYER_H_
00017 #define _TIME_VALUE_LAYER_H_
00018
00019 #include "SingleColourLayer.h"
00020 #include "data/model/SparseTimeValueModel.h"
00021
00022 #include <QObject>
00023 #include <QColor>
00024
00025 class View;
00026 class QPainter;
00027
00028 class TimeValueLayer : public SingleColourLayer
00029 {
00030 Q_OBJECT
00031
00032 public:
00033 TimeValueLayer();
00034
00035 virtual void paint(View *v, QPainter &paint, QRect rect) const;
00036
00037 virtual int getVerticalScaleWidth(View *v, QPainter &) const;
00038 virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
00039
00040 virtual QString getFeatureDescription(View *v, QPoint &) const;
00041
00042 virtual bool snapToFeatureFrame(View *v, int &frame,
00043 size_t &resolution,
00044 SnapType snap) const;
00045
00046 virtual void drawStart(View *v, QMouseEvent *);
00047 virtual void drawDrag(View *v, QMouseEvent *);
00048 virtual void drawEnd(View *v, QMouseEvent *);
00049
00050 virtual void eraseStart(View *v, QMouseEvent *);
00051 virtual void eraseDrag(View *v, QMouseEvent *);
00052 virtual void eraseEnd(View *v, QMouseEvent *);
00053
00054 virtual void editStart(View *v, QMouseEvent *);
00055 virtual void editDrag(View *v, QMouseEvent *);
00056 virtual void editEnd(View *v, QMouseEvent *);
00057
00058 virtual bool editOpen(View *v, QMouseEvent *);
00059
00060 virtual void moveSelection(Selection s, size_t newStartFrame);
00061 virtual void resizeSelection(Selection s, Selection newSize);
00062 virtual void deleteSelection(Selection s);
00063
00064 virtual void copy(View *v, Selection s, Clipboard &to);
00065 virtual bool paste(View *v, const Clipboard &from, int frameOffset,
00066 bool interactive);
00067
00068 virtual const Model *getModel() const { return m_model; }
00069 void setModel(SparseTimeValueModel *model);
00070
00071 virtual PropertyList getProperties() const;
00072 virtual QString getPropertyLabel(const PropertyName &) const;
00073 virtual PropertyType getPropertyType(const PropertyName &) const;
00074 virtual QString getPropertyGroupName(const PropertyName &) const;
00075 virtual int getPropertyRangeAndValue(const PropertyName &,
00076 int *min, int *max, int *deflt) const;
00077 virtual QString getPropertyValueLabel(const PropertyName &,
00078 int value) const;
00079 virtual void setProperty(const PropertyName &, int value);
00080
00081 void setFillColourMap(int);
00082 int getFillColourMap() const { return m_colourMap; }
00083
00084 enum PlotStyle {
00085 PlotPoints,
00086 PlotStems,
00087 PlotConnectedPoints,
00088 PlotLines,
00089 PlotCurve,
00090 PlotSegmentation
00091 };
00092
00093 void setPlotStyle(PlotStyle style);
00094 PlotStyle getPlotStyle() const { return m_plotStyle; }
00095
00096 enum VerticalScale {
00097 AutoAlignScale,
00098 LinearScale,
00099 LogScale,
00100 PlusMinusOneScale
00101 };
00102
00103 void setVerticalScale(VerticalScale scale);
00104 VerticalScale getVerticalScale() const { return m_verticalScale; }
00105
00106 virtual bool isLayerScrollable(const View *v) const;
00107
00108 virtual bool isLayerEditable() const { return true; }
00109
00110 virtual int getCompletion(View *) const { return m_model->getCompletion(); }
00111
00112 virtual bool needsTextLabelHeight() const {
00113 return m_plotStyle == PlotSegmentation && m_model->hasTextLabels();
00114 }
00115
00116 virtual bool getValueExtents(float &min, float &max,
00117 bool &logarithmic, QString &unit) const;
00118
00119 virtual bool getDisplayExtents(float &min, float &max) const;
00120
00121 virtual void toXml(QTextStream &stream, QString indent = "",
00122 QString extraAttributes = "") const;
00123
00124 void setProperties(const QXmlAttributes &attributes);
00125
00126 protected:
00127 void getScaleExtents(View *, float &min, float &max, bool &log) const;
00128 int getYForValue(View *, float value) const;
00129 float getValueForY(View *, int y) const;
00130 QColor getColourForValue(View *v, float value) const;
00131 bool shouldAutoAlign() const;
00132
00133 SparseTimeValueModel::PointList getLocalPoints(View *v, int) const;
00134
00135 virtual int getDefaultColourHint(bool dark, bool &impose);
00136
00137 SparseTimeValueModel *m_model;
00138 bool m_editing;
00139 SparseTimeValueModel::Point m_originalPoint;
00140 SparseTimeValueModel::Point m_editingPoint;
00141 SparseTimeValueModel::EditCommand *m_editingCommand;
00142 int m_colourMap;
00143 PlotStyle m_plotStyle;
00144 VerticalScale m_verticalScale;
00145 };
00146
00147 #endif
00148