annotate view/Pane.h @ 1202:6828735468c9 svg

Implement "Export SVG file..."
author Chris Cannam
date Mon, 19 Dec 2016 16:32:34 +0000
parents 4a578a360011
children 67f437277069
rev   line source
Chris@127 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@127 2
Chris@127 3 /*
Chris@127 4 Sonic Visualiser
Chris@127 5 An audio file viewer and annotation editor.
Chris@127 6 Centre for Digital Music, Queen Mary, University of London.
Chris@182 7 This file copyright 2006 Chris Cannam and QMUL.
Chris@127 8
Chris@127 9 This program is free software; you can redistribute it and/or
Chris@127 10 modify it under the terms of the GNU General Public License as
Chris@127 11 published by the Free Software Foundation; either version 2 of the
Chris@127 12 License, or (at your option) any later version. See the file
Chris@127 13 COPYING included with this distribution for more information.
Chris@127 14 */
Chris@127 15
Chris@127 16 #ifndef _PANE_H_
Chris@127 17 #define _PANE_H_
Chris@127 18
Chris@127 19 #include <QFrame>
Chris@127 20 #include <QPoint>
Chris@127 21
Chris@127 22 #include "base/ZoomConstraint.h"
Chris@128 23 #include "View.h"
Chris@127 24 #include "base/Selection.h"
Chris@127 25
Chris@127 26 class QWidget;
Chris@127 27 class QPaintEvent;
Chris@127 28 class Layer;
Chris@133 29 class Thumbwheel;
Chris@172 30 class Panner;
Chris@189 31 class NotifyingPushButton;
Chris@282 32 class KeyReference;
Chris@127 33
Chris@127 34 class Pane : public View
Chris@127 35 {
Chris@127 36 Q_OBJECT
Chris@127 37
Chris@127 38 public:
Chris@127 39 Pane(QWidget *parent = 0);
Chris@1202 40 virtual QString getPropertyContainerIconName() const override { return "pane"; }
Chris@127 41
Chris@127 42 virtual bool shouldIlluminateLocalFeatures(const Layer *layer,
Chris@1202 43 QPoint &pos) const override;
Chris@127 44 virtual bool shouldIlluminateLocalSelection(QPoint &pos,
Chris@127 45 bool &closeToLeft,
Chris@1202 46 bool &closeToRight) const override;
Chris@127 47
Chris@127 48 void setCentreLineVisible(bool visible);
Chris@127 49 bool getCentreLineVisible() const { return m_centreLineVisible; }
Chris@127 50
Chris@1202 51 virtual sv_frame_t getFirstVisibleFrame() const override;
Chris@222 52
Chris@1202 53 int getVerticalScaleWidth() const;
Chris@276 54
Chris@1202 55 virtual QImage *renderToNewImage() override {
Chris@1202 56 return View::renderToNewImage();
Chris@1202 57 }
Chris@1202 58
Chris@1202 59 virtual QImage *renderPartToNewImage(sv_frame_t f0, sv_frame_t f1) override;
Chris@1202 60
Chris@1202 61 virtual QSize getRenderedImageSize() override {
Chris@1202 62 return View::getRenderedImageSize();
Chris@1202 63 }
Chris@1202 64
Chris@1202 65 virtual QSize getRenderedPartImageSize(sv_frame_t f0, sv_frame_t f1) override;
Chris@227 66
Chris@316 67 virtual void toXml(QTextStream &stream, QString indent = "",
Chris@1202 68 QString extraAttributes = "") const override;
Chris@127 69
Chris@282 70 static void registerShortcuts(KeyReference &kr);
Chris@282 71
matthiasm@822 72 enum PaneType {
matthiasm@822 73 Normal = 0,
matthiasm@822 74 TonyMain = 1,
matthiasm@822 75 TonySelection = 2
matthiasm@822 76 };
matthiasm@822 77
Chris@127 78 signals:
Chris@127 79 void paneInteractedWith();
Chris@127 80 void rightButtonMenuRequested(QPoint position);
Chris@312 81 void dropAccepted(QStringList uriList);
Chris@312 82 void dropAccepted(QString text);
Chris@908 83 void doubleClickSelectInvoked(sv_frame_t frame);
Chris@730 84 void regionOutlined(QRect rect);
Chris@127 85
Chris@127 86 public slots:
Chris@127 87 virtual void toolModeChanged();
Chris@133 88 virtual void zoomWheelsEnabledChanged();
Chris@806 89 virtual void viewZoomLevelChanged(View *v, int z, bool locked);
Chris@320 90 virtual void modelAlignmentCompletionChanged();
Chris@127 91
Chris@132 92 virtual void horizontalThumbwheelMoved(int value);
Chris@132 93 virtual void verticalThumbwheelMoved(int value);
Chris@133 94 virtual void verticalZoomChanged();
Chris@174 95 virtual void verticalPannerMoved(float x, float y, float w, float h);
Chris@188 96 virtual void editVerticalPannerExtents();
Chris@133 97
Chris@437 98 virtual void layerParametersChanged();
Chris@437 99
Chris@133 100 virtual void propertyContainerSelected(View *, PropertyContainer *pc);
Chris@132 101
Chris@730 102 void zoomToRegion(QRect r);
Chris@730 103
Chris@189 104 void mouseEnteredWidget();
Chris@189 105 void mouseLeftWidget();
Chris@189 106
Chris@802 107 protected slots:
Chris@802 108 void playbackScheduleTimerElapsed();
Chris@802 109
Chris@127 110 protected:
Chris@127 111 virtual void paintEvent(QPaintEvent *e);
Chris@127 112 virtual void mousePressEvent(QMouseEvent *e);
Chris@127 113 virtual void mouseReleaseEvent(QMouseEvent *e);
Chris@127 114 virtual void mouseMoveEvent(QMouseEvent *e);
Chris@127 115 virtual void mouseDoubleClickEvent(QMouseEvent *e);
Chris@290 116 virtual void enterEvent(QEvent *e);
Chris@127 117 virtual void leaveEvent(QEvent *e);
Chris@127 118 virtual void wheelEvent(QWheelEvent *e);
Chris@133 119 virtual void resizeEvent(QResizeEvent *e);
Chris@312 120 virtual void dragEnterEvent(QDragEnterEvent *e);
Chris@312 121 virtual void dropEvent(QDropEvent *e);
Chris@127 122
Chris@826 123 void wheelVertical(int sign, Qt::KeyboardModifiers);
Chris@826 124 void wheelHorizontal(int sign, Qt::KeyboardModifiers);
Chris@826 125 void wheelHorizontalFine(int pixels, Qt::KeyboardModifiers);
Chris@826 126
Chris@261 127 void drawVerticalScale(QRect r, Layer *, QPainter &);
Chris@261 128 void drawFeatureDescription(Layer *, QPainter &);
Chris@908 129 void drawCentreLine(sv_samplerate_t, QPainter &, bool omitLine);
Chris@759 130 void drawModelTimeExtents(QRect, QPainter &, const Model *);
Chris@908 131 void drawDurationAndRate(QRect, const Model *, sv_samplerate_t, QPainter &);
Chris@326 132 void drawWorkTitle(QRect, QPainter &, const Model *);
Chris@261 133 void drawLayerNames(QRect, QPainter &);
Chris@261 134 void drawEditingSelection(QPainter &);
Chris@326 135 void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down);
Chris@261 136
Chris@908 137 virtual bool render(QPainter &paint, int x0, sv_frame_t f0, sv_frame_t f1);
Chris@229 138
Chris@127 139 Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
Chris@127 140
Chris@127 141 bool editSelectionStart(QMouseEvent *e);
Chris@127 142 bool editSelectionDrag(QMouseEvent *e);
Chris@127 143 bool editSelectionEnd(QMouseEvent *e);
Chris@127 144 bool selectionIsBeingEdited() const;
Chris@127 145
Chris@133 146 void updateHeadsUpDisplay();
Chris@174 147 void updateVerticalPanner();
Chris@174 148
Chris@174 149 bool canTopLayerMoveVertical();
Chris@908 150 bool getTopLayerDisplayExtents(double &valueMin, double &valueMax,
Chris@908 151 double &displayMin, double &displayMax,
Chris@188 152 QString *unit = 0);
Chris@908 153 bool setTopLayerDisplayExtents(double displayMin, double displayMax);
Chris@174 154
Chris@174 155 void dragTopLayer(QMouseEvent *e);
Chris@174 156 void dragExtendSelection(QMouseEvent *e);
Chris@189 157 void updateContextHelp(const QPoint *pos);
Chris@259 158 void edgeScrollMaybe(int x);
Chris@133 159
Chris@753 160 Layer *getTopFlexiNoteLayer();
Chris@753 161
Chris@908 162 void schedulePlaybackFrameMove(sv_frame_t frame);
Chris@802 163
Chris@127 164 bool m_identifyFeatures;
Chris@127 165 QPoint m_identifyPoint;
Chris@127 166 QPoint m_clickPos;
Chris@127 167 QPoint m_mousePos;
Chris@127 168 bool m_clickedInRange;
Chris@127 169 bool m_shiftPressed;
Chris@127 170 bool m_ctrlPressed;
Chris@510 171 bool m_altPressed;
Chris@266 172
Chris@127 173 bool m_navigating;
Chris@127 174 bool m_resizing;
Chris@343 175 bool m_editing;
Chris@343 176 bool m_releasing;
Chris@908 177 sv_frame_t m_dragCentreFrame;
Chris@908 178 double m_dragStartMinValue;
Chris@127 179 bool m_centreLineVisible;
Chris@908 180 sv_frame_t m_selectionStartFrame;
Chris@127 181 Selection m_editingSelection;
Chris@127 182 int m_editingSelectionEdge;
Chris@222 183 mutable int m_scaleWidth;
Chris@133 184
Chris@826 185 int m_pendingWheelAngle;
Chris@826 186
Chris@150 187 enum DragMode {
Chris@150 188 UnresolvedDrag,
Chris@150 189 VerticalDrag,
Chris@150 190 HorizontalDrag,
Chris@150 191 FreeDrag
Chris@150 192 };
Chris@150 193 DragMode m_dragMode;
Chris@150 194
Chris@343 195 DragMode updateDragMode(DragMode currentMode,
Chris@343 196 QPoint origin,
Chris@343 197 QPoint currentPoint,
Chris@343 198 bool canMoveHorizontal,
Chris@343 199 bool canMoveVertical,
Chris@343 200 bool resistHorizontal,
Chris@343 201 bool resistVertical);
Chris@343 202
Chris@133 203 QWidget *m_headsUpDisplay;
Chris@172 204 Panner *m_vpan;
Chris@133 205 Thumbwheel *m_hthumb;
Chris@133 206 Thumbwheel *m_vthumb;
Chris@189 207 NotifyingPushButton *m_reset;
Chris@262 208
Chris@290 209 bool m_mouseInWidget;
Chris@290 210
Chris@802 211 bool m_playbackFrameMoveScheduled;
Chris@908 212 sv_frame_t m_playbackFrameMoveTo;
Chris@802 213
Chris@267 214 static QCursor *m_measureCursor1;
Chris@267 215 static QCursor *m_measureCursor2;
Chris@127 216 };
Chris@127 217
Chris@127 218 #endif
Chris@127 219