changeset 607:5b72899d692b

Give a dedicated key to toggling the centre line, and move it out of the overlay level setting -- reducing number of overlay levels to 3. Introduce two distinct vertical scale types (so that we can hide the spectrogram colour scale part easily)
author Chris Cannam
date Mon, 30 Jan 2012 16:01:59 +0000
parents fbab21439115
children 0dba6a391760
files layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h layer/ImageLayer.h layer/Layer.h layer/NoteLayer.h layer/RegionLayer.h layer/SliceLayer.cpp layer/SliceLayer.h layer/SpectrogramLayer.cpp layer/SpectrogramLayer.h layer/SpectrumLayer.cpp layer/SpectrumLayer.h layer/TextLayer.h layer/TimeInstantLayer.h layer/TimeRulerLayer.h layer/TimeValueLayer.cpp layer/TimeValueLayer.h layer/WaveformLayer.cpp layer/WaveformLayer.h view/Pane.cpp view/View.cpp view/ViewManager.cpp view/ViewManager.h
diffstat 23 files changed, 108 insertions(+), 47 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/Colour3DPlotLayer.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -714,7 +714,7 @@
 }
 
 int
-Colour3DPlotLayer::getVerticalScaleWidth(View *, QPainter &paint) const
+Colour3DPlotLayer::getVerticalScaleWidth(View *, bool, QPainter &paint) const
 {
     if (!m_model) return 0;
 
@@ -736,7 +736,7 @@
 }
 
 void
