comparison view/View.h @ 902:a1226b3b7925 cxx11

Toward building with new sv types
author Chris Cannam
date Wed, 04 Mar 2015 19:11:32 +0000
parents 532302d04571
children e0f08e108064
comparison
equal deleted inserted replaced
901:0fe1f4407261 902:a1226b3b7925
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
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
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, bool); 342 void zoomLevelChanged(int, bool);
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();
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