Skip to content

Commit 756409a

Browse files
committed
Add docstrings to LfpDisplayNode
1 parent c21b1a6 commit 756409a

6 files changed

Lines changed: 134 additions & 36 deletions

File tree

Plugins/LfpDisplayNode/LfpChannelDisplay.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,11 @@ void LfpChannelDisplay::setInputInverted(bool isInverted)
780780
}
781781
}
782782

783+
bool LfpChannelDisplay::getInputInverted()
784+
{
785+
return inputInverted;
786+
}
787+
783788
void LfpChannelDisplay::setDrawMethod(bool isDrawMethod)
784789
{
785790

Plugins/LfpDisplayNode/LfpChannelDisplay.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ class LfpChannelDisplay : public Component
129129
/** Sets whether this channel display should be inverted */
130130
void setInputInverted(bool);
131131

132+
/** Returns whether this channel display is inverted */
133+
bool getInputInverted();
134+
132135
/** Sets whether this channel display can be inverted */
133136
void setCanBeInverted(bool);
134137

Plugins/LfpDisplayNode/LfpDisplay.cpp

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ LfpDisplay::LfpDisplay(LfpDisplaySplitter* c, Viewport* v)
113113

114114
addMouseListener(this, true);
115115

116-
for (int i = 0; i < 8; i++)
116+
for (int ttlLine = 0; ttlLine < 8; ttlLine++)
117117
{
118-
eventDisplayEnabled[i] = true;
118+
eventDisplayEnabled[ttlLine] = true;
119119
}
120120

121121
savedChannelState.insertMultiple(0, true, 10000); // max 10k channels
@@ -444,7 +444,7 @@ void LfpDisplay::refresh()
444444
totalPixelsToFill = canvasSplit->screenBufferWidth - fillfrom + fillto;
445445
}
446446

447-
//std::cout << fillfrom << " : " << fillto << " ::: " << "totalPixelsToFill: " << totalPixelsToFill << std::endl;
447+
std::cout << fillfrom << " : " << fillto << " ::: " << "totalPixelsToFill: " << totalPixelsToFill << std::endl;
448448

449449
int topBorder = viewport->getViewPositionY();
450450
int bottomBorder = viewport->getViewHeight() + topBorder;
@@ -659,6 +659,19 @@ void LfpDisplay::setInputInverted(bool isInverted)
659659

660660
}
661661

662+
Array<bool> LfpDisplay::getInputInverted()
663+
{
664+
665+
Array<bool> invertedState;
666+
667+
for (int i = 0; i < numChans; i++)
668+
{
669+
invertedState.add(channels[i]->getInputInverted());
670+
}
671+
672+
return invertedState;
673+
}
674+
662675
void LfpDisplay::setDrawMethod(bool isDrawMethod)
663676
{
664677
for (int i = 0; i < numChans; i++)
@@ -715,6 +728,13 @@ void LfpDisplay::orderChannelsByDepth(bool state)
715728

716729
}
717730

731+
bool LfpDisplay::shouldOrderChannelsByDepth()
732+
{
733+
734+
return channelsOrderedByDepth;
735+
736+
}
737+
718738
int LfpDisplay::getChannelDisplaySkipAmount()
719739
{
720740
return displaySkipAmt;
@@ -1238,15 +1258,15 @@ void LfpDisplay::mouseDown(const MouseEvent& event)
12381258

12391259
}
12401260

1241-
bool LfpDisplay::setEventDisplayState(int ch, bool state)
1261+
bool LfpDisplay::setEventDisplayState(int ttlLine, bool state)
12421262
{
1243-
eventDisplayEnabled[ch] = state;
1244-
return eventDisplayEnabled[ch];
1263+
eventDisplayEnabled[ttlLine] = state;
1264+
return eventDisplayEnabled[ttlLine];
12451265
}
12461266

1247-
bool LfpDisplay::getEventDisplayState(int ch)
1267+
bool LfpDisplay::getEventDisplayState(int ttlLine)
12481268
{
1249-
return eventDisplayEnabled[ch];
1269+
return eventDisplayEnabled[ttlLine];
12501270
}
12511271

12521272
void LfpDisplay::setEnabledState(bool state, int chan, bool updateSaved)

Plugins/LfpDisplayNode/LfpDisplay.h

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ namespace LfpViewer {
4444
bitmap is drawn by the LfpViewport using Viewport::setViewedComponent.
4545
4646
*/
47-
class LfpDisplay : public Component, public Timer
47+
class LfpDisplay : public Component,
48+
public Timer
4849
{
4950
public:
5051

@@ -96,15 +97,25 @@ class LfpDisplay : public Component, public Timer
9697
/** Returns the display range for the specified channel type */
9798
int getRange(ContinuousChannel::Type type);
9899

100+
/** Sets the channel height in pixels */
99101
void setChannelHeight(int r, bool resetSingle = true);
102+
103+
/** Returns the channel height in pixels */
100104
int getChannelHeight();
101-
102-
ChannelColourScheme * getColourSchemePtr();
103-
105+
104106
/** Caches a new channel height without updating the channels */
105107
void cacheNewChannelHeight(int r);
106108

109+
/** Gets a pointer to the current color scheme */
110+
ChannelColourScheme* getColourSchemePtr();
111+
112+
/** Sets whether the input should be inverted */
107113
void setInputInverted(bool);
114+
115+
/** Returns whether the input should be inverted across all channels */
116+
Array<bool> getInputInverted();
117+
118+
/** Changes between super-sampled and per-pixel plotter */
108119
void setDrawMethod(bool);
109120

110121
/** Returns a bool indicating if the channels are displayed in reverse order (true) */
@@ -115,30 +126,50 @@ class LfpDisplay : public Component, public Timer
115126

116127
/** Reorders the displayed channels by depth if state == true and normal if false */
117128
void orderChannelsByDepth(bool state);
129+
130+
/** Returns true if channels are ordered by depth */
131+
bool shouldOrderChannelsByDepth();
118132

119133
/** Returns a factor of 2 by which the displayed channels should skip */
120134
int getChannelDisplaySkipAmount();
121135

122136
/** Set the amount of channels to skip (hide) between each that is displayed */
123137
void setChannelDisplaySkipAmount(int skipAmt);
124138

139+
/** Updates colors across channels */
125140
void setColors();
126141

142+
/** Sets the index of the selected color scheme */
127143
void setActiveColourSchemeIdx(int index);
144+
145+
/** Gets the index of the selected color scheme */
128146
int getActiveColourSchemeIdx();
129147

148+
/** Returns the number of available color schemes*/
130149
int getNumColourSchemes();
150+
151+
/** Returns the names of the available color schemes*/
131152
StringArray getColourSchemeNameArray();
132153

133-
bool setEventDisplayState(int ch, bool state);
134-
bool getEventDisplayState(int ch);
154+
/** Sets whether events are displayed for a particular ttl line*/
155+
bool setEventDisplayState(int ttlLine, bool state);
156+
157+
/** Returns whether events are displayed for a particular ttl line */
158+
bool getEventDisplayState(int ttlLine);
135159

160+
/** Returns the number of adjacent channels of each color */
136161
int getColorGrouping();
162+
163+
/** Sets the number of adjacent channels of each color */
137164
void setColorGrouping(int i);
138165

166+
/** Sets whether a particular channel is enabled */
139167
void setEnabledState(bool state, int chan, bool updateSavedChans = true);
140-
bool getEnabledState(int);
168+
169+
/** Returns whether a particular channel is enabled */
170+
bool getEnabledState(int chan);
141171

172+
/** Sets the scroll offset for this display*/
142173
void setScrollPosition(int x, int y);
143174

144175
/** Returns true if the median offset is enabled for plotting, else false */
@@ -187,9 +218,8 @@ class LfpDisplay : public Component, public Timer
187218
LfpChannelDisplayInfo* channelInfo;
188219
};
189220

190-
Array<LfpChannelTrack> drawableChannels; // holds the channels and info that are
191-
// drawable to the screen
192-
221+
/** Holds the channels that are being drawn */
222+
Array<LfpChannelTrack> drawableChannels;
193223

194224
/** Set the viewport's channel focus behavior.
195225
@@ -214,18 +244,25 @@ class LfpDisplay : public Component, public Timer
214244
/** Returns a const pointer to the internally managed plotter method class */
215245
LfpBitmapPlotter * const getPlotterPtr() const;
216246

247+
/** Current background color (based on the selected color scheme)*/
217248
Colour backgroundColour;
218249

250+
/** Array of channel colors (based on the selected color scheme*/
219251
Array<Colour> channelColours;
220252

221-
OwnedArray<LfpChannelDisplay> channels; // all channels
222-
OwnedArray<LfpChannelDisplayInfo> channelInfo; // all channelInfos
253+
/** All available channels (even ones that are not drawn) */
254+
OwnedArray<LfpChannelDisplay> channels;
223255

224-
void timerCallback() override;
225-
256+
/** All available display info objects (even ones that are not drawn) */
257+
OwnedArray<LfpChannelDisplayInfo> channelInfo;
258+
259+
/** Holds state of event display for first 8 ttl lines */
226260
bool eventDisplayEnabled[8];
227-
bool displayIsPaused = false; // simple pause function, skips screen buffer updates
228261

262+
/** Enables simple pause function by skipping screen buffer updates */
263+
bool displayIsPaused = false;
264+
265+
/** Pointer to display options*/
229266
LfpDisplayOptions* options;
230267

231268
/** Convenience struct to store all variables particular to zooming mechanics */
@@ -246,13 +283,19 @@ class LfpDisplay : public Component, public Timer
246283
bool unpauseOnScrollEnd;
247284
};
248285

