Skip to content

Commit 70f8839

Browse files
committed
Update SpikePlot labels
1 parent 8e9f0f6 commit 70f8839

2 files changed

Lines changed: 71 additions & 72 deletions

File tree

Plugins/SpikeViewer/SpikePlots.cpp

Lines changed: 64 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ SpikePlot::SpikePlot (SpikeDisplayCanvas* sdc,
3232
int p,
3333
String name_,
3434
Array<String> continuousChannelNames_,
35-
std::string identifier_) :
36-
canvas (sdc),
37-
electrodeNumber (elecNum),
38-
plotType (p),
39-
limitsChanged (true),
40-
name (name_),
41-
continuousChannelNames(continuousChannelNames_),
42-
identifier (identifier_)
35+
std::string identifier_) : canvas (sdc),
36+
electrodeNumber (elecNum),
37+
plotType (p),
38+
limitsChanged (true),
39+
name (name_),
40+
continuousChannelNames (continuousChannelNames_),
41+
identifier (identifier_)
4342
{
4443
font = FontOptions ("Inter", "Medium", 16.0f);
4544

@@ -96,7 +95,6 @@ SpikePlot::SpikePlot (SpikeDisplayCanvas* sdc,
9695
channelNameLabel = std::make_unique<Label>();
9796
channelNameLabel->setText (name, dontSendNotification);
9897
channelNameLabel->setFont (font);
99-
channelNameLabel->setColour (Label::textColourId, findColour (ThemeColours::defaultText));
10098
channelNameLabel->setBounds (10, 0, 200, 20);
10199
addAndMakeVisible (channelNameLabel.get());
102100

@@ -204,7 +202,7 @@ void SpikePlot::initAxes()
204202
channelComparison = continuousChannelNames[1] + " vs " + continuousChannelNames[3];
205203
else if (i == 5)
206204
channelComparison = continuousChannelNames[2] + " vs " + continuousChannelNames[3];
207-
205+
208206
ProjectionAxes* pAx = new ProjectionAxes (canvas, proj, channelComparison);
209207
projectionAxes.add (pAx);
210208
addAndMakeVisible (pAx);
@@ -484,11 +482,10 @@ void SpikePlot::invertSpikes (bool shouldInvert)
484482

485483
GenericAxes::GenericAxes (SpikeDisplayCanvas* canvas,
486484
SpikePlotType type_,
487-
String channelName_) :
488-
canvas (canvas),
489-
type (type_),
490-
channelName(channelName_),
491-
gotFirstSpike (false)
485+
String channelName_) : canvas (canvas),
486+
type (type_),
487+
channelName (channelName_),
488+
gotFirstSpike (false)
492489
{
493490
ylims[0] = 0;
494491
ylims[1] = 1;
@@ -576,26 +573,25 @@ double GenericAxes::ad16ToUv (int x, int gain)
576573
return result;
577574
}
578575

579-
WaveAxes::WaveAxes (SpikeDisplayCanvas* canvas,
576+
WaveAxes::WaveAxes (SpikeDisplayCanvas* canvas,
580577
int electrodeIndex,
581578
int channel_,
582579
String channelName,
583-
std::string identifier_) :
584-
GenericAxes (canvas, WAVE_AXES, channelName),
585-
electrodeIndex (electrodeIndex),
586-
drawGrid (true),
587-
displayThresholdLevel (0.0f),
588-
detectorThresholdLevel (0.0f),
589-
spikesReceivedSinceLastRedraw (0),
590-
spikeIndex (0),
591-
bufferSize (5),
592-
range (250.0f),
593-
isOverThresholdSlider (false),
594-
isDraggingThresholdSlider (false),
595-
thresholdCoordinator (nullptr),
596-
spikesInverted (false),
597-
channel (channel_),
598-
identifier (identifier_)
580+
std::string identifier_) : GenericAxes (canvas, WAVE_AXES, channelName),
581+
electrodeIndex (electrodeIndex),
582+
drawGrid (true),
583+
displayThresholdLevel (0.0f),
584+
detectorThresholdLevel (0.0f),
585+
spikesReceivedSinceLastRedraw (0),
586+
spikeIndex (0),
587+
bufferSize (5),
588+
range (250.0f),
589+
isOverThresholdSlider (false),
590+
isDraggingThresholdSlider (false),
591+
thresholdCoordinator (nullptr),
592+
spikesInverted (false),
593+
channel (channel_),
594+
identifier (identifier_)
599595
{
600596
addMouseListener (this, true);
601597

@@ -609,18 +605,17 @@ WaveAxes::WaveAxes (SpikeDisplayCanvas* canvas,
609605
}
610606

611607
thresholdLabel = std::make_unique<Label>();
612-
thresholdLabel->setFont(font);
613-
thresholdLabel->setJustificationType(Justification::right);
614-
thresholdLabel->setColour(Label::textColourId, thresholdColour);
615-
addAndMakeVisible(thresholdLabel.get());
608+
thresholdLabel->setFont (font);
609+
thresholdLabel->setJustificationType (Justification::right);
610+
thresholdLabel->setColour (Label::textColourId, thresholdColour);
611+
addAndMakeVisible (thresholdLabel.get());
616612

617613
channelNameLabel = std::make_unique<Label>();
618-
channelNameLabel->setFont(font);
619-
channelNameLabel->setJustificationType(Justification::left);
620-
channelNameLabel->setColour(Label::textColourId, Colours::white);
621-
channelNameLabel->setText(channelName, dontSendNotification);
622-
channelNameLabel->setBounds(getWidth()-44, 5, 40, 13);
623-
addAndMakeVisible(channelNameLabel.get());
614+
channelNameLabel->setFont (font);
615+
channelNameLabel->setJustificationType (Justification::left);
616+
channelNameLabel->setColour (Label::textColourId, Colours::white.withAlpha (0.5f));
617+
channelNameLabel->setText (channelName, dontSendNotification);
618+
addAndMakeVisible (channelNameLabel.get());
624619
}
625620

626621
void WaveAxes::setRange (float r)
@@ -648,7 +643,7 @@ void WaveAxes::paint (Graphics& g)
648643

649644
// draw the threshold line and labels
650645
drawThresholdSlider (g);
651-
646+
652647
// if no spikes have been received then don't plot anything
653648
if (! gotFirstSpike)
654649
{
@@ -666,7 +661,6 @@ void WaveAxes::paint (Graphics& g)
666661
plotSpike (spikeBuffer[spikeIndex], g);
667662

668663
spikesReceivedSinceLastRedraw = 0;
669-
670664
}
671665

672666
void WaveAxes::plotSpike (const Spike* s, Graphics& g, bool latestSpike)
@@ -692,9 +686,8 @@ void WaveAxes::plotSpike (const Spike* s, Graphics& g, bool latestSpike)
692686
if (latestSpike)
693687
g.setColour (Colours::white);
694688
else
695-
g.setColour(Colours::white.withAlpha(0.4f));
689+
g.setColour (Colours::white.withAlpha (0.4f));
696690
}
697-
698691

699692
// type corresponds to channel so we need to calculate the starting
700693
// sample based upon which channel is getting plotted
@@ -760,15 +753,14 @@ void WaveAxes::drawThresholdSlider (Graphics& g)
760753

761754
if (isOverThresholdSlider)
762755
{
763-
thresholdLabel->setText(String(int(displayThresholdLevel)), dontSendNotification);
764-
thresholdLabel->setBounds(getWidth() - 25, h + 4, 22, 12);
765-
thresholdLabel->setVisible(true);
756+
thresholdLabel->setText (String (int (displayThresholdLevel)), dontSendNotification);
757+
thresholdLabel->setBounds (getWidth() - 25, h + 4, 22, 12);
758+
thresholdLabel->setVisible (true);
766759
}
767760
else
768761
{
769-
thresholdLabel->setVisible(false);
762+
thresholdLabel->setVisible (false);
770763
}
771-
772764

773765
// draw detector threshold (not editable)
774766
if (! spikesInverted)
@@ -800,7 +792,7 @@ void WaveAxes::drawWaveformGrid (Graphics& g)
800792
tick = 250.0f;
801793

802794
g.setColour (Colours::darkgrey);
803-
g.setFont (10);
795+
g.setFont (FontOptions (10.0f));
804796

805797
for (float y = -range / 2; y < range / 2; y += tick)
806798
{
@@ -814,10 +806,15 @@ void WaveAxes::drawWaveformGrid (Graphics& g)
814806
g.fillRect (0.0f, yy, w, 1.0f);
815807
}
816808

