Skip to content

Commit ee2598d

Browse files
committed
Add switch to splitter used to update channel list after filter message
1 parent e13d0c6 commit ee2598d

5 files changed

Lines changed: 17 additions & 23 deletions

File tree

Plugins/LfpDisplayNode/LfpDisplay.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,10 @@ void LfpDisplay::refresh()
381381
if (numChans == 0)
382382
return;
383383

384+
if(canvasSplit -> shouldRebuildChannelList) {
385+
canvasSplit -> shouldRebuildChannelList = false;
386+
rebuildDrawableChannelsList();
387+
}
384388
// Ensure the lfpChannelBitmap has been initialized
385389
if (lfpChannelBitmap.isNull() || lfpChannelBitmap.getWidth() < getWidth() - canvasSplit->leftmargin)
386390
{
@@ -982,14 +986,17 @@ void LfpDisplay::rebuildDrawableChannelsList()
982986
removeAllChildren(); // start with clean slate
983987

984988
Array<LfpChannelTrack> channelsToDraw; // all visible channels will be added to this array
985-
986-
int filteredChannelsSize = canvasSplit -> displayBuffer -> hasFilter ? canvasSplit -> displayBuffer -> filteredChannels.size() : 0;
987-
const StringArray& filteredChannels = canvasSplit -> displayBuffer -> filteredChannels;
989+
int filteredChannelsSize = 0;
990+
StringArray filteredChannels;
991+
if(canvasSplit -> displayBuffer) {
992+
filteredChannelsSize = canvasSplit -> displayBuffer -> hasFilter ? canvasSplit -> displayBuffer -> filteredChannels.size() : 0;
993+
filteredChannels = canvasSplit -> displayBuffer -> filteredChannels;
994+
}
988995
// iterate over all channels and select drawable ones
989996
for (int i = 0, drawableChannelNum = 0, filterChannelIndex = 0; i < channels.size(); i++)
990997
{
991998
//std::cout << "Checking for hidden channels" << std::endl;
992-
String channelName = canvasSplit->displayBuffer->channelMetadata[i].name;
999+
String channelName = filteredChannelsSize ? canvasSplit->displayBuffer->channelMetadata[i].name: "";
9931000
if(filteredChannelsSize == 0 || (filterChannelIndex < filteredChannelsSize && channelName == filteredChannels[filterChannelIndex])) {
9941001
if (displaySkipAmt == 0 || ((filteredChannelsSize ? filterChannelIndex : i) % displaySkipAmt == 0)) // no skips, add all channels
9951002
{

Plugins/LfpDisplayNode/LfpDisplayCanvas.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,8 @@ class LfpDisplaySplitter : public Component,
340340
uint16 selectedStreamId;
341341

342342
void refreshScreenBuffer();
343+
344+
bool shouldRebuildChannelList = false;
343345

344346
private:
345347

Plugins/LfpDisplayNode/LfpDisplayNode.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,9 @@ void LfpDisplayNode::handleBroadcastMessage(String msg) {
341341
int streamID = parts[2].getIntValue();
342342
parts.removeRange(0, 3);
343343
displayBufferMap[streamID] -> setFilteredChannels(parts);
344+
for(auto split : splitDisplays) {
345+
split -> shouldRebuildChannelList = true;
346+
}
344347

345348
}
346349

Plugins/LfpDisplayNode/LfpDisplayOptions.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,6 @@ LfpDisplayOptions::LfpDisplayOptions(LfpDisplayCanvas* canvas_, LfpDisplaySplitt
431431
lfpDisplay->setRange(voltageRanges[ContinuousChannel::Type::AUX][selectedVoltageRange[ContinuousChannel::Type::AUX] - 1].getFloatValue()
432432
*rangeGain[ContinuousChannel::Type::AUX]
433433
, ContinuousChannel::Type::AUX);
434-
435-
refreshButton = new UtilityButton("Refresh", Font("Default", "Plain", 15));
436-
refreshButton->setRadius(5.0f);
437-
refreshButton->setEnabledState(true);
438-
refreshButton->setCorners(true, true, true, true);
439-
refreshButton->addListener(this);
440-
addAndMakeVisible(refreshButton.get());
441434

442435
}
443436

@@ -472,10 +465,7 @@ void LfpDisplayOptions::resized()
472465

473466
pauseButton->setBounds(680, getHeight() - 40, 70, 30);
474467

475-
refreshButton->setBounds(765, getHeight() - 40, 70, 30);
476-
477-
478-
colourSchemeOptionSelection->setBounds(refreshButton->getRight() + 30,
468+
colourSchemeOptionSelection->setBounds(pauseButton->getRight() + 30,
479469
getHeight() - 30,
480470
180,
481471
height);
@@ -940,12 +930,6 @@ void LfpDisplayOptions::buttonClicked(Button* b)
940930
timescale->setPausedState(b->getToggleState());
941931
return;
942932
}
943-
944-
if (b == refreshButton.get())
945-
{
946-
lfpDisplay->rebuildDrawableChannelsList();
947-
return;
948-
}
949933

950934
if (b == showHideOptionsButton.get())
951935
{

Plugins/LfpDisplayNode/LfpDisplayOptions.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ class LfpDisplayOptions :
185185
std::unique_ptr<ComboBox> rangeSelection;
186186
OwnedArray<UtilityButton> typeButtons;
187187

188-
ScopedPointer<UtilityButton> refreshButton;
189-
190188
std::unique_ptr<ComboBox> overlapSelection; // what do we do with this?
191189

192190
OwnedArray<EventDisplayInterface> eventDisplayInterfaces;

0 commit comments

Comments
 (0)