249-
TrackZoomInfo_Struct trackZoomInfo; // and create an instance here
286+
/** Instance of trackZoomInfo struct */
287+
TrackZoomInfo_Struct trackZoomInfo;
250288

289+
/** Stores whether or not channels are enabled */
251290
Array<bool> savedChannelState;
252291

292+
/** x-index of display bitmap updated on previous refresh */
253293
int lastBitmapIndex;
254294

255295
private:
296+
297+
/** Used to throttle refresh speed when scrolling backwards */
298+
void timerCallback() override;
256299

257300
int singleChan;
258301

@@ -266,7 +309,10 @@ class LfpDisplay : public Component, public Timer
266309

267310
int numChans;
268311
int displaySkipAmt;
269-
int cachedDisplayChannelHeight; // holds a channel height if reset during single channel focus
312+
313+
/** Holds a channel height if reset during single channel focus */
314+
int cachedDisplayChannelHeight;
315+
270316
float drawableSampleRate;
271317
uint32 drawableSubprocessor;
272318

@@ -297,5 +343,5 @@ class LfpDisplay : public Component, public Timer
297343
OwnedArray<ChannelColourScheme> colourSchemeList;
298344
};
299345

300-
}; // namespace
346+
}; // end LfpViewer namespace
301347
#endif

Plugins/LfpDisplayNode/LfpDisplayCanvas.cpp

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ void LfpDisplayCanvas::mouseUp(const MouseEvent& e)
560560
{
561561
if (borderToDrag >= 0)
562562
{
563-
std::cout << "Mouse up" << std::endl;
563+
//std::cout << "Mouse up" << std::endl;
564564

565565
resized();
566566
borderToDrag = -1;
@@ -967,22 +967,22 @@ void LfpDisplaySplitter::updateSettings()
967967

968968
}
969969

970-
lfpDisplay->rebuildDrawableChannelsList();
970+
lfpDisplay->rebuildDrawableChannelsList(); // calls setColors(), which calls refresh
971971

972972
isLoading = false;
973973

974-
syncDisplay();
975-
syncDisplayBuffer();
974+
syncDisplay(); // sets lastBitmapIndex to 0
975+
syncDisplayBuffer(); // sets displayBufferIndex to 0
976976

977977
isUpdating = false;
978978

979-
lfpDisplay->setColors();
979+
//lfpDisplay->setColors(); // calls refresh
980980

981981
resized();
982982

983983
lfpDisplay->restoreViewPosition();
984984

985-
lfpDisplay->refresh();
985+
//lfpDisplay->refresh(); // calls refresh
986986

987987
}
988988

@@ -1249,7 +1249,7 @@ void LfpDisplaySplitter::updateScreenBuffer()
12491249

12501250
// HELPFUL FOR DEBUGGING:
12511251

1252-
/*if (channel == 0)
1252+
if (channel == 0)
12531253
std::cout << "Split "
12541254
<< splitID << " ch: "
12551255
<< channel << " sbi: "
@@ -1262,7 +1262,7 @@ void LfpDisplaySplitter::updateScreenBuffer()
12621262
<< subSampleOffset << " max: "
12631263
<< maxSamples << " playhead: "
12641264
<< lfpDisplay->lastBitmapIndex
1265-
<< std::endl;*/
1265+
<< std::endl;
12661266

12671267
int sampleNumber = 0;
12681268

@@ -1483,6 +1483,16 @@ void LfpDisplaySplitter::setTimebase(float t)
14831483
{
14841484
timebase = t;
14851485

1486+
if (timebase <= 0.1)
1487+
{
1488+
stopTimer();
1489+
startTimer(1000);
1490+
}
1491+
else {
1492+
stopTimer();
1493+
startTimer(50);
1494+
}
1495+
14861496
if (trialAveraging)
14871497
{
14881498
numTrials = -1;
@@ -1660,8 +1670,11 @@ void LfpDisplaySplitter::visibleAreaChanged()
16601670

16611671
void LfpDisplaySplitter::refresh()
16621672
{
1673+
16631674
updateScreenBuffer();
1664-
if(shouldRebuildChannelList) {
1675+
1676+
if(shouldRebuildChannelList)
1677+
{
16651678
shouldRebuildChannelList = false;
16661679
lfpDisplay->rebuildDrawableChannelsList(); // calls resized()/refresh() after rebuilding list
16671680
}

Plugins/LfpDisplayNode/LfpDisplayOptions.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,10 @@ void LfpDisplayOptions::togglePauseButton(bool sendUpdate)
775775

776776
void LfpDisplayOptions::setChannelsReversed(bool state)
777777
{
778+
779+
if (lfpDisplay->getChannelsReversed() == state) // ignore if we're not changing state
780+
return;
781+
778782
lfpDisplay->setChannelsReversed(state);
779783
canvasSplit->fullredraw = true;
780784

@@ -791,6 +795,7 @@ void LfpDisplayOptions::setChannelsReversed(bool state)
791795

792796
void LfpDisplayOptions::setInputInverted(bool state)
793797
{
798+
794799
lfpDisplay->setInputInverted(state);
795800

796801
invertInputButton->setToggleState(state, dontSendNotification);
@@ -849,6 +854,9 @@ void LfpDisplayOptions::setAveraging(bool state)
849854
void LfpDisplayOptions::setSortByDepth(bool state)
850855
{
851856

857+
if (lfpDisplay->shouldOrderChannelsByDepth() == state)
858+
return;
859+
852860
if (canvasSplit->displayBuffer != nullptr)
853861
lfpDisplay->orderChannelsByDepth(state);
854862

@@ -1504,7 +1512,10 @@ void LfpDisplayOptions::loadParameters(XmlElement* xml)
15041512
//LOGD(" --> setShowChannelNumbers: ", MS_FROM_START, " milliseconds");
15051513
start = Time::getHighResolutionTicks();
15061514

1507-
setInputInverted(xmlNode->getBoolAttribute("isInverted", false));
1515+
bool shouldInvert = xmlNode->getBoolAttribute("isInverted", false);
1516+
1517+
if (invertInputButton->getToggleState() != shouldInvert)
1518+
setInputInverted(shouldInvert);
15081519

15091520
//LOGD(" --> setInputInverted: ", MS_FROM_START, " milliseconds");
15101521
start = Time::getHighResolutionTicks();

0 commit comments

Comments
 (0)