Skip to content

Commit 98f396b

Browse files
committed
Fixed bug with LFP channels disappearing on reload
1 parent aeb21c2 commit 98f396b

2 files changed

Lines changed: 29 additions & 18 deletions

File tree

Source/Plugins/LfpDisplayNodeBeta/LfpDisplayCanvas.cpp

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ void LfpDisplayCanvas::update()
508508
//std::cout << chName << std::endl;
509509

510510
lfpDisplay->channelInfo[i]->setName(chName);
511-
lfpDisplay->enableChannel(isChannelEnabled[i], i);
511+
lfpDisplay->setEnabledState(isChannelEnabled[i], i);
512512

513513
}
514514

@@ -1254,6 +1254,8 @@ void LfpDisplayCanvas::saveVisualizerParameters(XmlElement* xml)
12541254
}
12551255
}
12561256

1257+
lfpDisplay->reactivateChannels();
1258+
12571259
xmlNode->setAttribute("EventButtonState", eventButtonState);
12581260

12591261
String channelDisplayState = "";
@@ -1328,13 +1330,13 @@ void LfpDisplayCanvas::loadVisualizerParameters(XmlElement* xml)
13281330
if (channelDisplayState.substring(i,i+1).equalsIgnoreCase("1"))
13291331
{
13301332
//std::cout << "LfpDisplayCanvas enabling channel " << i << std::endl;
1331-
lfpDisplay->enableChannel(true, i);
1333+
lfpDisplay->setEnabledState(true, i);
13321334
isChannelEnabled.set(i,true); //lfpDisplay->enableChannel(true, i);
13331335
}
13341336
else
13351337
{
13361338
//std::cout << "LfpDisplayCanvas disabling channel " << i << std::endl;
1337-
lfpDisplay->enableChannel(false, i);
1339+
lfpDisplay->setEnabledState(false, i);
13381340
isChannelEnabled.set(i,false);
13391341
}
13401342

@@ -1884,25 +1886,39 @@ void LfpDisplay::toggleSingleChannel(int chan)
18841886
if (chan != singleChan)
18851887
{
18861888
singleChan = chan;
1889+
18871890
int newHeight = viewport->getHeight();
18881891
channelInfo[chan]->setEnabledState(true);
1892+
18891893
setChannelHeight(newHeight, false);
18901894
setSize(getWidth(), numChans*getChannelHeight());
1895+
18911896
viewport->setScrollBarsShown(false,false);
18921897
viewport->setViewPosition(Point<int>(0,chan*newHeight));
1893-
for (int n = 0; n < numChans; n++)
1898+
1899+
for (int i = 0; i < channels.size(); i++)
18941900
{
1895-
savedChannelState.set(n, channels[n]->getEnabledState());
1896-
if (n != chan) channelInfo[n]->setEnabledState(false);
1901+
if (i != chan)
1902+
channels[i]->setEnabledState(false);
18971903
}
18981904

18991905
}
19001906
else
19011907
{
19021908
setChannelHeight(canvas->getChannelHeight());
1909+
1910+
reactivateChannels();
19031911
}
19041912
}
19051913

1914+
void LfpDisplay::reactivateChannels()
1915+
{
1916+
1917+
for (int n = 0; n < channels.size(); n++)
1918+
setEnabledState(savedChannelState[n], n);
1919+
1920+
}
1921+
19061922
bool LfpDisplay::getSingleChannelState()
19071923
{
19081924
if (singleChan < 0) return false;
@@ -1967,22 +1983,17 @@ bool LfpDisplay::getEventDisplayState(int ch)
19671983
return eventDisplayEnabled[ch];
19681984
}
19691985

1970-
void LfpDisplay::enableChannel(bool state, int chan)
1971-
{
19721986

1987+
void LfpDisplay::setEnabledState(bool state, int chan, bool updateSaved)
1988+
{
19731989
if (chan < numChans)
19741990
{
1991+
channels[chan]->setEnabledState(state);
19751992
channelInfo[chan]->setEnabledState(state);
1976-
canvas->isChannelEnabled.set(chan, state);
1977-
}
1978-
}
19791993

1980-
void LfpDisplay::setEnabledState(bool state, int chan)
1981-
{
1994+
if (updateSaved)
1995+
savedChannelState.set(chan, state);
19821996

1983-
if (chan < numChans)
1984-
{
1985-
channels[chan]->setEnabledState(state);
19861997
canvas->isChannelEnabled.set(chan, state);
19871998
}
19881999
}

Source/Plugins/LfpDisplayNodeBeta/LfpDisplayCanvas.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,8 @@ class LfpDisplay : public Component
302302
int getColorGrouping();
303303
void setColorGrouping(int i);
304304

305-
void setEnabledState(bool, int);
305+
void setEnabledState(bool state, int chan, bool updateSavedChans = true);
306306
bool getEnabledState(int);
307-
void enableChannel(bool, int);
308307

309308
bool getSingleChannelState();
310309

@@ -318,6 +317,7 @@ class LfpDisplay : public Component
318317
bool eventDisplayEnabled[8];
319318
bool isPaused; // simple pause function, skips screen bufer updates
320319

320+
void reactivateChannels();
321321

322322
private:
323323

0 commit comments

Comments
 (0)