svgui  1.9
TimeInstantLayer.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _TIME_INSTANT_LAYER_H_
17 #define _TIME_INSTANT_LAYER_H_
18 
19 #include "SingleColourLayer.h"
20 #include "data/model/SparseOneDimensionalModel.h"
21 
22 #include <QObject>
23 #include <QColor>
24 
25 class View;
26 class QPainter;
27 
29 {
30  Q_OBJECT
31 
32 public:
34  virtual ~TimeInstantLayer();
35 
36  virtual void paint(View *v, QPainter &paint, QRect rect) const;
37 
38  virtual QString getLabelPreceding(int) const;
39  virtual QString getFeatureDescription(View *v, QPoint &) const;
40 
41  virtual bool snapToFeatureFrame(View *v, int &frame,
42  int &resolution,
43  SnapType snap) const;
44 
45  virtual void drawStart(View *v, QMouseEvent *);
46  virtual void drawDrag(View *v, QMouseEvent *);
47  virtual void drawEnd(View *v, QMouseEvent *);
48 
49  virtual void eraseStart(View *v, QMouseEvent *);
50  virtual void eraseDrag(View *v, QMouseEvent *);
51  virtual void eraseEnd(View *v, QMouseEvent *);
52 
53  virtual void editStart(View *v, QMouseEvent *);
54  virtual void editDrag(View *v, QMouseEvent *);
55  virtual void editEnd(View *v, QMouseEvent *);
56 
57  virtual bool editOpen(View *, QMouseEvent *);
58 
59  virtual void moveSelection(Selection s, int newStartFrame);
60  virtual void resizeSelection(Selection s, Selection newSize);
61  virtual void deleteSelection(Selection s);
62 
63  virtual void copy(View *v, Selection s, Clipboard &to);
64  virtual bool paste(View *v, const Clipboard &from, int frameOffset,
65  bool interactive);
66 
67  virtual const Model *getModel() const { return m_model; }
68  void setModel(SparseOneDimensionalModel *model);
69 
70  virtual PropertyList getProperties() const;
71  virtual QString getPropertyLabel(const PropertyName &) const;
72  virtual PropertyType getPropertyType(const PropertyName &) const;
73  virtual int getPropertyRangeAndValue(const PropertyName &,
74  int *min, int *max, int *deflt) const;
75  virtual QString getPropertyValueLabel(const PropertyName &,
76  int value) const;
77  virtual void setProperty(const PropertyName &, int value);
78 
79  enum PlotStyle {
82  };
83 
84  void setPlotStyle(PlotStyle style);
85  PlotStyle getPlotStyle() const { return m_plotStyle; }
86 
87  virtual bool isLayerScrollable(const View *v) const;
88 
89  virtual bool isLayerEditable() const { return true; }
90 
91  virtual int getCompletion(View *) const { return m_model->getCompletion(); }
92 
93  virtual bool needsTextLabelHeight() const { return m_model->hasTextLabels(); }
94 
95  virtual bool getValueExtents(float &, float &, bool &, QString &) const {
96  return false;
97  }
98 
99  virtual void toXml(QTextStream &stream, QString indent = "",
100  QString extraAttributes = "") const;
101 
102  void setProperties(const QXmlAttributes &attributes);
103 
105  if (m_plotStyle == PlotSegmentation) {
107  } else {
108  return ColourDistinguishes;
109  }
110  }
111 
112  virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
113 
114 protected:
115  SparseOneDimensionalModel::PointList getLocalPoints(View *v, int) const;
116 
117  virtual int getDefaultColourHint(bool dark, bool &impose);
118 
119  bool clipboardAlignmentDiffers(View *v, const Clipboard &) const;
120 
121  SparseOneDimensionalModel *m_model;
122  bool m_editing;
123  SparseOneDimensionalModel::Point m_editingPoint;
124  SparseOneDimensionalModel::EditCommand *m_editingCommand;
126 
127  void finish(SparseOneDimensionalModel::EditCommand *command) {
128  Command *c = command->finish();
129  if (c) CommandHistory::getInstance()->addCommand(c, false);
130  }
131 };
132 
133 #endif
134 
virtual QString getPropertyLabel(const PropertyName &) const
virtual void eraseDrag(View *v, QMouseEvent *)
virtual void copy(View *v, Selection s, Clipboard &to)
virtual bool needsTextLabelHeight() const
virtual void resizeSelection(Selection s, Selection newSize)
virtual PropertyList getProperties() const
virtual QString getFeatureDescription(View *v, QPoint &) const
virtual const Model * getModel() const
virtual void drawStart(View *v, QMouseEvent *)
virtual void drawDrag(View *v, QMouseEvent *)
virtual void moveSelection(Selection s, int newStartFrame)
virtual ColourSignificance getLayerColourSignificance() const
Implements Layer::getLayerColourSignificance()
virtual QString getLabelPreceding(int) const
SparseOneDimensionalModel::Point m_editingPoint
void setModel(SparseOneDimensionalModel *model)
SparseOneDimensionalModel * m_model
void addCommand(Command *command)
Add a command to the command history.
virtual PropertyType getPropertyType(const PropertyName &) const
ColourSignificance
Definition: Layer.h:304
virtual void drawEnd(View *v, QMouseEvent *)
virtual bool snapToFeatureFrame(View *v, int &frame, int &resolution, SnapType snap) const
Adjust the given frame to snap to the nearest feature, if possible.
void setProperties(const QXmlAttributes &attributes)
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
SparseOneDimensionalModel::EditCommand * m_editingCommand
PlotStyle getPlotStyle() const
virtual void paint(View *v, QPainter &paint, QRect rect) const
Paint the given rectangle of this layer onto the given view using the given painter,...
void setPlotStyle(PlotStyle style)
virtual int getCompletion(View *) const
Return the proportion of background work complete in drawing this view, as a percentage – in most cas...
virtual bool isLayerEditable() const
This should return true if the layer can be edited by the user.
virtual bool paste(View *v, const Clipboard &from, int frameOffset, bool interactive)
Paste from the given clipboard onto the layer at the given frame offset.
virtual int getDefaultColourHint(bool dark, bool &impose)
bool clipboardAlignmentDiffers(View *v, const Clipboard &) const
SnapType
Definition: Layer.h:157
static CommandHistory * getInstance()
virtual void eraseStart(View *v, QMouseEvent *)
virtual bool isLayerScrollable(const View *v) const
This should return true if the layer can safely be scrolled automatically by a given view (simply cop...
virtual bool editOpen(View *, QMouseEvent *)
Open an editor on the item under the mouse (e.g.
virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const
virtual ~TimeInstantLayer()
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
Definition: View.h:50
virtual QString getPropertyValueLabel(const PropertyName &, int value) const
virtual void editEnd(View *v, QMouseEvent *)
virtual void setProperty(const PropertyName &, int value)
virtual void deleteSelection(Selection s)
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const
Convert the layer's data (though not those of the model it refers to) into XML for file output.
virtual void editDrag(View *v, QMouseEvent *)
void finish(SparseOneDimensionalModel::EditCommand *command)
virtual void eraseEnd(View *v, QMouseEvent *)
virtual int getVerticalScaleWidth(View *, bool, QPainter &) const
virtual bool getValueExtents(float &, float &, bool &, QString &) const
Return the minimum and maximum values for the y axis of the model in this layer, as well as whether t...
virtual void editStart(View *v, QMouseEvent *)
SparseOneDimensionalModel::PointList getLocalPoints(View *v, int) const