Skip to content

Commit d86865a

Browse files
committed
Fixed a bug when adding a Source input to LfpViewer with canvas open
1 parent a659d68 commit d86865a

1 file changed

Lines changed: 19 additions & 11 deletions

File tree

Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void LfpDisplayCanvas::resized()
149149
{
150150
if (lfpDisplay->getSingleChannelState())
151151
lfpDisplay->setChannelHeight(viewport->getHeight(),false);
152-
152+
std::cout << "resizing canvas" << std::endl;
153153
lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness, lfpDisplay->getChannelHeight()*lfpDisplay->drawableChannels.size());
154154
}
155155
else
@@ -215,6 +215,8 @@ void LfpDisplayCanvas::update()
215215
displayBufferIndex.clear();
216216

217217
options->setEnabled(nChans != 0);
218+
// must manually ensure that overlapSelection propagates up to canvas
219+
channelOverlapFactor = options->selectedOverlapValue.getFloatValue();
218220

219221
for (int i = 0; i <= nChans; i++) // extra channel for events
220222
{
@@ -248,7 +250,7 @@ void LfpDisplayCanvas::update()
248250

249251
if (nChans != lfpDisplay->getNumChannels())
250252
{
251-
//std::cout << "Setting num inputs on LfpDisplayCanvas to " << nChans << std::endl;
253+
std::cout << "Setting num inputs on LfpDisplayCanvas to " << nChans << std::endl;
252254

253255
refreshScreenBuffer();
254256

@@ -267,10 +269,14 @@ void LfpDisplayCanvas::update()
267269

268270
}
269271

270-
if (nChans > 0)
271-
lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
272-
else
273-
lfpDisplay->setBounds(0, 0, getWidth(), getHeight());
272+
// if (nChans > 0)
273+
// lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
274+
// else
275+
if (nChans == 0) lfpDisplay->setBounds(0, 0, getWidth(), getHeight());
276+
else {
277+
lfpDisplay->rebuildDrawableChannelsList();
278+
lfpDisplay->setBounds(0, 0, getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
279+
}
274280

275281
resized();
276282
}
@@ -282,10 +288,10 @@ void LfpDisplayCanvas::update()
282288
lfpDisplay->channelInfo[i]->updateType();
283289
}
284290

291+
if (nChans > 0)
292+
lfpDisplay->rebuildDrawableChannelsList();
285293
}
286294

287-
if (nChans > 0)
288-
lfpDisplay->rebuildDrawableChannelsList();
289295

290296
}
291297

@@ -656,9 +662,9 @@ void LfpDisplayCanvas::paint(Graphics& g)
656662
for (int i = 0; i < 10; i++)
657663
{
658664
if (i == 5 || i == 0)
659-
g.drawLine(w/10*i+leftmargin,0,w/10*i+leftmargin,getHeight()-60,3.0f);
665+
g.drawLine(w/10*i+leftmargin,timescale->getHeight(),w/10*i+leftmargin,getHeight()-60-timescale->getHeight(),3.0f);
660666
else
661-
g.drawLine(w/10*i+leftmargin,0,w/10*i+leftmargin,getHeight()-60,1.0f);
667+
g.drawLine(w/10*i+leftmargin,timescale->getHeight(),w/10*i+leftmargin,getHeight()-60-timescale->getHeight(),1.0f);
662668
}
663669

664670
g.drawLine(0,getHeight()-60,getWidth(),getHeight()-60,3.0f);
@@ -2278,7 +2284,7 @@ void LfpDisplay::setNumChannels(int numChannels)
22782284
setColors();
22792285

22802286

2281-
//std::cout << "TOTAL HEIGHT = " << totalHeight << std::endl;
2287+
std::cout << "TOTAL HEIGHT = " << totalHeight << std::endl;
22822288

22832289
}
22842290

@@ -2327,6 +2333,7 @@ int LfpDisplay::getTotalHeight()
23272333
void LfpDisplay::resized()
23282334
{
23292335
int totalHeight = 0;
2336+
std::cout << "channelOverlapFactor " << canvas->channelOverlapFactor << std::endl;
23302337

23312338
for (int i = 0; i < drawableChannels.size(); i++)
23322339
{
@@ -3107,6 +3114,7 @@ void LfpChannelDisplay::resized()
31073114
// all of this will likely need to be moved into the sharedLfpDisplay image in the lfpDisplay, not here
31083115
// now that the complete height is know, the sharedLfpDisplay image that we'll draw the pixel-wise lfp plot to needs to be resized
31093116
//lfpChannelBitmap = Image(Image::ARGB, getWidth(), getHeight(), false);
3117+
std::cout << "[channel " << chan << "] " << getPosition().toString() << std::endl;
31103118
}
31113119

31123120

0 commit comments

Comments
 (0)