Mercurial > hg > svgui
comparison layer/Layer.h @ 1216:dc2af6616c83
Merge from branch 3.0-integration
author | Chris Cannam |
---|---|
date | Fri, 13 Jan 2017 10:29:50 +0000 |
parents | e3c7da3d896e |
children | c02c51ae5238 a34a2a25907c |
comparison
equal
deleted
inserted
replaced
1048:e8102ff5573b | 1216:dc2af6616c83 |
---|---|
37 | 37 |
38 class ZoomConstraint; | 38 class ZoomConstraint; |
39 class Model; | 39 class Model; |
40 class QPainter; | 40 class QPainter; |
41 class View; | 41 class View; |
42 class LayerGeometryProvider; | |
42 class QMouseEvent; | 43 class QMouseEvent; |
43 class Clipboard; | 44 class Clipboard; |
44 class RangeMapper; | 45 class RangeMapper; |
45 | 46 |
46 /** | 47 /** |
81 virtual bool supportsOtherZoomLevels() const { return true; } | 82 virtual bool supportsOtherZoomLevels() const { return true; } |
82 | 83 |
83 /** | 84 /** |
84 * Paint the given rectangle of this layer onto the given view | 85 * Paint the given rectangle of this layer onto the given view |
85 * using the given painter, superimposing it on top of any | 86 * using the given painter, superimposing it on top of any |
86 * existing material in that view. The view is provided here | 87 * existing material in that view. The LayerGeometryProvider (an |
87 * because it is possible for one layer to exist in more than one | 88 * interface implemented by View) is provided here because it is |
88 * view, so the dimensions of the view may vary from one paint | 89 * possible for one layer to exist in more than one view, so the |
89 * call to another (without any view having been resized). | 90 * dimensions of the view may vary from one paint call to another |
90 */ | 91 * (without any view having been resized). |
91 virtual void paint(View *, QPainter &, QRect) const = 0; | 92 */ |
93 virtual void paint(LayerGeometryProvider *, QPainter &, QRect) const = 0; | |
92 | 94 |
93 /** | 95 /** |
94 * Enable or disable synchronous painting. If synchronous | 96 * Enable or disable synchronous painting. If synchronous |
95 * painting is enabled, a call to paint() must complete painting | 97 * painting is enabled, a call to paint() must complete painting |
96 * the entire rectangle before it returns. If synchronous | 98 * the entire rectangle before it returns. If synchronous |
126 virtual void setPresentationName(QString name); | 128 virtual void setPresentationName(QString name); |
127 | 129 |
128 virtual QString getLayerPresentationName() const; | 130 virtual QString getLayerPresentationName() const; |
129 virtual QPixmap getLayerPresentationPixmap(QSize) const { return QPixmap(); } | 131 virtual QPixmap getLayerPresentationPixmap(QSize) const { return QPixmap(); } |
130 | 132 |
131 virtual int getVerticalScaleWidth(View *, bool detailed, | 133 virtual int getVerticalScaleWidth(LayerGeometryProvider *, bool detailed, |
132 QPainter &) const = 0; | 134 QPainter &) const = 0; |
133 | 135 |
134 virtual void paintVerticalScale(View *, bool /* detailed */, | 136 virtual void paintVerticalScale(LayerGeometryProvider *, bool /* detailed */, |
135 QPainter &, QRect) const { } | 137 QPainter &, QRect) const { } |
136 | 138 |
137 virtual bool getCrosshairExtents(View *, QPainter &, QPoint /* cursorPos */, | 139 virtual bool getCrosshairExtents(LayerGeometryProvider *, QPainter &, QPoint /* cursorPos */, |
138 std::vector<QRect> &) const { | 140 std::vector<QRect> &) const { |
139 return false; | 141 return false; |
140 } | 142 } |
141 virtual void paintCrosshairs(View *, QPainter &, QPoint) const { } | 143 virtual void paintCrosshairs(LayerGeometryProvider *, QPainter &, QPoint) const { } |
142 | 144 |
143 virtual void paintMeasurementRects(View *, QPainter &, | 145 virtual void paintMeasurementRects(LayerGeometryProvider *, QPainter &, |
144 bool showFocus, QPoint focusPoint) const; | 146 bool showFocus, QPoint focusPoint) const; |
145 | 147 |
146 virtual bool nearestMeasurementRectChanged(View *, QPoint prev, | 148 virtual bool nearestMeasurementRectChanged(LayerGeometryProvider *, QPoint prev, |
147 QPoint now) const; | 149 QPoint now) const; |
148 | 150 |
149 virtual QString getFeatureDescription(View *, QPoint &) const { | 151 virtual QString getFeatureDescription(LayerGeometryProvider *, QPoint &) const { |
150 return ""; | 152 return ""; |
151 } | 153 } |
152 | 154 |
153 virtual QString getLabelPreceding(sv_frame_t /* frame */) const { | 155 virtual QString getLabelPreceding(sv_frame_t /* frame */) const { |
154 return ""; | 156 return ""; |
178 * Return true if a suitable feature was found and frame adjusted | 180 * Return true if a suitable feature was found and frame adjusted |
179 * accordingly. Return false if no suitable feature was available | 181 * accordingly. Return false if no suitable feature was available |
180 * (and leave frame unmodified). If returning true, also return | 182 * (and leave frame unmodified). If returning true, also return |
181 * the resolution of the model in this layer in sample frames. | 183 * the resolution of the model in this layer in sample frames. |
182 */ | 184 */ |
183 virtual bool snapToFeatureFrame(View * /* v */, | 185 virtual bool snapToFeatureFrame(LayerGeometryProvider * /* v */, |
184 sv_frame_t & /* frame */, | 186 sv_frame_t & /* frame */, |
185 int &resolution, | 187 int &resolution, |
186 SnapType /* snap */) const { | 188 SnapType /* snap */) const { |
187 resolution = 1; | 189 resolution = 1; |
188 return false; | 190 return false; |
202 * Return true if a suitable feature was found and frame adjusted | 204 * Return true if a suitable feature was found and frame adjusted |
203 * accordingly. Return false if no suitable feature was available | 205 * accordingly. Return false if no suitable feature was available |
204 * (and leave frame unmodified). If returning true, also return | 206 * (and leave frame unmodified). If returning true, also return |
205 * the resolution of the model in this layer in sample frames. | 207 * the resolution of the model in this layer in sample frames. |
206 */ | 208 */ |
207 virtual bool snapToSimilarFeature(View * /* v */, | 209 virtual bool snapToSimilarFeature(LayerGeometryProvider * /* v */, |
208 sv_frame_t & /* source frame */, | 210 sv_frame_t & /* source frame */, |
209 int &resolution, | 211 int &resolution, |
210 SnapType /* snap */) const { | 212 SnapType /* snap */) const { |
211 resolution = 1; | 213 resolution = 1; |
212 return false; | 214 return false; |
215 // Draw, erase, and edit modes: | 217 // Draw, erase, and edit modes: |
216 // | 218 // |
217 // Layer needs to get actual mouse events, I guess. Draw mode is | 219 // Layer needs to get actual mouse events, I guess. Draw mode is |
218 // probably the easier. | 220 // probably the easier. |
219 | 221 |
220 virtual void drawStart(View *, QMouseEvent *) { } | 222 virtual void drawStart(LayerGeometryProvider *, QMouseEvent *) { } |
221 virtual void drawDrag(View *, QMouseEvent *) { } | 223 virtual void drawDrag(LayerGeometryProvider *, QMouseEvent *) { } |
222 virtual void drawEnd(View *, QMouseEvent *) { } | 224 virtual void drawEnd(LayerGeometryProvider *, QMouseEvent *) { } |
223 | 225 |
224 virtual void eraseStart(View *, QMouseEvent *) { } | 226 virtual void eraseStart(LayerGeometryProvider *, QMouseEvent *) { } |
225 virtual void eraseDrag(View *, QMouseEvent *) { } | 227 virtual void eraseDrag(LayerGeometryProvider *, QMouseEvent *) { } |
226 virtual void eraseEnd(View *, QMouseEvent *) { } | 228 virtual void eraseEnd(LayerGeometryProvider *, QMouseEvent *) { } |
227 | 229 |
228 virtual void editStart(View *, QMouseEvent *) { } | 230 virtual void editStart(LayerGeometryProvider *, QMouseEvent *) { } |
229 virtual void editDrag(View *, QMouseEvent *) { } | 231 virtual void editDrag(LayerGeometryProvider *, QMouseEvent *) { } |
230 virtual void editEnd(View *, QMouseEvent *) { } | 232 virtual void editEnd(LayerGeometryProvider *, QMouseEvent *) { } |
231 | 233 |
232 virtual void splitStart(View *, QMouseEvent *) { } | 234 virtual void splitStart(LayerGeometryProvider *, QMouseEvent *) { } |
233 virtual void splitEnd(View *, QMouseEvent *) { } | 235 virtual void splitEnd(LayerGeometryProvider *, QMouseEvent *) { } |
234 virtual void addNote(View *, QMouseEvent *) { }; | 236 virtual void addNote(LayerGeometryProvider *, QMouseEvent *) { }; |
235 | 237 |
236 // Measurement rectangle (or equivalent). Unlike draw and edit, | 238 // Measurement rectangle (or equivalent). Unlike draw and edit, |
237 // the base Layer class can provide working implementations of | 239 // the base Layer class can provide working implementations of |
238 // these for most situations. | 240 // these for most situations. |
239 // | 241 // |
240 virtual void measureStart(View *, QMouseEvent *); | 242 virtual void measureStart(LayerGeometryProvider *, QMouseEvent *); |
241 virtual void measureDrag(View *, QMouseEvent *); | 243 virtual void measureDrag(LayerGeometryProvider *, QMouseEvent *); |
242 virtual void measureEnd(View *, QMouseEvent *); | 244 virtual void measureEnd(LayerGeometryProvider *, QMouseEvent *); |
243 virtual void measureDoubleClick(View *, QMouseEvent *); | 245 virtual void measureDoubleClick(LayerGeometryProvider *, QMouseEvent *); |
244 | 246 |
245 virtual bool haveCurrentMeasureRect() const { | 247 virtual bool haveCurrentMeasureRect() const { |
246 return m_haveCurrentMeasureRect; | 248 return m_haveCurrentMeasureRect; |
247 } | 249 } |
248 virtual void deleteCurrentMeasureRect(); // using a command | 250 virtual void deleteCurrentMeasureRect(); // using a command |
250 /** | 252 /** |
251 * Open an editor on the item under the mouse (e.g. on | 253 * Open an editor on the item under the mouse (e.g. on |
252 * double-click). If there is no item or editing is not | 254 * double-click). If there is no item or editing is not |
253 * supported, return false. | 255 * supported, return false. |
254 */ | 256 */ |
255 virtual bool editOpen(View *, QMouseEvent *) { return false; } | 257 virtual bool editOpen(LayerGeometryProvider *, QMouseEvent *) { return false; } |
256 | 258 |
257 virtual void moveSelection(Selection, sv_frame_t /* newStartFrame */) { } | 259 virtual void moveSelection(Selection, sv_frame_t /* newStartFrame */) { } |
258 virtual void resizeSelection(Selection, Selection /* newSize */) { } | 260 virtual void resizeSelection(Selection, Selection /* newSize */) { } |
259 virtual void deleteSelection(Selection) { } | 261 virtual void deleteSelection(Selection) { } |
260 | 262 |
261 virtual void copy(View *, Selection, Clipboard & /* to */) { } | 263 virtual void copy(LayerGeometryProvider *, Selection, Clipboard & /* to */) { } |
262 | 264 |
263 /** | 265 /** |
264 * Paste from the given clipboard onto the layer at the given | 266 * Paste from the given clipboard onto the layer at the given |
265 * frame offset. If interactive is true, the layer may ask the | 267 * frame offset. If interactive is true, the layer may ask the |
266 * user about paste options through a dialog if desired, and may | 268 * user about paste options through a dialog if desired, and may |
267 * return false if the user cancelled the paste operation. This | 269 * return false if the user cancelled the paste operation. This |
268 * function should return true if a paste actually occurred. | 270 * function should return true if a paste actually occurred. |
269 */ | 271 */ |
270 virtual bool paste(View *, | 272 virtual bool paste(LayerGeometryProvider *, |
271 const Clipboard & /* from */, | 273 const Clipboard & /* from */, |
272 sv_frame_t /* frameOffset */, | 274 sv_frame_t /* frameOffset */, |
273 bool /* interactive */) { return false; } | 275 bool /* interactive */) { return false; } |
274 | 276 |
275 // Text mode: | 277 // Text mode: |
287 * possible because of invariant (non-scrolling) material | 289 * possible because of invariant (non-scrolling) material |
288 * displayed over the top, but the widget may be able to optimise | 290 * displayed over the top, but the widget may be able to optimise |
289 * scrolling better if it is known that individual views can be | 291 * scrolling better if it is known that individual views can be |
290 * scrolled safely in this way. | 292 * scrolled safely in this way. |
291 */ | 293 */ |
292 virtual bool isLayerScrollable(const View *) const { return true; } | 294 virtual bool isLayerScrollable(const LayerGeometryProvider *) const { return true; } |
293 | 295 |
294 /** | 296 /** |
295 * This should return true if the layer completely obscures any | 297 * This should return true if the layer completely obscures any |
296 * underlying layers. It's used to determine whether the view can | 298 * underlying layers. It's used to determine whether the view can |
297 * safely draw any selection rectangles under the layer instead of | 299 * safely draw any selection rectangles under the layer instead of |
342 * this view, as a percentage -- in most cases this will be the | 344 * this view, as a percentage -- in most cases this will be the |
343 * value returned by pointer from a call to the underlying model's | 345 * value returned by pointer from a call to the underlying model's |
344 * isReady(int *) call. The view may choose to show a progress | 346 * isReady(int *) call. The view may choose to show a progress |
345 * meter if it finds that this returns < 100 at any given moment. | 347 * meter if it finds that this returns < 100 at any given moment. |
346 */ | 348 */ |
347 virtual int getCompletion(View *) const { return 100; } | 349 virtual int getCompletion(LayerGeometryProvider *) const { return 100; } |
348 | 350 |
349 /** | 351 /** |
350 * Return an error string if any errors have occurred while | 352 * Return an error string if any errors have occurred while |
351 * loading or processing data for the given view. Return the | 353 * loading or processing data for the given view. Return the |
352 * empty string if no error has occurred. | 354 * empty string if no error has occurred. |
353 */ | 355 */ |
354 virtual QString getError(View *) const { return ""; } | 356 virtual QString getError(LayerGeometryProvider *) const { return ""; } |
355 | 357 |
356 virtual void setObjectName(const QString &name); | 358 virtual void setObjectName(const QString &name); |
357 | 359 |
358 /** | 360 /** |
359 * Convert the layer's data (though not those of the model it | 361 * Convert the layer's data (though not those of the model it |
398 * when it should set itself un-dormant again. | 400 * when it should set itself un-dormant again. |
399 * | 401 * |
400 * A layer class that overrides this function must also call this | 402 * A layer class that overrides this function must also call this |
401 * class's implementation. | 403 * class's implementation. |
402 */ | 404 */ |
403 virtual void setLayerDormant(const View *v, bool dormant); | 405 virtual void setLayerDormant(const LayerGeometryProvider *v, bool dormant); |
404 | 406 |
405 /** | 407 /** |
406 * Return whether the layer is dormant (i.e. hidden) in the given | 408 * Return whether the layer is dormant (i.e. hidden) in the given |
407 * view. | 409 * view. |
408 */ | 410 */ |
409 virtual bool isLayerDormant(const View *v) const; | 411 virtual bool isLayerDormant(const LayerGeometryProvider *v) const; |
410 | 412 |
411 virtual PlayParameters *getPlayParameters(); | 413 virtual PlayParameters *getPlayParameters(); |
412 | 414 |
413 virtual bool needsTextLabelHeight() const { return false; } | 415 virtual bool needsTextLabelHeight() const { return false; } |
414 | 416 |
455 * Return the value and unit at the given x coordinate in the | 457 * Return the value and unit at the given x coordinate in the |
456 * given view. This is for descriptive purposes using the | 458 * given view. This is for descriptive purposes using the |
457 * measurement tool. The default implementation works correctly | 459 * measurement tool. The default implementation works correctly |
458 * if the layer hasTimeXAxis(). | 460 * if the layer hasTimeXAxis(). |
459 */ | 461 */ |
460 virtual bool getXScaleValue(const View *v, int x, | 462 virtual bool getXScaleValue(const LayerGeometryProvider *v, int x, |
461 double &value, QString &unit) const; | 463 double &value, QString &unit) const; |
462 | 464 |
463 /** | 465 /** |
464 * Return the value and unit at the given y coordinate in the | 466 * Return the value and unit at the given y coordinate in the |
465 * given view. | 467 * given view. |
466 */ | 468 */ |
467 virtual bool getYScaleValue(const View *, int /* y */, | 469 virtual bool getYScaleValue(const LayerGeometryProvider *, int /* y */, |
468 double &/* value */, QString &/* unit */) const { | 470 double &/* value */, QString &/* unit */) const { |
469 return false; | 471 return false; |
470 } | 472 } |
471 | 473 |
472 /** | 474 /** |
473 * Return the difference between the values at the given y | 475 * Return the difference between the values at the given y |
474 * coordinates in the given view, and the unit of the difference. | 476 * coordinates in the given view, and the unit of the difference. |
475 * The default implementation just calls getYScaleValue twice and | 477 * The default implementation just calls getYScaleValue twice and |
476 * returns the difference, with the same unit. | 478 * returns the difference, with the same unit. |
477 */ | 479 */ |
478 virtual bool getYScaleDifference(const View *v, int y0, int y1, | 480 virtual bool getYScaleDifference(const LayerGeometryProvider *v, int y0, int y1, |
479 double &diff, QString &unit) const; | 481 double &diff, QString &unit) const; |
480 | 482 |
481 /** | 483 /** |
482 * Get the number of vertical zoom steps available for this layer. | 484 * Get the number of vertical zoom steps available for this layer. |
483 * If vertical zooming is not available, return 0. The meaning of | 485 * If vertical zooming is not available, return 0. The meaning of |
524 * from a session if its model cannot be found. | 526 * from a session if its model cannot be found. |
525 */ | 527 */ |
526 virtual bool canExistWithoutModel() const { return false; } | 528 virtual bool canExistWithoutModel() const { return false; } |
527 | 529 |
528 public slots: | 530 public slots: |
529 void showLayer(View *, bool show); | 531 void showLayer(LayerGeometryProvider *, bool show); |
530 | 532 |
531 signals: | 533 signals: |
532 void modelChanged(); | 534 void modelChanged(); |
533 void modelCompletionChanged(); | 535 void modelCompletionChanged(); |
534 void modelAlignmentCompletionChanged(); | 536 void modelAlignmentCompletionChanged(); |
543 void verticalZoomChanged(); | 545 void verticalZoomChanged(); |
544 | 546 |
545 protected: | 547 protected: |
546 void connectSignals(const Model *); | 548 void connectSignals(const Model *); |
547 | 549 |
548 virtual sv_frame_t alignToReference(View *v, sv_frame_t frame) const; | 550 virtual sv_frame_t alignToReference(LayerGeometryProvider *v, sv_frame_t frame) const; |
549 virtual sv_frame_t alignFromReference(View *v, sv_frame_t frame) const; | 551 virtual sv_frame_t alignFromReference(LayerGeometryProvider *v, sv_frame_t frame) const; |
550 bool clipboardHasDifferentAlignment(View *v, const Clipboard &clip) const; | 552 bool clipboardHasDifferentAlignment(LayerGeometryProvider *v, const Clipboard &clip) const; |
551 | 553 |
552 struct MeasureRect { | 554 struct MeasureRect { |
553 | 555 |
554 mutable QRect pixrect; | 556 mutable QRect pixrect; |
555 bool haveFrames; | 557 bool haveFrames; |
610 mutable QPoint m_currentMeasureRectPoint; | 612 mutable QPoint m_currentMeasureRectPoint; |
611 | 613 |
612 // Note that pixrects are only correct for a single view. | 614 // Note that pixrects are only correct for a single view. |
613 // So we should update them at the start of the paint procedure | 615 // So we should update them at the start of the paint procedure |
614 // (painting is single threaded) and only use them after that. | 616 // (painting is single threaded) and only use them after that. |
615 void updateMeasurePixrects(View *v) const; | 617 void updateMeasurePixrects(LayerGeometryProvider *v) const; |
616 | 618 |
617 virtual void updateMeasureRectYCoords(View *v, const MeasureRect &r) const; | 619 virtual void updateMeasureRectYCoords(LayerGeometryProvider *v, const MeasureRect &r) const; |
618 virtual void setMeasureRectYCoord(View *v, MeasureRect &r, bool start, int y) const; | 620 virtual void setMeasureRectYCoord(LayerGeometryProvider *v, MeasureRect &r, bool start, int y) const; |
619 virtual void setMeasureRectFromPixrect(View *v, MeasureRect &r, QRect pixrect) const; | 621 virtual void setMeasureRectFromPixrect(LayerGeometryProvider *v, MeasureRect &r, QRect pixrect) const; |
620 | 622 |
621 // This assumes updateMeasurementPixrects has been called | 623 // This assumes updateMeasurementPixrects has been called |
622 MeasureRectSet::const_iterator findFocusedMeasureRect(QPoint) const; | 624 MeasureRectSet::const_iterator findFocusedMeasureRect(QPoint) const; |
623 | 625 |
624 void paintMeasurementRect(View *v, QPainter &paint, | 626 void paintMeasurementRect(LayerGeometryProvider *v, QPainter &paint, |
625 const MeasureRect &r, bool focus) const; | 627 const MeasureRect &r, bool focus) const; |
626 | 628 |
627 QString m_presentationName; | 629 QString m_presentationName; |
628 | 630 |
629 private: | 631 private: |