From 6e50090a2cee1a65a4f3c5f14bc603a2b45ff627 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Wed, 19 Jun 2013 21:06:09 -0400 Subject: [PATCH] Channel Mapping Node now saves its own parameters --- Source/Processors/ChannelMappingNode.cpp | 2 +- .../Editors/ChannelMappingEditor.cpp | 78 +++++++++++++++++-- 2 files changed, 72 insertions(+), 8 deletions(-) diff --git a/Source/Processors/ChannelMappingNode.cpp b/Source/Processors/ChannelMappingNode.cpp index 61fa6c81b..62615d963 100644 --- a/Source/Processors/ChannelMappingNode.cpp +++ b/Source/Processors/ChannelMappingNode.cpp @@ -28,7 +28,7 @@ ChannelMappingNode::ChannelMappingNode() - : GenericProcessor("Channel Mapping"), channelBuffer(1,10000) + : GenericProcessor("Channel Map"), channelBuffer(1,10000) { referenceArray.resize(1024); // make room for 1024 channels channelArray.resize(1024); diff --git a/Source/Processors/Editors/ChannelMappingEditor.cpp b/Source/Processors/Editors/ChannelMappingEditor.cpp index d93aff3d0..bd8c587cb 100644 --- a/Source/Processors/Editors/ChannelMappingEditor.cpp +++ b/Source/Processors/Editors/ChannelMappingEditor.cpp @@ -205,6 +205,26 @@ void ChannelMappingEditor::saveEditorParameters(XmlElement* xml) xml->setAttribute("Type", "ChannelMappingEditor"); + for (int i = 0; i < channelArray.size(); i++) + { + XmlElement* channelXml = xml->createNewChildElement("CHANNEL"); + channelXml->setAttribute("Number", i); + channelXml->setAttribute("Mapping", channelArray[i]); + channelXml->setAttribute("Reference", referenceArray[i]); + } + + // String channelString = ""; + // String referenceString = ""; + + // for (int i = 0; i < channelArray.size(); i++) + // { + // channelString += String(channelArray[i]); + // referenceString += String(referenceArray[i]); + // } + + // xml->setAttribute("Channels", channelString); + // xml->setAttribute("References", referenceString); + // XmlElement* selectedChannel = xml->createNewChildElement("SELECTEDID"); // selectedChannel->setAttribute("ID",referenceSelector->getSelectedId()); @@ -214,15 +234,59 @@ void ChannelMappingEditor::saveEditorParameters(XmlElement* xml) void ChannelMappingEditor::loadEditorParameters(XmlElement* xml) { - forEachXmlChildElement(*xml, xmlNode) + // String channelString = xml->getStringAttribute("Channels"); + // String referenceString = xml->getStringAttribute("References"); + + forEachXmlChildElementWithTagName(*xml, channelXml, "CHANNEL") { - // if (xmlNode->hasTagName("SELECTEDID")) - // { - // - // int id = xmlNode->getIntAttribute("ID"); + int i = channelXml->getIntAttribute("Number"); - // referenceSelector->setSelectedId(id); + if (i < channelArray.size()) + { + + int mapping = channelXml->getIntAttribute("Mapping"); + int reference = channelXml->getIntAttribute("Reference"); + + channelArray.set(i, mapping); + referenceArray.set(i, reference); + + electrodeButtons[i]->setChannelNum(mapping); + electrodeButtons[i]->repaint(); + + getProcessor()->setCurrentChannel(i); + + getProcessor()->setParameter(1, reference-1); // set reference + + getProcessor()->setParameter(0, mapping-1); // set mapping + } - // } } + + // for (int i = 0; i < channelString.length(); i++) + // { + + // String ch = channelString.substring(i,i); + // String ref = referenceString.substring(i,i); + + // if (i < channelArray.size()) + // { + // int chNum = ch.getIntValue(); + // int refNum = ref.getIntValue(); + + // channelArray.set(i, chNum); + // referenceArray.set(i, refNum); + + // electrodeButtons[i]->setChannelNum(chNum); + // electrodeButtons[i]->repaint(); + + // getProcessor()->setCurrentChannel(i); + + // getProcessor()->setParameter(1, refNum-1); // set reference + + // getProcessor()->setParameter(0, chNum-1); // set mapping + + // } + + // } + } \ No newline at end of file -- GitLab