changeset 140:a35098a9c814

* start work on prefs dialog * some work on highlighting local points in spectrogram
author Chris Cannam
date Thu, 20 Jul 2006 16:51:20 +0000
parents 8ce30801f39a
children 4f26f623a8bc
files base/Preferences.cpp base/Preferences.h base/View.cpp base/Window.h
diffstat 4 files changed, 46 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/base/Preferences.cpp	Wed Jul 19 16:55:29 2006 +0000
+++ b/base/Preferences.cpp	Thu Jul 20 16:51:20 2006 +0000
@@ -20,7 +20,9 @@
 
 Preferences::Preferences() :
     m_smoothSpectrogram(true),
-    m_tuningFrequency(440)
+    m_tuningFrequency(440),
+    m_propertyBoxLayout(VerticallyStacked),
+    m_windowType(HanningWindow)
 {
 }
 
@@ -31,6 +33,7 @@
     props.push_back("Smooth Spectrogram");
     props.push_back("Tuning Frequency");
     props.push_back("Property Box Layout");
+    props.push_back("Window Type");
     return props;
 }
 
@@ -46,6 +49,9 @@
     if (name == "Property Box Layout") {
         return tr("Arrangement of Layer Properties");
     }
+    if (name == "Window Type") {
+        return tr("Spectral Analysis Window Shape");
+    }
     return name;
 }
 
@@ -61,6 +67,9 @@
     if (name == "Property Box Layout") {
         return ValueProperty;
     }
+    if (name == "Window Type") {
+        return ValueProperty;
+    }
     return InvalidProperty;
 }
 
@@ -82,6 +91,12 @@
         return m_propertyBoxLayout == Layered ? 1 : 0;
     }        
 
+    if (name == "Window Type") {
+        if (min) *min = int(RectangularWindow);
+        if (max) *max = int(ParzenWindow);
+        return int(m_windowType);
+    }
+
     return 0;
 }
 
@@ -93,6 +108,17 @@
         if (value == 0) return tr("Vertically Stacked");
         else return tr("Layered");
     }
+    if (name == "Window Type") {
+        switch (WindowType(value)) {
+        case RectangularWindow: return tr("Rectangular");
+        case BartlettWindow: return tr("Bartlett");
+        case HammingWindow: return tr("Hamming");
+        case HanningWindow: return tr("Hanning");
+        case BlackmanWindow: return tr("Blackman");
+        case GaussianWindow: return tr("Gaussian");
+        case ParzenWindow: return tr("Parzen");
+        }
+    }
     return "";
 }
 
@@ -117,6 +143,8 @@
         //!!!
     } else if (name == "Property Box Layout") {
         setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
+    } else if (name == "Window Type") {
+        setWindowType(WindowType(value));
     }
 }
 
@@ -147,3 +175,12 @@
     }
 }
 
+void
+Preferences::setWindowType(WindowType type)
+{
+    if (m_windowType != type) {
+        m_windowType = type;
+        //!!! emit
+    }
+}
+
--- a/base/Preferences.h	Wed Jul 19 16:55:29 2006 +0000
+++ b/base/Preferences.h	Thu Jul 20 16:51:20 2006 +0000
@@ -18,6 +18,8 @@
 
 #include "PropertyContainer.h"
 
+#include "Window.h"
+
 class Preferences : public PropertyContainer
 {
     Q_OBJECT
@@ -35,6 +37,7 @@
 
     bool getSmoothSpectrogram() const { return m_smoothSpectrogram; }
     float getTuningFrequency() const { return m_tuningFrequency; }
+    WindowType getWindowType() const { return m_windowType; }
 
     //!!! harmonise with PaneStack
     enum PropertyBoxLayout {
@@ -49,6 +52,7 @@
     void setSmoothSpectrogram(bool smooth);
     void setTuningFrequency(float freq);
     void setPropertyBoxLayout(PropertyBoxLayout layout);
+    void setWindowType(WindowType type);
 
 private:
     Preferences(); 
@@ -59,6 +63,7 @@
     bool m_smoothSpectrogram;
     float m_tuningFrequency;
     PropertyBoxLayout m_propertyBoxLayout;
+    WindowType m_windowType;
 };
 
 #endif
--- a/base/View.cpp	Wed Jul 19 16:55:29 2006 +0000
+++ b/base/View.cpp	Thu Jul 20 16:51:20 2006 +0000
@@ -31,7 +31,7 @@
 #include <cassert>
 #include <math.h>
 
-#define DEBUG_VIEW_WIDGET_PAINT 1
+//#define DEBUG_VIEW_WIDGET_PAINT 1
 
 using std::cerr;
 using std::endl;
--- a/base/Window.h	Wed Jul 19 16:55:29 2006 +0000
+++ b/base/Window.h	Thu Jul 20 16:51:20 2006 +0000
@@ -53,6 +53,8 @@
 	for (size_t i = 0; i < m_size; ++i) dst[i] = src[i] * m_cache[i];
     }
 
+    T getValue(size_t i) { return m_cache[i]; }
+
     WindowType getType() const { return m_type; }
     size_t getSize() const { return m_size; }