changeset 10:8f5b812baaee

* Hook up SV file i/o. You can now save and load sessions. Some problems -- gain is not reloaded correctly for waveforms, reloaded panes are not properly reconnected to the panner, and no doubt plenty of others.
author Chris Cannam
date Tue, 17 Jan 2006 17:45:55 +0000
parents 561be41ad083
children 2d5005f2b3d9
files layer/SpectrogramLayer.cpp layer/TimeInstantLayer.cpp layer/TimeRulerLayer.cpp layer/TimeValueLayer.cpp layer/WaveformLayer.cpp
diffstat 5 files changed, 26 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Mon Jan 16 18:04:09 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Tue Jan 17 17:45:55 2006 +0000
@@ -142,6 +142,10 @@
 {
     int deft = 0;
 
+    int throwaway;
+    if (!min) min = &throwaway;
+    if (!max) max = &throwaway;
+
     if (name == tr("Gain")) {
 
 	*min = -50;
@@ -552,18 +556,9 @@
     // don't need to invalidate main cache here
     m_pixmapCacheInvalid = true;
     
-    int formerColourRotation = m_colourRotation;
-
     m_colourScheme = scheme;
     setCacheColourmap();
 
-    int distance = formerColourRotation - m_colourRotation;
-
-    if (distance != 0) {
-	rotateCacheColourmap(-distance);
-	m_colourRotation = formerColourRotation;
-    }
-
     m_mutex.unlock();
 
     emit layerParametersChanged();
@@ -685,6 +680,8 @@
 {
     if (m_cacheInvalid || !m_cache) return;
 
+    int formerRotation = m_colourRotation;
+
     m_cache->setNumColors(256);
     
     m_cache->setColor(0, qRgb(255, 255, 255));
@@ -735,11 +732,15 @@
     }
 
     m_colourRotation = 0;
+    rotateCacheColourmap(m_colourRotation - formerRotation);
+    m_colourRotation = formerRotation;
 }
 
 void
 SpectrogramLayer::rotateCacheColourmap(int distance)
 {
+    if (!m_cache) return;
+
     QRgb newPixels[256];
 
     newPixels[0] = m_cache->color(0);
@@ -914,7 +915,7 @@
 	    MUNLOCK((void *)m_layer.m_cache, width * height);
     
 	    m_layer.setCacheColourmap();
-    
+
 	    m_layer.m_cache->fill(0);
 	    m_layer.m_mutex.unlock();
 
@@ -1441,13 +1442,13 @@
 	    }
 		    
 	    if (divisor > 0.0) {
-
+/*
 		int pixel = int(total / divisor);
 		if (pixel > 255) pixel = 255;
 		if (pixel < 1) pixel = 1;
 		assert(x <= scaled.width());
 		scaled.setPixel(x, y, m_cache->color(pixel));
-/*
+*/
 		float pixel = total / divisor;
 		float lq = pixel - int(pixel);
 		float hq = int(pixel) + 1 - pixel;
@@ -1459,7 +1460,7 @@
 		     qGreen(low) * lq + qGreen(high) * hq + 0.01,
 		     qBlue(low) * lq + qBlue(high) * hq + 0.01);
 		scaled.setPixel(x, y, mixed);
-*/
+
 	    } else {
 		assert(x <= scaled.width());
 		scaled.setPixel(x, y, qRgb(0, 0, 0));
--- a/layer/TimeInstantLayer.cpp	Mon Jan 16 18:04:09 2006 +0000
+++ b/layer/TimeInstantLayer.cpp	Tue Jan 17 17:45:55 2006 +0000
@@ -68,8 +68,8 @@
 
     if (name == tr("Colour")) {
 
-	*min = 0;
-	*max = 5;
+	if (min) *min = 0;
+	if (max) *max = 5;
 
 	if (m_colour == Qt::black) deft = 0;
 	else if (m_colour == Qt::darkRed) deft = 1;
--- a/layer/TimeRulerLayer.cpp	Mon Jan 16 18:04:09 2006 +0000
+++ b/layer/TimeRulerLayer.cpp	Tue Jan 17 17:45:55 2006 +0000
@@ -67,8 +67,8 @@
 
     if (name == tr("Colour")) {
 
-	*min = 0;
-	*max = 5;
+	if (min) *min = 0;
+	if (max) *max = 5;
 
 	if (m_colour == Qt::black) deft = 0;
 	else if (m_colour == Qt::darkRed) deft = 1;
--- a/layer/TimeValueLayer.cpp	Mon Jan 16 18:04:09 2006 +0000
+++ b/layer/TimeValueLayer.cpp	Tue Jan 17 17:45:55 2006 +0000
@@ -74,8 +74,8 @@
 
     if (name == tr("Colour")) {
 
-	*min = 0;
-	*max = 5;
+	if (min) *min = 0;
+	if (max) *max = 5;
 
 	if (m_colour == Qt::black) deft = 0;
 	else if (m_colour == Qt::darkRed) deft = 1;
@@ -86,8 +86,8 @@
 
     } else if (name == tr("Plot Type")) {
 	
-	*min = 0;
-	*max = 4;
+	if (min) *min = 0;
+	if (max) *max = 4;
 	
 	deft = int(m_plotStyle);
 
--- a/layer/WaveformLayer.cpp	Mon Jan 16 18:04:09 2006 +0000
+++ b/layer/WaveformLayer.cpp	Tue Jan 17 17:45:55 2006 +0000
@@ -98,6 +98,10 @@
 {
     int deft = 0;
 
+    int throwaway;
+    if (!min) min = &throwaway;
+    if (!max) max = &throwaway;
+
     if (name == tr("Gain")) {
 
 	*min = -50;