bool ProcessorGraph::enableProcessors() { updateConnections(getEditorViewport()->requestSignalChain()); std::cout << "Enabling processors..." << std::endl; bool allClear; if (getNumNodes() < 5) { getUIComponent()->disableCallbacks(); return false; } for (int i = 0; i < getNumNodes(); i++) { Node* node = getNode(i); if (node->nodeId != OUTPUT_NODE_ID) { GenericProcessor* p = (GenericProcessor*) node->getProcessor(); allClear = p->isReady(); if (!allClear) { std::cout << p->getName() << " said it's not OK." << std::endl; // sendActionMessage("Could not initialize acquisition."); getUIComponent()->disableCallbacks(); return false; } } } for (int i = 0; i < getNumNodes(); i++) { Node* node = getNode(i); if (node->nodeId != OUTPUT_NODE_ID) { GenericProcessor* p = (GenericProcessor*) node->getProcessor(); p->enableEditor(); p->enable(); } } getEditorViewport()->signalChainCanBeEdited(false); // sendActionMessage("Acquisition started."); return true; }
void SignalGeneratorEditor::labelTextChanged(Label* label) { SignalGenerator* sg = (SignalGenerator*) getProcessor(); sg->nOut = numChannelsLabel->getText().getIntValue(); getEditorViewport()->makeEditorVisible(this); }
void RHD2000Editor::buttonEvent(Button* button) { if (button == rescanButton && !acquisitionIsActive) { board->scanPorts(); for (int i = 0; i < 4; i++) { headstageOptionsInterfaces[i]->checkEnabledState(); } } else if (button == electrodeButtons[0]) { channelSelector->setRadioStatus(true); } else if (button == electrodeButtons[1]) { channelSelector->setRadioStatus(true); } else if (button == adcButton && !acquisitionIsActive) { board->enableAdcs(button->getToggleState()); getEditorViewport()->makeEditorVisible(this, false, true); } }
bool GenericEditor::checkDrawerButton(Button* button) { if (button == drawerButton) { if (drawerButton->getToggleState()) { channelSelector->setVisible(true); drawerWidth = channelSelector->getDesiredWidth() + 20; desiredWidth += drawerWidth; } else { channelSelector->setVisible(false); desiredWidth -= drawerWidth; } getEditorViewport()->makeEditorVisible(this); deselect(); return true; } else { return false; } }
bool ProcessorGraph::disableProcessors() { std::cout << "Disabling processors..." << std::endl; bool allClear; for (int i = 0; i < getNumNodes(); i++) { Node* node = getNode(i); if (node->nodeId != OUTPUT_NODE_ID) { GenericProcessor* p = (GenericProcessor*) node->getProcessor(); std::cout << "Disabling " << p->getName() << std::endl; p->disableEditor(); allClear = p->disable(); if (!allClear) { // sendActionMessage("Could not stop acquisition."); return false; } } } getEditorViewport()->signalChainCanBeEdited(true); // sendActionMessage("Acquisition ended."); return true; }
void SpikeDetectorEditor::labelTextChanged(Label* label) { if (label->getText().equalsIgnoreCase("1") && isPlural) { for (int n = 1; n < electrodeTypes->getNumItems()+1; n++) { electrodeTypes->changeItemText(n, electrodeTypes->getItemText(n-1).trimCharactersAtEnd("s")); } isPlural = false; String currentText = electrodeTypes->getText(); electrodeTypes->setText(currentText.trimCharactersAtEnd("s")); } else if (!label->getText().equalsIgnoreCase("1") && !isPlural) { for (int n = 1; n < electrodeTypes->getNumItems()+1; n++) { String currentString = electrodeTypes->getItemText(n-1); currentString += "s"; electrodeTypes->changeItemText(n,currentString); } isPlural = true; String currentText = electrodeTypes->getText(); electrodeTypes->setText(currentText += "s"); } getEditorViewport()->makeEditorVisible(this, false, true); }
void SpikeDetectorEditor::checkSettings() { electrodeList->setSelectedItemIndex(0); drawElectrodeButtons(0); getEditorViewport()->makeEditorVisible(this, true, true); }
bool UIComponent::perform (const InvocationInfo& info) { switch (info.commandID) { case openConfiguration: { sendActionMessage(getEditorViewport()->loadState()); break; } case saveConfiguration: { sendActionMessage(getEditorViewport()->saveState()); break; } case clearSignalChain: getEditorViewport()->clearSignalChain(); break; case showHelp: std::cout << "SHOW ME SOME HELP!" << std::endl; break; case toggleProcessorList: processorList->toggleState(); break; case toggleFileInfo: controlPanel->toggleState(); break; case toggleSignalChain: editorViewportButton->toggleState(); break; default: break; } return true; }
void MergerEditor::mouseDown(const MouseEvent& e) { if (e.mods.isRightButtonDown()) { PopupMenu m; m.addItem(1, "Choose input 2:",false); Array<GenericProcessor*> availableProcessors = getProcessorGraph()->getListOfProcessors(); for (int i = 0; i < availableProcessors.size(); i++) { if (!availableProcessors[i]->isSink() && !availableProcessors[i]->isMerger() && !availableProcessors[i]->isSplitter() && availableProcessors[i]->getDestNode() != getProcessor()) { String name = String(availableProcessors[i]->getNodeId()); name += " - "; name += availableProcessors[i]->getName(); m.addItem(i+2, name); //processorsInList.add(availableProcessors[i]); } } const int result = m.show(); if (result > 1) { std::cout << "Selected " << availableProcessors[result-2]->getName() << std::endl; switchSource(1); Merger* processor = (Merger*) getProcessor(); processor->setMergerSourceNode(availableProcessors[result-2]); availableProcessors[result-2]->setDestNode(getProcessor()); getGraphViewer()->updateNodeLocations(); getEditorViewport()->makeEditorVisible(this, false, true); } } }
void MergerEditor::buttonEvent(Button* button) { if (button == pipelineSelectorA) { pipelineSelectorA->setToggleState(true, dontSendNotification); pipelineSelectorB->setToggleState(false, dontSendNotification); Merger* processor = (Merger*) getProcessor(); processor->switchIO(0); } else if (button == pipelineSelectorB) { pipelineSelectorB->setToggleState(true, dontSendNotification); pipelineSelectorA->setToggleState(false, dontSendNotification); Merger* processor = (Merger*) getProcessor(); processor->switchIO(1); } getEditorViewport()->makeEditorVisible(this, false); }
void SpikeSorterEditor::labelTextChanged(Label* label) { getEditorViewport()->makeEditorVisible(this, false, true); }
void RecordNode::setParameter(int parameterIndex, float newValue) { //editor->updateParameterButtons(parameterIndex); // 0 = stop recording // 1 = start recording // 2 = toggle individual channel (0.0f = OFF, anything else = ON) if (parameterIndex == 1) { isRecording = true; // std::cout << "START RECORDING." << std::endl; if (newDirectoryNeeded) { createNewDirectory(); recordingNumber = 0; } else { recordingNumber++; // increment recording number within this directory } if (!rootFolder.exists()) { rootFolder.createDirectory(); String settingsFileName = rootFolder.getFullPathName() + File::separator + "settings.xml"; getEditorViewport()->saveState(File(settingsFileName)); } createNewFiles(); openFile(eventChannel); blockIndex = 0; // reset index // create / open necessary files for (int i = 0; i < channelPointers.size(); i++) { // std::cout << "Checking channel " << i << std::endl; if (channelPointers[i]->getRecordState()) { openFile(channelPointers[i]); } } allFilesOpened = true; } else if (parameterIndex == 0) { // std::cout << "STOP RECORDING." << std::endl; if (isRecording) { // close necessary files signalFilesShouldClose = true; } isRecording = false; } else if (parameterIndex == 2) { if (isProcessing) { std::cout << "Toggling channel " << currentChannel << std::endl; if (newValue == 0.0f) { channelPointers[currentChannel]->setRecordState(false); if (isRecording) { if (blockIndex < BLOCK_LENGTH) { // fill out the rest of the current buffer writeContinuousBuffer(zeroBuffer.getReadPointer(0), BLOCK_LENGTH - blockIndex, currentChannel); } closeFile(channelPointers[currentChannel]); } } else { channelPointers[currentChannel]->setRecordState(true); if (isRecording) { openFile(channelPointers[currentChannel]); if (blockIndex > 0) { writeTimestampAndSampleCount(channelPointers[currentChannel]->file); // fill up the first data block up to sample count writeContinuousBuffer(zeroBuffer.getReadPointer(0), blockIndex, currentChannel); } } } } } }
bool UIComponent::perform(const InvocationInfo& info) { switch (info.commandID) { case openConfiguration: { FileChooser fc("Choose a file to load...", CoreServices::getDefaultUserSaveDirectory(), "*", true); if (fc.browseForFileToOpen()) { currentConfigFile = fc.getResult(); sendActionMessage(getEditorViewport()->loadState(currentConfigFile)); } else { sendActionMessage("No configuration selected."); } break; } case saveConfiguration: { if (currentConfigFile.exists()) { sendActionMessage(getEditorViewport()->saveState(currentConfigFile)); } else { FileChooser fc("Choose the file name...", CoreServices::getDefaultUserSaveDirectory(), "*", true); if (fc.browseForFileToSave(true)) { currentConfigFile = fc.getResult(); std::cout << currentConfigFile.getFileName() << std::endl; sendActionMessage(getEditorViewport()->saveState(currentConfigFile)); } else { sendActionMessage("No file chosen."); } } break; } case saveConfigurationAs: { FileChooser fc("Choose the file name...", CoreServices::getDefaultUserSaveDirectory(), "*", true); if (fc.browseForFileToSave(true)) { currentConfigFile = fc.getResult(); std::cout << currentConfigFile.getFileName() << std::endl; sendActionMessage(getEditorViewport()->saveState(currentConfigFile)); } else { sendActionMessage("No file chosen."); } break; } case reloadOnStartup: { mainWindow->shouldReloadOnStartup = !mainWindow->shouldReloadOnStartup; } break; case clearSignalChain: { getEditorViewport()->clearSignalChain(); break; } case showHelp: { URL url = URL("https://open-ephys.atlassian.net/wiki/display/OEW/Open+Ephys+GUI"); url.launchInDefaultBrowser(); break; } case toggleProcessorList: processorList->toggleState(); break; case toggleFileInfo: controlPanel->toggleState(); break; case toggleSignalChain: editorViewportButton->toggleState(); break; case resizeWindow: mainWindow->centreWithSize(800, 600); break; default: break; } return true; }
void updateSignalChain(GenericEditor* source) { getEditorViewport()->makeEditorVisible(source, false, true); }
void UIComponent::getCommandInfo(CommandID commandID, ApplicationCommandInfo& result) { bool acquisitionStarted = getAudioComponent()->callbacksAreActive(); switch (commandID) { case openConfiguration: result.setInfo("Open...", "Load a saved processor graph.", "General", 0); result.addDefaultKeypress('O', ModifierKeys::commandModifier); result.setActive(!acquisitionStarted); break; case saveConfiguration: result.setInfo("Save", "Save the current processor graph.", "General", 0); result.addDefaultKeypress('S', ModifierKeys::commandModifier); break; case saveConfigurationAs: result.setInfo("Save as...", "Save the current processor graph with a new name.", "General", 0); result.addDefaultKeypress('S', ModifierKeys::commandModifier | ModifierKeys::shiftModifier); break; case reloadOnStartup: result.setInfo("Reload on startup", "Load the last used configuration on startup.", "General", 0); result.setActive(!acquisitionStarted); result.setTicked(mainWindow->shouldReloadOnStartup); break; case undo: result.setInfo("Undo", "Undo the last action.", "General", 0); result.addDefaultKeypress('Z', ModifierKeys::commandModifier); result.setActive(false); break; case redo: result.setInfo("Redo", "Undo the last action.", "General", 0); result.addDefaultKeypress('Y', ModifierKeys::commandModifier); result.setActive(false); break; case copySignalChain: result.setInfo("Copy", "Copy a portion of the signal chain.", "General", 0); result.addDefaultKeypress('C', ModifierKeys::commandModifier); result.setActive(false); break; case pasteSignalChain: result.setInfo("Paste", "Paste a portion of the signal chain.", "General", 0); result.addDefaultKeypress('V', ModifierKeys::commandModifier); result.setActive(false); break; case clearSignalChain: result.setInfo("Clear signal chain", "Clear the current signal chain.", "General", 0); result.addDefaultKeypress(KeyPress::backspaceKey, ModifierKeys::commandModifier); result.setActive(!getEditorViewport()->isSignalChainEmpty() && !acquisitionStarted); break; case toggleProcessorList: result.setInfo("Processor List", "Show/hide Processor List.", "General", 0); result.addDefaultKeypress('P', ModifierKeys::shiftModifier); result.setTicked(processorList->isOpen()); break; case toggleSignalChain: result.setInfo("Signal Chain", "Show/hide Signal Chain.", "General", 0); result.addDefaultKeypress('S', ModifierKeys::shiftModifier); result.setTicked(editorViewportButton->isOpen()); break; case toggleFileInfo: result.setInfo("File Info", "Show/hide File Info.", "General", 0); result.addDefaultKeypress('F', ModifierKeys::shiftModifier); result.setTicked(controlPanel->isOpen()); break; case showHelp: result.setInfo("Show help...", "Take me to the GUI wiki.", "General", 0); result.setActive(true); break; case resizeWindow: result.setInfo("Reset window bounds", "Reset window bounds", "General", 0); break; default: break; }; }
bool UIComponent::perform(const InvocationInfo& info) { switch (info.commandID) { case openConfiguration: { FileChooser fc("Choose a file to load...", File::getCurrentWorkingDirectory(), "*.xml", true); if (fc.browseForFileToOpen()) { File currentFile = fc.getResult(); sendActionMessage(getEditorViewport()->loadState(currentFile)); } else { sendActionMessage("No configuration selected."); } break; } case saveConfiguration: { FileChooser fc("Choose the file to save...", File::getCurrentWorkingDirectory(), "*", true); if (fc.browseForFileToSave(true)) { File currentFile = fc.getResult(); std::cout << currentFile.getFileName() << std::endl; sendActionMessage(getEditorViewport()->saveState(currentFile)); } else { sendActionMessage("No file chosen."); } break; } case clearSignalChain: getEditorViewport()->clearSignalChain(); break; case showHelp: std::cout << "SHOW ME SOME HELP!" << std::endl; break; case toggleProcessorList: processorList->toggleState(); break; case toggleFileInfo: controlPanel->toggleState(); break; case toggleSignalChain: editorViewportButton->toggleState(); break; default: break; } return true; }
void highlightEditor(GenericEditor* ed) { getEditorViewport()->makeEditorVisible(ed); }
void SpikeDetectorEditor::buttonEvent(Button* button) { if (electrodeEditorButtons[0]->getToggleState()) // EDIT is active { std::cout << "Editing active." << std::endl; if (electrodeButtons.contains((ElectrodeButton*) button)) { ElectrodeButton* eb = (ElectrodeButton*) button; int electrodeNum = eb->getChannelNum()-1; std::cout << "Channel number: " << electrodeNum << std::endl; Array<int> a; a.add(electrodeNum); channelSelector->setActiveChannels(a); SpikeDetector* processor = (SpikeDetector*) getProcessor(); thresholdSlider->setActive(true); thresholdSlider->setValue(processor->getChannelThreshold(electrodeList->getSelectedItemIndex(), electrodeButtons.indexOf((ElectrodeButton*) button))); } } int num = numElectrodes->getText().getIntValue(); if (button == upButton) { numElectrodes->setText(String(++num), true); return; } else if (button == downButton) { if (num > 1) numElectrodes->setText(String(--num), true); return; } else if (button == plusButton) { // std::cout << "Plus button pressed!" << std::endl; int type = electrodeTypes->getSelectedId(); std::cout << type << std::endl; int nChans; switch (type) { case 1: nChans = 1; break; case 2: nChans = 2; break; case 3: nChans = 4; break; default: nChans = 1; } for (int n = 0; n < num; n++) { if (!addElectrode(nChans)) { sendActionMessage("Not enough channels to add electrode."); } } refreshElectrodeList(); if (electrodeList->getNumItems() > 0) { electrodeList->setSelectedId(electrodeList->getNumItems(), true); electrodeList->setText(electrodeList->getItemText(electrodeList->getNumItems()-1)); lastId = electrodeList->getNumItems(); electrodeList->setEditableText(true); drawElectrodeButtons(electrodeList->getNumItems()-1); } getEditorViewport()->makeEditorVisible(this, true, true); return; } else if (button == electrodeEditorButtons[0]) // EDIT { Array<int> activeChannels; for (int i = 0; i < electrodeButtons.size(); i++) { if (button->getToggleState()) { electrodeButtons[i]->setToggleState(false, false); electrodeButtons[i]->setRadioGroupId(299); channelSelector->activateButtons(); channelSelector->setRadioStatus(true); } else { electrodeButtons[i]->setToggleState(true, false); electrodeButtons[i]->setRadioGroupId(0); channelSelector->inactivateButtons(); channelSelector->setRadioStatus(false); activeChannels.add(electrodeButtons[i]->getChannelNum()-1); } } if (!button->getToggleState()) { thresholdSlider->setActive(false); // This will be -1 with nothing selected int selectedItemIndex = electrodeList->getSelectedItemIndex(); if (selectedItemIndex != -1) { drawElectrodeButtons(selectedItemIndex); } else { electrodeButtons.clear(); } } // channelSelector->setActiveChannels(activeChannels); return; } else if (button == electrodeEditorButtons[1]) // MONITOR { return; } else if (button == electrodeEditorButtons[2]) // DELETE { removeElectrode(electrodeList->getSelectedItemIndex()); getEditorViewport()->makeEditorVisible(this, true, true); return; } }
void SpikeDetectorEditor::buttonEvent(Button* button) { if (electrodeButtons.contains((ElectrodeButton*) button)) { if (electrodeEditorButtons[0]->getToggleState()) // EDIT is active { ElectrodeButton* eb = (ElectrodeButton*) button; int electrodeNum = eb->getChannelNum()-1; // std::cout << "Channel number: " << electrodeNum << std::endl; Array<int> a; a.add(electrodeNum); channelSelector->setActiveChannels(a); SpikeDetector* processor = (SpikeDetector*) getProcessor(); thresholdSlider->setActive(true); thresholdSlider->setValue(processor->getChannelThreshold(electrodeList->getSelectedItemIndex(), electrodeButtons.indexOf((ElectrodeButton*) button))); } else { SpikeDetector* processor = (SpikeDetector*) getProcessor(); ElectrodeButton* eb = (ElectrodeButton*) button; int electrodeNum = electrodeList->getSelectedItemIndex(); int channelNum = electrodeButtons.indexOf(eb); processor->setChannelActive(electrodeNum, channelNum, button->getToggleState()); std::cout << "Disabling channel " << channelNum << " of electrode " << electrodeNum << std::endl; } } int num = numElectrodes->getText().getIntValue(); if (button == upButton) { numElectrodes->setText(String(++num), sendNotification); return; } else if (button == downButton) { if (num > 1) numElectrodes->setText(String(--num), sendNotification); return; } else if (button == plusButton) { // std::cout << "Plus button pressed!" << std::endl; if (acquisitionIsActive) { sendActionMessage("Stop acquisition before adding electrodes."); return; } int type = electrodeTypes->getSelectedId(); // std::cout << type << std::endl; int nChans; switch (type) { case 1: nChans = 1; break; case 2: nChans = 2; break; case 3: nChans = 4; break; default: nChans = 1; } for (int n = 0; n < num; n++) { if (!addElectrode(nChans)) { sendActionMessage("Not enough channels to add electrode."); } } electrodeEditorButtons[1]->setToggleState(false, false); getEditorViewport()->makeEditorVisible(this, true, true); return; } else if (button == electrodeEditorButtons[0]) // EDIT { Array<int> activeChannels; for (int i = 0; i < electrodeButtons.size(); i++) { if (button->getToggleState()) { electrodeButtons[i]->setToggleState(false, false); electrodeButtons[i]->setRadioGroupId(299); channelSelector->activateButtons(); channelSelector->setRadioStatus(true); } else { electrodeButtons[i]->setToggleState(true, false); electrodeButtons[i]->setRadioGroupId(0); channelSelector->inactivateButtons(); channelSelector->setRadioStatus(false); activeChannels.add(electrodeButtons[i]->getChannelNum()-1); } } if (!button->getToggleState()) { thresholdSlider->setActive(false); // This will be -1 with nothing selected int selectedItemIndex = electrodeList->getSelectedItemIndex(); if (selectedItemIndex != -1) { drawElectrodeButtons(selectedItemIndex); } else { electrodeButtons.clear(); } } // channelSelector->setActiveChannels(activeChannels); return; } else if (button == electrodeEditorButtons[1]) // MONITOR { Button* audioMonitorButton = electrodeEditorButtons[1]; channelSelector->clearAudio(); SpikeDetector* processor = (SpikeDetector*) getProcessor(); Array<Electrode*> electrodes = processor->getElectrodes(); for (int i = 0; i < electrodes.size(); i++) { Electrode* e = electrodes[i]; e->isMonitored = false; } Electrode* e = processor->getActiveElectrode(); if (e != nullptr) { e->isMonitored = audioMonitorButton->getToggleState(); for (int i = 0; i < e->numChannels; i++) { std::cout << "Channel " << e->channels[i] << std::endl; int channelNum = e->channels[i]; channelSelector->setAudioStatus(channelNum, audioMonitorButton->getToggleState()); } } else { audioMonitorButton->setToggleState(false, false); } return; } else if (button == electrodeEditorButtons[2]) // DELETE { if (acquisitionIsActive) { sendActionMessage("Stop acquisition before deleting electrodes."); return; } removeElectrode(electrodeList->getSelectedItemIndex()); getEditorViewport()->makeEditorVisible(this, true, true); return; } }