TimeInstantLayer.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 _TIME_INSTANT_LAYER_H_
00017 #define _TIME_INSTANT_LAYER_H_
00018 
00019 #include "SingleColourLayer.h"
00020 #include "data/model/SparseOneDimensionalModel.h"
00021 
00022 #include <QObject>
00023 #include <QColor>
00024 
00025 class View;
00026 class QPainter;
00027 
00028 class TimeInstantLayer : public SingleColourLayer
00029 {
00030     Q_OBJECT
00031 
00032 public:
00033     TimeInstantLayer();
00034     virtual ~TimeInstantLayer();
00035 
00036     virtual void paint(View *v, QPainter &paint, QRect rect) const;
00037 
00038     virtual QString getFeatureDescription(View *v, QPoint &) const;
00039 
00040     virtual bool snapToFeatureFrame(View *v, int &frame,
00041                                     size_t &resolution,
00042                                     SnapType snap) const;
00043 
00044     virtual void drawStart(View *v, QMouseEvent *);
00045     virtual void drawDrag(View *v, QMouseEvent *);
00046     virtual void drawEnd(View *v, QMouseEvent *);
00047 
00048     virtual void eraseStart(View *v, QMouseEvent *);
00049     virtual void eraseDrag(View *v, QMouseEvent *);
00050     virtual void eraseEnd(View *v, QMouseEvent *);
00051 
00052     virtual void editStart(View *v, QMouseEvent *);
00053     virtual void editDrag(View *v, QMouseEvent *);
00054     virtual void editEnd(View *v, QMouseEvent *);
00055 
00056     virtual bool editOpen(View *, QMouseEvent *);
00057 
00058     virtual void moveSelection(Selection s, size_t newStartFrame);
00059     virtual void resizeSelection(Selection s, Selection newSize);
00060     virtual void deleteSelection(Selection s);
00061 
00062     virtual void copy(View *v, Selection s, Clipboard &to);
00063     virtual bool paste(View *v, const Clipboard &from, int frameOffset,
00064                        bool interactive);
00065 
00066     virtual const Model *getModel() const { return m_model; }
00067     void setModel(SparseOneDimensionalModel *model);
00068 
00069     virtual PropertyList getProperties() const;
00070     virtual QString getPropertyLabel(const PropertyName &) const;
00071     virtual PropertyType getPropertyType(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 PlotStyle {
00079         PlotInstants,
00080         PlotSegmentation
00081     };
00082 
00083     void setPlotStyle(PlotStyle style);
00084     PlotStyle getPlotStyle() const { return m_plotStyle; }
00085 
00086     virtual bool isLayerScrollable(const View *v) const;
00087 
00088     virtual bool isLayerEditable() const { return true; }
00089 
00090     virtual int getCompletion(View *) const { return m_model->getCompletion(); }
00091 
00092     virtual bool needsTextLabelHeight() const { return m_model->hasTextLabels(); }
00093 
00094     virtual bool getValueExtents(float &, float &, bool &, QString &) const {
00095         return false;
00096     }
00097 
00098     virtual void toXml(QTextStream &stream, QString indent = "",
00099                        QString extraAttributes = "") const;
00100 
00101     void setProperties(const QXmlAttributes &attributes);
00102 
00103 protected:
00104     SparseOneDimensionalModel::PointList getLocalPoints(View *v, int) const;
00105 
00106     virtual int getDefaultColourHint(bool dark, bool &impose);
00107 
00108     bool clipboardAlignmentDiffers(View *v, const Clipboard &) const;
00109 
00110     SparseOneDimensionalModel *m_model;
00111     bool m_editing;
00112     SparseOneDimensionalModel::Point m_editingPoint;
00113     SparseOneDimensionalModel::EditCommand *m_editingCommand;
00114     PlotStyle m_plotStyle;
00115 };
00116 
00117 #endif
00118 

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