817-
//g.drawText (String (y, 0), Rectangle<float> (0, yy + 3, 40, 10), Justification::centredLeft);
809+
g.drawText (String (y, 0), Rectangle<float> (0, yy + 3, 40, 10), Justification::centredLeft);
818810
}
819811
}
820812

813+
void WaveAxes::resized()
814+
{
815+
channelNameLabel->setBounds (getWidth() - 44, 5, 40, 13);
816+
}
817+
821818
bool WaveAxes::updateSpikeData (const Spike* s)
822819
{
823820
if (! gotFirstSpike)
@@ -973,15 +970,14 @@ void WaveAxes::setDisplayThreshold (float threshold)
973970

974971
// --------------------------------------------------
975972

976-
ProjectionAxes::ProjectionAxes (SpikeDisplayCanvas* canvas,
973+
ProjectionAxes::ProjectionAxes (SpikeDisplayCanvas* canvas,
977974
Projection proj_,
978-
String channelNames) :
979-
GenericAxes (canvas, PROJECTION_AXES, channelNames),
980-
imageDim (500),
981-
rangeX (250),
982-
rangeY (250),
983-
spikesReceivedSinceLastRedraw (0),
984-
proj (proj_)
975+
String channelNames) : GenericAxes (canvas, PROJECTION_AXES, channelNames),
976+
imageDim (500),
977+
rangeX (250),
978+
rangeY (250),
979+
spikesReceivedSinceLastRedraw (0),
980+
proj (proj_)
985981
{
986982
projectionImage = Image (Image::RGB, imageDim, imageDim, true, SoftwareImageType());
987983

@@ -990,12 +986,12 @@ ProjectionAxes::ProjectionAxes (SpikeDisplayCanvas* canvas,
990986
n2ProjIdx (proj, &ampDim1, &ampDim2);
991987

992988
channelNameLabel = std::make_unique<Label>();
993-
channelNameLabel->setFont(13);
994-
channelNameLabel->setJustificationType(Justification::left);
995-
channelNameLabel->setColour(Label::textColourId, Colours::white.withAlpha(0.3f));
996-
channelNameLabel->setText(channelName, dontSendNotification);
997-
channelNameLabel->setBounds(4, 5, 100, 13);
998-
addAndMakeVisible(channelNameLabel.get());
989+
channelNameLabel->setFont (13);
990+
channelNameLabel->setJustificationType (Justification::left);
991+
channelNameLabel->setColour (Label::textColourId, Colours::white.withAlpha (0.4f));
992+
channelNameLabel->setText (channelName, dontSendNotification);
993+
channelNameLabel->setBounds (4, 5, 100, 13);
994+
addAndMakeVisible (channelNameLabel.get());
999995
}
1000996

1001997
void ProjectionAxes::setRange (float x, float y)
@@ -1017,7 +1013,7 @@ void ProjectionAxes::paint (Graphics& g)
10171013
imageDim - rangeY,
10181014
rangeX,
10191015
rangeY);
1020-
}
1016+
}
10211017

10221018
bool ProjectionAxes::updateSpikeData (const Spike* s)
10231019
{

Plugins/SpikeViewer/SpikePlots.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ class SpikePlot : public Component,
110110
void setId (std::string id);
111111

112112
/** Draws outline and electrode name*/
113-
void paint (Graphics& g);
113+
void paint (Graphics& g) override;
114114

115115
/** Sets bounds of sub-axes*/
116-
void resized();
116+
void resized() override;
117117

118118
/** Plots latest spikes in buffer*/
119119
void refresh();
@@ -296,7 +296,10 @@ class WaveAxes : public GenericAxes
296296
bool checkThreshold (const Spike* spike);
297297

298298
/** Draws the component (calls plotSpike)*/
299-
void paint (Graphics& g);
299+
void paint (Graphics& g) override;
300+
301+
/** Sets the position for label */
302+
void resized() override;
300303

301304
/** Draws a single spike */
302305
void plotSpike (const Spike* s, Graphics& g, bool latestSpike = true);
@@ -394,7 +397,7 @@ class ProjectionAxes : public GenericAxes
394397
bool updateSpikeData (const Spike* s);
395398

396399
/** Displays the projection image*/
397-
void paint (Graphics& g);
400+
void paint (Graphics& g) override;
398401

399402
/** Removes the projection image*/
400403
void clear();

0 commit comments

Comments
 (0)