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

Merge branch 'spikevis' into utilities

parents b41183d8 745b03e5
No related branches found
No related tags found
No related merge requests found
...@@ -48,28 +48,30 @@ void SpikeDisplayEditor::initializeButtons(){ ...@@ -48,28 +48,30 @@ void SpikeDisplayEditor::initializeButtons(){
x = xInitial; x = xInitial;
y += h + yPad/2; y += h + yPad/2;
panUpBtn = new ChannelSelectorButton("+", titleFont);
panUpBtn->setBounds(x, y, w, h);
panUpBtn->setClickingTogglesState(false);
panUpBtn->addListener(this);
x+= w+xPad;
panDownBtn = new ChannelSelectorButton("-", titleFont); panDownBtn = new ChannelSelectorButton("-", titleFont);
panDownBtn->setBounds(x, y, w, h); panDownBtn->setBounds(x, y, w, h);
panDownBtn->setClickingTogglesState(false); panDownBtn->setClickingTogglesState(false);
panDownBtn->addListener(this); panDownBtn->addListener(this);
x+= w+xPad*2; x+= w+xPad;
zoomInBtn = new ChannelSelectorButton("+", titleFont); panUpBtn = new ChannelSelectorButton("+", titleFont);
zoomInBtn->setBounds(x,y,w,h); panUpBtn->setBounds(x, y, w, h);
zoomInBtn->setClickingTogglesState(false); panUpBtn->setClickingTogglesState(false);
zoomInBtn->addListener(this); panUpBtn->addListener(this);
x += w + xPad; x+= w+xPad*2;
zoomOutBtn = new ChannelSelectorButton("-", titleFont); zoomOutBtn = new ChannelSelectorButton("-", titleFont);
zoomOutBtn->setBounds(x,y,w,h); zoomOutBtn->setBounds(x,y,w,h);
zoomOutBtn->setClickingTogglesState(false); zoomOutBtn->setClickingTogglesState(false);
zoomOutBtn->addListener(this); zoomOutBtn->addListener(this);
x += w + xPad;
zoomInBtn = new ChannelSelectorButton("+", titleFont);
zoomInBtn->setBounds(x,y,w,h);
zoomInBtn->setClickingTogglesState(false);
zoomInBtn->addListener(this);
x += w + xPad*3; x += w + xPad*3;
...@@ -79,8 +81,6 @@ void SpikeDisplayEditor::initializeButtons(){ ...@@ -79,8 +81,6 @@ void SpikeDisplayEditor::initializeButtons(){
clearBtn->addListener(this); clearBtn->addListener(this);
x += (w + xPad) *2; x += (w + xPad) *2;
/* /*
x = xInitial; x = xInitial;
y += h + yPad; y += h + yPad;
...@@ -127,15 +127,14 @@ void SpikeDisplayEditor::initializeButtons(){ ...@@ -127,15 +127,14 @@ void SpikeDisplayEditor::initializeButtons(){
} }
addAndMakeVisible(panUpBtn);
addAndMakeVisible(panDownBtn); addAndMakeVisible(panDownBtn);
addAndMakeVisible(panUpBtn);
addAndMakeVisible(panLabel); addAndMakeVisible(panLabel);
addAndMakeVisible(zoomInBtn);
addAndMakeVisible(zoomOutBtn); addAndMakeVisible(zoomOutBtn);
addAndMakeVisible(zoomInBtn);
addAndMakeVisible(zoomLabel); addAndMakeVisible(zoomLabel);
addAndMakeVisible(clearBtn); addAndMakeVisible(clearBtn);
//addAndMakeVisible(saveImgBtn); //addAndMakeVisible(saveImgBtn);
......
...@@ -24,19 +24,20 @@ ...@@ -24,19 +24,20 @@
#include "SpikeDisplayCanvas.h" #include "SpikeDisplayCanvas.h"
SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) : processor(n), SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) : processor(n),
xBuffer(25), yBuffer(25), newSpike(false), plotsInitialized(false), xBuffer(25), yBuffer(25), newSpike(false), plotsInitialized(false),
totalScrollPix(0) totalScrollPix(0)
{ {
nSources = 0; //processor->getNumInputs(); nPlots = 8;
std::cout<<"SpikeDisplayNode has :"<<nSources<<" outputs!"<<std::endl; nCols = 2; //processor->getNumInputs();
std::cout<<"SpikeDisplayNode has :"<<nPlots<<" outputs!"<<std::endl;
for (int i=0; i<nSources; i++) for (int i=0; i<nPlots; i++)
nChannels[i] = processor->getNumberOfChannelsForInput(i); nChannels[i] = processor->getNumberOfChannelsForInput(i);
std::cout << "Setting num inputs on SpikeDisplayCanvas to " << nSources << std::endl; std::cout << "Setting num inputs on SpikeDisplayCanvas to " << nPlots << std::endl;
...@@ -50,18 +51,13 @@ SpikeDisplayCanvas::~SpikeDisplayCanvas() ...@@ -50,18 +51,13 @@ SpikeDisplayCanvas::~SpikeDisplayCanvas()
void SpikeDisplayCanvas::initializeSpikePlots(){ void SpikeDisplayCanvas::initializeSpikePlots(){
std::cout<<"Initializing Plots"<<std::endl; std::cout<<"Initializing Plots"<<std::endl;
int nPlots = 6;
int nCols = 2;
int totalWidth = getWidth(); int totalWidth = getWidth();
int plotWidth = (totalWidth - yBuffer * ( nCols+1)) / nCols + .99; int plotWidth = (totalWidth - yBuffer * ( nCols+1)) / nCols + .99;
int plotHeight = plotWidth / 2 + .5; int plotHeight = plotWidth / 2 + .5;
int rowCount = 0; int rowCount = 0;
int i;
for (i=0; i<nPlots; i++) for (int i=0; i<nPlots; i++)
{ {
StereotrodePlot p = StereotrodePlot( StereotrodePlot p = StereotrodePlot(
...@@ -79,7 +75,8 @@ void SpikeDisplayCanvas::initializeSpikePlots(){ ...@@ -79,7 +75,8 @@ void SpikeDisplayCanvas::initializeSpikePlots(){
rowCount++; rowCount++;
} }
totalHeight = yBuffer + rowCount * (plotHeight + yBuffer) + yBuffer;
totalHeight = rowCount * (plotHeight + yBuffer) + yBuffer * 2;
// Set the total height of the Canvas to the top of the top most plot // Set the total height of the Canvas to the top of the top most plot
plotsInitialized = true; plotsInitialized = true;
...@@ -88,9 +85,6 @@ void SpikeDisplayCanvas::initializeSpikePlots(){ ...@@ -88,9 +85,6 @@ void SpikeDisplayCanvas::initializeSpikePlots(){
void SpikeDisplayCanvas::repositionSpikePlots(){ void SpikeDisplayCanvas::repositionSpikePlots(){
int nPlots = plots.size();
int nCols = 2;
int totalWidth = getWidth(); int totalWidth = getWidth();
int plotWidth = (totalWidth - yBuffer * ( nCols+1)) / nCols + .99; int plotWidth = (totalWidth - yBuffer * ( nCols+1)) / nCols + .99;
...@@ -110,12 +104,11 @@ void SpikeDisplayCanvas::repositionSpikePlots(){ ...@@ -110,12 +104,11 @@ void SpikeDisplayCanvas::repositionSpikePlots(){
} }
// Set the total height of the Canvas to the top of the top most plot // Set the total height of the Canvas to the top of the top most plot
totalHeight = yBuffer + rowCount * (plotHeight + yBuffer) + yBuffer; totalHeight = rowCount * (plotHeight + yBuffer) + yBuffer * 2;
} }
void SpikeDisplayCanvas::newOpenGLContextCreated() void SpikeDisplayCanvas::newOpenGLContextCreated()
{ {
std::cout<<"SpikeDisplayCanvas::newOpenGLContextCreated()"<<std::endl; std::cout<<"SpikeDisplayCanvas::newOpenGLContextCreated()"<<std::endl;
setUp2DCanvas(); setUp2DCanvas();
activateAntiAliasing(); activateAntiAliasing();
...@@ -123,8 +116,6 @@ void SpikeDisplayCanvas::newOpenGLContextCreated() ...@@ -123,8 +116,6 @@ void SpikeDisplayCanvas::newOpenGLContextCreated()
glClearColor (0.667, 0.698, 0.718, 1.0); glClearColor (0.667, 0.698, 0.718, 1.0);
resized(); resized();
endAnimation(); endAnimation();
//startTimer(50);
} }
void SpikeDisplayCanvas::beginAnimation() void SpikeDisplayCanvas::beginAnimation()
...@@ -217,7 +208,8 @@ void SpikeDisplayCanvas::canvasWasResized() ...@@ -217,7 +208,8 @@ void SpikeDisplayCanvas::canvasWasResized()
void SpikeDisplayCanvas::renderOpenGL() void SpikeDisplayCanvas::renderOpenGL()
{ {
if(!plotsInitialized) if(!plotsInitialized)
initializeSpikePlots(); initializeSpikePlots();
glClearColor (0.667, 0.698, 0.718, 1.0); glClearColor (0.667, 0.698, 0.718, 1.0);
glClear(GL_COLOR_BUFFER_BIT); // clear buffers to preset values glClear(GL_COLOR_BUFFER_BIT); // clear buffers to preset values
// std::cout<<"SpikeDisplayCanvas::renderOpenGL"<<std::endl; // std::cout<<"SpikeDisplayCanvas::renderOpenGL"<<std::endl;
......
...@@ -105,7 +105,8 @@ private: ...@@ -105,7 +105,8 @@ private:
int getTotalHeight(); int getTotalHeight();
int nSources; int nPlots;
int nCols;
int nChannels[MAX_NUMBER_OF_SPIKE_CHANNELS]; int nChannels[MAX_NUMBER_OF_SPIKE_CHANNELS];
void initializeSpikePlots(); void initializeSpikePlots();
......
...@@ -8,7 +8,8 @@ ProjectionAxes::ProjectionAxes(): ...@@ -8,7 +8,8 @@ ProjectionAxes::ProjectionAxes():
buffIdx(-1), buffIdx(-1),
totalSpikes(0), totalSpikes(0),
newSpike(false), newSpike(false),
isTextureValid(false), isTextureValid(false),
fboCreated(false),
allSpikesNextRender(false) allSpikesNextRender(false)
{ {
GenericAxes::type = PROJ1x2; GenericAxes::type = PROJ1x2;
...@@ -20,6 +21,7 @@ ProjectionAxes::ProjectionAxes(): ...@@ -20,6 +21,7 @@ ProjectionAxes::ProjectionAxes():
n2ProjIdx(type, &ampDim1, &ampDim2); n2ProjIdx(type, &ampDim1, &ampDim2);
clearOnNextDraw = false; clearOnNextDraw = false;
} }
ProjectionAxes::ProjectionAxes(int x, int y, double w, double h, int t): ProjectionAxes::ProjectionAxes(int x, int y, double w, double h, int t):
...@@ -31,6 +33,7 @@ ProjectionAxes::ProjectionAxes(int x, int y, double w, double h, int t): ...@@ -31,6 +33,7 @@ ProjectionAxes::ProjectionAxes(int x, int y, double w, double h, int t):
totalSpikes(0), totalSpikes(0),
newSpike(false), newSpike(false),
isTextureValid(false), isTextureValid(false),
fboCreated(false),
allSpikesNextRender(false) allSpikesNextRender(false)
{ {
GenericAxes::gotFirstSpike = false; GenericAxes::gotFirstSpike = false;
...@@ -103,6 +106,8 @@ void ProjectionAxes::plot(){ ...@@ -103,6 +106,8 @@ void ProjectionAxes::plot(){
plot(); plot();
return; return;
} }
// else
// std::cout<<"All is good no errors detected"<<std::endl;
} }
void ProjectionAxes::plotOldSpikes(bool allSpikes){ void ProjectionAxes::plotOldSpikes(bool allSpikes){
...@@ -194,15 +199,17 @@ void ProjectionAxes::createTexture(){ ...@@ -194,15 +199,17 @@ void ProjectionAxes::createTexture(){
texWidth = BaseUIElement::width; texWidth = BaseUIElement::width;
texHeight = BaseUIElement::height; texHeight = BaseUIElement::height;
std::cout<<"Creating a new texture of size:"<<texWidth<<"x"<<texHeight<<std::endl; std::cout<<"Creating a new texture of size:"<<texWidth<<"x"<<texHeight;//<<std::endl;
// Delete the old texture // Delete the old texture
glDeleteTextures(1, &textureId); glDeleteTextures(1, &textureId);
// Generate a new texture // Generate a new texture
glGenTextures(1, &textureId); glGenTextures(1, &textureId);
std::cout<<" textureId:"<<textureId<<std::endl;
// Bind the texture, and set the appropriate parameters // Bind the texture, and set the appropriate parameters
glBindTexture(GL_TEXTURE_2D, textureId); glBindTexture(GL_TEXTURE_2D, textureId);
glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE); glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texWidth, texHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
glGenerateMipmap(GL_TEXTURE_2D);
// generate a new FrameBufferObject // generate a new FrameBufferObject
createFBO(); createFBO();
...@@ -212,13 +219,15 @@ void ProjectionAxes::createTexture(){ ...@@ -212,13 +219,15 @@ void ProjectionAxes::createTexture(){
} }
void ProjectionAxes::createFBO(){ void ProjectionAxes::createFBO(){
std::cout<<"Creating a new frame buffer object"<<std::endl; std::cout<<"Creating a new FBO, is already created?:"<<fboCreated<<" ";//<<std::endl;
// if (!isTextureValid) // if (!isTextureValid)
// createTexture(); // createTexture();
// Delete the old frame buffer, render buffer // Delete the old frame buffer, render buffer
glDeleteFramebuffers(1, &fboId); if (fboCreated){
glDeleteRenderbuffers(1, &rboId); glDeleteFramebuffers(1, &fboId);
glDeleteRenderbuffers(1, &rboId);
}
// Generate and Bind the frame buffer // Generate and Bind the frame buffer
glGenFramebuffersEXT(1, &fboId); glGenFramebuffersEXT(1, &fboId);
...@@ -227,23 +236,30 @@ void ProjectionAxes::createFBO(){ ...@@ -227,23 +236,30 @@ void ProjectionAxes::createFBO(){
// Generate and bind the new Render Buffer // Generate and bind the new Render Buffer
glGenRenderbuffersEXT(1, &rboId); glGenRenderbuffersEXT(1, &rboId);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rboId); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rboId);
std::cout<<" fboID:"<<fboId<<" rboID:"<<rboId<<std::endl;
glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, texWidth, texHeight); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, texWidth, texHeight);
glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
// Attach the texture to the framebuffer // Attach the texture to the framebuffer
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, textureId, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, textureId, 0);
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboId); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rboId);
// If the FrameBuffer wasn't created then we have a bigger problem. Abort the program. // If the FrameBuffer wasn't created then we have a bigger problem. Abort the program.
if(!checkFramebufferStatus()){ if(!checkFramebufferStatus()){
std::cout<<"FrameBufferObject not created! Are you running the newest version of OpenGL?"<<std::endl; std::cout<<"FrameBufferObject not created! Are you running the newest version of OpenGL?"<<std::endl;
std::cout<<"FrameBufferObjects are REQUIRED! Quitting!"<<std::endl; std::cout<<"FrameBufferObjects are REQUIRED! Quitting!"<<std::endl;
exit(1); exit(1);
} }
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
fboCreated = true;
} }
void ProjectionAxes::drawSpikesToTexture(bool allSpikes){ void ProjectionAxes::drawSpikesToTexture(bool allSpikes){
//std::cout<<"ProjectionAxes::drawSpikesToTexture() plotting all spikes:"<<allSpikes<<std::endl; //std::cout<<"ProjectionAxes::drawSpikesToTexture() plotting all spikes:"<<allSpikes<<std::endl;
......
...@@ -37,7 +37,6 @@ class ProjectionAxes: public GenericAxes{ ...@@ -37,7 +37,6 @@ class ProjectionAxes: public GenericAxes{
void createFBO(); void createFBO();
void drawSpikesToTexture(bool allSpikes); void drawSpikesToTexture(bool allSpikes);
// void updateTexture();
void drawTexturedQuad(); void drawTexturedQuad();
void plotOldSpikes(bool allSpikes); void plotOldSpikes(bool allSpikes);
void plotNewestSpike(); void plotNewestSpike();
...@@ -54,6 +53,7 @@ class ProjectionAxes: public GenericAxes{ ...@@ -54,6 +53,7 @@ class ProjectionAxes: public GenericAxes{
bool clearOnNextDraw; bool clearOnNextDraw;
bool isTextureValid; bool isTextureValid;
bool fboCreated;
void clearTexture(); void clearTexture();
void validateTexture(); void validateTexture();
......
...@@ -82,7 +82,7 @@ void WaveAxes::plot(){ ...@@ -82,7 +82,7 @@ void WaveAxes::plot(){
//Draw the individual waveform points connected with a line //Draw the individual waveform points connected with a line
glColor3fv(waveColor); glColor3fv(waveColor);
glLineWidth(1); glLineWidth(2);
glBegin( GL_LINE_STRIP ); glBegin( GL_LINE_STRIP );
int dSamples = 1; int dSamples = 1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment