Skip to content

Commit ad750b7

Browse files
authored
Merge pull request #165 from kmichaelfox/development
Fix canvas to display as empty when there is no source node input
2 parents bd37a08 + ec86755 commit ad750b7

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
@@ -145,10 +145,18 @@ void LfpDisplayCanvas::resized()
145145
timescale->setBounds(leftmargin,0,getWidth()-scrollBarThickness-leftmargin,30);
146146
viewport->setBounds(0,30,getWidth(),getHeight()-90);
147147

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

153161
if (optionsDrawerIsOpen)
154162
options->setBounds(0, getHeight()-200, getWidth(), 200);
@@ -198,14 +206,16 @@ void LfpDisplayCanvas::endAnimation()
198206

199207
void LfpDisplayCanvas::update()
200208
{
201-
nChans = jmax(processor->getNumInputs(),1);
209+
nChans = jmax(processor->getNumInputs(), 0);
202210

203211
resizeSamplesPerPixelBuffer(nChans);
204212

205213
sampleRate.clear();
206214
screenBufferIndex.clear();
207215
lastScreenBufferIndex.clear();
208216
displayBufferIndex.clear();
217+
218+
options->setEnabled(nChans != 0);
209219

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

259269
}
260-
261-
lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
262-
270+
271+
if (nChans > 0)
272+
lfpDisplay->setBounds(0,0,getWidth()-scrollBarThickness*2, lfpDisplay->getTotalHeight());
273+
else
274+
lfpDisplay->setBounds(0, 0, getWidth(), getHeight());
275+
263276
resized();
264277
}
265278
else
@@ -272,7 +285,8 @@ void LfpDisplayCanvas::update()
272285

273286
}
274287

275-
lfpDisplay->rebuildDrawableChannelsList();
288+
if (nChans > 0)
289+
lfpDisplay->rebuildDrawableChannelsList();
276290

277291
}
278292

@@ -1472,6 +1486,8 @@ void LfpDisplayOptions::setTimebaseAndSelectionText(float timebase)
14721486

14731487
void LfpDisplayOptions::comboBoxChanged(ComboBox* cb)
14741488
{
1489+
if (canvas->getNumChannels() == 0) return;
1490+
14751491
if (cb == channelDisplaySkipSelection)
14761492
{
14771493
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)