annotate layer/TextLayer.h @ 38:beb801473743

* Rearrange spectrogram cacheing so that gain, normalization, instantaneous frequency calculations etc can be done from the cached data (increasing the size of the cache, but also the usability).
author Chris Cannam
date Thu, 23 Feb 2006 18:01:31 +0000
parents c28ebb4ba4de
children 78515b1e29eb
rev   line source
Chris@35 1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
Chris@35 2
Chris@35 3 /*
Chris@35 4 A waveform viewer and audio annotation editor.
Chris@35 5 Chris Cannam, Queen Mary University of London, 2005-2006
Chris@35 6
Chris@35 7 This is experimental software. Not for distribution.
Chris@35 8 */
Chris@35 9
Chris@35 10 #ifndef _TEXT_LAYER_H_
Chris@35 11 #define _TEXT_LAYER_H_
Chris@35 12
Chris@35 13 #include "base/Layer.h"
Chris@35 14 #include "model/TextModel.h"
Chris@35 15
Chris@35 16 #include <QObject>
Chris@35 17 #include <QColor>
Chris@35 18
Chris@35 19 class View;
Chris@35 20 class QPainter;
Chris@35 21
Chris@35 22 class TextLayer : public Layer
Chris@35 23 {
Chris@35 24 Q_OBJECT
Chris@35 25
Chris@35 26 public:
Chris@35 27 TextLayer(View *w);
Chris@35 28
Chris@35 29 virtual void paint(QPainter &paint, QRect rect) const;
Chris@35 30
Chris@35 31 virtual QString getFeatureDescription(QPoint &) const;
Chris@35 32
Chris@35 33 virtual bool snapToFeatureFrame(int &frame,
Chris@35 34 size_t &resolution,
Chris@35 35 SnapType snap) const;
Chris@35 36
Chris@35 37 virtual void drawStart(QMouseEvent *);
Chris@35 38 virtual void drawDrag(QMouseEvent *);
Chris@35 39 virtual void drawEnd(QMouseEvent *);
Chris@35 40
Chris@35 41 virtual void editStart(QMouseEvent *);
Chris@35 42 virtual void editDrag(QMouseEvent *);
Chris@35 43 virtual void editEnd(QMouseEvent *);
Chris@35 44
Chris@36 45 virtual void editOpen(QMouseEvent *); // on double-click
Chris@36 46
Chris@35 47 virtual const Model *getModel() const { return m_model; }
Chris@35 48 void setModel(TextModel *model);
Chris@35 49
Chris@35 50 virtual PropertyList getProperties() const;
Chris@35 51 virtual PropertyType getPropertyType(const PropertyName &) const;
Chris@35 52 virtual int getPropertyRangeAndValue(const PropertyName &,
Chris@35 53 int *min, int *max) const;
Chris@35 54 virtual QString getPropertyValueLabel(const PropertyName &,
Chris@35 55 int value) const;
Chris@35 56 virtual void setProperty(const PropertyName &, int value);
Chris@35 57
Chris@35 58 void setBaseColour(QColor);
Chris@35 59 QColor getBaseColour() const { return m_colour; }
Chris@35 60
Chris@35 61 virtual bool isLayerScrollable() const;
Chris@35 62
Chris@35 63 virtual bool isLayerEditable() const { return true; }
Chris@35 64
Chris@35 65 virtual int getCompletion() const { return m_model->getCompletion(); }
Chris@35 66
Chris@35 67 virtual QString toXmlString(QString indent = "",
Chris@35 68 QString extraAttributes = "") const;
Chris@35 69
Chris@35 70 void setProperties(const QXmlAttributes &attributes);
Chris@35 71
Chris@35 72 protected:
Chris@35 73 int getYForHeight(float height) const;
Chris@35 74 float getHeightForY(int y) const;
Chris@35 75
Chris@35 76 TextModel::PointList getLocalPoints(int x, int y) const;
Chris@35 77
Chris@35 78 TextModel *m_model;
Chris@35 79 bool m_editing;
Chris@36 80 QPoint m_editOrigin;
Chris@35 81 TextModel::Point m_originalPoint;
Chris@35 82 TextModel::Point m_editingPoint;
Chris@35 83 TextModel::EditCommand *m_editingCommand;
Chris@35 84 QColor m_colour;
Chris@35 85 };
Chris@35 86
Chris@35 87 #endif
Chris@35 88