-Colour3DPlotLayer::paintVerticalScale(View *v, QPainter &paint, QRect rect) const
+Colour3DPlotLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const
 {
     if (!m_model) return;
 
--- a/layer/Colour3DPlotLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/Colour3DPlotLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -51,8 +51,8 @@
     virtual const Model *getModel() const { return m_model; }
     virtual void paint(View *v, QPainter &paint, QRect rect) const;
 
-    virtual int getVerticalScaleWidth(View *v, QPainter &) const;
-    virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
+    virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const;
+    virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const;
 
     virtual QString getFeatureDescription(View *v, QPoint &) const;
 
--- a/layer/ImageLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/ImageLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -92,6 +92,8 @@
     virtual void toXml(QTextStream &stream, QString indent = "",
                        QString extraAttributes = "") const;
 
+    virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
+
     virtual void setLayerDormant(const View *v, bool dormant);
 
     void setProperties(const QXmlAttributes &attributes);
--- a/layer/Layer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/Layer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -128,8 +128,11 @@
     virtual QString getLayerPresentationName() const;
     virtual QPixmap getLayerPresentationPixmap(QSize) const { return QPixmap(); }
 
-    virtual int getVerticalScaleWidth(View *, QPainter &) const { return 0; }
-    virtual void paintVerticalScale(View *, QPainter &, QRect) const { }
+    virtual int getVerticalScaleWidth(View *, bool detailed,
+                                      QPainter &) const = 0;
+
+    virtual void paintVerticalScale(View *, bool detailed,
+                                    QPainter &, QRect) const { }
 
     virtual bool getCrosshairExtents(View *, QPainter &, QPoint /* cursorPos */,
                                      std::vector<QRect> &) const {
--- a/layer/NoteLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/NoteLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -102,6 +102,8 @@
     virtual void setVerticalZoomStep(int);
     virtual RangeMapper *getNewVerticalZoomRangeMapper() const;
 
+    virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
+
     /**
      * Add a note-on.  Used when recording MIDI "live".  The note will
      * not be finally added to the layer until the corresponding
--- a/layer/RegionLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/RegionLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -116,6 +116,8 @@
     virtual void toXml(QTextStream &stream, QString indent = "",
                        QString extraAttributes = "") const;
 
+    virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
+
     void setProperties(const QXmlAttributes &attributes);
 
 protected slots:
--- a/layer/SliceLayer.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/SliceLayer.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -330,7 +330,7 @@
 
     paint.setPen(getBaseQColor());
 
-    int xorigin = getVerticalScaleWidth(v, paint) + 1;
+    int xorigin = getVerticalScaleWidth(v, true, paint) + 1;
     int w = v->width() - xorigin - 1;
 
     m_xorigins[v] = xorigin; // for use in getFeatureDescription
@@ -498,7 +498,7 @@
 }
 
 int
-SliceLayer::getVerticalScaleWidth(View *, QPainter &paint) const
+SliceLayer::getVerticalScaleWidth(View *, bool, QPainter &paint) const
 {
     if (m_energyScale == LinearScale || m_energyScale == AbsoluteScale) {
 	return std::max(paint.fontMetrics().width("0.0") + 13,
@@ -510,7 +510,7 @@
 }
 
 void
-SliceLayer::paintVerticalScale(View *v, QPainter &paint, QRect rect) const
+SliceLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const
 {
     float thresh = m_threshold;
     if (m_energyScale != LinearScale && m_energyScale != AbsoluteScale) {
--- a/layer/SliceLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/SliceLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -42,8 +42,8 @@
 
     virtual QString getFeatureDescription(View *v, QPoint &) const;
 
-    virtual int getVerticalScaleWidth(View *v, QPainter &) const;
-    virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
+    virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const;
+    virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const;
 
     virtual ColourSignificance getLayerColourSignificance() const {
         return ColourAndBackgroundSignificant;
--- a/layer/SpectrogramLayer.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/SpectrogramLayer.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -3031,7 +3031,7 @@
     QRect horizontal(0, cursorPos.y(), cursorPos.x(), 1);
     extents.push_back(horizontal);
 
-    int sw = getVerticalScaleWidth(v, paint);
+    int sw = getVerticalScaleWidth(v, false, paint);//!!!
 
     QRect freq(sw, cursorPos.y() - paint.fontMetrics().ascent() - 2,
                paint.fontMetrics().width("123456 Hz") + 2,
@@ -3065,7 +3065,7 @@
 {
     paint.save();
 
-    int sw = getVerticalScaleWidth(v, paint);
+    int sw = getVerticalScaleWidth(v, false, paint); //!!!
 
     QFont fn = paint.font();
     if (fn.pointSize() > 8) {
@@ -3260,11 +3260,12 @@
 }
 
 int
-SpectrogramLayer::getVerticalScaleWidth(View *, QPainter &paint) const
+SpectrogramLayer::getVerticalScaleWidth(View *, bool detailed, QPainter &paint) const
 {
     if (!m_model || !m_model->isOK()) return 0;
 
-    int cw = getColourScaleWidth(paint);
+    int cw = 0;
+    if (detailed) cw = getColourScaleWidth(paint);
 
     int tw = paint.fontMetrics().width(QString("%1")
 				     .arg(m_maxFrequency > 0 ?
@@ -3280,7 +3281,7 @@
 }
 
 void
-SpectrogramLayer::paintVerticalScale(View *v, QPainter &paint, QRect rect) const
+SpectrogramLayer::paintVerticalScale(View *v, bool detailed, QPainter &paint, QRect rect) const
 {
     if (!m_model || !m_model->isOK()) {
 	return;
@@ -3303,14 +3304,16 @@
 	if (bins > m_fftSize / 2) bins = m_fftSize / 2;
     }
 
-    int cw = getColourScaleWidth(paint);
+    int cw = 0;
+
+    if (detailed) cw = getColourScaleWidth(paint);
     int cbw = paint.fontMetrics().width("dB");
 
     int py = -1;
     int textHeight = paint.fontMetrics().height();
     int toff = -textHeight + paint.fontMetrics().ascent() + 2;
 
-    if (h > textHeight * 3 + 10) {
+    if (detailed && (h > textHeight * 3 + 10)) {
 
         int topLines = 2;
         if (m_colourScale == PhaseColourScale) topLines = 1;
--- a/layer/SpectrogramLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/SpectrogramLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -60,8 +60,8 @@
     virtual void paint(View *v, QPainter &paint, QRect rect) const;
     virtual void setSynchronousPainting(bool synchronous);
 
-    virtual int getVerticalScaleWidth(View *v, QPainter &) const;
-    virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
+    virtual int getVerticalScaleWidth(View *v, bool detailed, QPainter &) const;
+    virtual void paintVerticalScale(View *v, bool detailed, QPainter &paint, QRect rect) const;
 
     virtual bool getCrosshairExtents(View *, QPainter &, QPoint cursorPos,
                                      std::vector<QRect> &extents) const;
--- a/layer/SpectrumLayer.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/SpectrumLayer.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -442,7 +442,7 @@
     int hoffset = 2;
     if (m_binScale == LogBins) hoffset = 13;
 
-    int sw = getVerticalScaleWidth(v, paint);
+    int sw = getVerticalScaleWidth(v, false, paint);
 
     QRect value(sw, cursorPos.y() - paint.fontMetrics().ascent() - 2,
                 paint.fontMetrics().width("0.0000001 V") + 2,
@@ -668,7 +668,7 @@
 
     float thresh = (powf(10, -6) / m_gain) * (m_windowSize / 2.f); // -60dB adj
 
-    int xorigin = getVerticalScaleWidth(v, paint) + 1;
+    int xorigin = getVerticalScaleWidth(v, false, paint) + 1;
     int w = v->width() - xorigin - 1;
 
     int pkh = 0;
--- a/layer/SpectrumLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/SpectrumLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -93,6 +93,8 @@
     void setShowPeaks(bool);
     bool getShowPeaks() const { return m_showPeaks; }
 
+    virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
+
     virtual void toXml(QTextStream &stream, QString indent = "",
                        QString extraAttributes = "") const;
 
--- a/layer/TextLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/TextLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -83,6 +83,8 @@
     virtual bool getValueExtents(float &min, float &max,
                                  bool &logarithmic, QString &unit) const;
 
+    virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
+
     virtual void toXml(QTextStream &stream, QString indent = "",
                        QString extraAttributes = "") const;
 
--- a/layer/TimeInstantLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/TimeInstantLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -109,6 +109,8 @@
         }
     }
 
+    virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
+
 protected:
     SparseOneDimensionalModel::PointList getLocalPoints(View *v, int) const;
 
--- a/layer/TimeRulerLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/TimeRulerLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -53,6 +53,8 @@
 
     virtual QString getLayerPresentationName() const;
 
+    virtual int getVerticalScaleWidth(View *, bool, QPainter &) const { return 0; }
+
     virtual void toXml(QTextStream &stream, QString indent = "",
                        QString extraAttributes = "") const;
 
--- a/layer/TimeValueLayer.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/TimeValueLayer.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -1106,7 +1106,7 @@
 }
 
 int
-TimeValueLayer::getVerticalScaleWidth(View *, QPainter &paint) const
+TimeValueLayer::getVerticalScaleWidth(View *, bool, QPainter &paint) const
 {
     int w = paint.fontMetrics().width("-000.000");
     if (m_plotStyle == PlotSegmentation) return w + 20;
@@ -1114,7 +1114,7 @@
 }
 
 void
-TimeValueLayer::paintVerticalScale(View *v, QPainter &paint, QRect) const
+TimeValueLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect) const
 {
     if (!m_model) return;
 
@@ -1139,7 +1139,7 @@
 
     char buffer[40];
 
-    int w = getVerticalScaleWidth(v, paint);
+    int w = getVerticalScaleWidth(v, false, paint);
 
     int tx = 5;
 
--- a/layer/TimeValueLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/TimeValueLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -34,8 +34,8 @@
 
     virtual void paint(View *v, QPainter &paint, QRect rect) const;
 
-    virtual int getVerticalScaleWidth(View *v, QPainter &) const;
-    virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
+    virtual int getVerticalScaleWidth(View *v, bool, QPainter &) const;
+    virtual void paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const;
 
     virtual QString getFeatureDescription(View *v, QPoint &) const;
     virtual QString getLabelPreceding(size_t) const;
--- a/layer/WaveformLayer.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/WaveformLayer.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -1154,7 +1154,7 @@
 }
 
 int
-WaveformLayer::getVerticalScaleWidth(View *, QPainter &paint) const
+WaveformLayer::getVerticalScaleWidth(View *, bool, QPainter &paint) const
 {
     if (m_scale == LinearScale) {
 	return paint.fontMetrics().width("0.0") + 13;
@@ -1165,7 +1165,7 @@
 }
 
 void
-WaveformLayer::paintVerticalScale(View *v, QPainter &paint, QRect rect) const
+WaveformLayer::paintVerticalScale(View *v, bool, QPainter &paint, QRect rect) const
 {
     if (!m_model || !m_model->isOK()) {
 	return;
--- a/layer/WaveformLayer.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/layer/WaveformLayer.h	Mon Jan 30 16:01:59 2012 +0000
@@ -46,8 +46,8 @@
         return ColourAndBackgroundSignificant;
     }
 
-    virtual int getVerticalScaleWidth(View *v, QPainter &) const;
-    virtual void paintVerticalScale(View *v, QPainter &paint, QRect rect) const;
+    virtual int getVerticalScaleWidth(View *v, bool detailed, QPainter &) const;
+    virtual void paintVerticalScale(View *v, bool detailed, QPainter &paint, QRect rect) const;
 
     void setModel(const RangeSummarisableTimeValueModel *model);
 
--- a/view/Pane.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/view/Pane.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -554,7 +554,8 @@
     // then the scale should be drawn from any underlying layer
     // with a scale regardless of unit.
 
-    int sw = topLayer->getVerticalScaleWidth(this, paint);
+    int sw = topLayer->getVerticalScaleWidth
+        (this, m_manager->shouldShowVerticalColourScale(), paint);
 
     if (sw > 0) {
         scaleLayer = topLayer;
@@ -576,7 +577,8 @@
                         
                     if ((*vi) == topLayer) continue;
                         
-                    sw = (*vi)->getVerticalScaleWidth(this, paint);
+                    sw = (*vi)->getVerticalScaleWidth
+                        (this, m_manager->shouldShowVerticalColourScale(), paint);
                         
                     if (sw > 0) {
                         scaleLayer = *vi;
@@ -605,7 +607,8 @@
                         if ((*vi)->getValueExtents(min, max, log, unit) &&
                             unit == requireUnit) {
 
-                            sw = (*vi)->getVerticalScaleWidth(this, paint);
+                            sw = (*vi)->getVerticalScaleWidth
+                                (this, m_manager->shouldShowVerticalColourScale(), paint);
                             if (sw > 0) {
                                 scaleLayer = *vi;
                                 m_scaleWidth = sw;
@@ -633,7 +636,8 @@
         
         paint.setBrush(Qt::NoBrush);
         scaleLayer->paintVerticalScale
-            (this, paint, QRect(0, 0, m_scaleWidth, height()));
+            (this, m_manager->shouldShowVerticalColourScale(),
+             paint, QRect(0, 0, m_scaleWidth, height()));
         
         paint.restore();
     }
@@ -1053,7 +1057,8 @@
             
             paint.setBrush(Qt::NoBrush);
             (*vi)->paintVerticalScale
-                (this, paint, QRect(xorigin, 0, m_scaleWidth, height()));
+                (this, m_manager->shouldShowVerticalColourScale(),
+                 paint, QRect(xorigin, 0, m_scaleWidth, height()));
             
             paint.restore();
             break;
@@ -1078,7 +1083,8 @@
         for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
             --vi;
             QPainter paint(image);
-            m_scaleWidth = (*vi)->getVerticalScaleWidth(this, paint);
+            m_scaleWidth = (*vi)->getVerticalScaleWidth
+                (this, m_manager->shouldShowVerticalColourScale(), paint);
             break;
         }
     } else {
@@ -1114,7 +1120,8 @@
         for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
             --vi;
             QPainter paint(image);
-            sw = (*vi)->getVerticalScaleWidth(this, paint);
+            sw = (*vi)->getVerticalScaleWidth
+                (this, m_manager->shouldShowVerticalColourScale(), paint);
             break;
         }
     }
--- a/view/View.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/view/View.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -674,6 +674,8 @@
 	    this, SLOT(selectionChanged()));
     connect(m_manager, SIGNAL(overlayModeChanged()),
             this, SLOT(overlayModeChanged()));
+    connect(m_manager, SIGNAL(showCentreLineChanged()),
+            this, SLOT(overlayModeChanged()));
     connect(m_manager, SIGNAL(zoomWheelsEnabledChanged()),
             this, SLOT(zoomWheelsEnabledChanged()));
 
--- a/view/ViewManager.cpp	Mon Jan 30 13:24:55 2012 +0000
+++ b/view/ViewManager.cpp	Mon Jan 30 16:01:59 2012 +0000
@@ -43,8 +43,9 @@
     m_playSelectionMode(false),
     m_playSoloMode(false),
     m_alignMode(false),
-    m_overlayMode(StandardOverlays),
+    m_overlayMode(MinimalOverlays),
     m_zoomWheelsEnabled(true),
+    m_showCentreLine(true),
     m_illuminateLocalFeatures(true),
     m_showWorkTitle(false),
     m_lightPalette(QApplication::palette()),
@@ -54,8 +55,17 @@
     settings.beginGroup("MainWindow");
     m_overlayMode = OverlayMode
         (settings.value("overlay-mode", int(m_overlayMode)).toInt());
+
+    if (m_overlayMode != NoOverlays &&
+        m_overlayMode != MinimalOverlays &&
+        m_overlayMode != AllOverlays) {
+        m_overlayMode = MinimalOverlays;
+    }
+
     m_zoomWheelsEnabled =
         settings.value("zoom-wheels-enabled", m_zoomWheelsEnabled).toBool();
+    m_showCentreLine =
+        settings.value("show-centre-line", m_showCentreLine).toBool();
     settings.endGroup();
 
     if (getGlobalDarkBackground()) {
@@ -609,6 +619,22 @@
 }
 
 void
+ViewManager::setShowCentreLine(bool show)
+{
+    if (m_showCentreLine != show) {
+        m_showCentreLine = show;
+        emit showCentreLineChanged();
+        if (show) emit activity("Show centre line");
+        else emit activity("Hide centre line");
+    }
+
+    QSettings settings;
+    settings.beginGroup("MainWindow");
+    settings.setValue("show-centre-line", int(m_showCentreLine));
+    settings.endGroup();
+}
+
+void
 ViewManager::setGlobalDarkBackground(bool dark)
 {
     // also save the current palette, in case the user has changed it
--- a/view/ViewManager.h	Mon Jan 30 13:24:55 2012 +0000
+++ b/view/ViewManager.h	Mon Jan 30 16:01:59 2012 +0000
@@ -148,26 +148,28 @@
     enum OverlayMode {
         NoOverlays,
         MinimalOverlays,
-        StandardOverlays,
         AllOverlays
     };
     void setOverlayMode(OverlayMode mode);
     OverlayMode getOverlayMode() const { return m_overlayMode; }
 
-    bool shouldShowCentreLine() const {
+    void setShowCentreLine(bool show);
+    bool shouldShowCentreLine() const { return m_showCentreLine; }
+
+    bool shouldShowDuration() const {
         return m_overlayMode != NoOverlays;
     }
     bool shouldShowFrameCount() const {
+        return m_showCentreLine && shouldShowDuration();
+    }
+    bool shouldShowVerticalScale() const {
         return m_overlayMode != NoOverlays;
     }
-    bool shouldShowDuration() const {
-        return m_overlayMode > MinimalOverlays;
-    }
-    bool shouldShowVerticalScale() const {
-        return m_overlayMode > MinimalOverlays;
+    bool shouldShowVerticalColourScale() const {
+        return m_overlayMode == AllOverlays;
     }
     bool shouldShowSelectionExtents() const {
-        return m_overlayMode > MinimalOverlays;
+        return m_overlayMode != NoOverlays;
     }
     bool shouldShowLayerNames() const {
         return m_overlayMode == AllOverlays;
@@ -232,6 +234,9 @@
     /** Emitted when the overlay mode has been changed. */
     void overlayModeChanged();
 
+    /** Emitted when the centre line visibility has been changed. */
+    void showCentreLineChanged();
+
     /** Emitted when the zoom wheels have been toggled. */
     void zoomWheelsEnabledChanged();
 
@@ -294,6 +299,7 @@
 
     OverlayMode m_overlayMode;
     bool m_zoomWheelsEnabled;
+    bool m_showCentreLine;
     bool m_illuminateLocalFeatures;
     bool m_showWorkTitle;