changeset 972:1011ffb1b6d5 osx-retina

Merge from default branch
author Chris Cannam
date Wed, 10 Jun 2015 13:38:02 +0100
parents 0aac065f09f9 (current diff) fd934705973f (diff)
children bc23c2cfff65 66da6f009edd
files layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h
diffstat 7 files changed, 91 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Thu May 21 16:05:14 2015 +0100
+++ b/layer/Colour3DPlotLayer.cpp	Wed Jun 10 13:38:02 2015 +0100
@@ -54,6 +54,7 @@
     m_normalizeVisibleArea(false),
     m_normalizeHybrid(false),
     m_invertVertical(false),
+    m_rectified(false),
     m_opaque(false),
     m_smooth(false),
     m_peakResolution(256),
@@ -162,6 +163,7 @@
     list.push_back("Gain");
     list.push_back("Bin Scale");
     list.push_back("Invert Vertical Scale");
+    list.push_back("Show Rectified");
     list.push_back("Opaque");
     list.push_back("Smooth");
     return list;
@@ -175,6 +177,7 @@
     if (name == "Normalize Columns") return tr("Normalize Columns");
     if (name == "Normalize Visible Area") return tr("Normalize Visible Area");
     if (name == "Invert Vertical Scale") return tr("Invert Vertical Scale");
+    if (name == "Show Rectified") return tr("Half-Wave Rectify");
     if (name == "Gain") return tr("Gain");
     if (name == "Opaque") return tr("Always Opaque");
     if (name == "Smooth") return tr("Smooth");
@@ -188,6 +191,7 @@
     if (name == "Normalize Columns") return "normalise-columns";
     if (name == "Normalize Visible Area") return "normalise";
     if (name == "Invert Vertical Scale") return "invert-vertical";
+    if (name == "Show Rectified") return "derivative";
     if (name == "Opaque") return "opaque";
     if (name == "Smooth") return "smooth";
     return "";
@@ -200,6 +204,7 @@
     if (name == "Normalize Columns") return ToggleProperty;
     if (name == "Normalize Visible Area") return ToggleProperty;
     if (name == "Invert Vertical Scale") return ToggleProperty;
+    if (name == "Show Rectified") return ToggleProperty;
     if (name == "Opaque") return ToggleProperty;
     if (name == "Smooth") return ToggleProperty;
     return ValueProperty;
@@ -211,6 +216,7 @@
     if (name == "Normalize Columns" ||
         name == "Normalize Visible Area" ||
 	name == "Colour Scale" ||
+        name == "Show Rectified" ||
         name == "Gain") return tr("Scale");
     if (name == "Bin Scale" ||
         name == "Invert Vertical Scale") return tr("Bins");
@@ -275,6 +281,13 @@
         *deflt = 0;
 	val = (m_invertVertical ? 1 : 0);
 
+    } else if (name == "Show Rectified") {
+
+        if (min) *min = 0;
+        if (max) *max = 0;
+        if (deflt) *deflt = 0;
+        val = (m_rectified ? 1.0 : 0.0);
+
     } else if (name == "Bin Scale") {
 
 	*min = 0;
@@ -355,6 +368,8 @@
 	setNormalizeVisibleArea(value ? true : false);
     } else if (name == "Invert Vertical Scale") {
 	setInvertVertical(value ? true : false);
+    } else if (name == "Show Rectified") {
+        setShowRectified(value > 0.5);
     } else if (name == "Opaque") {
 	setOpaque(value ? true : false);
     } else if (name == "Smooth") {
@@ -472,6 +487,15 @@
 }
 
 void
