Skip to content

Commit 21d75a3

Browse files
committed
Change filter message parsing to expect rectangular selection params
1 parent 2af690e commit 21d75a3

5 files changed

Lines changed: 18 additions & 26 deletions

File tree

Plugins/LfpDisplayNode/DisplayBuffer.cpp

Lines changed: 1 addition & 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), hasFilter(false)
31+
id(id_), name(name_), sampleRate(sampleRate_), isNeeded(true)
3232
{
3333
previousSize = 0;
3434
numChannels = 0;

Plugins/LfpDisplayNode/DisplayBuffer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ namespace LfpViewer {
9191

9292
Array<ChannelMetadata> channelMetadata;
9393

94-
void setFilteredChannels(StringArray channels) {filteredChannels = channels;hasFilter = true;}
94+
void setFilteredChannels(StringArray channels) {filteredChannels = channels;}
9595

9696
String name;
9797
int id;
@@ -127,8 +127,6 @@ namespace LfpViewer {
127127
Array<int> displays;
128128

129129
StringArray filteredChannels;
130-
131-
bool hasFilter;
132130

133131
};
134132
};

Plugins/LfpDisplayNode/LfpDisplay.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
5050

5151
#include <math.h>
5252
#include <numeric>
53-
#include <vector>
5453

5554
using namespace LfpViewer;
5655

@@ -982,21 +981,19 @@ void LfpDisplay::rebuildDrawableChannelsList()
982981
removeAllChildren(); // start with clean slate
983982

984983
Array<LfpChannelTrack> channelsToDraw; // all visible channels will be added to this array
985-
int filteredChannelsSize = 0;
986984
StringArray filteredChannels;
987985
if(canvasSplit -> displayBuffer) {
988-
filteredChannelsSize = canvasSplit -> displayBuffer -> hasFilter ? canvasSplit -> displayBuffer -> filteredChannels.size() : 0;
989986
filteredChannels = canvasSplit -> displayBuffer -> filteredChannels;
990987
}
991988
// iterate over all channels and select drawable ones
992989
for (int i = 0, drawableChannelNum = 0, filterChannelIndex = 0; i < channels.size(); i++)
993990
{
994991
//std::cout << "Checking for hidden channels" << std::endl;
995-
String channelName = filteredChannelsSize ? canvasSplit->displayBuffer->channelMetadata[i].name: "";
996-
if(filteredChannelsSize == 0 || (filterChannelIndex < filteredChannelsSize && channelName == filteredChannels[filterChannelIndex])) {
997-
if (displaySkipAmt == 0 || ((filteredChannelsSize ? filterChannelIndex : i) % displaySkipAmt == 0)) // no skips, add all channels
992+
String channelName = filteredChannels.size() ? canvasSplit->displayBuffer->channelMetadata[i].name: "";
993+
//check if no filter list is used or if the current channel has the same name as the current filtered channel in the list
994+
if(filteredChannels.size() == 0 || (filterChannelIndex < filteredChannels.size() && channelName == filteredChannels[filterChannelIndex])) {
995+
if (displaySkipAmt == 0 || ((filteredChannels.size() ? filterChannelIndex : i) % displaySkipAmt == 0)) // no skips, add all channels
998996
{
999-
//std::cout << canvasSplit->displayBuffer->channelMetadata[i].name << std::endl;
1000997

1001998
channels[i]->setHidden(false);
1002999
channelInfo[i]->setHidden(false);

Plugins/LfpDisplayNode/LfpDisplayNode.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -328,14 +328,8 @@ void LfpDisplayNode::acknowledgeTrigger(int id)
328328
latestTrigger.set(id, -1);
329329
}
330330

331-
String LfpDisplayNode::handleConfigMessage(String msg) {
332-
std::cout << "in lfp config: " << msg <<std::endl;
333-
}
334-
335331
void LfpDisplayNode::handleBroadcastMessage(String msg) {
336332
DynamicObject::Ptr jsonMessage = JSON::parse(msg).getDynamicObject();
337-
std::cout<< msg<< std::endl;
338-
StringArray parts = StringArray::fromTokens(msg, ";", "");
339333
String pluginName= jsonMessage -> getProperty("plugin");
340334
if(pluginName != "LFPViewer") {
341335
return;
@@ -346,17 +340,22 @@ void LfpDisplayNode::handleBroadcastMessage(String msg) {
346340
if(payload.get() == nullptr)
347341
return;
348342
int streamID = payload -> getProperty("streamID");
349-
var indexes = payload -> getProperty("indexes");
350-
if(streamID < 0 || indexes.size() == 0 ){
343+
int start = payload -> getProperty("start");
344+
int rows = payload -> getProperty("rows");
345+
int cols = payload -> getProperty("cols");
346+
int colsPerRow = payload -> getProperty("colsPerRow");
347+
if(streamID < 0 || start < 0 || rows < 0 || cols < 0 || colsPerRow < 0){
351348
return;
352349
}
353350
StringArray channelNames;
354-
for(int i = 0; i < indexes.size(); i++) {
355-
channelNames.add("CH"+String(indexes[i]));
351+
for(int row = 0; row < rows; row++) {
352+
for(int col = 0; col < cols; col++) {
353+
channelNames.add("CH"+String(start + col + row*colsPerRow));
354+
}
356355
}
357356
displayBufferMap[streamID] -> setFilteredChannels(channelNames);
358357
for(auto split : splitDisplays) {
359-
split -> shouldRebuildChannelList = true;
358+
split -> shouldRebuildChannelList = split->displayBuffer->id == streamID;
360359
}
361360

362361
}

Plugins/LfpDisplayNode/LfpDisplayNode.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,8 @@ 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-
102+
103+
/** Handles messages from other processors during acquisition*/
106104
void handleBroadcastMessage(String msg) override;
107105

108106
private:

0 commit comments

Comments
 (0)