Mercurial > hg > svgui
comparison view/View.h @ 1148:c0d841cb8ab9 tony-2.0-integration
Merge latest SV 3.0 branch code
author | Chris Cannam |
---|---|
date | Fri, 19 Aug 2016 15:58:57 +0100 |
parents | 179ea8a2f650 |
children | 57d192e26331 6828735468c9 |
comparison
equal
deleted
inserted
replaced
1009:96cf499fad62 | 1148:c0d841cb8ab9 |
---|---|
17 #define _VIEW_H_ | 17 #define _VIEW_H_ |
18 | 18 |
19 #include <QFrame> | 19 #include <QFrame> |
20 #include <QProgressBar> | 20 #include <QProgressBar> |
21 | 21 |
22 #include "LayerGeometryProvider.h" | 22 #include "layer/LayerGeometryProvider.h" |
23 | 23 |
24 #include "base/ZoomConstraint.h" | 24 #include "base/ZoomConstraint.h" |
25 #include "base/PropertyContainer.h" | 25 #include "base/PropertyContainer.h" |
26 #include "ViewManager.h" | 26 #include "ViewManager.h" |
27 #include "base/XmlExportable.h" | 27 #include "base/XmlExportable.h" |
62 * be managed elsewhere (e.g. by the Document). | 62 * be managed elsewhere (e.g. by the Document). |
63 */ | 63 */ |
64 virtual ~View(); | 64 virtual ~View(); |
65 | 65 |
66 /** | 66 /** |
67 * Retrieve the id of this object. Views have their own unique | |
68 * ids, but ViewProxy objects share the id of their View. | |
69 */ | |
70 int getId() const { return m_id; } | |
71 | |
72 /** | |
67 * Retrieve the first visible sample frame on the widget. | 73 * Retrieve the first visible sample frame on the widget. |
68 * This is a calculated value based on the centre-frame, widget | 74 * This is a calculated value based on the centre-frame, widget |
69 * width and zoom level. The result may be negative. | 75 * width and zoom level. The result may be negative. |
70 */ | 76 */ |
71 sv_frame_t getStartFrame() const; | 77 sv_frame_t getStartFrame() const; |
104 | 110 |
105 /** | 111 /** |
106 * Return the closest frame to the given pixel x-coordinate. | 112 * Return the closest frame to the given pixel x-coordinate. |
107 */ | 113 */ |
108 sv_frame_t getFrameForX(int x) const; | 114 sv_frame_t getFrameForX(int x) const; |
115 | |
116 /** | |
117 * Return the closest pixel x-coordinate corresponding to a given | |
118 * view x-coordinate. Default is no scaling, ViewProxy handles | |
119 * scaling case. | |
120 */ | |
121 int getXForViewX(int viewx) const { return viewx; } | |
122 | |
123 /** | |
124 * Return the closest view x-coordinate corresponding to a given | |
125 * pixel x-coordinate. Default is no scaling, ViewProxy handles | |
126 * scaling case. | |
127 */ | |
128 int getViewXForX(int x) const { return x; } | |
109 | 129 |
110 /** | 130 /** |
111 * Return the pixel y-coordinate corresponding to a given | 131 * Return the pixel y-coordinate corresponding to a given |
112 * frequency, if the frequency range is as specified. This does | 132 * frequency, if the frequency range is as specified. This does |
113 * not imply any policy about layer frequency ranges, but it might | 133 * not imply any policy about layer frequency ranges, but it might |
122 * Return the closest frequency to the given pixel y-coordinate, | 142 * Return the closest frequency to the given pixel y-coordinate, |
123 * if the frequency range is as specified. | 143 * if the frequency range is as specified. |
124 * | 144 * |
125 * Not thread-safe in logarithmic mode. Call only from GUI thread. | 145 * Not thread-safe in logarithmic mode. Call only from GUI thread. |
126 */ | 146 */ |
127 double getFrequencyForY(int y, double minFreq, double maxFreq, | 147 double getFrequencyForY(double y, double minFreq, double maxFreq, |
128 bool logarithmic) const; | 148 bool logarithmic) const; |
129 | 149 |
130 /** | 150 /** |
131 * Return the zoom level, i.e. the number of frames per pixel | 151 * Return the zoom level, i.e. the number of frames per pixel |
132 */ | 152 */ |
133 int getZoomLevel() const; | 153 int getZoomLevel() const; |
243 virtual bool getFollowGlobalZoom() const { return m_followZoom; } | 263 virtual bool getFollowGlobalZoom() const { return m_followZoom; } |
244 | 264 |
245 virtual bool hasLightBackground() const; | 265 virtual bool hasLightBackground() const; |
246 virtual QColor getForeground() const; | 266 virtual QColor getForeground() const; |
247 virtual QColor getBackground() const; | 267 virtual QColor getBackground() const; |
248 | |
249 virtual void drawVisibleText(QPainter &p, int x, int y, | |
250 QString text, TextStyle style) const; | |
251 | 268 |
252 virtual void drawMeasurementRect(QPainter &p, const Layer *, | 269 virtual void drawMeasurementRect(QPainter &p, const Layer *, |
253 QRect rect, bool focus) const; | 270 QRect rect, bool focus) const; |
254 | 271 |
255 virtual bool shouldShowFeatureLabels() const { | 272 virtual bool shouldShowFeatureLabels() const { |
331 Model *getAligningModel() const; | 348 Model *getAligningModel() const; |
332 sv_frame_t alignFromReference(sv_frame_t) const; | 349 sv_frame_t alignFromReference(sv_frame_t) const; |
333 sv_frame_t alignToReference(sv_frame_t) const; | 350 sv_frame_t alignToReference(sv_frame_t) const; |
334 sv_frame_t getAlignedPlaybackFrame() const; | 351 sv_frame_t getAlignedPlaybackFrame() const; |
335 | 352 |
353 void updatePaintRect(QRect r) { update(r); } | |
354 | |
336 View *getView() { return this; } | 355 View *getView() { return this; } |
337 const View *getView() const { return this; } | 356 const View *getView() const { return this; } |
338 | 357 |
339 signals: | 358 signals: |
340 void propertyContainerAdded(PropertyContainer *pc); | 359 void propertyContainerAdded(PropertyContainer *pc); |
349 | 368 |
350 void centreFrameChanged(sv_frame_t frame, | 369 void centreFrameChanged(sv_frame_t frame, |
351 bool globalScroll, | 370 bool globalScroll, |
352 PlaybackFollowMode followMode); | 371 PlaybackFollowMode followMode); |
353 | 372 |
354 void zoomLevelChanged(int, bool); | 373 void zoomLevelChanged(int level, bool locked); |
355 | 374 |
356 void contextHelpChanged(const QString &); | 375 void contextHelpChanged(const QString &); |
357 | 376 |
358 public slots: | 377 public slots: |
359 virtual void modelChanged(); | 378 virtual void modelChanged(); |
382 | 401 |
383 virtual void progressCheckStalledTimerElapsed(); | 402 virtual void progressCheckStalledTimerElapsed(); |
384 | 403 |
385 protected: | 404 protected: |
386 View(QWidget *, bool showProgress); | 405 View(QWidget *, bool showProgress); |
406 | |
407 int m_id; | |
408 | |
387 virtual void paintEvent(QPaintEvent *e); | 409 virtual void paintEvent(QPaintEvent *e); |
388 virtual void drawSelections(QPainter &); | 410 virtual void drawSelections(QPainter &); |
389 virtual bool shouldLabelSelections() const { return true; } | 411 virtual bool shouldLabelSelections() const { return true; } |
390 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1); | 412 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1); |
391 virtual void setPaintFont(QPainter &paint); | 413 virtual void setPaintFont(QPainter &paint); |