From ce2b2a854223125778d2fba8b83d0c9df639b678 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Sun, 4 Aug 2013 15:20:56 -0400 Subject: [PATCH] Attempt to allow LFP channels to save their enabled state --- .../Processors/DataThreads/RHD2000Thread.cpp | 2 +- .../Visualization/LfpDisplayCanvas.cpp | 61 ++++++++++++++++++- .../Visualization/LfpDisplayCanvas.h | 5 +- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp index 702ad2e2e..047f56423 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.cpp +++ b/Source/Processors/DataThreads/RHD2000Thread.cpp @@ -87,7 +87,7 @@ void RHD2000Thread::initializeBoard() if (!evalBoard->uploadFpgaBitfile(bitfilename)) { - std::cout << "Couldn't upload bitfile." << std::endl; + std::cout << "Couldn't upload bitfile from " << bitfilename << std::endl; // what to do if there's an error } diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.cpp b/Source/Processors/Visualization/LfpDisplayCanvas.cpp index efe84d189..42dc6e02a 100755 --- a/Source/Processors/Visualization/LfpDisplayCanvas.cpp +++ b/Source/Processors/Visualization/LfpDisplayCanvas.cpp @@ -463,6 +463,20 @@ void LfpDisplayCanvas::saveVisualizerParameters(XmlElement* xml) xmlNode->setAttribute("EventButtonState", eventButtonState); + String channelDisplayState = ""; + + for (int i = 0; i < nChans; i++) + { + if (lfpDisplay->getEnabledState(i)) + { + channelDisplayState += "1"; + } else { + channelDisplayState += "0"; + } + } + + xmlNode->setAttribute("ChannelDisplayState", channelDisplayState); + xmlNode->setAttribute("ScrollX",viewport->getViewPositionX()); xmlNode->setAttribute("ScrollY",viewport->getViewPositionY()); } @@ -481,7 +495,7 @@ void LfpDisplayCanvas::loadVisualizerParameters(XmlElement* xml) viewport->setViewPosition(xmlNode->getIntAttribute("ScrollX"), xmlNode->getIntAttribute("ScrollY")); - int eventButtonState = xmlNode->getIntAttribute("eventButtonState"); + int eventButtonState = xmlNode->getIntAttribute("EventButtonState"); for (int i = 0; i < 8; i++) { @@ -489,6 +503,21 @@ void LfpDisplayCanvas::loadVisualizerParameters(XmlElement* xml) eventDisplayInterfaces[i]->checkEnabledState(); } + + String channelDisplayState = xmlNode->getStringAttribute("ChannelDisplayState"); + + for (int i = 0; i < channelDisplayState.length(); i++) + { + + if (channelDisplayState.substring(i,i+1).equalsIgnoreCase("1")) + { + lfpDisplay->setEnabledState(true, i); + } else { + lfpDisplay->setEnabledState(false, i); + } + + + } } } @@ -596,6 +625,7 @@ int LfpDisplay::getNumChannels() return numChans; } + void LfpDisplay::setNumChannels(int numChannels) { numChans = numChannels; @@ -861,11 +891,27 @@ bool LfpDisplay::getEventDisplayState(int ch) return eventDisplayEnabled[ch]; } -void LfpDisplay::setEnabledState(bool state, int ch) +void LfpDisplay::setEnabledState(bool state, int chan) { - channels[ch]->setEnabledState(state); + + if (chan < numChans) + { + + channels[chan]->setEnabledState(state); + channelInfo[chan]->setEnabledState(state); + } } + bool LfpDisplay::getEnabledState(int chan) + { + if (chan < numChans) + { + return channels[chan]->getEnabledState(); + } + + return false; + } + // ------------------------------------------------------------------ @@ -894,6 +940,10 @@ LfpChannelDisplay::~LfpChannelDisplay() void LfpChannelDisplay::setEnabledState(bool state) { + + + std::cout << "Setting channel " << name << " to " << state << std::endl; + isEnabled = state; } @@ -1139,6 +1189,11 @@ void LfpChannelDisplayInfo::buttonClicked(Button* button) } +void LfpChannelDisplayInfo::setEnabledState(bool state) +{ + enableButton->setToggleState(state, false); +} + void LfpChannelDisplayInfo::paint(Graphics& g) { diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.h b/Source/Processors/Visualization/LfpDisplayCanvas.h index 44f1498dd..4c6426480 100755 --- a/Source/Processors/Visualization/LfpDisplayCanvas.h +++ b/Source/Processors/Visualization/LfpDisplayCanvas.h @@ -187,7 +187,7 @@ public: bool getEventDisplayState(int ch); void setEnabledState(bool, int); - + bool getEnabledState(int); Array<Colour> channelColours; @@ -233,6 +233,7 @@ public: int getRange(); void setEnabledState(bool); + bool getEnabledState() {return isEnabled;} bool fullredraw; // used to indicate that a full redraw is required. is set false after each full redraw @@ -273,6 +274,8 @@ public: void resized(); + void setEnabledState(bool); + private: ScopedPointer<UtilityButton> enableButton; -- GitLab