From 090660a7ae8cf51f2cc300f733fcffc76fb8f3e6 Mon Sep 17 00:00:00 2001
From: jsiegle <jsiegle@mit.edu>
Date: Sun, 22 Apr 2012 14:37:29 -0400
Subject: [PATCH] Reorganized layout of SpikeDisplayCanvas

---
 Source/Processors/Editors/GenericEditor.cpp   |   2 +
 Source/Processors/Editors/GenericEditor.h     |   1 +
 .../Editors/SpikeDetectorEditor.cpp           |  11 +-
 .../Processors/Editors/SpikeDisplayEditor.cpp |  36 ++++-
 .../Processors/Editors/SpikeDisplayEditor.h   |   3 +
 Source/Processors/GenericProcessor.cpp        |   1 +
 Source/Processors/GenericProcessor.h          |   9 ++
 Source/Processors/SpikeDetector.cpp           |  56 ++++---
 Source/Processors/SpikeDisplayNode.cpp        |  52 +++++-
 Source/Processors/SpikeDisplayNode.h          |   5 +-
 .../Visualization/LfpDisplayCanvas.cpp        |  26 +--
 .../Processors/Visualization/OpenGLCanvas.cpp |   4 +
 .../Visualization/SpikeDisplayCanvas.cpp      | 151 ++++++------------
 .../Visualization/SpikeDisplayCanvas.h        |   8 +-
 14 files changed, 195 insertions(+), 170 deletions(-)

diff --git a/Source/Processors/Editors/GenericEditor.cpp b/Source/Processors/Editors/GenericEditor.cpp
index 4634d80c5..0895d8250 100644
--- a/Source/Processors/Editors/GenericEditor.cpp
+++ b/Source/Processors/Editors/GenericEditor.cpp
@@ -360,6 +360,8 @@ void GenericEditor::update()
 			drawerButton->setVisible(true);
 	}
 
+	updateSettings();
+
 	updateVisualizer(); // does nothing unless this method
 						// has been implemented
 
diff --git a/Source/Processors/Editors/GenericEditor.h b/Source/Processors/Editors/GenericEditor.h
index 3f4f1af73..b6515c5c4 100644
--- a/Source/Processors/Editors/GenericEditor.h
+++ b/Source/Processors/Editors/GenericEditor.h
@@ -108,6 +108,7 @@ public:
 	void refreshColors();
 
 	virtual void update();
+	virtual void updateSettings() {}
 	virtual void updateVisualizer() {}
 
 	Array<int> getActiveChannels();
diff --git a/Source/Processors/Editors/SpikeDetectorEditor.cpp b/Source/Processors/Editors/SpikeDetectorEditor.cpp
index f61fafd37..e46dcb584 100644
--- a/Source/Processors/Editors/SpikeDetectorEditor.cpp
+++ b/Source/Processors/Editors/SpikeDetectorEditor.cpp
@@ -23,6 +23,7 @@
 
 #include "SpikeDetectorEditor.h"
 #include "../SpikeDetector.h"
+#include "../../UI/EditorViewport.h"
 #include <stdio.h>
 
 
@@ -51,7 +52,7 @@ SpikeDetectorEditor::SpikeDetectorEditor (GenericProcessor* parentNode)
     electrodeTypes->setJustificationType (Justification::centredLeft);
     electrodeTypes->addListener(this);
     electrodeTypes->setBounds(65,40,130,16);
-    electrodeTypes->setSelectedId(4);
+    electrodeTypes->setSelectedId(2);
     addAndMakeVisible(electrodeTypes);
 
     electrodeList = new ComboBox("Electrode List");
@@ -61,7 +62,7 @@ SpikeDetectorEditor::SpikeDetectorEditor (GenericProcessor* parentNode)
     electrodeList->setBounds(20,80,115,20);
     addAndMakeVisible(electrodeList);
 
-    numElectrodes = new Label("Number of Electrodes","4");
+    numElectrodes = new Label("Number of Electrodes","2");
     numElectrodes->setEditable(true);
     numElectrodes->addListener(this);
     numElectrodes->setBounds(30,40,25,20);
@@ -149,6 +150,8 @@ void SpikeDetectorEditor::buttonEvent(Button* button)
 
         drawElectrodeButtons(electrodeList->getNumItems()-1);
 
