Chris@0
|
1
|
Chris@0
|
2 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
3
|
Chris@0
|
4 /*
|
Chris@0
|
5 A waveform viewer and audio annotation editor.
|
Chris@2
|
6 Chris Cannam, Queen Mary University of London, 2005-2006
|
Chris@0
|
7
|
Chris@0
|
8 This is experimental software. Not for distribution.
|
Chris@0
|
9 */
|
Chris@0
|
10
|
Chris@0
|
11 #ifndef _VIEWER_H_
|
Chris@0
|
12 #define _VIEWER_H_
|
Chris@0
|
13
|
Chris@0
|
14 #include "PropertyContainer.h"
|
Chris@0
|
15
|
Chris@0
|
16 #include <QObject>
|
Chris@0
|
17 #include <QRect>
|
Chris@0
|
18
|
Chris@0
|
19 class ZoomConstraint;
|
Chris@0
|
20 class Model;
|
Chris@0
|
21 class QPainter;
|
Chris@0
|
22 class View;
|
Chris@0
|
23
|
Chris@0
|
24 /**
|
Chris@0
|
25 * The base class for visual representations of the data found in a
|
Chris@0
|
26 * Model. Layers are expected to be able to draw themselves onto a
|
Chris@0
|
27 * View, and may also be editable.
|
Chris@0
|
28 */
|
Chris@0
|
29
|
Chris@0
|
30 class Layer : public QObject,
|
Chris@0
|
31 public PropertyContainer
|
Chris@0
|
32 {
|
Chris@0
|
33 Q_OBJECT
|
Chris@0
|
34
|
Chris@0
|
35 public:
|
Chris@0
|
36 Layer(View *w);
|
Chris@0
|
37 virtual ~Layer();
|
Chris@0
|
38
|
Chris@0
|
39 virtual const Model *getModel() const = 0;
|
Chris@0
|
40 virtual const ZoomConstraint *getZoomConstraint() const { return 0; }
|
Chris@0
|
41 virtual void paint(QPainter &, QRect) const = 0;
|
Chris@0
|
42
|
Chris@0
|
43 enum VerticalPosition {
|
Chris@0
|
44 PositionTop, PositionMiddle, PositionBottom
|
Chris@0
|
45 };
|
Chris@0
|
46 virtual VerticalPosition getPreferredTimeRulerPosition() const {
|
Chris@0
|
47 return PositionMiddle;
|
Chris@0
|
48 }
|
Chris@0
|
49 virtual VerticalPosition getPreferredFrameCountPosition() const {
|
Chris@0
|
50 return PositionBottom;
|
Chris@0
|
51 }
|
Chris@0
|
52
|
Chris@0
|
53 virtual QString getPropertyContainerName() const {
|
Chris@0
|
54 return objectName();
|
Chris@0
|
55 }
|
Chris@0
|
56
|
Chris@0
|
57 virtual int getVerticalScaleWidth(QPainter &) const { return 0; }
|
Chris@0
|
58 virtual void paintVerticalScale(QPainter &, QRect) const { }
|
Chris@0
|
59
|
Chris@0
|
60 virtual QRect getFeatureDescriptionRect(QPainter &, QPoint) const {
|
Chris@0
|
61 return QRect(0, 0, 0, 0);
|
Chris@0
|
62 }
|
Chris@0
|
63 virtual void paintLocalFeatureDescription(QPainter &, QRect, QPoint) const {
|
Chris@0
|
64 }
|
Chris@0
|
65
|
Chris@0
|
66 /**
|
Chris@0
|
67 * This should return true if the view can safely be scrolled
|
Chris@0
|
68 * automatically by the widget (simply copying the existing data
|
Chris@0
|
69 * and then refreshing the exposed area) without altering its
|
Chris@0
|
70 * meaning. For the widget as a whole this is usually not
|
Chris@0
|
71 * possible because of invariant (non-scrolling) material
|
Chris@0
|
72 * displayed over the top, but the widget may be able to optimise
|
Chris@0
|
73 * scrolling better if it is known that individual views can be
|
Chris@0
|
74 * scrolled safely in this way.
|
Chris@0
|
75 */
|
Chris@0
|
76 virtual bool isLayerScrollable() const { return true; }
|
Chris@0
|
77
|
Chris@0
|
78 /**
|
Chris@0
|
79 * Return the proportion of background work complete in drawing
|
Chris@0
|
80 * this view, as a percentage -- in most cases this will be the
|
Chris@0
|
81 * value returned by pointer from a call to the underlying model's
|
Chris@0
|
82 * isReady(int *) call. The widget may choose to show a progress
|
Chris@0
|
83 * meter if it finds that this returns < 100 at any given moment.
|
Chris@0
|
84 */
|
Chris@0
|
85 virtual int getCompletion() const { return 100; }
|
Chris@0
|
86
|
Chris@0
|
87 virtual void setObjectName(const QString &name);
|
Chris@0
|
88
|
Chris@0
|
89 signals:
|
Chris@0
|
90 void modelChanged();
|
Chris@0
|
91 void modelCompletionChanged();
|
Chris@0
|
92 void modelChanged(size_t startFrame, size_t endFrame);
|
Chris@0
|
93 void modelReplaced();
|
Chris@0
|
94
|
Chris@0
|
95 void layerParametersChanged();
|
Chris@0
|
96 void layerNameChanged();
|
Chris@0
|
97
|
Chris@0
|
98 protected:
|
Chris@0
|
99 View *m_view;
|
Chris@0
|
100 };
|
Chris@0
|
101
|
Chris@0
|
102 #endif
|
Chris@0
|
103
|