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