+        getEditorViewport()->makeEditorVisible(this);
+
     } else if (button == electrodeEditorButtons[0]) // EDIT
     {
 
@@ -220,7 +223,7 @@ void SpikeDetectorEditor::labelTextChanged(Label* label)
 {
     if (label->getText().equalsIgnoreCase("1") && isPlural)
     {
-        for (int n = 1; n < 21; n++)
+        for (int n = 1; n < electrodeTypes->getNumItems()+1; n++)
         {
             electrodeTypes->changeItemText(n,
                     electrodeTypes->getItemText(n-1).trimCharactersAtEnd("s"));
@@ -236,7 +239,7 @@ void SpikeDetectorEditor::labelTextChanged(Label* label)
         const String s = "s";
         size_t one = 1;
 
-        for (int n = 1; n < 21; n++)
+        for (int n = 1; n < electrodeTypes->getNumItems()+1; n++)
         {
             String currentString = electrodeTypes->getItemText(n-1);
             currentString += "s";
diff --git a/Source/Processors/Editors/SpikeDisplayEditor.cpp b/Source/Processors/Editors/SpikeDisplayEditor.cpp
index b55ac351e..7e4117c86 100644
--- a/Source/Processors/Editors/SpikeDisplayEditor.cpp
+++ b/Source/Processors/Editors/SpikeDisplayEditor.cpp
@@ -1,7 +1,28 @@
-#include "SpikeDisplayEditor.h"
-#include <string>
+/*
+    ------------------------------------------------------------------
+
+    This file is part of the Open Ephys GUI
+    Copyright (C) 2012 Open Ephys
+
+    ------------------------------------------------------------------
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
 
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+*/
+
+#include "SpikeDisplayEditor.h"
+#include <string>
 
 SpikeDisplayEditor::SpikeDisplayEditor (GenericProcessor* parentNode) 
 	: VisualizerEditor(parentNode,200)
@@ -153,6 +174,17 @@ Visualizer* SpikeDisplayEditor::createNewCanvas()
 
 }
 
+// void SpikeDisplayEditor::updateSettings()
+// {
+// 	// called by base class
+
+// }
+
+// void SpikeDisplayEditor::updateVisualizer()
+// {
+	
+// }
+
 void SpikeDisplayEditor::buttonCallback(Button* button)
 {
 	//std::cout<<"Got event from component:"<<button<<std::endl;
diff --git a/Source/Processors/Editors/SpikeDisplayEditor.h b/Source/Processors/Editors/SpikeDisplayEditor.h
index e5d4fd393..1124ca2c6 100644
--- a/Source/Processors/Editors/SpikeDisplayEditor.h
+++ b/Source/Processors/Editors/SpikeDisplayEditor.h
@@ -44,6 +44,9 @@ public:
 
 	void buttonCallback (Button* button);
 
+    // void updateSettings();
+    // void updateVisualizer();
+
 	Visualizer* createNewCanvas();
 
 private:	
diff --git a/Source/Processors/GenericProcessor.cpp b/Source/Processors/GenericProcessor.cpp
index a24af8954..49b896801 100644
--- a/Source/Processors/GenericProcessor.cpp
+++ b/Source/Processors/GenericProcessor.cpp
@@ -283,6 +283,7 @@ void GenericProcessor::clearSettings()
 	settings.bitVolts.clear();
 	settings.eventChannelIds.clear();
 	settings.eventChannelNames.clear();
+	settings.eventChannelTypes.clear();
 }
 
 void GenericProcessor::update()
diff --git a/Source/Processors/GenericProcessor.h b/Source/Processors/GenericProcessor.h
index d530a434b..6d235dffe 100644
--- a/Source/Processors/GenericProcessor.h
+++ b/Source/Processors/GenericProcessor.h
@@ -193,6 +193,14 @@ public:
  		CONTINUOUS = 6
  	};
 
+ 	enum eventChannelTypes
+ 	{
+ 		GENERIC_EVENT = 999,
+ 		SINGLE_ELECTRODE = 1,
+ 		STEREOTRODE = 2,
+ 		TETRODE = 4
+ 	};
+
 	int saveOrder;
 	int loadOrder;
 
@@ -215,6 +223,7 @@ public:
 
 		Array<int> eventChannelIds;
 		StringArray eventChannelNames;
+		Array<int> eventChannelTypes;
 
 	};
 
diff --git a/Source/Processors/SpikeDetector.cpp b/Source/Processors/SpikeDetector.cpp
index ff8dcef3b..58618068a 100644
--- a/Source/Processors/SpikeDetector.cpp
+++ b/Source/Processors/SpikeDetector.cpp
@@ -29,29 +29,34 @@ SpikeDetector::SpikeDetector()
       overflowBuffer(2,100), dataBuffer(overflowBuffer)
 	
 {
-
-    electrodeTypes.add("hentrode");
-    electrodeTypes.add("duotrode");
-    electrodeTypes.add("triode");
+    //// the standard form:
+    electrodeTypes.add("single electrode");
+    electrodeTypes.add("stereotrode");
     electrodeTypes.add("tetrode");
-    electrodeTypes.add("pentrode");
-    electrodeTypes.add("hextrode");
-    electrodeTypes.add("heptrode");
-    electrodeTypes.add("octrode");
-    electrodeTypes.add("enneatrode");
-    electrodeTypes.add("decatrode");
-    electrodeTypes.add("hendecatrode");
-    electrodeTypes.add("dodecatrode");
-    electrodeTypes.add("triskaidecatrode");
-    electrodeTypes.add("tetrakaidecatrode");
-    electrodeTypes.add("pentakaidecatrode");
-    electrodeTypes.add("hexadecatrode");
-    electrodeTypes.add("heptakaidecatrode");
-    electrodeTypes.add("octakaidecatrode");
-    electrodeTypes.add("enneakaidecatrode");
-    electrodeTypes.add("icosatrode");
-
-    for (int i = 0; i < 21; i++)
+
+    //// the technically correct form (Greek cardinal prefixes):
+    // electrodeTypes.add("hentrode");
+    // electrodeTypes.add("duotrode");
+    // electrodeTypes.add("triode");
+    // electrodeTypes.add("tetrode");
+    // electrodeTypes.add("pentrode");
+    // electrodeTypes.add("hextrode");
+    // electrodeTypes.add("heptrode");
+    // electrodeTypes.add("octrode");
+    // electrodeTypes.add("enneatrode");
+    // electrodeTypes.add("decatrode");
+    // electrodeTypes.add("hendecatrode");
+    // electrodeTypes.add("dodecatrode");
+    // electrodeTypes.add("triskaidecatrode");
+    // electrodeTypes.add("tetrakaidecatrode");
+    // electrodeTypes.add("pentakaidecatrode");
+    // electrodeTypes.add("hexadecatrode");
+    // electrodeTypes.add("heptakaidecatrode");
+    // electrodeTypes.add("octakaidecatrode");
+    // electrodeTypes.add("enneakaidecatrode");
+    // electrodeTypes.add("icosatrode");
+
+    for (int i = 0; i < electrodeTypes.size()+1; i++)
     {
         electrodeCounter.add(0);
     }
@@ -75,6 +80,13 @@ void SpikeDetector::updateSettings()
 
     overflowBuffer.setSize(getNumInputs(),overflowBufferSize);
 
+    for (int i = 0; i < electrodes.size(); i++)
+    {
+       settings.eventChannelIds.add(i);
+       settings.eventChannelNames.add(electrodes[i]->name);
+       settings.eventChannelTypes.add(electrodes[i]->numChannels);
+    }
+
 }
 
 bool SpikeDetector::addElectrode(int nChans)
diff --git a/Source/Processors/SpikeDisplayNode.cpp b/Source/Processors/SpikeDisplayNode.cpp
index b48c32e57..12208d58a 100644
--- a/Source/Processors/SpikeDisplayNode.cpp
+++ b/Source/Processors/SpikeDisplayNode.cpp
@@ -50,11 +50,16 @@ AudioProcessorEditor* SpikeDisplayNode::createEditor()
 
 }
 
-void SpikeDisplayNode::updateSettings()
-{
-	std::cout << "Setting num inputs on SpikeDisplayNode to " << getNumInputs() << std::endl;
-}
+// void SpikeDisplayNode::updateSettings()
+// {
+// 	//std::cout << "Setting num inputs on SpikeDisplayNode to " << getNumInputs() << std::endl;
+
+// }
+
+// void SpikeDisplayNode::updateVisualizer()
+// {
 
+// }
 
 bool SpikeDisplayNode::enable()
 {
@@ -73,9 +78,42 @@ bool SpikeDisplayNode::disable()
 	return true;
 }
 
-int SpikeDisplayNode::getNumberOfChannelsForInput(int i){
-	std::cout<<"SpikeDisplayNode::getNumberOfChannelsForInput()"<<std::endl;
-	return 1;
+int SpikeDisplayNode::getNumberOfChannelsForElectrode(int i)
+{
+	//std::cout<<"SpikeDisplayNode::getNumberOfChannelsForInput()"<<std::endl;
+	
+	int electrodeIndex = -1;
+
+	for (int i = 0; i < settings.eventChannelTypes.size(); i++)
+	{
+		if (settings.eventChannelTypes[i] < 999)
+		{
+			electrodeIndex++;
+
+			if (electrodeIndex == i)
+			{
+				return settings.eventChannelTypes[i];
+			}
+		}
+	}
+
+	return 0;
+}
+
+int SpikeDisplayNode::getNumElectrodes()
+{
+	int nElectrodes = 0;
+
+	for (int i = 0; i < settings.eventChannelTypes.size(); i++)
+	{
+		if (settings.eventChannelTypes[i] < 999)
+		{
+			nElectrodes++;
+		}
+	}
+
+	return nElectrodes;
+
 }
 
 
diff --git a/Source/Processors/SpikeDisplayNode.h b/Source/Processors/SpikeDisplayNode.h
index 7b48706e4..fdd01a401 100644
--- a/Source/Processors/SpikeDisplayNode.h
+++ b/Source/Processors/SpikeDisplayNode.h
@@ -64,12 +64,13 @@ public:
 
 	void setParameter(int, float);
 
-	void updateSettings();
+	//void updateSettings();
 
 	bool enable();
 	bool disable();
 
-	int getNumberOfChannelsForInput(int i);
+	int getNumberOfChannelsForElectrode(int i);
+	int getNumElectrodes();
 
 	bool getNextSpike(SpikeObject *spike);
 	
diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.cpp b/Source/Processors/Visualization/LfpDisplayCanvas.cpp
index 54ce9160e..ae1ba15a6 100644
--- a/Source/Processors/Visualization/LfpDisplayCanvas.cpp
+++ b/Source/Processors/Visualization/LfpDisplayCanvas.cpp
@@ -234,9 +234,9 @@ void LfpDisplayCanvas::renderOpenGL()
 			drawWaveform(i,isSelected);
 		}	
 	}
