Mercurial > hg > svcore
comparison base/Layer.h @ 36:935a2419a77c
* Refactor Layer classes so as no longer to store a single View pointer;
instead they need to be able to draw themselves on any View on demand.
Layers with caches (e.g. spectrogram) will need to be further refactored
so as to maintain a per-View cache
* Begin refactoring MainWindow by pulling out the document stuff (set of
layers, models etc) into a Document class. Not yet in use.
This revision is fairly unstable.
author | Chris Cannam |
---|---|
date | Thu, 02 Mar 2006 16:58:49 +0000 |
parents | 0164c8d3023b |
children | e1a0cf2dcc79 |
comparison
equal
deleted
inserted
replaced
35:0164c8d3023b | 36:935a2419a77c |
---|---|
35 public XmlExportable | 35 public XmlExportable |
36 { | 36 { |
37 Q_OBJECT | 37 Q_OBJECT |
38 | 38 |
39 public: | 39 public: |
40 Layer(View *w); | 40 Layer(); |
41 virtual ~Layer(); | 41 virtual ~Layer(); |
42 | 42 |
43 virtual const Model *getModel() const = 0; | 43 virtual const Model *getModel() const = 0; |
44 virtual const View *getView() const { return m_view; } | |
45 virtual const ZoomConstraint *getZoomConstraint() const { return 0; } | 44 virtual const ZoomConstraint *getZoomConstraint() const { return 0; } |
46 virtual void paint(QPainter &, QRect) const = 0; | 45 virtual void paint(View *, QPainter &, QRect) const = 0; |
47 | 46 |
48 enum VerticalPosition { | 47 enum VerticalPosition { |
49 PositionTop, PositionMiddle, PositionBottom | 48 PositionTop, PositionMiddle, PositionBottom |
50 }; | 49 }; |
51 virtual VerticalPosition getPreferredTimeRulerPosition() const { | 50 virtual VerticalPosition getPreferredTimeRulerPosition() const { |
59 | 58 |
60 virtual QString getPropertyContainerName() const { | 59 virtual QString getPropertyContainerName() const { |
61 return objectName(); | 60 return objectName(); |
62 } | 61 } |
63 | 62 |
64 virtual int getVerticalScaleWidth(QPainter &) const { return 0; } | 63 virtual int getVerticalScaleWidth(View *, QPainter &) const { return 0; } |
65 virtual void paintVerticalScale(QPainter &, QRect) const { } | 64 virtual void paintVerticalScale(View *, QPainter &, QRect) const { } |
66 | 65 |
67 virtual QString getFeatureDescription(QPoint &) const { | 66 virtual QString getFeatureDescription(View *, QPoint &) const { |
68 return ""; | 67 return ""; |
69 } | 68 } |
70 | 69 |
71 //!!! We also need a method (like the vertical scale method) for | 70 //!!! We also need a method (like the vertical scale method) for |
72 //drawing additional scales like a colour scale. That is, unless | 71 //drawing additional scales like a colour scale. That is, unless |
97 * Return true if a suitable feature was found and frame adjusted | 96 * Return true if a suitable feature was found and frame adjusted |
98 * accordingly. Return false if no suitable feature was | 97 * accordingly. Return false if no suitable feature was |
99 * available. Also return the resolution of the model in this | 98 * available. Also return the resolution of the model in this |
100 * layer in sample frames. | 99 * layer in sample frames. |
101 */ | 100 */ |
102 virtual bool snapToFeatureFrame(int &frame, | 101 virtual bool snapToFeatureFrame(View *v, |
102 int &frame, | |
103 size_t &resolution, | 103 size_t &resolution, |
104 SnapType snap) const { | 104 SnapType snap) const { |
105 resolution = 1; | 105 resolution = 1; |
106 return false; | 106 return false; |
107 } | 107 } |
109 // Draw and edit modes: | 109 // Draw and edit modes: |
110 // | 110 // |
111 // Layer needs to get actual mouse events, I guess. Draw mode is | 111 // Layer needs to get actual mouse events, I guess. Draw mode is |
112 // probably the easier. | 112 // probably the easier. |
113 | 113 |
114 virtual void drawStart(QMouseEvent *) { } | 114 virtual void drawStart(View *, QMouseEvent *) { } |
115 virtual void drawDrag(QMouseEvent *) { } | 115 virtual void drawDrag(View *, QMouseEvent *) { } |
116 virtual void drawEnd(QMouseEvent *) { } | 116 virtual void drawEnd(View *, QMouseEvent *) { } |
117 | 117 |
118 virtual void editStart(QMouseEvent *) { } | 118 virtual void editStart(View *, QMouseEvent *) { } |
119 virtual void editDrag(QMouseEvent *) { } | 119 virtual void editDrag(View *, QMouseEvent *) { } |
120 virtual void editEnd(QMouseEvent *) { } | 120 virtual void editEnd(View *, QMouseEvent *) { } |
121 | 121 |
122 virtual void editOpen(QMouseEvent *) { } // on double-click | 122 virtual void editOpen(View *, QMouseEvent *) { } // on double-click |
123 | 123 |
124 virtual void moveSelection(Selection s, size_t newStartFrame) { } | 124 virtual void moveSelection(Selection s, size_t newStartFrame) { } |
125 virtual void resizeSelection(Selection s, Selection newSize) { } | 125 virtual void resizeSelection(Selection s, Selection newSize) { } |
126 virtual void deleteSelection(Selection s) { } | 126 virtual void deleteSelection(Selection s) { } |
127 | 127 |
132 // and current label from the layer, and then the pane can pop up | 132 // and current label from the layer, and then the pane can pop up |
133 // a little text entry dialog at the right location. Or we edit | 133 // a little text entry dialog at the right location. Or we edit |
134 // in place? Probably the dialog is easier. | 134 // in place? Probably the dialog is easier. |
135 | 135 |
136 /** | 136 /** |
137 * This should return true if the view can safely be scrolled | 137 * This should return true if the layer can safely be scrolled |
138 * automatically by the widget (simply copying the existing data | 138 * automatically by a given view (simply copying the existing data |
139 * and then refreshing the exposed area) without altering its | 139 * and then refreshing the exposed area) without altering its |
140 * meaning. For the widget as a whole this is usually not | 140 * meaning. For the view widget as a whole this is usually not |
141 * possible because of invariant (non-scrolling) material | 141 * possible because of invariant (non-scrolling) material |
142 * displayed over the top, but the widget may be able to optimise | 142 * displayed over the top, but the widget may be able to optimise |
143 * scrolling better if it is known that individual views can be | 143 * scrolling better if it is known that individual views can be |
144 * scrolled safely in this way. | 144 * scrolled safely in this way. |
145 */ | 145 */ |
146 virtual bool isLayerScrollable() const { return true; } | 146 virtual bool isLayerScrollable(const View *) const { return true; } |
147 | 147 |
148 /** | 148 /** |
149 * This should return true if the layer completely obscures any | 149 * This should return true if the layer completely obscures any |
150 * underlying layers. It's used to determine whether the view can | 150 * underlying layers. It's used to determine whether the view can |
151 * safely draw any selection rectangles under the layer instead of | 151 * safely draw any selection rectangles under the layer instead of |
176 | 176 |
177 /** | 177 /** |
178 * Return the pixel x-coordinate corresponding to a given sample | 178 * Return the pixel x-coordinate corresponding to a given sample |
179 * frame (which may be negative). | 179 * frame (which may be negative). |
180 */ | 180 */ |
181 int getXForFrame(long frame) const; | 181 // int getXForFrame(long frame) const; |
182 | 182 |
183 /** | 183 /** |
184 * Return the closest frame to the given pixel x-coordinate. | 184 * Return the closest frame to the given pixel x-coordinate. |
185 */ | 185 */ |
186 long getFrameForX(int x) const; | 186 // long getFrameForX(int x) const; |
187 | 187 |
188 /** | 188 /** |
189 * Convert the layer's data (though not those of the model it | 189 * Convert the layer's data (though not those of the model it |
190 * refers to) into an XML string for file output. This class | 190 * refers to) into an XML string for file output. This class |
191 * implements the basic name/type/model-id output; subclasses will | 191 * implements the basic name/type/model-id output; subclasses will |
209 * layer may respond by (for example) freeing any cache memory it | 209 * layer may respond by (for example) freeing any cache memory it |
210 * is using, until next time its paint method is called. It does | 210 * is using, until next time its paint method is called. It does |
211 * not need to remember not to draw itself; the view will handle | 211 * not need to remember not to draw itself; the view will handle |
212 * that. | 212 * that. |
213 */ | 213 */ |
214 virtual void setLayerDormant(bool dormant) { m_dormant = dormant; } | 214 //!!! update for multiview |
215 virtual void setLayerDormant(const View *, bool dormant) { m_dormant = dormant; } | |
215 | 216 |
216 /** | 217 /** |
217 * Return whether the layer is dormant (i.e. hidden). | 218 * Return whether the layer is dormant (i.e. hidden). |
218 */ | 219 */ |
219 virtual bool isLayerDormant() const { return m_dormant; } | 220 //!!! update for multiview |
221 virtual bool isLayerDormant(const View *) const { return m_dormant; } | |
220 | 222 |
221 virtual PlayParameters *getPlayParameters(); | 223 virtual PlayParameters *getPlayParameters(); |
222 | 224 |
223 public slots: | 225 public slots: |
224 void showLayer(bool show); | 226 //!!! update for multiview |
227 void showLayer(View *, bool show); | |
225 | 228 |
226 signals: | 229 signals: |
227 void modelChanged(); | 230 void modelChanged(); |
228 void modelCompletionChanged(); | 231 void modelCompletionChanged(); |
229 void modelChanged(size_t startFrame, size_t endFrame); | 232 void modelChanged(size_t startFrame, size_t endFrame); |
231 | 234 |
232 void layerParametersChanged(); | 235 void layerParametersChanged(); |
233 void layerNameChanged(); | 236 void layerNameChanged(); |
234 | 237 |
235 protected: | 238 protected: |
236 View *m_view; | 239 // View *m_view; |
237 bool m_dormant; | 240 bool m_dormant; |
238 }; | 241 }; |
239 | 242 |
240 #endif | 243 #endif |
241 | 244 |