diff --git a/Source/Processors/Editors/SpikeDisplayEditor.cpp b/Source/Processors/Editors/SpikeDisplayEditor.cpp index 565967fa5b872b97228370d7918d68d384fa40eb..0f9fc3db2874aa5d0405f0a21b1ca8b5c913432c 100755 --- a/Source/Processors/Editors/SpikeDisplayEditor.cpp +++ b/Source/Processors/Editors/SpikeDisplayEditor.cpp @@ -143,7 +143,7 @@ void SpikeDisplayEditor::initializeButtons() allSubChansBtn->setToggleState(true, false); x += (w+xPad) * 2; - for (int i=0; i<nSubChannels; i++) + for (int i = 0; i < nSubChannels; i++) { String s = ""; s += i; diff --git a/Source/Processors/FilterNode.cpp b/Source/Processors/FilterNode.cpp index 7b7500f3597404978519241a036fb93ec3c890f2..ac453c109920bb17a2d5ac45afb565a44f1aa7a0 100755 --- a/Source/Processors/FilterNode.cpp +++ b/Source/Processors/FilterNode.cpp @@ -249,11 +249,11 @@ void FilterNode::process(AudioSampleBuffer& buffer, void FilterNode::saveCustomChannelParametersToXml(XmlElement* channelInfo, int channelNumber, bool isEventChannel) { - std::cout << "CHANNEL: " << channelNumber << std::endl; + //std::cout << "CHANNEL: " << channelNumber << std::endl; if (!isEventChannel && channelNumber > -1 && channelNumber < highCuts.size()) { - std::cout << "Saving custom parameters for filter node." << std::endl; + //std::cout << "Saving custom parameters for filter node." << std::endl; XmlElement* channelParams = channelInfo->createNewChildElement("PARAMETERS"); channelParams->setAttribute("highcut",highCuts[channelNumber]); @@ -285,4 +285,4 @@ void FilterNode::loadCustomChannelParametersFromXml(XmlElement* channelInfo, boo } -} +} diff --git a/Source/Processors/SpikeDisplayNode.cpp b/Source/Processors/SpikeDisplayNode.cpp index 008bb1c21b9c01b45b1a95979af30ce06bcf7a73..161aed18f00c95c9393e388042bb8a21f9a4ac9e 100755 --- a/Source/Processors/SpikeDisplayNode.cpp +++ b/Source/Processors/SpikeDisplayNode.cpp @@ -125,10 +125,10 @@ void SpikeDisplayNode::setParameter(int param, float val) -void SpikeDisplayNode::process(AudioSampleBuffer& buffer, MidiBuffer& midiMessages, int& nSamples) +void SpikeDisplayNode::process(AudioSampleBuffer& buffer, MidiBuffer& events, int& nSamples) { - checkForEvents(midiMessages); // automatically calls 'handleEvent + checkForEvents(events); // automatically calls 'handleEvent } @@ -143,21 +143,3 @@ void SpikeDisplayNode::handleEvent(int eventType, MidiMessage& event, int sample } } - -bool SpikeDisplayNode::getNextSpike(SpikeObject* spike) -{ - std::cout<<"SpikeDisplayNode::getNextSpike()"<<std::endl; - /* - if (bufferSize<1 || spikebuffer.empty()) - return false; - else{ - SpikeObject s = spikebuffer.front(); - spikebuffer.pop(); - bufferSize--; - *spike = s; - return true; - } - */ - return false; - -} \ No newline at end of file diff --git a/Source/Processors/SpikeDisplayNode.h b/Source/Processors/SpikeDisplayNode.h index 54922440afe86becbe2164eed36ae1e62591c93c..66dcb85b44be709aece4b795320145063c9c961e 100755 --- a/Source/Processors/SpikeDisplayNode.h +++ b/Source/Processors/SpikeDisplayNode.h @@ -75,8 +75,6 @@ public: int getNumberOfChannelsForElectrode(int i); int getNumElectrodes(); - bool getNextSpike(SpikeObject* spike); - private: int numberOfSources; diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp index b36307fc645d395003a7dfbe2fea9ec35c51cc61..93efb480738edc0ff113b866a7f15756945aaf47 100755 --- a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp +++ b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp @@ -37,6 +37,11 @@ SpikeDisplayCanvas::SpikeDisplayCanvas(SpikeDisplayNode* n) : scrollBarThickness = viewport->getScrollBarThickness(); + clearButton = new UtilityButton("Clear plots", Font("Small Text", 13, Font::plain)); + clearButton->setRadius(3.0f); + clearButton->addListener(this); + addAndMakeVisible(clearButton); + addAndMakeVisible(viewport); setWantsKeyboardFocus(true); @@ -52,14 +57,14 @@ SpikeDisplayCanvas::~SpikeDisplayCanvas() void SpikeDisplayCanvas::beginAnimation() { - std::cout << "Beginning animation." << std::endl; + std::cout << "SpikeDisplayCanvas beginning animation." << std::endl; startCallbacks(); } void SpikeDisplayCanvas::endAnimation() { - std::cout << "Ending animation." << std::endl; + std::cout << "SpikeDisplayCanvas ending animation." << std::endl; stopCallbacks(); } @@ -67,17 +72,16 @@ void SpikeDisplayCanvas::endAnimation() void SpikeDisplayCanvas::update() { - std::cout << "UPDATING SpikeDisplayCanvas" << std::endl; + std::cout << "Updating SpikeDisplayCanvas" << std::endl; int nPlots = processor->getNumElectrodes(); - spikeDisplay->clear(); + spikeDisplay->removePlots(); for (int i = 0; i < nPlots; i++) { spikeDisplay->addSpikePlot(processor->getNumberOfChannelsForElectrode(i), i); } - //initializeSpikePlots(); spikeDisplay->resized(); spikeDisplay->repaint(); } @@ -86,8 +90,6 @@ void SpikeDisplayCanvas::update() void SpikeDisplayCanvas::refreshState() { // called when the component's tab becomes visible again - // displayBufferIndex = processor->getDisplayBufferIndex(); - // screenBufferIndex = 0; resized(); } @@ -96,6 +98,9 @@ void SpikeDisplayCanvas::resized() viewport->setBounds(0,0,getWidth(),getHeight()-90); spikeDisplay->setBounds(0,0,getWidth()-scrollBarThickness, spikeDisplay->getTotalHeight()); + + clearButton->setBounds(10, getHeight()-40, 80,20); + } void SpikeDisplayCanvas::paint(Graphics& g) @@ -172,6 +177,17 @@ bool SpikeDisplayCanvas::keyPressed(const KeyPress& key) } +void SpikeDisplayCanvas::buttonClicked(Button* button) +{ + + if (button == clearButton) + { + spikeDisplay->clear(); + } +} + + + // ---------------------------------------------------------------- SpikeDisplay::SpikeDisplay(SpikeDisplayCanvas* sdc, Viewport* v) : @@ -199,6 +215,12 @@ void SpikeDisplay::clear() } +void SpikeDisplay::removePlots() +{ + spikePlots.clear(); + +} + void SpikeDisplay::addSpikePlot(int numChannels, int electrodeNum) { @@ -238,6 +260,9 @@ void SpikeDisplay::resized() float width, height; + + float maxHeight = 0; + for (int i = 0; i < spikePlots.size(); i++) { @@ -271,6 +296,8 @@ void SpikeDisplay::resized() spikePlots[i]->setBounds(width*column, row*height, width, height); + maxHeight = jmax(maxHeight, row*height + height); + if (spikePlots[i]->nChannels == 1) { stereotrodeStart = (int)(height*(float(row)+1)); @@ -282,6 +309,7 @@ void SpikeDisplay::resized() } + for (int i = 0; i < spikePlots.size(); i++) { @@ -293,21 +321,23 @@ void SpikeDisplay::resized() if (spikePlots[i]->nChannels == 2) { spikePlots[i]->setBounds(x, y+stereotrodeStart, w2, h2); + maxHeight = jmax(maxHeight, (float) y+stereotrodeStart+h2); } else if (spikePlots[i]->nChannels == 4) { spikePlots[i]->setBounds(x, y+stereotrodeStart+tetrodeStart, w2, h2); + maxHeight = jmax(maxHeight, (float) y+stereotrodeStart+tetrodeStart+h2); } + } - totalHeight = 5000; // don't even deal with making the display the correct height + totalHeight = (int) maxHeight + 50; - if (totalHeight < getHeight()) - { - canvas->resized(); - } + std::cout << "New height = " << totalHeight << std::endl; + + setBounds(0, 0, getWidth(), totalHeight); } } @@ -356,7 +386,7 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p) : nWaveAx = 4; nProjAx = 6; nChannels = 4; - minWidth = 500; + minWidth = 400; aspectRatio = 0.5f; break; // case HIST_PLOT: @@ -365,7 +395,7 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p) : // nHistAx = 1; // break; default: // unsupported number of axes provided - std::cout<<"SpikePlot as UNKNOWN, defaulting to SINGLE_PLOT"<<std::endl; + std::cout << "SpikePlot as UNKNOWN, defaulting to SINGLE_PLOT" << std::endl; nWaveAx = 1; nProjAx = 0; plotType = SINGLE_PLOT; @@ -783,6 +813,10 @@ void WaveAxes::updateSpikeData(const SpikeObject& s) void WaveAxes::clear() { + + spikeBuffer.clear(); + spikeIndex = 0; + for (int n = 0; n < bufferSize; n++) { SpikeObject so; diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.h b/Source/Processors/Visualization/SpikeDisplayCanvas.h index 8edb6ecf2dba2788406250814f54582eb58cb143..e97e9ac15446fab1dae55d586a6e88ff53a12b8e 100755 --- a/Source/Processors/Visualization/SpikeDisplayCanvas.h +++ b/Source/Processors/Visualization/SpikeDisplayCanvas.h @@ -66,7 +66,7 @@ class SpikePlot; */ -class SpikeDisplayCanvas : public Visualizer +class SpikeDisplayCanvas : public Visualizer, public Button::Listener { public: @@ -93,6 +93,8 @@ public: bool keyPressed(const KeyPress& key); + void buttonClicked(Button* button); + private: SpikeDisplayNode* processor; @@ -101,7 +103,7 @@ private: ScopedPointer<SpikeDisplay> spikeDisplay; ScopedPointer<Viewport> viewport; - + ScopedPointer<UtilityButton> clearButton; bool newSpike; SpikeObject spike; @@ -118,6 +120,7 @@ public: SpikeDisplay(SpikeDisplayCanvas*, Viewport*); ~SpikeDisplay(); + void removePlots(); void clear(); void addSpikePlot(int numChannels, int electrodeNum);