Skip to content
Snippets Groups Projects
Commit abbcc647 authored by jsiegle's avatar jsiegle
Browse files

Merge branch 'spikevis' of https://github.com/open-ephys/GUI into utilities

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