svgui  1.9
Colour3DPlotLayer.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 and QMUL.
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 _COLOUR_3D_PLOT_H_
17 #define _COLOUR_3D_PLOT_H_
18 
19 #include "SliceableLayer.h"
20 
21 #include "data/model/DenseThreeDimensionalModel.h"
22 
23 class View;
24 class QPainter;
25 class QImage;
26 
41 {
42  Q_OBJECT
43 
44 public:
47 
48  virtual const ZoomConstraint *getZoomConstraint() const {
49  return m_model ? m_model->getZoomConstraint() : 0;
50  }
51  virtual const Model *getModel() const { return m_model; }
52  virtual void paint(View *v, QPainter &paint, QRect rect) const;
53 
54  virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const;
55  virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const;
56 
57  virtual QString getFeatureDescription(View *v, QPoint &) const;
58 
59  virtual bool snapToFeatureFrame(View *v, int &frame,
60  int &resolution,
61  SnapType snap) const;
62 
63  virtual void setLayerDormant(const View *v, bool dormant);
64 
65  virtual bool isLayerScrollable(const View *v) const;
66 
69  }
70 
71  void setModel(const DenseThreeDimensionalModel *model);
72 
73  virtual int getCompletion(View *) const { return m_model->getCompletion(); }
74 
75  virtual PropertyList getProperties() const;
76  virtual PropertyType getPropertyType(const PropertyName &) const;
77  virtual QString getPropertyLabel(const PropertyName &) const;
78  virtual QString getPropertyIconName(const PropertyName &) const;
79  virtual QString getPropertyGroupName(const PropertyName &) const;
80  virtual int getPropertyRangeAndValue(const PropertyName &,
81  int *min, int *max, int *deflt) const;
82  virtual QString getPropertyValueLabel(const PropertyName &,
83  int value) const;
84  virtual RangeMapper *getNewPropertyRangeMapper(const PropertyName &) const;
85  virtual void setProperty(const PropertyName &, int value);
86  virtual void setProperties(const QXmlAttributes &);
87 
88  enum ColourScale {
93  };
94 
97 
98  void setColourMap(int map);
99  int getColourMap() const;
100 
105  void setGain(float gain);
106  float getGain() const;
107 
108  enum BinScale {
111  };
112 
116  void setBinScale(BinScale);
117  BinScale getBinScale() const;
118 
123  void setNormalizeColumns(bool n);
124  bool getNormalizeColumns() const;
125 
129  void setNormalizeVisibleArea(bool n);
130  bool getNormalizeVisibleArea() const;
131 
136  void setNormalizeHybrid(bool n);
137  bool getNormalizeHybrid() const;
138 
139  void setInvertVertical(bool i);
140  bool getInvertVertical() const;
141 
142  void setOpaque(bool i);
143  bool getOpaque() const;
144 
145  void setSmooth(bool i);
146  bool getSmooth() const;
147 
148  virtual bool getValueExtents(float &min, float &max,
149  bool &logarithmic, QString &unit) const;
150 
151  virtual bool getDisplayExtents(float &min, float &max) const;
152  virtual bool setDisplayExtents(float min, float max);
153 
154  virtual bool getYScaleValue(const View *, int /* y */,
155  float &/* value */, QString &/* unit */) const;
156 
157  virtual int getVerticalZoomSteps(int &defaultStep) const;
158  virtual int getCurrentVerticalZoomStep() const;
159  virtual void setVerticalZoomStep(int);
160  virtual RangeMapper *getNewVerticalZoomRangeMapper() const;
161 
162  virtual const Model *getSliceableModel() const { return m_model; }
163 
164  virtual void toXml(QTextStream &stream, QString indent = "",
165  QString extraAttributes = "") const;
166 
167 protected slots:
168  void cacheInvalid();
169  void cacheInvalid(int startFrame, int endFrame);
170  void modelChanged();
171  void modelChangedWithin(int, int);
172 
173 protected:
174  const DenseThreeDimensionalModel *m_model; // I do not own this
175 
176  mutable QImage *m_cache;
177  mutable QImage *m_peaksCache;
178  mutable int m_cacheValidStart;
179  mutable int m_cacheValidEnd;
180 
184  float m_gain;
190  bool m_opaque;
191  bool m_smooth;
193 
194  // Minimum and maximum bin numbers visible within the view. We
195  // always snap to whole bins at view edges.
196  int m_miny;
197  int m_maxy;
198 
205  float getYForBin(View *, float bin) const;
206 
213  float getBinForY(View *, float y) const;
214 
215  DenseThreeDimensionalModel::Column getColumn(int col) const;
216 
222  bool shouldPaintDenseIn(const View *) const;
223 
224  int getColourScaleWidth(QPainter &) const;
225  void fillCache(int firstBin, int lastBin) const;
226  void paintDense(View *v, QPainter &paint, QRect rect) const;
227 };
228 
229 #endif
int getColourMap() const
virtual int getVerticalZoomSteps(int &defaultStep) const
Get the number of vertical zoom steps available for this layer.
virtual PropertyList getProperties() const
bool getNormalizeHybrid() const
bool shouldPaintDenseIn(const View *) const
True if we have the opaque or smooth flag set, or if the cells are so small you can't see their borde...
virtual PropertyType getPropertyType(const PropertyName &) const
virtual bool getYScaleValue(const View *, int, float &, QString &) const
Return the value and unit at the given y coordinate in the given view.
void fillCache(int firstBin, int lastBin) const
virtual bool setDisplayExtents(float min, float max)
Set the displayed minimum and maximum values for the y axis to the given range, if supported.
virtual ColourSignificance getLayerColourSignificance() const
This should return the degree of meaning associated with colour in this layer.
void setNormalizeHybrid(bool n)
Normalize each column to its maximum value, and then scale by the log of the (absolute) maximum value...
float getYForBin(View *, float bin) const
Return the y coordinate at which the given bin "starts" (i.e.
int getColourScaleWidth(QPainter &) const
virtual int getPropertyRangeAndValue(const PropertyName &, int *min, int *max, int *deflt) const
This is a view that displays dense 3-D data (time, some sort of binned y-axis range,...
virtual const Model * getSliceableModel() const
ColourSignificance
Definition: Layer.h:304
void setColourMap(int map)
virtual bool getValueExtents(float &min, float &max, bool &logarithmic, QString &unit) const
Return the minimum and maximum values for the y axis of the model in this layer, as well as whether t...
ColourScale m_colourScale
void setInvertVertical(bool i)
virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const
virtual QString getPropertyGroupName(const PropertyName &) const
bool getNormalizeColumns() const
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.
void setModel(const DenseThreeDimensionalModel *model)
virtual int getCompletion(View *) const
Return the proportion of background work complete in drawing this view, as a percentage – in most cas...
ColourScale getColourScale() const
void modelChangedWithin(int, int)
void setGain(float gain)
Set the gain multiplier for sample values in this view.
void setNormalizeVisibleArea(bool n)
Normalize each value against the maximum in the visible region.
virtual RangeMapper * getNewPropertyRangeMapper(const PropertyName &) const
virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const
virtual QString getFeatureDescription(View *v, QPoint &) const
virtual const Model * getModel() const
virtual bool getDisplayExtents(float &min, float &max) const
Return the minimum and maximum values within the displayed range for the y axis, if only a subset of ...
virtual QString getPropertyLabel(const PropertyName &) const
virtual void setVerticalZoomStep(int)
Set the vertical zoom step.
void setNormalizeColumns(bool n)
Normalize each column to its maximum value, independent of its neighbours.
virtual const ZoomConstraint * getZoomConstraint() const
Return a zoom constraint object defining the supported zoom levels for this layer.
SnapType
Definition: Layer.h:157
virtual RangeMapper * getNewVerticalZoomRangeMapper() const
Create and return a range mapper for vertical zoom step values.
virtual void setProperty(const PropertyName &, int value)
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...
bool getNormalizeVisibleArea() const
void setBinScale(BinScale)
Specify the scale for the y axis.
virtual void setLayerDormant(const View *v, bool dormant)
Indicate that a layer is not currently visible in the given view and is not expected to become visibl...
const DenseThreeDimensionalModel * m_model
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
Definition: View.h:50
Base class for layers that can be sliced, that is, that contain models appropriate for use in a Slice...
void setColourScale(ColourScale)
virtual void setProperties(const QXmlAttributes &)
Set the particular properties of a layer (those specific to the subclass) from a set of XML attribute...
DenseThreeDimensionalModel::Column getColumn(int col) const
bool getInvertVertical() const
virtual QString getPropertyIconName(const PropertyName &) const
virtual int getCurrentVerticalZoomStep() const
Get the current vertical zoom step.
void paintDense(View *v, QPainter &paint, QRect rect) const
virtual bool snapToFeatureFrame(View *v, int &frame, int &resolution, SnapType snap) const
Adjust the given frame to snap to the nearest feature, if possible.
virtual QString getPropertyValueLabel(const PropertyName &, int value) const
float getBinForY(View *, float y) const
Return the bin number, possibly fractional, at the given y coordinate.
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,...
BinScale getBinScale() const