@@ -32,7 +32,7 @@ using namespace LfpViewer;
3232#pragma mark - LfpDisplayCanvas -
3333
3434LfpDisplayCanvas::LfpDisplayCanvas (LfpDisplayNode* processor_) :
35- timebase(1 .0f ), displayGain(1 .0f ), timeOffset(0 .0f ),
35+ timebase(1 .0f ), displayGain(1 .0f ), timeOffset(0 .0f ),
3636 processor(processor_)
3737{
3838
@@ -255,12 +255,9 @@ void LfpDisplayCanvas::update()
255255 // std::cout << "Updating channel names" << std::endl;
256256 for (int i = 0 ; i < nChans; i++)
257257 {
258-
259258 String chName = processor->getDataChannel (i)->getName ();
260-
261259 lfpDisplay->channelInfo [i]->setName (chName);
262260 lfpDisplay->setEnabledState (isChannelEnabled[i], i);
263-
264261 }
265262
266263 if (nChans == 0 ) lfpDisplay->setBounds (0 , 0 , getWidth (), getHeight ());
@@ -275,7 +272,8 @@ void LfpDisplayCanvas::update()
275272 {
276273 for (int i = 0 ; i < nChans; i++)
277274 {
278- // std::cout << i << std::endl;
275+ String chName = processor->getDataChannel (i)->getName ();
276+ lfpDisplay->channelInfo [i]->setName (chName);
279277 lfpDisplay->channels [i]->updateType ();
280278 lfpDisplay->channelInfo [i]->updateType ();
281279 }
@@ -949,7 +947,21 @@ LfpDisplayOptions::LfpDisplayOptions(LfpDisplayCanvas* canvas_, LfpTimescale* ti
949947 medianOffsetPlottingButton->setToggleState (false , sendNotification);
950948 addAndMakeVisible (medianOffsetPlottingButton);
951949
952-
950+ // init channel name toggle
951+ showChannelNumberLabel = new Label (" showcChannelLabel" , " Show channel number instead of name" );
952+ showChannelNumberLabel->setFont (labelFont);
953+ showChannelNumberLabel->setColour (Label::textColourId, labelColour);
954+ addAndMakeVisible (showChannelNumberLabel);
955+
956+ showChannelNumberButton = new UtilityButton (" 0" , labelFont);
957+ showChannelNumberButton->setRadius (5 .0f );
958+ showChannelNumberButton->setEnabledState (true );
959+ showChannelNumberButton->setCorners (true , true , true , true );
960+ showChannelNumberButton->addListener (this );
961+ showChannelNumberButton->setClickingTogglesState (true );
962+ showChannelNumberButton->setToggleState (false , sendNotification);
963+ addAndMakeVisible (showChannelNumberButton);
964+
953965
954966 // init show/hide options button
955967 showHideOptionsButton = new ShowHideOptionsButton (this );
@@ -1153,7 +1165,7 @@ LfpDisplayOptions::LfpDisplayOptions(LfpDisplayCanvas* canvas_, LfpTimescale* ti
11531165 EventDisplayInterface* eventOptions = new EventDisplayInterface (lfpDisplay, canvas, i);
11541166 eventDisplayInterfaces.add (eventOptions);
11551167 addAndMakeVisible (eventOptions);
1156- eventOptions->setBounds (500 +(floor (i/2 )*20 ), getHeight ()-20 -(i%2 )*20 , 40 , 20 );
1168+ eventOptions->setBounds (700 +(floor (i/2 )*20 ), getHeight ()-20 -(i%2 )*20 , 40 , 20 );
11571169
11581170 lfpDisplay->setEventDisplayState (i,true );
11591171
@@ -1223,6 +1235,15 @@ void LfpDisplayOptions::resized()
12231235 150 ,
12241236 22 );
12251237
1238+ // Channel name toggle
1239+ showChannelNumberButton->setBounds (medianOffsetPlottingLabel->getRight () + 5 ,
1240+ medianOffsetPlottingLabel->getY (),
1241+ 20 ,
1242+ 20 );
1243+ showChannelNumberLabel->setBounds (showChannelNumberButton->getRight (),
1244+ showChannelNumberButton->getY (),
1245+ 200 ,
1246+ 22 );
12261247
12271248 // Spike raster plotting button
12281249 spikeRasterSelection->setBounds (medianOffsetPlottingButton->getX (),
@@ -1334,6 +1355,11 @@ bool LfpDisplayOptions::getInputInvertedState()
13341355 return invertInputButton->getToggleState ();
13351356}
13361357
1358+ bool LfpDisplayOptions::getChannelNameState ()
1359+ {
1360+ return showChannelNumberButton->getToggleState ();
1361+ }
1362+
13371363bool LfpDisplayOptions::getDisplaySpikeRasterizerState ()
13381364{
13391365// return spikeRasterButton->getToggleState();
@@ -1446,6 +1472,16 @@ void LfpDisplayOptions::buttonClicked(Button* b)
14461472 canvas->toggleOptionsDrawer (b->getToggleState ());
14471473 }
14481474
1475+ if (b == showChannelNumberButton)
1476+ {
1477+ int numChannels = lfpDisplay->channelInfo .size ();
1478+ for (int i = 0 ; i < numChannels; ++i)
1479+ {
1480+ lfpDisplay->channelInfo [i]->repaint ();
1481+ }
1482+ return ;
1483+ }
1484+
14491485 int idx = typeButtons.indexOf ((UtilityButton*)b);
14501486
14511487 if ((idx >= 0 ) && (b->getToggleState ()))
@@ -3078,6 +3114,7 @@ LfpChannelDisplay::LfpChannelDisplay(LfpDisplayCanvas* c, LfpDisplay* d, LfpDisp
30783114 , options(o)
30793115 , isSelected(false )
30803116 , chan(channelNumber)
3117+ , name(" " )
30813118 , drawableChan(channelNumber)
30823119 , channelOverlap(300 )
30833120 , channelHeight(30 )
@@ -3513,6 +3550,11 @@ int LfpChannelDisplay::getChannelNumber()
35133550 return chan;
35143551}
35153552
3553+ String LfpChannelDisplay::getName ()
3554+ {
3555+ return name;
3556+ }
3557+
35163558int LfpChannelDisplay::getDrawableChannelNumber ()
35173559{
35183560 return drawableChan;
@@ -3569,7 +3611,7 @@ LfpChannelDisplayInfo::LfpChannelDisplayInfo(LfpDisplayCanvas* canvas_, LfpDispl
35693611 y = -1 .0f ;
35703612
35713613// enableButton = new UtilityButton(String(ch+1), Font("Small Text", 13, Font::plain));
3572- enableButton = new UtilityButton (" * " , Font (" Small Text" , 13 , Font::plain));
3614+ enableButton = new UtilityButton (" " , Font (" Small Text" , 13 , Font::plain));
35733615 enableButton->setRadius (5 .0f );
35743616
35753617 enableButton->setEnabledState (true );
@@ -3728,25 +3770,20 @@ void LfpChannelDisplayInfo::paint(Graphics& g)
37283770{
37293771
37303772 int center = getHeight ()/2 - (isSingleChannel?(75 ):(0 ));
3773+ const bool showChannelNumbers = options->getChannelNameState ();
37313774
3732- // g.setColour(lineColour);
3733- // if (chan > 98)
3734- // g.fillRoundedRectangle(5,center-8,51,22,8.0f);
3735- // else
3736-
3737- // g.fillRoundedRectangle(5,center-8,41,22,8.0f);
3738-
37393775 // Draw the channel numbers
37403776 g.setColour (Colours::grey);
3741- const String channelString = (isChannelNumberHidden () ? (" --" ) : String (getChannelNumber () + 1 ));
3777+ const String channelString = (isChannelNumberHidden () ? (" --" ) :
3778+ showChannelNumbers ? String (getChannelNumber () + 1 ) : getName ());
37423779 bool isCentered = !getEnabledButtonVisibility ();
37433780
37443781 g.drawText (channelString,
3745- 2 ,
3782+ showChannelNumbers ? 6 : 2 ,
37463783 center-4 ,
3747- isCentered ? ( getWidth ()/2 - 4 ) : ( getWidth ()/ 4 ) ,
3784+ getWidth ()/2 ,
37483785 10 ,
3749- isCentered ? Justification::centred : Justification::centredRight ,
3786+ isCentered ? Justification::centred : Justification::centredLeft ,
37503787 false );
37513788
37523789 g.setColour (lineColour);
@@ -3797,17 +3834,11 @@ void LfpChannelDisplayInfo::resized()
37973834{
37983835
37993836 int center = getHeight ()/2 - (isSingleChannel?(75 ):(0 ));
3800-
3801- // if (chan > 98)
3802- // enableButton->setBounds(8,center-5,45,16);
3803- // else
3804- // enableButton->setBounds(8,center-5,35,16);
3805-
38063837 setEnabledButtonVisibility (getHeight () >= 16 );
38073838
38083839 if (getEnabledButtonVisibility ())
38093840 {
3810- enableButton->setBounds (getWidth ()/4 + 5 , ( center) - 7 , 15 , 15 );
3841+ enableButton->setBounds (getWidth ()/2 - 10 , center - 5 , 10 , 10 );
38113842 }
38123843
38133844 setChannelNumberIsHidden (getHeight () < 16 && (getDrawableChannelNumber () + 1 ) % 10 != 0 );
0 commit comments