NoteLayer.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 Chris Cannam.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _NOTE_LAYER_H_
00017 #define _NOTE_LAYER_H_
00018 
00019 #include "SingleColourLayer.h"
00020 #include "data/model/NoteModel.h"
00021 
00022 #include <QObject>
00023 #include <QColor>
00024 
00025 class View;
00026 class QPainter;
00027 
00028 class NoteLayer : public SingleColourLayer
00029 {
00030     Q_OBJECT
00031 
00032 public:
00033     NoteLayer();
00034 
00035     virtual void paint(View *v, QPainter &paint, QRect rect) const;
00036 
00037     virtual QString getFeatureDescription(View *v, QPoint &) const;
00038 
00039     virtual bool snapToFeatureFrame(View *v, int &frame,
00040                                     size_t &resolution,
00041                                     SnapType snap) const;
00042 
00043     virtual void drawStart(View *v, QMouseEvent *);
00044     virtual void drawDrag(View *v, QMouseEvent *);
00045     virtual void drawEnd(View *v, QMouseEvent *);
00046 
00047     virtual void eraseStart(View *v, QMouseEvent *);
00048     virtual void eraseDrag(View *v, QMouseEvent *);
00049     virtual void eraseEnd(View *v, QMouseEvent *);
00050 
00051     virtual void editStart(View *v, QMouseEvent *);
00052     virtual void editDrag(View *v, QMouseEvent *);
00053     virtual void editEnd(View *v, QMouseEvent *);
00054 
00055     virtual bool editOpen(View *v, QMouseEvent *);
00056 
00057     virtual void moveSelection(Selection s, size_t newStartFrame);
00058     virtual void resizeSelection(Selection s, Selection newSize);
00059     virtual void deleteSelection(Selection s);
00060 
00061     virtual void copy(View *v, Selection s, Clipboard &to);
00062     virtual bool paste(View *v, const Clipboard &from, int frameOffset,
00063                        bool interactive);
00064 
00065     virtual const Model *getModel() const { return m_model; }
00066     void setModel(NoteModel *model);
00067 
00068     virtual PropertyList getProperties() const;
00069     virtual QString getPropertyLabel(const PropertyName &) const;
00070     virtual PropertyType getPropertyType(const PropertyName &) const;
00071     virtual QString getPropertyGroupName(const PropertyName &) const;
00072     virtual int getPropertyRangeAndValue(const PropertyName &,
00073                                          int *min, int *max, int *deflt) const;
00074     virtual QString getPropertyValueLabel(const PropertyName &,
00075                                           int value) const;
00076     virtual void setProperty(const PropertyName &, int value);
00077 
00078     enum VerticalScale {
00079         AutoAlignScale,
00080         LinearScale,
00081         LogScale,
00082         MIDIRangeScale
00083     };
00084 
00085     void setVerticalScale(VerticalScale scale);
00086     VerticalScale getVerticalScale() const { return m_verticalScale; }
00087 
00088     virtual bool isLayerScrollable(const View *v) const;
00089 
00090     virtual bool isLayerEditable() const { return true; }
00091 
00092     virtual int getCompletion(View *) const { return m_model->getCompletion(); }
00093 
00094     virtual bool getValueExtents(float &min, float &max,
00095                                  bool &log, QString &unit) const;
00096 
00097     virtual bool getDisplayExtents(float &min, float &max) const;
00098 
00099     virtual void toXml(QTextStream &stream, QString indent = "",
00100                        QString extraAttributes = "") const;
00101 
00102     void setProperties(const QXmlAttributes &attributes);
00103 
00104 protected:
00105     void getScaleExtents(View *, float &min, float &max, bool &log) const;
00106     int getYForValue(View *v, float value) const;
00107     float getValueForY(View *v, int y) const;
00108     bool shouldConvertMIDIToHz() const;
00109 
00110     virtual int getDefaultColourHint(bool dark, bool &impose);
00111 
00112     NoteModel::PointList getLocalPoints(View *v, int) const;
00113 
00114     NoteModel *m_model;
00115     bool m_editing;
00116     NoteModel::Point m_originalPoint;
00117     NoteModel::Point m_editingPoint;
00118     NoteModel::EditCommand *m_editingCommand;
00119     VerticalScale m_verticalScale;
00120 };
00121 
00122 #endif
00123 

Generated on Wed Feb 20 15:45:27 2008 for SonicVisualiser by  doxygen 1.5.1