@@ -81,7 +81,14 @@ SpikeSorterCanvas::SpikeSorterCanvas(SpikeSorter* n) :
8181 prevElectrode->setRadius (3 .0f );
8282 prevElectrode->addListener (this );
8383 addAndMakeVisible (prevElectrode);
84-
84+
85+ editAllThresholds = new UtilityButton (" Edit All Thresholds" ,Font (" Small Text" , 13 , Font::plain));
86+ editAllThresholds->addListener (this );
87+ editAllThresholds->setBounds (140 ,30 ,60 ,20 );
88+ editAllThresholds->setClickingTogglesState (true );
89+ addAndMakeVisible (editAllThresholds);
90+ //
91+
8592 addAndMakeVisible (viewport);
8693
8794 setWantsKeyboardFocus (true );
@@ -159,6 +166,8 @@ void SpikeSorterCanvas::resized()
159166
160167 newIDbuttons->setBounds (0 , 270 , 120 ,20 );
161168 deleteAllUnits->setBounds (0 , 300 , 120 ,20 );
169+
170+ editAllThresholds->setBounds (0 , 330 , 120 ,20 );
162171
163172}
164173
@@ -402,7 +411,15 @@ void SpikeSorterCanvas::buttonClicked(Button* button)
402411 electrode->spikePlot ->updateUnitsFromProcessor ();
403412 processor->removeAllUnits (electrode->electrodeID );
404413 }
405-
414+ else if (button == editAllThresholds){
415+
416+ }
417+
418+ // new
419+ if (button == editAllThresholds){
420+ processor->setEditAllState (button->getToggleState ());
421+ }
422+
406423 repaint ();
407424}
408425
@@ -1072,6 +1089,7 @@ void WaveformAxes::plotSpike(SorterSpikePtr s, Graphics& g)
10721089{
10731090 if (s.get () == nullptr ) return ;
10741091 float h = getHeight ();
1092+
10751093 g.setColour (Colour (s->color [0 ], s->color [1 ], s->color [2 ]));
10761094 // g.setColour(Colours::pink);
10771095 // compute the spatial width for each waveform sample
@@ -1094,13 +1112,15 @@ void WaveformAxes::plotSpike(SorterSpikePtr s, Graphics& g)
10941112
10951113 float x = 0 .0f ;
10961114
1115+
10971116 for (int i = 0 ; i < spikeSamples - 1 ; i++)
10981117 {
10991118 // std::cout << s.data[sampIdx] << std::endl;
11001119
11011120
11021121 float s1 = h - (h / 2 + s->getData ()[offset + i] / (range)* h);
11031122 float s2 = h - (h / 2 + s->getData ()[offset + i + 1 ] / (range)* h);
1123+
11041124 if (signalFlipped)
11051125 {
11061126 s1 = h - s1;
@@ -1456,7 +1476,20 @@ void WaveformAxes::mouseDrag(const MouseEvent& event)
14561476
14571477 displayThresholdLevel = (0 .5f - thresholdSliderPosition) * range;
14581478 // update processor
1459- processor->getActiveElectrode ()->thresholds [channel] = displayThresholdLevel;
1479+
1480+ if (processor->getEditAllState ()){
1481+ int numElectrodes = processor->getNumElectrodes ();
1482+ for (int electrodeIt = 0 ; electrodeIt < numElectrodes ; electrodeIt++){
1483+ // processor->setChannelThreshold(electrodeList->getSelectedItemIndex(),i,slider->getValue());
1484+ for (int channelIt = 0 ; channelIt < processor->getNumChannels (electrodeIt) ; channelIt++){
1485+ processor->setChannelThreshold (electrodeIt,channelIt,displayThresholdLevel);
1486+ }
1487+ }
1488+ }
1489+ else {
1490+ processor->getActiveElectrode ()->thresholds [channel] = displayThresholdLevel;
1491+ }
1492+
14601493 SpikeSorterEditor* edt = (SpikeSorterEditor*) processor->getEditor ();
14611494 for (int k=0 ; k<processor->getActiveElectrode ()->numChannels ; k++)
14621495 edt->electrodeButtons [k]->setToggleState (false , dontSendNotification);
@@ -1684,7 +1717,7 @@ void WaveformAxes::paint(Graphics& g)
16841717 for (int spikeNum = 0 ; spikeNum < bufferSize; spikeNum++)
16851718 {
16861719
1687- if (spikeNum != spikeIndex)
1720+ if (spikeNum != spikeIndex && spikeBuffer[spikeNum] != nullptr )
16881721 {
16891722 g.setColour (Colours::grey);
16901723 plotSpike (spikeBuffer[spikeNum], g);
@@ -1693,7 +1726,8 @@ void WaveformAxes::paint(Graphics& g)
16931726 }
16941727
16951728 g.setColour (Colours::white);
1696- plotSpike (spikeBuffer[spikeIndex], g);
1729+ if (spikeBuffer[spikeIndex] != nullptr )
1730+ plotSpike (spikeBuffer[spikeIndex], g);
16971731
16981732 spikesReceivedSinceLastRedraw = 0 ;
16991733
0 commit comments