diff --git a/Source/Processors/Editors/SpikeDisplayEditor.cpp b/Source/Processors/Editors/SpikeDisplayEditor.cpp index 5118577e4fefbf43471d1458cf2682ab442c7f0e..f697ea3529a628480304ada750baae841ed23f53 100644 --- a/Source/Processors/Editors/SpikeDisplayEditor.cpp +++ b/Source/Processors/Editors/SpikeDisplayEditor.cpp @@ -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); diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp index 33315e9aa1a1d1a5ed93554870a9f96c0db22b12..30f30d592a02afa56739c4717cafa98da553c082 100644 --- a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp +++ b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp @@ -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; diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.h b/Source/Processors/Visualization/SpikeDisplayCanvas.h index c142b3566c7c3aa9a71e6dbcce56e0df5803aa90..56c7fc0db559962cd14503ffc3aa211104791aef 100644 --- a/Source/Processors/Visualization/SpikeDisplayCanvas.h +++ b/Source/Processors/Visualization/SpikeDisplayCanvas.h @@ -105,7 +105,8 @@ private: int getTotalHeight(); - int nSources; + int nPlots; + int nCols; int nChannels[MAX_NUMBER_OF_SPIKE_CHANNELS]; void initializeSpikePlots(); diff --git a/Source/Processors/Visualization/SpikePlotting/ProjectionAxes.cpp b/Source/Processors/Visualization/SpikePlotting/ProjectionAxes.cpp index 204f579643386a60053d50bceedc6df80c8afb93..e96d43132687c31facac8c6e59a0ae19ba33999c 100644 --- a/Source/Processors/Visualization/SpikePlotting/ProjectionAxes.cpp +++ b/Source/Processors/Visualization/SpikePlotting/ProjectionAxes.cpp @@ -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, &Dim1, &Dim2); 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; diff --git a/Source/Processors/Visualization/SpikePlotting/ProjectionAxes.h b/Source/Processors/Visualization/SpikePlotting/ProjectionAxes.h index f3fdfd0c1b65fc75e6bb76c82ae518449fc86c67..a5270dac1b306729c03a24985cab3495655ad9f7 100644 --- a/Source/Processors/Visualization/SpikePlotting/ProjectionAxes.h +++ b/Source/Processors/Visualization/SpikePlotting/ProjectionAxes.h @@ -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(); diff --git a/Source/Processors/Visualization/SpikePlotting/WaveAxes.cpp b/Source/Processors/Visualization/SpikePlotting/WaveAxes.cpp index 18feacbed932645bcdf1d36a0a63ea031f7f7347..cd3b0e9cc51fdbf2523d89469a5874929b95de01 100644 --- a/Source/Processors/Visualization/SpikePlotting/WaveAxes.cpp +++ b/Source/Processors/Visualization/SpikePlotting/WaveAxes.cpp @@ -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;