+Colour3DPlotLayer::setShowRectified(bool show)
+{
+    if (m_rectified == show) return;
+    m_rectified = show;
+    cacheInvalid();
+    emit layerParametersChanged();
+}
+
+void
 Colour3DPlotLayer::setOpaque(bool n)
 {
     if (m_opaque == n) return;
@@ -933,7 +957,20 @@
 {
     Profiler profiler("Colour3DPlotLayer::getColumn");
 
+    DenseThreeDimensionalModel::Column prev;
+    if (m_rectified && (col > m_model->getStartFrame())) {
+        prev = m_model->getColumn(col - 1);
+    }
+    
     DenseThreeDimensionalModel::Column values = m_model->getColumn(col);
+
+    if (m_rectified && !prev.empty()) {
+        for (int y = 0; y < values.size(); ++y) {
+            if (values[y] < prev[y]) values[y] = 0;
+            else values[y] -= prev[y];
+        }
+    }
+    
     while (values.size() < m_model->getHeight()) values.push_back(0.f);
     if (!m_normalizeColumns && !m_normalizeHybrid) return values;
 
--- a/layer/Colour3DPlotLayer.h	Thu May 21 16:05:14 2015 +0100
+++ b/layer/Colour3DPlotLayer.h	Wed Jun 10 13:38:02 2015 +0100
@@ -139,6 +139,9 @@
     void setInvertVertical(bool i);
     bool getInvertVertical() const;
 
+    void setShowRectified(bool);
+    bool getShowRectified() const { return m_rectified; }
+
     void setOpaque(bool i);
     bool getOpaque() const;
 
@@ -187,6 +190,7 @@
     bool        m_normalizeVisibleArea;
     bool        m_normalizeHybrid;
     bool        m_invertVertical;
+    bool        m_rectified;
     bool        m_opaque;
     bool        m_smooth;
     int         m_peakResolution;
--- a/view/Overview.cpp	Thu May 21 16:05:14 2015 +0100
+++ b/view/Overview.cpp	Wed Jun 10 13:38:02 2015 +0100
@@ -35,6 +35,10 @@
     m_followZoom = false;
     setPlaybackFollow(PlaybackIgnore);
     m_modelTestTime.start();
+
+    bool light = hasLightBackground();
+    if (light) m_boxColour = Qt::darkGray;
+    else m_boxColour = Qt::lightGray;
 }
 
 void
@@ -159,6 +163,12 @@
 }
 
 void
+Overview::setBoxColour(QColor c)
+{
+    m_boxColour = c;
+}
+
+void
 Overview::paintEvent(QPaintEvent *e)
 {
     // Recalculate zoom in case the size of the widget has changed.
@@ -263,7 +273,7 @@
     
     foreach (QRect vr, rects) {
         paint.setBrush(Qt::NoBrush);
-        paint.setPen(QPen(Qt::gray, 2));
+        paint.setPen(QPen(m_boxColour, 2));
         paint.drawRoundedRect(vr, 4, 4);
     }
 
--- a/view/Overview.h	Thu May 21 16:05:14 2015 +0100
+++ b/view/Overview.h	Wed Jun 10 13:38:02 2015 +0100
@@ -49,6 +49,8 @@
     virtual void viewZoomLevelChanged(View *, int, bool);
     virtual void viewManagerPlaybackFrameChanged(sv_frame_t);
 
+    virtual void setBoxColour(QColor);
+    
 protected:
     virtual void paintEvent(QPaintEvent *e);
     virtual void mousePressEvent(QMouseEvent *e);
@@ -67,6 +69,7 @@
     bool m_clickedInRange;
     sv_frame_t m_dragCentreFrame;
     QTime m_modelTestTime;
+    QColor m_boxColour;
     
     typedef std::set<View *> ViewSet;
     ViewSet m_views;
--- a/view/Pane.cpp	Thu May 21 16:05:14 2015 +0100
+++ b/view/Pane.cpp	Wed Jun 10 13:38:02 2015 +0100
@@ -388,10 +388,10 @@
 Pane::selectionIsBeingEdited() const
 {
     if (!m_editingSelection.isEmpty()) {
-    if (m_mousePos != m_clickPos &&
-        getFrameForX(m_mousePos.x()) != getFrameForX(m_clickPos.x())) {
-        return true;
-    }
+        if (m_mousePos != m_clickPos &&
+            getFrameForX(m_mousePos.x()) != getFrameForX(m_clickPos.x())) {
+            return true;
+        }
     }
     return false;
 }
@@ -2111,14 +2111,25 @@
         max = snapFrameRight;
     }
 
