Skip to content
Snippets Groups Projects
Commit 768da1d7 authored by Stuart Layton's avatar Stuart Layton
Browse files

minor updates to the generation of spikeobjects and the way that plots are...

minor updates to the generation of spikeobjects and the way that plots are laid out in the spike display canvas. Resizing causes the program to hang, not sure why...
parent 98c1dfad
Branches
Tags
No related merge requests found
......@@ -24,7 +24,7 @@
#include "SpikeDisplayCanvas.h"
SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) : processor(n),
xBuffer(25), yBuffer(25), newSpike(false)
xBuffer(25), yBuffer(25), newSpike(false), plotsInitialized(false)
{
......@@ -32,24 +32,13 @@ SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) : processor(n),
nSources = 0; //processor->getNumInputs();
std::cout<<"SpikeDisplayNode has :"<<nSources<<" outputs!"<<std::endl;
//memset(nChannels, 0, sizeof(nChannels[0]) * MAX_NUMBER_OF_SPIKE_SOURCES);
for (int i=0; i<nSources; i++)
nChannels[i] = processor->getNumberOfChannelsForInput(i);
// sampleRate = processor->getSampleRate();
std::cout << "Setting num inputs on SpikeDisplayCanvas to " << nSources << std::endl;
//generateEmptySpike(&spike, 1);
initializeSpikePlots();
// displayBuffer = processor->getDisplayBufferAddress();
// displayBufferSize = displayBuffer->getNumSamples();
// std::cout << "Setting displayBufferSize on SpikeDisplayCanvas to " << displayBufferSize << std::endl;
// totalHeight = (plotHeight+yBuffer)*nChans + yBuffer;
// screenBuffer = new AudioSampleBuffer(nChans, 10000);
}
SpikeDisplayCanvas::~SpikeDisplayCanvas()
......@@ -60,12 +49,13 @@ SpikeDisplayCanvas::~SpikeDisplayCanvas()
void SpikeDisplayCanvas::initializeSpikePlots(){
std::cout<<"Initializing Plots"<<std::endl;
int nPlots = 1;
int nPlots = 4;
int nCols = 2;
int totalWidth = 1000; // This is a hack the width as the width isn't known before its drawn
int totalWidth = getWidth(); // This is a hack the width as the width isn't known before its drawn
int plotWidth = (totalWidth - (nPlots + 1 ) * xBuffer) / nCols + .5;
int plotWidth = (totalWidth - yBuffer * ( nCols+1)) / nCols + .99;
int plotHeight = plotWidth / 2 + .5;
int rowCount = 0;
......@@ -90,10 +80,33 @@ void SpikeDisplayCanvas::initializeSpikePlots(){
}
// Set the total height of the Canvas to the top of the top most plot
totalHeight = yBuffer + (rowCount + 1) * (plotHeight + yBuffer);
plotsInitialized = true;
//repositionSpikePlots();
}
void SpikeDisplayCanvas::repositionSpikePlots(){
int nPlots = 4;
int nCols = 2;
int totalWidth = getWidth(); // This is a hack the width as the width isn't known before its drawn
int plotWidth = (totalWidth - yBuffer * ( nCols+1)) / nCols + .99;
int plotHeight = plotWidth / 2 + .5;
int rowCount = 0;
for (int i=0; i<nPlots; i++)
{
plots[i].setPosition( xBuffer + i%nCols * (plotWidth + xBuffer) ,
yBuffer + rowCount * (plotHeight + yBuffer),
plotWidth,
plotHeight); // deprecated conversion from string constant to char
if (i%nCols == nCols-1)
rowCount++;
}
// Set the total height of the Canvas to the top of the top most plot
totalHeight = yBuffer + (rowCount + 1) * (plotHeight + yBuffer);
}
void SpikeDisplayCanvas::newOpenGLContextCreated()
{
......@@ -183,6 +196,8 @@ void SpikeDisplayCanvas::canvasWasResized()
void SpikeDisplayCanvas::renderOpenGL()
{
if(!plotsInitialized)
initializeSpikePlots();
glClearColor (0.667, 0.698, 0.718, 1.0);
glClear(GL_COLOR_BUFFER_BIT); // clear buffers to preset values
// std::cout<<"SpikeDisplayCanvas::renderOpenGL"<<std::endl;
......@@ -197,12 +212,11 @@ void SpikeDisplayCanvas::renderOpenGL()
// Distribute those spike to the appropriate plot object
SpikeObject tmpSpike;
for (int j=0; j<2; j++)
for (int i=0; i<plots.size(); i++){
generateSimulatedSpike(&tmpSpike, 0, 150);
plots[i].processSpikeObject(tmpSpike);
plots[i].redraw();
}
for (int i=0; i<plots.size(); i++){
generateSimulatedSpike(&tmpSpike, 0, 150);
plots[i].processSpikeObject(tmpSpike);
plots[i].redraw();
}
//}
//std::cout << getHeight()<<" "<< getTotalHeight()<<" "<<std::endl;
......
......@@ -93,6 +93,7 @@ private:
int nChannels[MAX_NUMBER_OF_SPIKE_CHANNELS];
void initializeSpikePlots();
void repositionSpikePlots();
void canvasWasResized();
void mouseDownInCanvas(const MouseEvent& e);
......
......@@ -145,7 +145,7 @@ void generateSimulatedSpike(SpikeObject *s, uint64_t timestamp, int noise)
2910, 2430, 1810, 1180, 680, 380, 270, 320, 460, 630,
770, 870, 940, 970, 990, 1000, 1000, 1000, 1000, 1000, 1000, 1000},
{ 1000, 1000, 1000, 1000, 1000, 1040, 1140, 1440, 2040, 2240,
2800, 2440, 2280, 2080, 1640, 920, 520, 300, 140, 040,
2400, 2340, 2280, 1880, 1640, 920, 520, 300, 140, 040,
20, 20, 40, 100, 260, 500, 740, 900, 960, 1000, 1000, 1000}
};
......@@ -164,7 +164,7 @@ void generateSimulatedSpike(SpikeObject *s, uint64_t timestamp, int noise)
s->nSamples = 32;
int idx=0;
int waveType = rand()%3; // Pick one of the three predefined waveshapes to generate
int waveType = rand()%2; // Pick one of the three predefined waveshapes to generate
int shift = 1000;
for (int i=0; i<4; i++)
......
......@@ -25,7 +25,7 @@ StereotrodePlot::~StereotrodePlot(){
// the right direction
void StereotrodePlot::redraw(){
//std::cout<<"StereotrodePlot() starting drawing"<<std::endl;\
std::cout<<"StereotrodePlot() starting drawing"<<std::endl;\
//BaseUIElement::clearNextDraw = true;
//BaseUIElement::redraw();
......@@ -82,6 +82,7 @@ void StereotrodePlot::initAxes(){
}
void StereotrodePlot::setPosition(int x, int y, double w, double h){
std::cout<<"StereotrodePlot::setPosition()"<<std::endl;
BaseUIElement::setPosition(x,y,w,h);
int minX = BaseUIElement::xpos;
int minY = BaseUIElement::ypos;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment