Skip to content

Commit

Permalink
Add placeholder to IMRO combo box
Browse files Browse the repository at this point in the history
  • Loading branch information
medengineer committed Dec 18, 2023
1 parent ea40d22 commit c67322b
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions Source/UI/NeuropixInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,13 +408,20 @@ NeuropixInterface::NeuropixInterface(DataSource* p,

File baseDirectory = File::getSpecialLocation(File::currentExecutableFile).getParentDirectory();
File imroDirectory = baseDirectory.getChildFile("IMRO");

if (File(imroDirectory).findChildFiles(File::findFiles, false, "*.imro").size())
loadImroComboBox->addItem("Select a preset...", 1);
else
loadImroComboBox->addItem("No pre-set IMRO found", 1);

loadImroComboBox->addSeparator();

for (const auto& filename : File(imroDirectory).findChildFiles(File::findFiles, false, "*.imro")) {
imroFiles.add(filename.getFileNameWithoutExtension());
imroLoadedFromFolder.add(true);
loadImroComboBox->addItem(imroFiles.getLast(), imroFiles.size());
loadImroComboBox->addItem(imroFiles.getLast(), imroFiles.size() + 1);
}
if (!imroFiles.size())
loadImroComboBox->addItem("No pre-set IMRO found", 1);
loadImroComboBox->setSelectedId(1, dontSendNotification);
addAndMakeVisible(loadImroComboBox);

probeSettingsLabel = new Label("Settings", "Probe settings:");
Expand Down Expand Up @@ -756,22 +763,24 @@ void NeuropixInterface::comboBoxChanged(ComboBox* comboBox)
return;
}

int i = comboBox->getSelectedId() - 1;

LOGC("Attempting to load IMRO file: ", imroFiles[i]);
int fileIndex = comboBox->getSelectedId() - 2;

if (imroFiles[i].length())
if (imroFiles[fileIndex].length())
{
ProbeSettings settings = getProbeSettings();

settings.clearElectrodeSelection();

bool success = IMRO::readSettingsFromImro(File(imroFiles[i]), settings);
bool success = IMRO::readSettingsFromImro(File(imroFiles[fileIndex]), settings);

if (success)
{
applyProbeSettings(settings);
loadImroComboBox->setSelectedId(0, false);
loadImroComboBox->setSelectedId(comboBox->getSelectedId(), false);
}
else
{
loadImroComboBox->setSelectedId(1, false);
}
}

Expand Down

0 comments on commit c67322b

Please sign in to comment.