Pane.h

Go to the documentation of this file.
00001 
00002 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00003 
00004 /*
00005     Sonic Visualiser
00006     An audio file viewer and annotation editor.
00007     Centre for Digital Music, Queen Mary, University of London.
00008     This file copyright 2006 Chris Cannam and QMUL.
00009     
00010     This program is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU General Public License as
00012     published by the Free Software Foundation; either version 2 of the
00013     License, or (at your option) any later version.  See the file
00014     COPYING included with this distribution for more information.
00015 */
00016 
00017 #ifndef _PANE_H_
00018 #define _PANE_H_
00019 
00020 #include <QFrame>
00021 #include <QPoint>
00022 
00023 #include "base/ZoomConstraint.h"
00024 #include "View.h"
00025 #include "base/Selection.h"
00026 
00027 class QWidget;
00028 class QPaintEvent;
00029 class Layer;
00030 class Thumbwheel;
00031 class Panner;
00032 class NotifyingPushButton;
00033 class KeyReference;
00034 
00035 class Pane : public View
00036 {
00037     Q_OBJECT
00038 
00039 public:
00040     Pane(QWidget *parent = 0);
00041     virtual QString getPropertyContainerIconName() const { return "pane"; }
00042 
00043     virtual bool shouldIlluminateLocalFeatures(const Layer *layer,
00044                                                QPoint &pos) const;
00045     virtual bool shouldIlluminateLocalSelection(QPoint &pos,
00046                                                 bool &closeToLeft,
00047                                                 bool &closeToRight) const;
00048 
00049     void setCentreLineVisible(bool visible);
00050     bool getCentreLineVisible() const { return m_centreLineVisible; }
00051 
00052     virtual size_t getFirstVisibleFrame() const;
00053 
00054     virtual size_t getVerticalScaleWidth() const;
00055 
00056     virtual QImage *toNewImage(size_t f0, size_t f1);
00057     virtual QImage *toNewImage() { return View::toNewImage(); }
00058     virtual QSize getImageSize(size_t f0, size_t f1);
00059     virtual QSize getImageSize() { return View::getImageSize(); }
00060 
00061     virtual void toXml(QTextStream &stream, QString indent = "",
00062                        QString extraAttributes = "") const;
00063 
00064     static void registerShortcuts(KeyReference &kr);
00065 
00066 signals:
00067     void paneInteractedWith();
00068     void rightButtonMenuRequested(QPoint position);
00069     void dropAccepted(QStringList uriList);
00070     void dropAccepted(QString text);
00071 
00072 public slots:
00073     virtual void toolModeChanged();
00074     virtual void zoomWheelsEnabledChanged();
00075     virtual void viewZoomLevelChanged(View *v, unsigned long z, bool locked);
00076     virtual void modelAlignmentCompletionChanged();
00077 
00078     virtual void horizontalThumbwheelMoved(int value);
00079     virtual void verticalThumbwheelMoved(int value);
00080     virtual void verticalZoomChanged();
00081     virtual void verticalPannerMoved(float x, float y, float w, float h);
00082     virtual void editVerticalPannerExtents();
00083 
00084     virtual void propertyContainerSelected(View *, PropertyContainer *pc);
00085 
00086     void mouseEnteredWidget();
00087     void mouseLeftWidget();
00088 
00089 protected:
00090     virtual void paintEvent(QPaintEvent *e);
00091     virtual void mousePressEvent(QMouseEvent *e);
00092     virtual void mouseReleaseEvent(QMouseEvent *e);
00093     virtual void mouseMoveEvent(QMouseEvent *e);
00094     virtual void mouseDoubleClickEvent(QMouseEvent *e);
00095     virtual void enterEvent(QEvent *e);
00096     virtual void leaveEvent(QEvent *e);
00097     virtual void wheelEvent(QWheelEvent *e);
00098     virtual void resizeEvent(QResizeEvent *e);
00099     virtual void dragEnterEvent(QDragEnterEvent *e);
00100     virtual void dropEvent(QDropEvent *e);
00101 
00102     void drawVerticalScale(QRect r, Layer *, QPainter &);
00103     void drawFeatureDescription(Layer *, QPainter &);
00104     void drawCentreLine(int, QPainter &, bool omitLine);
00105     void drawDurationAndRate(QRect, const Model *, int, QPainter &);
00106     void drawWorkTitle(QRect, QPainter &, const Model *);
00107     void drawLayerNames(QRect, QPainter &);
00108     void drawEditingSelection(QPainter &);
00109     void drawAlignmentStatus(QRect, QPainter &, const Model *, bool down);
00110 
00111     virtual bool render(QPainter &paint, int x0, size_t f0, size_t f1);
00112 
00113     Selection getSelectionAt(int x, bool &closeToLeft, bool &closeToRight) const;
00114 
00115     bool editSelectionStart(QMouseEvent *e);
00116     bool editSelectionDrag(QMouseEvent *e);
00117     bool editSelectionEnd(QMouseEvent *e);
00118     bool selectionIsBeingEdited() const;
00119 
00120     void updateHeadsUpDisplay();
00121     void updateVerticalPanner();
00122 
00123     bool canTopLayerMoveVertical();
00124     bool getTopLayerDisplayExtents(float &valueMin, float &valueMax,
00125                                    float &displayMin, float &displayMax,
00126                                    QString *unit = 0);
00127     bool setTopLayerDisplayExtents(float displayMin, float displayMax);
00128 
00129     void dragTopLayer(QMouseEvent *e);
00130     void dragExtendSelection(QMouseEvent *e);
00131     void zoomToRegion(int x0, int y0, int x1, int y1);
00132     void updateContextHelp(const QPoint *pos);
00133     void edgeScrollMaybe(int x);
00134 
00135     bool m_identifyFeatures;
00136     QPoint m_identifyPoint;
00137     QPoint m_clickPos;
00138     QPoint m_mousePos;
00139     bool m_clickedInRange;
00140     bool m_shiftPressed;
00141     bool m_ctrlPressed;
00142 
00143     bool m_navigating;
00144     bool m_resizing;
00145     bool m_editing;
00146     bool m_releasing;
00147     size_t m_dragCentreFrame;
00148     float m_dragStartMinValue;
00149     bool m_centreLineVisible;
00150     size_t m_selectionStartFrame;
00151     Selection m_editingSelection;
00152     int m_editingSelectionEdge;
00153     mutable int m_scaleWidth;
00154 
00155     enum DragMode {
00156         UnresolvedDrag,
00157         VerticalDrag,
00158         HorizontalDrag,
00159         FreeDrag
00160     };
00161     DragMode m_dragMode;
00162 
00163     DragMode updateDragMode(DragMode currentMode,
00164                             QPoint origin,
00165                             QPoint currentPoint,
00166                             bool canMoveHorizontal,
00167                             bool canMoveVertical,
00168                             bool resistHorizontal,
00169                             bool resistVertical);
00170 
00171     QWidget *m_headsUpDisplay;
00172     Panner *m_vpan;
00173     Thumbwheel *m_hthumb;
00174     Thumbwheel *m_vthumb;
00175     NotifyingPushButton *m_reset;
00176 
00177     bool m_mouseInWidget;
00178 
00179     static QCursor *m_measureCursor1;
00180     static QCursor *m_measureCursor2;
00181 };
00182 
00183 #endif
00184 

Generated on Wed Feb 20 15:45:27 2008 for SonicVisualiser by  doxygen 1.5.1