+    sv_frame_t end = getModelsEndFrame();
+    if (min > end) min = end;
+    if (max > end) max = end;
+
     if (m_manager) {
-        m_manager->setInProgressSelection(Selection(alignToReference(min),
-                                                    alignToReference(max)),
-                                          !m_resizing && !m_ctrlPressed);
+
+        Selection sel(alignToReference(min), alignToReference(max));
+
+        bool exc;
+        bool same = (m_manager->haveInProgressSelection() &&
+                     m_manager->getInProgressSelection(exc) == sel);
+        
+        m_manager->setInProgressSelection(sel, !m_resizing && !m_ctrlPressed);
+
+        if (!same) {
+            edgeScrollMaybe(e->x());
+        }
     }
 
-    edgeScrollMaybe(e->x());
-
     update();
 
     if (min != max) {
@@ -2141,11 +2152,12 @@
         sv_frame_t offset = mouseFrame - getStartFrame();
         sv_frame_t available = getEndFrame() - getStartFrame();
         sv_frame_t move = 0;
-        if (offset >= double(available) * 0.95) {
-            move = sv_frame_t(double(offset - available) * 0.95) + 1;
-        } else if (offset <= double(available) * 0.10) {
-            move = sv_frame_t(double(available) * 0.10 - double(offset)) + 1;
-            move = -move;
+        sv_frame_t rightEdge = available - (available / 20);
+        sv_frame_t leftEdge = (available / 10);
+        if (offset >= rightEdge) {
+            move = offset - rightEdge + 1;
+        } else if (offset <= leftEdge) {
+            move = offset - leftEdge - 1;
         }
         if (move != 0) {
             setCentreFrame(m_centreFrame + move);
--- a/view/ViewManager.cpp	Thu May 21 16:05:14 2015 +0100
+++ b/view/ViewManager.cpp	Wed Jun 10 13:38:02 2015 +0100
@@ -166,6 +166,7 @@
 void
 ViewManager::setPlaybackFrame(sv_frame_t f)
 {
+    if (f < 0) f = 0;
     if (m_playbackFrame != f) {
 	m_playbackFrame = f;
 	emit playbackFrameChanged(f);
--- a/widgets/CSVFormatDialog.cpp	Thu May 21 16:05:14 2015 +0100
+++ b/widgets/CSVFormatDialog.cpp	Wed Jun 10 13:38:02 2015 +0100
@@ -252,15 +252,17 @@
 void
 CSVFormatDialog::applyStartTimePurpose()
 {
-    // First check if we already have any
-    for (int i = 0; i < m_format.getColumnCount(); ++i) {
+    // First check if we already have any. NB there may be fewer than
+    // m_format.getColumnCount() elements in m_columnPurposeCombos
+    // (because of the fuzzy column behaviour)
+    for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
         QComboBox *cb = m_columnPurposeCombos[i];
         if (cb->currentIndex() == int(CSVFormat::ColumnStartTime)) {
             return;
         }
     }
     // and if not, select one
-    for (int i = 0; i < m_format.getColumnCount(); ++i) {
+    for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
         QComboBox *cb = m_columnPurposeCombos[i];
         if (cb->currentIndex() == int(CSVFormat::ColumnValue)) {
             cb->setCurrentIndex(int(CSVFormat::ColumnStartTime));
@@ -272,7 +274,10 @@
 void
 CSVFormatDialog::removeStartTimePurpose()
 {
-    for (int i = 0; i < m_format.getColumnCount(); ++i) {
+    // NB there may be fewer than m_format.getColumnCount() elements
+    // in m_columnPurposeCombos (because of the fuzzy column
+    // behaviour)
+    for (int i = 0; i < m_columnPurposeCombos.size(); ++i) {
         QComboBox *cb = m_columnPurposeCombos[i];
         if (cb->currentIndex() == int(CSVFormat::ColumnStartTime)) {
             cb->setCurrentIndex(int(CSVFormat::ColumnValue));