Skip to content

Commit e13d0c6

Browse files
committed
Channels filtering with refresh button; crashing on Grid clear
1 parent 9476b7e commit e13d0c6

7 files changed

Lines changed: 58 additions & 11 deletions

File tree

Plugins/LfpDisplayNode/DisplayBuffer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace LfpViewer {
2828
#define BUFFER_LENGTH_S 1.0f
2929

3030
DisplayBuffer::DisplayBuffer(int id_, String name_, float sampleRate_) :
31-
id(id_), name(name_), sampleRate(sampleRate_), isNeeded(true)
31+
id(id_), name(name_), sampleRate(sampleRate_), isNeeded(true), hasFilter(false)
3232
{
3333
previousSize = 0;
3434
numChannels = 0;
@@ -41,6 +41,7 @@ DisplayBuffer::DisplayBuffer(int id_, String name_, float sampleRate_) :
4141
}
4242

4343
ttlState = 0;
44+
filteredChannels = StringArray();
4445
}
4546

4647
DisplayBuffer::~DisplayBuffer()

Plugins/LfpDisplayNode/DisplayBuffer.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ namespace LfpViewer {
9090
};
9191

9292
Array<ChannelMetadata> channelMetadata;
93+
94+
void setFilteredChannels(StringArray channels) {filteredChannels = channels;hasFilter = true;}
9395

9496
String name;
9597
int id;
@@ -123,9 +125,13 @@ namespace LfpViewer {
123125
void removeDisplay(int splitID);
124126

125127
Array<int> displays;
128+
129+
StringArray filteredChannels;
130+
131+
bool hasFilter;
126132

127133
};
128134
};
129135

130136

131-
#endif //__DISPLAYBUFFER_H__
137+
#endif //__DISPLAYBUFFER_H__

Plugins/LfpDisplayNode/LfpDisplay.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -982,20 +982,19 @@ void LfpDisplay::rebuildDrawableChannelsList()
982982
removeAllChildren(); // start with clean slate
983983

984984
Array<LfpChannelTrack> channelsToDraw; // all visible channels will be added to this array
985-
std::vector<int> filteredChannels;
986-
for(int i = 0 ; i < 64; i++) {
987-
filteredChannels.push_back(i + 32 + (64 * (i/16)));
988-
}
989-
int filteredChannelsSize = filteredChannels.size();
985+
986+
int filteredChannelsSize = canvasSplit -> displayBuffer -> hasFilter ? canvasSplit -> displayBuffer -> filteredChannels.size() : 0;
987+
const StringArray& filteredChannels = canvasSplit -> displayBuffer -> filteredChannels;
990988
// iterate over all channels and select drawable ones
991989
for (int i = 0, drawableChannelNum = 0, filterChannelIndex = 0; i < channels.size(); i++)
992990
{
993-
994991
//std::cout << "Checking for hidden channels" << std::endl;
995-
if(filteredChannelsSize == 0 || (filterChannelIndex < filteredChannelsSize && i == filteredChannels[filterChannelIndex])) {
992+
String channelName = canvasSplit->displayBuffer->channelMetadata[i].name;
993+
if(filteredChannelsSize == 0 || (filterChannelIndex < filteredChannelsSize && channelName == filteredChannels[filterChannelIndex])) {
996994
if (displaySkipAmt == 0 || ((filteredChannelsSize ? filterChannelIndex : i) % displaySkipAmt == 0)) // no skips, add all channels
997995
{
998-
filterChannelIndex++;
996+
//std::cout << canvasSplit->displayBuffer->channelMetadata[i].name << std::endl;
997+
999998
channels[i]->setHidden(false);
1000999
channelInfo[i]->setHidden(false);
10011000

@@ -1010,6 +1009,7 @@ void LfpDisplay::rebuildDrawableChannelsList()
10101009
addAndMakeVisible(channels[i]);
10111010
addAndMakeVisible(channelInfo[i]);
10121011
}
1012+
filterChannelIndex++;
10131013
}
10141014
else // skip some channels
10151015
{

Plugins/LfpDisplayNode/LfpDisplayNode.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,3 +327,20 @@ void LfpDisplayNode::acknowledgeTrigger(int id)
327327
{
328328
latestTrigger.set(id, -1);
329329
}
330+
331+
String LfpDisplayNode::handleConfigMessage(String msg) {
332+
std::cout << "in lfp config: " << msg <<std::endl;
333+
}
334+
335+
void LfpDisplayNode::handleBroadcastMessage(String msg) {
336+
std::cout<< msg<< std::endl;
337+
StringArray parts = StringArray::fromTokens(msg, ";", "");
338+
if(parts.size() < 3 || (parts[0] != "LFPViewer" && parts[1] != "FILTER")) {
339+
return;
340+
}
341+
int streamID = parts[2].getIntValue();
342+
parts.removeRange(0, 3);
343+
displayBufferMap[streamID] -> setFilteredChannels(parts);
344+
345+
}
346+

Plugins/LfpDisplayNode/LfpDisplayNode.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ class LfpDisplayNode : public GenericProcessor
9999

100100
/** Acknowledges receipt of a trigger for a given split display*/
101101
void acknowledgeTrigger(int splitId);
102+
103+
/** Handles a configuration message sent to this processor, while acquisition is not active*/
104+
String handleConfigMessage(String msg) override;
105+
106+
void handleBroadcastMessage(String msg) override;
102107

103108
private:
104109

Plugins/LfpDisplayNode/LfpDisplayOptions.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,13 @@ 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());
434441

435442
}
436443

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

466473
pauseButton->setBounds(680, getHeight() - 40, 70, 30);
467474

468-
colourSchemeOptionSelection->setBounds(pauseButton->getRight() + 30,
475+
refreshButton->setBounds(765, getHeight() - 40, 70, 30);
476+
477+
478+
colourSchemeOptionSelection->setBounds(refreshButton->getRight() + 30,
469479
getHeight() - 30,
470480
180,
471481
height);
@@ -930,6 +940,12 @@ void LfpDisplayOptions::buttonClicked(Button* b)
930940
timescale->setPausedState(b->getToggleState());
931941
return;
932942
}
943+
944+
if (b == refreshButton.get())
945+
{
946+
lfpDisplay->rebuildDrawableChannelsList();
947+
return;
948+
}
933949

934950
if (b == showHideOptionsButton.get())
935951
{

Plugins/LfpDisplayNode/LfpDisplayOptions.h

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

188+
ScopedPointer<UtilityButton> refreshButton;
189+
188190
std::unique_ptr<ComboBox> overlapSelection; // what do we do with this?
189191

190192
OwnedArray<EventDisplayInterface> eventDisplayInterfaces;

0 commit comments

Comments
 (0)