Skip to content

Commit ec86755

Browse files
committed
Fix canvas to display as empty when there is no source node inputs
1 parent d90abe7 commit ec86755

3 files changed

Lines changed: 46 additions & 13 deletions

File tree

Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayCanvas.cpp

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,18 @@ void LfpDisplayCanvas::resized()
144144
timescale->setBounds(leftmargin,0,getWidth()-scrollBarThickness-leftmargin,30);
145145
viewport->setBounds(0,30,getWidth(),getHeight()-90);
146146

147-
if (lfpDisplay->getSingleChannelState())
148-
lfpDisplay->setChannelHeight(viewport->getHeight(),false);
149-
150-
lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness, lfpDisplay->getChannelHeight()*lfpDisplay->drawableChannels.size());
147+
if (nChans > 0)
148+
{
149+
if (lfpDisplay->getSingleChannelState())
150+
lfpDisplay->setChannelHeight(viewport->getHeight(),false);
151+
152+
std::cout << "number of channels " << nChans << std::endl;
153+
lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness, lfpDisplay->getChannelHeight()*lfpDisplay->drawableChannels.size());
154+
}
155+
else
156+
{
157+
lfpDisplay->setBounds(0, 0, getWidth(), getHeight());
158+
}
151159

152160
if (optionsDrawerIsOpen)
153161
options->setBounds(0, getHeight()-200, getWidth(), 200);
@@ -197,14 +205,16 @@ void LfpDisplayCanvas::endAnimation()
197205

198206
void LfpDisplayCanvas::update()
199207
{
200-
nChans = jmax(processor->getNumInputs(),1);
208+
nChans = jmax(processor->getNumInputs(), 0);
201209

202210
resizeSamplesPerPixelBuffer(nChans);
203211

204212
sampleRate.clear();
205213
screenBufferIndex.clear();
206214
lastScreenBufferIndex.clear();
207215
displayBufferIndex.clear();
216+
217+
options->setEnabled(nChans != 0);
208218

209219
for (int i = 0; i <= nChans; i++) // extra channel for events
210220
{
@@ -256,9 +266,12 @@ void LfpDisplayCanvas::update()
256266
lfpDisplay->setEnabledState(isChannelEnabled[i], i);
257267

258268
}
259-
260-
lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
261-
269+
270+
if (nChans > 0)
271+
lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
272+
else
273+
lfpDisplay->setBounds(0, 0, getWidth(), getHeight());
274+
262275
resized();
263276
}
264277
else
@@ -271,7 +284,8 @@ void LfpDisplayCanvas::update()
271284

272285
}
273286

274-
lfpDisplay->rebuildDrawableChannelsList();
287+
if (nChans > 0)
288+
lfpDisplay->rebuildDrawableChannelsList();
275289

276290
}
277291

@@ -1471,6 +1485,8 @@ void LfpDisplayOptions::setTimebaseAndSelectionText(float timebase)
14711485

14721486
void LfpDisplayOptions::comboBoxChanged(ComboBox* cb)
14731487
{
1488+
if (canvas->getNumChannels() == 0) return;
1489+
14741490
if (cb == channelDisplaySkipSelection)
14751491
{
14761492
const int skipAmt = pow(2, cb->getSelectedId() - 1);

Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ using namespace LfpDisplayNodeAlpha;
2828

2929
LfpDisplayEditor::LfpDisplayEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors=true)
3030
: VisualizerEditor(parentNode, useDefaultParameterEditors)
31-
31+
, hasNoInputs(true)
3232
{
3333
lfpProcessor = (LfpDisplayNode*) parentNode;
3434
tabText = "LFP";
@@ -74,8 +74,8 @@ void LfpDisplayEditor::buttonClicked(Button *button)
7474
// (else) initialization errors. lots of time-critical cross dependencies here,
7575
// should be cleaned up
7676
updateSubprocessorSelectorOptions();
77-
((LfpDisplayCanvas *)canvas.get())->setDrawableSubprocessor(*(inputSubprocessorIndices.begin() + (subprocessorSelection->getSelectedId() - 1)));
78-
// ((LfpDisplayCanvas*)canvas.get())->setDrawableSampleRate(*(inputSampleRates.begin() + (subprocessorSelection->getSelectedId() - 1)));
77+
//((LfpDisplayCanvas *)canvas.get())->setDrawableSubprocessor(*(inputSubprocessorIndices.begin() + (subprocessorSelection->getSelectedId() - 1)));
78+
// setCanvasDrawableSubprocessor(subprocessorSelection->getSelectedId() - 1);
7979

8080
canvas->update();
8181

@@ -110,6 +110,8 @@ void LfpDisplayEditor::updateSubprocessorSelectorOptions()
110110
inputSampleRates.clear();
111111
subprocessorSelection->clear(dontSendNotification);
112112

113+
hasNoInputs = lfpProcessor->getTotalDataChannels() != 0;
114+
113115
for (int i = 0, len = lfpProcessor->getTotalDataChannels(); i < len; ++i)
114116
{
115117
int subProcessorIdx = lfpProcessor->getDataChannel(i)->getSubProcessorIdx();
@@ -142,13 +144,26 @@ void LfpDisplayEditor::updateSubprocessorSelectorOptions()
142144
subprocessorSampleRateLabel->setText(sampleRateLabelText, dontSendNotification);
143145
setCanvasDrawableSubprocessor(subprocessorToSet);
144146
}
147+
else
148+
{
149+
subprocessorSelection->addItem ("None", 1);
150+
subprocessorSelection->setSelectedId(1, dontSendNotification);
151+
152+
String sampleRateLabelText = "Sample Rate: <not available>";
153+
subprocessorSampleRateLabel->setText(sampleRateLabelText, dontSendNotification);
154+
setCanvasDrawableSubprocessor(-1);
155+
156+
}
145157
}
146158

147159
void LfpDisplayEditor::setCanvasDrawableSubprocessor(int index)
148160
{
149161
if (canvas)
150162
{
151-
((LfpDisplayCanvas *)canvas.get())->setDrawableSubprocessor(*(inputSubprocessorIndices.begin() + index));
163+
if (index >= 0)
164+
((LfpDisplayCanvas *)canvas.get())->setDrawableSubprocessor(*(inputSubprocessorIndices.begin() + index));
165+
else
166+
((LfpDisplayCanvas *)canvas.get())->setDrawableSubprocessor(-1);
152167
}
153168
}
154169

Source/Plugins/LfpDisplayNodeAlpha/LfpDisplayEditor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ class LfpDisplayEditor : public VisualizerEditor,
8484

8585
ScopedPointer<Label> subprocessorSampleRateLabel;
8686

87+
bool hasNoInputs;
88+
8789
/** Communicates the drawable subprocessor information to the canvas, if
8890
one exists
8991
*/

0 commit comments

Comments
 (0)