Mercurial > hg > svgui
comparison view/View.h @ 946:36cddc3de023 alignment_view
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 09:19:52 +0100 |
parents | 99373ca20caf 4a578a360011 |
children | f535f6e5dbb0 |
comparison
equal
deleted
inserted
replaced
897:499b637f2a26 | 946:36cddc3de023 |
---|---|
21 | 21 |
22 #include "base/ZoomConstraint.h" | 22 #include "base/ZoomConstraint.h" |
23 #include "base/PropertyContainer.h" | 23 #include "base/PropertyContainer.h" |
24 #include "ViewManager.h" | 24 #include "ViewManager.h" |
25 #include "base/XmlExportable.h" | 25 #include "base/XmlExportable.h" |
26 #include "base/BaseTypes.h" | |
26 | 27 |
27 // #define DEBUG_VIEW_WIDGET_PAINT 1 | 28 // #define DEBUG_VIEW_WIDGET_PAINT 1 |
28 | 29 |
29 class Layer; | 30 class Layer; |
30 class ViewPropertyContainer; | 31 class ViewPropertyContainer; |
62 /** | 63 /** |
63 * Retrieve the first visible sample frame on the widget. | 64 * Retrieve the first visible sample frame on the widget. |
64 * This is a calculated value based on the centre-frame, widget | 65 * This is a calculated value based on the centre-frame, widget |
65 * width and zoom level. The result may be negative. | 66 * width and zoom level. The result may be negative. |
66 */ | 67 */ |
67 int getStartFrame() const; | 68 sv_frame_t getStartFrame() const; |
68 | 69 |
69 /** | 70 /** |
70 * Set the widget pan based on the given first visible frame. The | 71 * Set the widget pan based on the given first visible frame. The |
71 * frame value may be negative. | 72 * frame value may be negative. |
72 */ | 73 */ |
73 void setStartFrame(int); | 74 void setStartFrame(sv_frame_t); |
74 | 75 |
75 /** | 76 /** |
76 * Return the centre frame of the visible widget. This is an | 77 * Return the centre frame of the visible widget. This is an |
77 * exact value that does not depend on the zoom block size. Other | 78 * exact value that does not depend on the zoom block size. Other |
78 * frame values (start, end) are calculated from this based on the | 79 * frame values (start, end) are calculated from this based on the |
79 * zoom and other factors. | 80 * zoom and other factors. |
80 */ | 81 */ |
81 int getCentreFrame() const { return m_centreFrame; } | 82 sv_frame_t getCentreFrame() const { return m_centreFrame; } |
82 | 83 |
83 /** | 84 /** |
84 * Set the centre frame of the visible widget. | 85 * Set the centre frame of the visible widget. |
85 */ | 86 */ |
86 void setCentreFrame(int f) { setCentreFrame(f, true); } | 87 void setCentreFrame(sv_frame_t f) { setCentreFrame(f, true); } |
87 | 88 |
88 /** | 89 /** |
89 * Retrieve the last visible sample frame on the widget. | 90 * Retrieve the last visible sample frame on the widget. |
90 * This is a calculated value based on the centre-frame, widget | 91 * This is a calculated value based on the centre-frame, widget |
91 * width and zoom level. | 92 * width and zoom level. |
92 */ | 93 */ |
93 int getEndFrame() const; | 94 sv_frame_t getEndFrame() const; |
94 | 95 |
95 /** | 96 /** |
96 * Return the pixel x-coordinate corresponding to a given sample | 97 * Return the pixel x-coordinate corresponding to a given sample |
97 * frame (which may be negative). | 98 * frame (which may be negative). |
98 */ | 99 */ |
99 int getXForFrame(int frame) const; | 100 int getXForFrame(sv_frame_t frame) const; |
100 | 101 |
101 /** | 102 /** |
102 * Return the closest frame to the given pixel x-coordinate. | 103 * Return the closest frame to the given pixel x-coordinate. |
103 */ | 104 */ |
104 int getFrameForX(int x) const; | 105 sv_frame_t getFrameForX(int x) const; |
105 | 106 |
106 /** | 107 /** |
107 * Return the pixel y-coordinate corresponding to a given | 108 * Return the pixel y-coordinate corresponding to a given |
108 * frequency, if the frequency range is as specified. This does | 109 * frequency, if the frequency range is as specified. This does |
109 * not imply any policy about layer frequency ranges, but it might | 110 * not imply any policy about layer frequency ranges, but it might |
110 * be useful for layers to match theirs up if desired. | 111 * be useful for layers to match theirs up if desired. |
111 * | 112 * |
112 * Not thread-safe in logarithmic mode. Call only from GUI thread. | 113 * Not thread-safe in logarithmic mode. Call only from GUI thread. |
113 */ | 114 */ |
114 float getYForFrequency(float frequency, float minFreq, float maxFreq, | 115 double getYForFrequency(double frequency, double minFreq, double maxFreq, |
115 bool logarithmic) const; | 116 bool logarithmic) const; |
116 | 117 |
117 /** | 118 /** |
118 * Return the closest frequency to the given pixel y-coordinate, | 119 * Return the closest frequency to the given pixel y-coordinate, |
119 * if the frequency range is as specified. | 120 * if the frequency range is as specified. |
120 * | 121 * |
121 * Not thread-safe in logarithmic mode. Call only from GUI thread. | 122 * Not thread-safe in logarithmic mode. Call only from GUI thread. |
122 */ | 123 */ |
123 float getFrequencyForY(int y, float minFreq, float maxFreq, | 124 double getFrequencyForY(int y, double minFreq, double maxFreq, |
124 bool logarithmic) const; | 125 bool logarithmic) const; |
125 | 126 |
126 /** | 127 /** |
127 * Return the zoom level, i.e. the number of frames per pixel | 128 * Return the zoom level, i.e. the number of frames per pixel |
128 */ | 129 */ |
161 | 162 |
162 /** | 163 /** |
163 * Return the number of layers, regardless of whether visible or | 164 * Return the number of layers, regardless of whether visible or |
164 * dormant, i.e. invisible, in this view. | 165 * dormant, i.e. invisible, in this view. |
165 */ | 166 */ |
166 virtual int getLayerCount() const { return m_layerStack.size(); } | 167 virtual int getLayerCount() const { return int(m_layerStack.size()); } |
167 | 168 |
168 /** | 169 /** |
169 * Return the nth layer, counted in stacking order. That is, | 170 * Return the nth layer, counted in stacking order. That is, |
170 * layer 0 is the bottom layer and layer "getLayerCount()-1" is | 171 * layer 0 is the bottom layer and layer "getLayerCount()-1" is |
171 * the top one. The returned layer may be visible or it may be | 172 * the top one. The returned layer may be visible or it may be |
172 * dormant, i.e. invisible. | 173 * dormant, i.e. invisible. |
173 */ | 174 */ |
174 virtual Layer *getLayer(int n) { | 175 virtual Layer *getLayer(int n) { |
175 if (n < int(m_layerStack.size())) return m_layerStack[n]; | 176 if (in_range_for(m_layerStack, n)) return m_layerStack[n]; |
176 else return 0; | 177 else return 0; |
177 } | 178 } |
178 | 179 |
179 /** | 180 /** |
180 * Return the nth layer, counted in the order they were | 181 * Return the nth layer, counted in the order they were |
227 virtual Layer *getTopLayer() { | 228 virtual Layer *getTopLayer() { |
228 return m_layerStack.empty() ? 0 : m_layerStack[m_layerStack.size()-1]; | 229 return m_layerStack.empty() ? 0 : m_layerStack[m_layerStack.size()-1]; |
229 } | 230 } |
230 | 231 |
231 virtual void setViewManager(ViewManager *m); | 232 virtual void setViewManager(ViewManager *m); |
232 virtual void setViewManager(ViewManager *m, int initialFrame); | 233 virtual void setViewManager(ViewManager *m, sv_frame_t initialFrame); |
233 virtual ViewManager *getViewManager() const { return m_manager; } | 234 virtual ViewManager *getViewManager() const { return m_manager; } |
234 | 235 |
235 virtual void setFollowGlobalPan(bool f); | 236 virtual void setFollowGlobalPan(bool f); |
236 virtual bool getFollowGlobalPan() const { return m_followPan; } | 237 virtual bool getFollowGlobalPan() const { return m_followPan; } |
237 | 238 |
292 // layers in fixed-order series | 293 // layers in fixed-order series |
293 virtual const PropertyContainer *getPropertyContainer(int i) const; | 294 virtual const PropertyContainer *getPropertyContainer(int i) const; |
294 virtual PropertyContainer *getPropertyContainer(int i); | 295 virtual PropertyContainer *getPropertyContainer(int i); |
295 | 296 |
296 // Render the contents on a wide canvas | 297 // Render the contents on a wide canvas |
297 virtual QImage *toNewImage(int f0, int f1); | 298 virtual QImage *toNewImage(sv_frame_t f0, sv_frame_t f1); |
298 virtual QImage *toNewImage(); | 299 virtual QImage *toNewImage(); |
299 virtual QSize getImageSize(int f0, int f1); | 300 virtual QSize getImageSize(sv_frame_t f0, sv_frame_t f1); |
300 virtual QSize getImageSize(); | 301 virtual QSize getImageSize(); |
301 | 302 |
302 virtual int getTextLabelHeight(const Layer *layer, QPainter &) const; | 303 virtual int getTextLabelHeight(const Layer *layer, QPainter &) const; |
303 | 304 |
304 virtual bool getValueExtents(QString unit, float &min, float &max, | 305 virtual bool getValueExtents(QString unit, double &min, double &max, |
305 bool &log) const; | 306 bool &log) const; |
306 | 307 |
307 virtual void toXml(QTextStream &stream, QString indent = "", | 308 virtual void toXml(QTextStream &stream, QString indent = "", |
308 QString extraAttributes = "") const; | 309 QString extraAttributes = "") const; |
309 | 310 |
310 // First frame actually in model, to right of scale, if present | 311 // First frame actually in model, to right of scale, if present |
311 virtual int getFirstVisibleFrame() const; | 312 virtual sv_frame_t getFirstVisibleFrame() const; |
312 virtual int getLastVisibleFrame() const; | 313 virtual sv_frame_t getLastVisibleFrame() const; |
313 | 314 |
314 int getModelsStartFrame() const; | 315 sv_frame_t getModelsStartFrame() const; |
315 int getModelsEndFrame() const; | 316 sv_frame_t getModelsEndFrame() const; |
316 | 317 |
317 typedef std::set<Model *> ModelSet; | 318 typedef std::set<Model *> ModelSet; |
318 ModelSet getModels(); | 319 ModelSet getModels(); |
319 | 320 |
320 //!!! | 321 //!!! |
321 Model *getAligningModel() const; | 322 Model *getAligningModel() const; |
322 int alignFromReference(int) const; | 323 sv_frame_t alignFromReference(sv_frame_t) const; |
323 int alignToReference(int) const; | 324 sv_frame_t alignToReference(sv_frame_t) const; |
324 int getAlignedPlaybackFrame() const; | 325 sv_frame_t getAlignedPlaybackFrame() const; |
325 | 326 |
326 signals: | 327 signals: |
327 void propertyContainerAdded(PropertyContainer *pc); | 328 void propertyContainerAdded(PropertyContainer *pc); |
328 void propertyContainerRemoved(PropertyContainer *pc); | 329 void propertyContainerRemoved(PropertyContainer *pc); |
329 void propertyContainerPropertyChanged(PropertyContainer *pc); | 330 void propertyContainerPropertyChanged(PropertyContainer *pc); |
332 void propertyContainerSelected(PropertyContainer *pc); | 333 void propertyContainerSelected(PropertyContainer *pc); |
333 void propertyChanged(PropertyContainer::PropertyName); | 334 void propertyChanged(PropertyContainer::PropertyName); |
334 | 335 |
335 void layerModelChanged(); | 336 void layerModelChanged(); |
336 | 337 |
337 void centreFrameChanged(int frame, | 338 void centreFrameChanged(sv_frame_t frame, |
338 bool globalScroll, | 339 bool globalScroll, |
339 PlaybackFollowMode followMode); | 340 PlaybackFollowMode followMode); |
340 | 341 |
341 void zoomLevelChanged(int level, bool locked); | 342 void zoomLevelChanged(int level, bool locked); |
342 | 343 |
343 void contextHelpChanged(const QString &); | 344 void contextHelpChanged(const QString &); |
344 | 345 |
345 public slots: | 346 public slots: |
346 virtual void modelChanged(); | 347 virtual void modelChanged(); |
347 virtual void modelChangedWithin(int startFrame, int endFrame); | 348 virtual void modelChangedWithin(sv_frame_t startFrame, sv_frame_t endFrame); |
348 virtual void modelCompletionChanged(); | 349 virtual void modelCompletionChanged(); |
349 virtual void modelAlignmentCompletionChanged(); | 350 virtual void modelAlignmentCompletionChanged(); |
350 virtual void modelReplaced(); | 351 virtual void modelReplaced(); |
351 virtual void layerParametersChanged(); | 352 virtual void layerParametersChanged(); |
352 virtual void layerParameterRangesChanged(); | 353 virtual void layerParameterRangesChanged(); |
353 virtual void layerMeasurementRectsChanged(); | 354 virtual void layerMeasurementRectsChanged(); |
354 virtual void layerNameChanged(); | 355 virtual void layerNameChanged(); |
355 | 356 |
356 virtual void globalCentreFrameChanged(int); | 357 virtual void globalCentreFrameChanged(sv_frame_t); |
357 virtual void viewCentreFrameChanged(View *, int); | 358 virtual void viewCentreFrameChanged(View *, sv_frame_t); |
358 virtual void viewManagerPlaybackFrameChanged(int); | 359 virtual void viewManagerPlaybackFrameChanged(sv_frame_t); |
359 virtual void viewZoomLevelChanged(View *, int, bool); | 360 virtual void viewZoomLevelChanged(View *, int, bool); |
360 | 361 |
361 virtual void propertyContainerSelected(View *, PropertyContainer *pc); | 362 virtual void propertyContainerSelected(View *, PropertyContainer *pc); |
362 | 363 |
363 virtual void selectionChanged(); | 364 virtual void selectionChanged(); |
372 protected: | 373 protected: |
373 View(QWidget *, bool showProgress); | 374 View(QWidget *, bool showProgress); |
374 virtual void paintEvent(QPaintEvent *e); | 375 virtual void paintEvent(QPaintEvent *e); |
375 virtual void drawSelections(QPainter &); | 376 virtual void drawSelections(QPainter &); |
376 virtual bool shouldLabelSelections() const { return true; } | 377 virtual bool shouldLabelSelections() const { return true; } |
377 virtual bool render(QPainter &paint, int x0, int f0, int f1); | 378 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1); |
378 virtual void setPaintFont(QPainter &paint); | 379 virtual void setPaintFont(QPainter &paint); |
379 | 380 |
380 typedef std::vector<Layer *> LayerList; | 381 typedef std::vector<Layer *> LayerList; |
381 | 382 |
382 int getModelsSampleRate() const; | 383 sv_samplerate_t getModelsSampleRate() const; |
383 bool areLayersScrollable() const; | 384 bool areLayersScrollable() const; |
384 LayerList getScrollableBackLayers(bool testChanged, bool &changed) const; | 385 LayerList getScrollableBackLayers(bool testChanged, bool &changed) const; |
385 LayerList getNonScrollableFrontLayers(bool testChanged, bool &changed) const; | 386 LayerList getNonScrollableFrontLayers(bool testChanged, bool &changed) const; |
386 int getZoomConstraintBlockSize(int blockSize, | 387 int getZoomConstraintBlockSize(int blockSize, |
387 ZoomConstraint::RoundingDirection dir = | 388 ZoomConstraint::RoundingDirection dir = |
396 // is generally the case except for spectrum/slice layers). It | 397 // is generally the case except for spectrum/slice layers). It |
397 // will not be possible to make or display selections if this is | 398 // will not be possible to make or display selections if this is |
398 // false. | 399 // false. |
399 bool hasTopLayerTimeXAxis() const; | 400 bool hasTopLayerTimeXAxis() const; |
400 | 401 |
401 bool setCentreFrame(int f, bool doEmit); | 402 bool setCentreFrame(sv_frame_t f, bool doEmit); |
402 | 403 |
403 void movePlayPointer(int f); | 404 void movePlayPointer(sv_frame_t f); |
404 | 405 |
405 void checkProgress(void *object); | 406 void checkProgress(void *object); |
406 int getProgressBarWidth() const; // if visible | 407 int getProgressBarWidth() const; // if visible |
407 | 408 |
408 int m_centreFrame; | 409 sv_frame_t m_centreFrame; |
409 int m_zoomLevel; | 410 int m_zoomLevel; |
410 bool m_followPan; | 411 bool m_followPan; |
411 bool m_followZoom; | 412 bool m_followZoom; |
412 PlaybackFollowMode m_followPlay; | 413 PlaybackFollowMode m_followPlay; |
413 bool m_followPlayIsDetached; | 414 bool m_followPlayIsDetached; |
414 int m_playPointerFrame; | 415 sv_frame_t m_playPointerFrame; |
415 bool m_lightBackground; | 416 bool m_lightBackground; |
416 bool m_showProgress; | 417 bool m_showProgress; |
417 | 418 |
418 QPixmap *m_cache; | 419 QPixmap *m_cache; |
419 int m_cacheCentreFrame; | 420 sv_frame_t m_cacheCentreFrame; |
420 int m_cacheZoomLevel; | 421 int m_cacheZoomLevel; |
421 bool m_selectionCached; | 422 bool m_selectionCached; |
422 | 423 |
423 bool m_deleting; | 424 bool m_deleting; |
424 | 425 |