-	drawScrollBars();
 
-	//std::cout << "Render." << std::endl;
+	drawScrollBars();
+	
 }
 
 void LfpDisplayCanvas::drawWaveform(int chan, bool isSelected)
@@ -367,25 +367,3 @@ void LfpDisplayCanvas::mouseDownInCanvas(const MouseEvent& e)
 	}
 
 }
-
-// void LfpDisplayCanvas::mouseDrag(const MouseEvent& e) {mouseDragInCanvas(e);}
-// void LfpDisplayCanvas::mouseMove(const MouseEvent& e) {mouseMoveInCanvas(e);}
-// void LfpDisplayCanvas::mouseUp(const MouseEvent& e) 	{mouseUpInCanvas(e);}
-// void LfpDisplayCanvas::mouseWheelMove(const MouseEvent& e, float a, float b) {mouseWheelMoveInCanvas(e,a,b);}
-
-// void LfpDisplayCanvas::resized()
-// {
-// 	//screenBuffer = new AudioSampleBuffer(nChans, getWidth());
-
-// 	// glClear(GL_COLOR_BUFFER_BIT);
-
-// 	// //int h = getParentComponent()->getHeight();
-
-// 	// if (scrollPix + getHeight() > getTotalHeight() && getTotalHeight() > getHeight())
-// 	// 	scrollPix = getTotalHeight() - getHeight();
-// 	// else
-// 	// 	scrollPix = 0;
-
-// 	// showScrollBars();
-// 	canvasWasResized();
-// }
\ No newline at end of file
diff --git a/Source/Processors/Visualization/OpenGLCanvas.cpp b/Source/Processors/Visualization/OpenGLCanvas.cpp
index a51104ccb..8577f66ab 100644
--- a/Source/Processors/Visualization/OpenGLCanvas.cpp
+++ b/Source/Processors/Visualization/OpenGLCanvas.cpp
@@ -210,6 +210,8 @@ void OpenGLCanvas::stopCallbacks()
 
 void OpenGLCanvas::drawScrollBars()
 {
+
+	//std::cout << "Drawing scroll bars" << std::endl;
 	
 	float scrollBarY = float(getHeight())/float(getTotalHeight());
 	float timeSinceScroll = timer->getMillisecondCounter()-scrollTime;
@@ -245,6 +247,8 @@ void OpenGLCanvas::drawScrollBars()
 void OpenGLCanvas::drawScrollBar(float y1, float y2, float alpha)
 {
 	glViewport(0,0,getWidth(),getHeight());
+	glOrtho (0, 1, 1, 0, 0, 1);
+	//setViewportRange(0, 0, getWidth(), getHeight());
 
 	float x1 = (getWidth()-8.0f)/getWidth();
 	float x2 = (getWidth()-2.0f)/getWidth();
diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
index 4e98409f6..9747f2825 100644
--- a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
+++ b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp
@@ -28,16 +28,17 @@ SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) : processor(n),
 	 	totalScrollPix(0)
 {
 
-	
+	nCols = 3;
 
-	nPlots = 1; //8;
-	nCols = 3; //processor->getNumInputs();
-	std::cout<<"SpikeDisplayNode has :"<<nPlots<<" outputs!"<<std::endl;
+	update();
+	
+	
+	// std::cout<<"SpikeDisplayNode has :"<<nPlots<<" outputs!"<<std::endl;
 	
-	for (int i=0; i<nPlots; i++)
-		nChannels[i] = processor->getNumberOfChannelsForInput(i);
+	// // for (int i=0; i<nPlots; i++)
+	// // 	nChannels[i] = processor->getNumberOfChannelsForElectrode(i);
 
-	std::cout << "Setting num inputs on SpikeDisplayCanvas to " << nPlots << std::endl;
+	// std::cout << "Setting num inputs on SpikeDisplayCanvas to " << nPlots << std::endl;
 	
 	
 	
@@ -49,15 +50,21 @@ SpikeDisplayCanvas::~SpikeDisplayCanvas()
 }
 
 void SpikeDisplayCanvas::initializeSpikePlots(){
+
 	std::cout<<"Initializing Plots"<<std::endl;
 
+	if (plots.size() != nPlots)
+	{
+
 	int totalWidth = getWidth(); 
 	
 	int plotWidth =  (totalWidth - yBuffer * ( nCols+1)) / nCols + .99;
 	int plotHeight = plotWidth / 2 + .5;
 	int rowCount = 0;
 
-	for (int i=0; i<nPlots; i++)
+	plots.clear();
+
+	for (int i=0; i < nPlots; i++)
 	{
 
 		StereotrodePlot p = StereotrodePlot( 
@@ -76,11 +83,13 @@ void SpikeDisplayCanvas::initializeSpikePlots(){
 
 	}
 
-	totalHeight = rowCount * (plotHeight + yBuffer) + yBuffer * 2;
+	//totalHeight = rowCount * (plotHeight + yBuffer) + yBuffer * 2;
 
 	// Set the total height of the Canvas to the top of the top most plot
 	plotsInitialized = true;
+
 	repositionSpikePlots();
+	}
 }
 
 void SpikeDisplayCanvas::repositionSpikePlots(){
@@ -91,11 +100,11 @@ void SpikeDisplayCanvas::repositionSpikePlots(){
 	int plotHeight = plotWidth / 2 + .5;
 	int rowCount = 0;
 
-	for (int i=0; i<plots.size(); i++)
+	for (int i=0; i < plots.size(); i++)
 	{
 
 		plots[i].setPosition(	xBuffer + i%nCols * (plotWidth + xBuffer) , 
-								yBuffer + rowCount * (plotHeight + yBuffer), 
+								getHeight() - ( yBuffer + plotHeight + rowCount * (plotHeight + yBuffer)) + getScrollAmount(), 
 								plotWidth, 
 								plotHeight); // deprecated conversion from string constant to char
 
@@ -104,7 +113,7 @@ void SpikeDisplayCanvas::repositionSpikePlots(){
 	 }
 
 	// Set the total height of the Canvas to the top of the top most plot
-	totalHeight = rowCount * (plotHeight + yBuffer) + yBuffer * 2;
+	totalHeight = (rowCount + 1) * (plotHeight + yBuffer) + yBuffer;
 }
 
 void SpikeDisplayCanvas::newOpenGLContextCreated()
@@ -116,19 +125,12 @@ void SpikeDisplayCanvas::newOpenGLContextCreated()
 
 	glClearColor (0.667, 0.698, 0.918, 1.0);
 	resized();
-	endAnimation();
+	//endAnimation();
 }
 
 void SpikeDisplayCanvas::beginAnimation()
 {
 	std::cout << "Beginning animation." << std::endl;
-
-	// displayBufferSize = displayBuffer->getNumSamples();
-
-	// screenBuffer->clear();
-
-	//displayBufferIndex = 0;
-//	screenBufferIndex = 0;
 	
 	startCallbacks();
 }
@@ -141,19 +143,14 @@ void SpikeDisplayCanvas::endAnimation()
 
 void SpikeDisplayCanvas::update()
 {
-	// nChans = processor->getNumInputs();
-	// sampleRate = processor->getSampleRate();
 
-	// std::cout << "Setting num inputs on SpikeDisplayCanvas to " << nChans << std::endl;
-	// if (nChans < 200 && nChans > 0)
-	// 	screenBuffer->setSize(nChans, 10000);
-	// //sampleRate = processor->getSampleRate();
+	std::cout << "UPDATING SpikeDisplayCanvas" << std::endl;
 
-    // screenBuffer->clear();
+	nPlots = processor->getNumElectrodes();
 
-	repaint();
+	initializeSpikePlots();
 
-	// totalHeight = (plotHeight+yBuffer)*nChans + yBuffer;
+	repaint();
 }
 
 
@@ -198,7 +195,7 @@ void SpikeDisplayCanvas::refreshState()
 	// screenBufferIndex = 0;
 
 	//resized();
-	totalScrollPix = 0;
+	//totalScrollPix = 0;
 }
 
 void SpikeDisplayCanvas::canvasWasResized()
@@ -208,12 +205,13 @@ void SpikeDisplayCanvas::canvasWasResized()
 
 void SpikeDisplayCanvas::renderOpenGL()
 {
-	if(!plotsInitialized)
-		initializeSpikePlots();
+	//if(!plotsInitialized)
+	//	initializeSpikePlots();
 
-	glClearColor (0.667, 0.698, 0.718, 1.0);
+	glClearColor (0.667, 0.698, 0.918, 1.0);
 	glClear(GL_COLOR_BUFFER_BIT); // clear buffers to preset values
-//	std::cout<<"SpikeDisplayCanvas::renderOpenGL"<<std::endl;
+
+	//std::cout<<"SpikeDisplayCanvas::renderOpenGL"<<std::endl;
 	// Get Spikes from the processor
 	// Iterate through each spike, passing them individually to the appropriate plots and calling redraw before moving on to the next spike
 	
@@ -224,8 +222,9 @@ void SpikeDisplayCanvas::renderOpenGL()
 	
 	// Distribute thoses spike to the appropriate plot object
 	
-	
+	// Generate fake spikes
 	SpikeObject tmpSpike;
+
 	 for (int i=0; i<plots.size(); i++){
 		generateSimulatedSpike(&tmpSpike, 0, 150);
 		plots[i].processSpikeObject(tmpSpike);
@@ -255,12 +254,13 @@ void SpikeDisplayCanvas::drawPlotTitle(int chan){
 	String s = "Source:";//String("Channel ");
 	s += (chan+1);
 
-	getFont(String("cpmono-bold"))->FaceSize(25);
+	getFont(String("cpmono-bold"))->FaceSize(15);
 	getFont(String("cpmono-bold"))->Render(s);
 }
 
 int SpikeDisplayCanvas::getTotalHeight() 
 {
+	//std::cout << "TOTAL HEIGHT = " << totalHeight << std::endl;
 	return totalHeight;
 }
 
@@ -285,7 +285,7 @@ void SpikeDisplayCanvas::mouseDownInCanvas(const MouseEvent& e)
 
 // void SpikeDisplayCanvas::mouseDrag(const MouseEvent& e) {mouseDragInCanvas(e);}
 // void SpikeDisplayCanvas::mouseMove(const MouseEvent& e) {mouseMoveInCanvas(e);}
-void SpikeDisplayCanvas::mouseUp(const MouseEvent& e) 	{
+void SpikeDisplayCanvas::mouseUpInCanvas(const MouseEvent& e) 	{
 	// std::cout<<"Mouse Event!"<<std::endl;
 
 	// bool inout = false;
@@ -300,54 +300,15 @@ void SpikeDisplayCanvas::mouseUp(const MouseEvent& e) 	{
 	// else
 	// 	panPlot(0,0,inout);
 }
-void SpikeDisplayCanvas::mouseWheelMove(const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) {
-
-	// std::cout<<"Mouse Wheel Move:"<< wheelIncrementX<<","<<wheelIncrementY;
-	// std::cout<<" Scroll Pix:"<<scrollPix<<std::endl;
-
-	int scrollAmount = 0;
-	// std::cout<<getTotalHeight()<<" "<<getHeight()<<std::endl;
-
-	if (getTotalHeight() > getHeight()) {
-		//if (wheelIncrementY > 0 )
-			scrollAmount += int(100.0f*wheelIncrementY);	
-		//else if (wheelIncrementY < 0)
-			
-		totalScrollPix += scrollAmount;
-		
-		// don't let the user scroll too far down
-		int minScrollDown = (-1 * totalHeight) + getHeight();
-		int maxScrollUp = 0; // never scroll plots up, there is nothing below the bottom plot
-
-		// std::cout<<"TotalScrollPix:"<<totalScrollPix<<" min:"<<minScrollDown<<" max:"<<maxScrollUp<<std::endl;
-		
-		if (totalScrollPix < minScrollDown){
-			totalScrollPix= minScrollDown;
-			scrollAmount = 0;
-		}
-		
-		else if (totalScrollPix > maxScrollUp)
-		{
-			totalScrollPix = maxScrollUp;
-			scrollAmount = 0;
-		}
-
-		for (int i=0; i<plots.size(); i++){
-			int x,y;
-			double w,h;
-			plots[i].getPosition(&x, &y, &w, &h);
-			plots[i].setPosition(x,y+scrollAmount, w, h);
-		}
-
-		scrollPix = 0;//totalScrollPix;
-
-		repaint();
+void SpikeDisplayCanvas::mouseWheelMoveInCanvas(const MouseEvent& e, float wheelIncrementX, float wheelIncrementY)
+{
 
-		showScrollBars();
+	repositionSpikePlots();
 
-	}
+	repaint();
+	//repaint();
 
-	mouseWheelMoveInCanvas(e, wheelIncrementX, wheelIncrementY);
+	// mouseWheelMoveInCanvas(e, wheelIncrementX, wheelIncrementY);
 }
 
 void SpikeDisplayCanvas::panPlot(int p, int c, bool up){
@@ -364,27 +325,7 @@ void SpikeDisplayCanvas::zoomPlot(int p, int c, bool in){
 	plots[p].zoom(c, in);
 }
 
-void SpikeDisplayCanvas::disablePointSmoothing(){
-
-//	glDisable(GL_LINE_SMOOTH);
-	glDisable(GL_POINT_SMOOTH);
-//	glDisable(GL_POLYGON_SMOOTH);
-
+void SpikeDisplayCanvas::disablePointSmoothing()
+{
+	glDisable(GL_POINT_SMOOTH); // needed to make projections visible
 }
-
-// void SpikeDisplayCanvas::resized()
-// {
-// 	//screenBuffer = new AudioSampleBuffer(nChans, getWidth());
-
-// 	// glClear(GL_COLOR_BUFFER_BIT);
-
-// 	// //int h = getParentComponent()->getHeight();
-
-// 	// if (scrollPix + getHeight() > getTotalHeight() && getTotalHeight() > getHeight())
-// 	// 	scrollPix = getTotalHeight() - getHeight();
-// 	// else
-// 	// 	scrollPix = 0;
-
-// 	// showScrollBars();
-// 	canvasWasResized();
-// }
\ No newline at end of file
diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.h b/Source/Processors/Visualization/SpikeDisplayCanvas.h
index e2bb49101..544192ee1 100644
--- a/Source/Processors/Visualization/SpikeDisplayCanvas.h
+++ b/Source/Processors/Visualization/SpikeDisplayCanvas.h
@@ -115,10 +115,10 @@ private:
 	void disablePointSmoothing();
 	void canvasWasResized();
 	void mouseDownInCanvas(const MouseEvent& e);
-	// void mouseDrag(const MouseEvent& e);
-	// void mouseMove(const MouseEvent& e);
-	void mouseUp(const MouseEvent& e);
-	void mouseWheelMove(const MouseEvent&, float, float);
+	//void mouseDragInCanvas(const MouseEvent& e);
+	//void mouseMoveInCanvas(const MouseEvent& e);
+	void mouseUpInCanvas(const MouseEvent& e);
+	void mouseWheelMoveInCanvas(const MouseEvent&, float, float);
 
 	JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpikeDisplayCanvas);
 	
-- 
GitLab