Pane.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam and QMUL.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_PANE_H
17 #define SV_PANE_H
18 
19 #include <QFrame>
20 #include <QPoint>
21 
22 #include "base/ZoomConstraint.h"
23 #include "View.h"
24 #include "base/Selection.h"
25 
26 class QWidget;
27 class QPaintEvent;
28 class Layer;
29 class Thumbwheel;
30 class Panner;
32 class KeyReference;
33 class QMenu;
34 
35 class Pane : public View
36 {
37  Q_OBJECT
38 
39 public:
40  Pane(QWidget *parent = 0);
41  virtual ~Pane();
42 
43  virtual QString getPropertyContainerIconName() const override { return "pane"; }
44 
45  virtual bool shouldIlluminateLocalFeatures(const Layer *layer,
46  QPoint &pos) const override;
47  virtual bool shouldIlluminateLocalSelection(QPoint &pos,
48  bool &closeToLeft,
49  bool &closeToRight) const override;
50 
51  void setCentreLineVisible(bool visible);
52  bool getCentreLineVisible() const { return m_centreLineVisible; }
53 
54  virtual sv_frame_t getFirstVisibleFrame() const override;
55 
56  int getVerticalScaleWidth() const;
57 
58  virtual QImage *renderToNewImage() override {
59  return View::renderToNewImage();
60  }
61 
62  virtual QImage *renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) override;
63 
64  virtual QSize getRenderedImageSize() override {
66  }
67 
68  virtual QSize getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) override;
69 
70  virtual void toXml(QTextStream &stream, QString indent = "",
71  QString extraAttributes = "") const override;
72 
73  static void registerShortcuts(KeyReference &kr);
74 
75  enum PaneType {
76  Normal = 0,
77  TonyMain = 1,
79  };
80 
81 signals:
82  void paneInteractedWith();
83  void rightButtonMenuRequested(QPoint position);
84  void dropAccepted(QStringList uriList);
85  void dropAccepted(QString text);
86  void doubleClickSelectInvoked(sv_frame_t frame);
87  void regionOutlined(QRect rect);
88 
89 public slots:
90  // view slots
91  virtual void toolModeChanged() override;
92  virtual void zoomWheelsEnabledChanged() override;
93  virtual void viewZoomLevelChanged(View *, ZoomLevel, bool locked) override;
94  virtual void modelAlignmentCompletionChanged(ModelId) override;
95 
96  // local slots, not overrides
97  void horizontalThumbwheelMoved(int value);
98  void verticalThumbwheelMoved(int value);
99  void verticalZoomChanged();
100  void verticalPannerMoved(float x, float y, float w, float h);
101  void verticalPannerContextMenuRequested(const QPoint &);
104 
105  virtual void layerParametersChanged() override;
106 
107  virtual void propertyContainerSelected(View *, PropertyContainer *pc) override;
108 
109  void zoomToRegion(QRect r);
110 
111  void mouseEnteredWidget();
112  void mouseLeftWidget();
113 
114 protected slots:
116 
117 protected:
118  virtual void paintEvent(QPaintEvent *e) override;
119  virtual void mousePressEvent(QMouseEvent *e) override;
120  virtual void mouseReleaseEvent(QMouseEvent *e) override;
121  virtual void mouseMoveEvent(QMouseEvent *e) override;
122  virtual void mouseDoubleClickEvent(QMouseEvent *e) override;
123  virtual void enterEvent(QEvent *e) override;
124  virtual void leaveEvent(QEvent *e) override;
125  virtual void wheelEvent(QWheelEvent *e) override;
126  virtual void resizeEvent(QResizeEvent *e) override;
127  virtual void dragEnterEvent(QDragEnterEvent *e) override;
128  virtual void dropEvent(QDropEvent *e) override;
129 
130  void wheelVertical(int sign, Qt::KeyboardModifiers);
131  void wheelHorizontal(int sign, Qt::KeyboardModifiers);
132  void wheelHorizontalFine(int pixels, Qt::KeyboardModifiers);
133 
134  void drawVerticalScale(QRect r, Layer *, QPainter &);
135  void drawFeatureDescription(Layer *, QPainter &);
136  void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine);
137  void drawModelTimeExtents(QRect, QPainter &, ModelId);
138  void drawDurationAndRate(QRect, ModelId, sv_samplerate_t, QPainter &);
139  void drawWorkTitle(QRect, QPainter &, ModelId);
140  void drawLayerNames(QRect, QPainter &);
141  void drawEditingSelection(QPainter &);
142  void drawAlignmentStatus(QRect, QPainter &, ModelId, bool down);
143 
144  virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1) override;
145 
146  Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
147 
148  bool editSelectionStart(QMouseEvent *e);
149  bool editSelectionDrag(QMouseEvent *e);
150  bool editSelectionEnd(QMouseEvent *e);
151  bool selectionIsBeingEdited() const;
152 
153  void updateHeadsUpDisplay();
154  void updateVerticalPanner();
155 
157  bool setTopLayerDisplayExtents(double displayMin, double displayMax);
158  bool getTopLayerDisplayExtents(double &valueMin, double &valueMax,
159  double &displayMin, double &displayMax,
160  QString *unit = 0);
161 
162  void dragTopLayer(QMouseEvent *e);
163  void dragExtendSelection(QMouseEvent *e);
164  void updateContextHelp(const QPoint *pos);
165  void edgeScrollMaybe(int x);
166 
168 
169  void schedulePlaybackFrameMove(sv_frame_t frame);
170 
173  QPoint m_clickPos;
174  QPoint m_mousePos;
179 
182  bool m_editing;
184  sv_frame_t m_dragCentreFrame;
190  mutable int m_scaleWidth;
191 
193 
194  enum DragMode {
199  };
201 
202  DragMode updateDragMode(DragMode currentMode,
203  QPoint origin,
204  QPoint currentPoint,
205  bool canMoveHorizontal,
206  bool canMoveVertical,
207  bool resistHorizontal,
208  bool resistVertical);
209 
216 
218 
221 
222  static QCursor *m_measureCursor1;
223  static QCursor *m_measureCursor2;
224 };
225 
226 #endif
227 
static QCursor * m_measureCursor1
!! ugh
Definition: Pane.h:222
virtual void leaveEvent(QEvent *e) override
Definition: Pane.cpp:2347
virtual void modelAlignmentCompletionChanged(ModelId) override
Definition: Pane.cpp:933
void drawFeatureDescription(Layer *, QPainter &)
Definition: Pane.cpp:695
static void registerShortcuts(KeyReference &kr)
Definition: Pane.cpp:1334
bool m_resizing
Definition: Pane.h:181
Very trivial enhancement to QPushButton to make it emit signals when the mouse enters and leaves (for...
Definition: Pane.h:35
bool m_playbackFrameMoveScheduled
Definition: Pane.h:219
bool m_identifyFeatures
Definition: Pane.h:171
The base class for visual representations of the data found in a Model.
Definition: Layer.h:54
bool m_clickedInRange
Definition: Pane.h:175
virtual QSize getRenderedImageSize() override
Calculate and return the size of image that will be generated by renderToNewImage().
Definition: Pane.h:64
virtual QImage * renderToNewImage()
Render the view contents to a new QImage (which may be wider than the visible View).
Definition: View.cpp:3151
NotifyingPushButton * m_reset
Definition: Pane.h:214
void zoomToRegion(QRect r)
Definition: Pane.cpp:1933
bool getCentreLineVisible() const
Definition: Pane.h:52
void drawLayerNames(QRect, QPainter &)
Definition: Pane.cpp:975
static QCursor * m_measureCursor2
Definition: Pane.h:223
virtual void dropEvent(QDropEvent *e) override
Definition: Pane.cpp:2642
virtual QImage * renderToNewImage() override
Render the view contents to a new QImage (which may be wider than the visible View).
Definition: Pane.h:58
virtual void dragEnterEvent(QDragEnterEvent *e) override
Definition: Pane.cpp:2621
Selection m_editingSelection
Definition: Pane.h:188
void doubleClickSelectInvoked(sv_frame_t frame)
void edgeScrollMaybe(int x)
Definition: Pane.cpp:2238
DragMode
Definition: Pane.h:194
int getVerticalScaleWidth() const
Definition: Pane.cpp:532
void mouseEnteredWidget()
Definition: Pane.cpp:2965
void drawAlignmentStatus(QRect, QPainter &, ModelId, bool down)
Definition: Pane.cpp:868
void dragTopLayer(QMouseEvent *e)
Definition: Pane.cpp:2001
virtual void toXml(QTextStream &stream, QString indent="", QString extraAttributes="") const override
Definition: Pane.cpp:2988
virtual void wheelEvent(QWheelEvent *e) override
Definition: Pane.cpp:2363
void dropAccepted(QStringList uriList)
bool m_editing
Definition: Pane.h:182
virtual QString getPropertyContainerIconName() const override
Definition: Pane.h:43
int m_editingSelectionEdge
Definition: Pane.h:189
bool m_navigating
Definition: Pane.h:180
bool getTopLayerDisplayExtents(double &valueMin, double &valueMax, double &displayMin, double &displayMax, QString *unit=0)
Definition: Pane.cpp:1311
virtual void propertyContainerSelected(View *, PropertyContainer *pc) override
Definition: Pane.cpp:2831
Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const
Definition: Pane.cpp:1267
void drawVerticalScale(QRect r, Layer *, QPainter &)
Definition: Pane.cpp:539
PaneType
Definition: Pane.h:75
double m_dragStartMinValue
Definition: Pane.h:185
void verticalPannerContextMenuRequested(const QPoint &)
Definition: Pane.cpp:2555
virtual void toolModeChanged() override
Definition: Pane.cpp:2751
Definition: Panner.h:23
void drawModelTimeExtents(QRect, QPainter &, ModelId)
Definition: Pane.cpp:827
void drawDurationAndRate(QRect, ModelId, sv_samplerate_t, QPainter &)
Definition: Pane.cpp:1120
virtual bool shouldIlluminateLocalSelection(QPoint &pos, bool &closeToLeft, bool &closeToRight) const override
Definition: Pane.cpp:315
virtual sv_frame_t getFirstVisibleFrame() const override
Definition: Pane.cpp:1258
virtual void zoomWheelsEnabledChanged() override
Definition: Pane.cpp:2805
virtual QSize getRenderedImageSize()
Calculate and return the size of image that will be generated by renderToNewImage().
Definition: View.cpp:3183
Thumbwheel * m_hthumb
Definition: Pane.h:212
void drawEditingSelection(QPainter &)
Definition: Pane.cpp:1049
virtual void mouseDoubleClickEvent(QMouseEvent *e) override
Definition: Pane.cpp:2267
void schedulePlaybackFrameMove(sv_frame_t frame)
Definition: Pane.cpp:1519
void regionOutlined(QRect rect)
void horizontalThumbwheelMoved(int value)
Definition: Pane.cpp:2515
void paneInteractedWith()
QPoint m_identifyPoint
Definition: Pane.h:172
bool setTopLayerDisplayExtents(double displayMin, double displayMax)
Definition: Pane.cpp:1326
virtual QImage * renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) override
Render the view contents between the given frame extents to a new QImage (which may be wider than the...
Definition: Pane.cpp:1200
virtual void paintEvent(QPaintEvent *e) override
Definition: Pane.cpp:360
virtual void mousePressEvent(QMouseEvent *e) override
Definition: Pane.cpp:1371
void editVerticalPannerExtents()
Definition: Pane.cpp:2578
Layer * getTopFlexiNoteLayer()
Definition: Pane.cpp:1359
virtual void viewZoomLevelChanged(View *, ZoomLevel, bool locked) override
Definition: Pane.cpp:2812
virtual void mouseMoveEvent(QMouseEvent *e) override
Definition: Pane.cpp:1667
bool editSelectionDrag(QMouseEvent *e)
Definition: Pane.cpp:2690
void playbackScheduleTimerElapsed()
Definition: Pane.cpp:1528
Thumbwheel * m_vthumb
Definition: Pane.h:213
bool editSelectionStart(QMouseEvent *e)
Definition: Pane.cpp:2672
virtual QSize getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) override
Calculate and return the size of image that will be generated by renderPartToNewImage(f0, f1).
Definition: Pane.cpp:1239
bool m_centreLineVisible
Definition: Pane.h:186
void updateVerticalPanner()
Definition: Pane.cpp:256
void wheelVertical(int sign, Qt::KeyboardModifiers)
Definition: Pane.cpp:2440
void mouseLeftWidget()
Definition: Pane.cpp:2982
virtual void enterEvent(QEvent *e) override
Definition: Pane.cpp:2341
sv_frame_t m_dragCentreFrame
Definition: Pane.h:184
sv_frame_t m_selectionStartFrame
Definition: Pane.h:187
QMenu * m_lastVerticalPannerContextMenu
Definition: Pane.h:215
virtual void resizeEvent(QResizeEvent *e) override
Definition: Pane.cpp:2357
void rightButtonMenuRequested(QPoint position)
bool canTopLayerMoveVertical()
Definition: Pane.cpp:1302
virtual bool shouldIlluminateLocalFeatures(const Layer *layer, QPoint &pos) const override
Definition: Pane.cpp:291
void verticalZoomChanged()
Definition: Pane.cpp:2858
QWidget * m_headsUpDisplay
Definition: Pane.h:210
bool m_ctrlPressed
Definition: Pane.h:177
virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1) override
Definition: Pane.cpp:1169
QPoint m_mousePos
Definition: Pane.h:174
bool editSelectionEnd(QMouseEvent *e)
Definition: Pane.cpp:2699
virtual void mouseReleaseEvent(QMouseEvent *e) override
Definition: Pane.cpp:1537
void updateHeadsUpDisplay()
Definition: Pane.cpp:113
void wheelHorizontal(int sign, Qt::KeyboardModifiers)
Definition: Pane.cpp:2484
View is the base class of widgets that display one or more overlaid views of data against a horizonta...
Definition: View.h:55
void wheelHorizontalFine(int pixels, Qt::KeyboardModifiers)
Definition: Pane.cpp:2492
void verticalThumbwheelMoved(int value)
Definition: Pane.cpp:2522
void verticalPannerMoved(float x, float y, float w, float h)
Definition: Pane.cpp:2542
bool m_releasing
Definition: Pane.h:183
bool m_shiftPressed
Definition: Pane.h:176
void resetVerticalPannerExtents()
Definition: Pane.cpp:2604
DragMode updateDragMode(DragMode currentMode, QPoint origin, QPoint currentPoint, bool canMoveHorizontal, bool canMoveVertical, bool resistHorizontal, bool resistVertical)
Definition: Pane.cpp:2113
Pane(QWidget *parent=0)
Definition: Pane.cpp:73
void updateContextHelp(const QPoint *pos)
Definition: Pane.cpp:2873
virtual ~Pane()
Definition: Pane.cpp:107
void dragExtendSelection(QMouseEvent *e)
Definition: Pane.cpp:2177
Panner * m_vpan
Definition: Pane.h:211
void drawWorkTitle(QRect, QPainter &, ModelId)
Definition: Pane.cpp:940
int m_scaleWidth
Definition: Pane.h:190
virtual void layerParametersChanged() override
Definition: Pane.cpp:2614
bool selectionIsBeingEdited() const
Definition: Pane.cpp:341
void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine)
Definition: Pane.cpp:753
int m_pendingWheelAngle
Definition: Pane.h:192
sv_frame_t m_playbackFrameMoveTo
Definition: Pane.h:220
bool m_altPressed
Definition: Pane.h:178
bool m_mouseInWidget
Definition: Pane.h:217
QPoint m_clickPos
Definition: Pane.h:173
void setCentreLineVisible(bool visible)
Definition: Pane.cpp:353
DragMode m_dragMode
Definition: Pane.h:200