From 0a38c98ad276d4ba42130e041139c6cea8358502 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Tue, 18 Jun 2013 21:55:16 -0400 Subject: [PATCH] LfpDisplayCanvas now saves the state of the event buttons --- .../Visualization/LfpDisplayCanvas.cpp | 35 +++++++++++++++---- .../Visualization/LfpDisplayCanvas.h | 26 +++++--------- Source/UI/UIComponent.cpp | 2 +- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.cpp b/Source/Processors/Visualization/LfpDisplayCanvas.cpp index a3263fc2f..7120471ba 100755 --- a/Source/Processors/Visualization/LfpDisplayCanvas.cpp +++ b/Source/Processors/Visualization/LfpDisplayCanvas.cpp @@ -112,7 +112,7 @@ LfpDisplayCanvas::LfpDisplayCanvas(LfpDisplayNode* processor_) : { - eventDisplayInterface* eventOptions = new eventDisplayInterface(lfpDisplay, this, i); + EventDisplayInterface* eventOptions = new EventDisplayInterface(lfpDisplay, this, i); eventDisplayInterfaces.add(eventOptions); addAndMakeVisible(eventOptions); eventOptions->setBounds(500+(floor(i/2)*20), getHeight()-20-(i%2)*20, 40, 20); @@ -448,6 +448,18 @@ void LfpDisplayCanvas::saveVisualizerParameters(XmlElement* xml) xmlNode->setAttribute("Timebase",timebaseSelection->getSelectedId()); xmlNode->setAttribute("Spread",spreadSelection->getSelectedId()); + int eventButtonState = 0; + + for (int i = 0; i < 8; i++) + { + if (lfpDisplay->eventDisplayEnabled[i]) + { + eventButtonState += (1 << i); + } + } + + xmlNode->setAttribute("EventButtonState", eventButtonState); + xmlNode->setAttribute("ScrollX",viewport->getViewPositionX()); xmlNode->setAttribute("ScrollY",viewport->getViewPositionY()); } @@ -465,6 +477,15 @@ void LfpDisplayCanvas::loadVisualizerParameters(XmlElement* xml) viewport->setViewPosition(xmlNode->getIntAttribute("ScrollX"), xmlNode->getIntAttribute("ScrollY")); + + int eventButtonState = xmlNode->getIntAttribute("eventButtonState"); + + for (int i = 0; i < 8; i++) + { + lfpDisplay->eventDisplayEnabled[i] = (eventButtonState >> i) & 1; + + eventDisplayInterfaces[i]->checkEnabledState(); + } } } @@ -1078,11 +1099,11 @@ void LfpChannelDisplayInfo::paint(Graphics& g) // Event display Options -------------------------------------------------------------------- -eventDisplayInterface::eventDisplayInterface(LfpDisplay* display_, LfpDisplayCanvas* canvas_, int chNum): +EventDisplayInterface::EventDisplayInterface(LfpDisplay* display_, LfpDisplayCanvas* canvas_, int chNum): isEnabled(true), display(display_), canvas(canvas_) { - channelNumber=chNum; + channelNumber = chNum; chButton = new UtilityButton(String(channelNumber+1), Font("Small Text", 13, Font::plain)); chButton->setRadius(5.0f); @@ -1098,19 +1119,19 @@ eventDisplayInterface::eventDisplayInterface(LfpDisplay* display_, LfpDisplayCan } -eventDisplayInterface::~eventDisplayInterface() +EventDisplayInterface::~EventDisplayInterface() { } -void eventDisplayInterface::checkEnabledState() +void EventDisplayInterface::checkEnabledState() { isEnabled = display->getEventDisplayState(channelNumber); //repaint(); } -void eventDisplayInterface::buttonClicked(Button* button) +void EventDisplayInterface::buttonClicked(Button* button) { checkEnabledState(); if (isEnabled) @@ -1127,7 +1148,7 @@ void eventDisplayInterface::buttonClicked(Button* button) } -void eventDisplayInterface::paint(Graphics& g) +void EventDisplayInterface::paint(Graphics& g) { checkEnabledState(); diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.h b/Source/Processors/Visualization/LfpDisplayCanvas.h index 0438cbb46..696c660a3 100755 --- a/Source/Processors/Visualization/LfpDisplayCanvas.h +++ b/Source/Processors/Visualization/LfpDisplayCanvas.h @@ -33,7 +33,7 @@ class LfpTimescale; class LfpDisplay; class LfpChannelDisplay; class LfpChannelDisplayInfo; -class eventDisplayInterface; +class EventDisplayInterface; /** @@ -100,9 +100,6 @@ private: static const int MAX_N_SAMP = 5000; // maximum display size in pixels //float waves[MAX_N_CHAN][MAX_N_SAMP*2]; // we need an x and y point for each sample - - - LfpDisplayNode* processor; AudioSampleBuffer* displayBuffer; AudioSampleBuffer* screenBuffer; @@ -120,8 +117,7 @@ private: StringArray timebases; StringArray spreads; // option for vertical spacing between channels - OwnedArray<eventDisplayInterface> eventDisplayInterfaces; - + OwnedArray<EventDisplayInterface> eventDisplayInterfaces; void refreshScreenBuffer(); void updateScreenBuffer(); @@ -133,7 +129,6 @@ private: int nChans; - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(LfpDisplayCanvas); }; @@ -197,6 +192,7 @@ public: Array<LfpChannelDisplay*> channels; Array<LfpChannelDisplayInfo*> channelInfo; + bool eventDisplayEnabled[8]; private: int numChans; @@ -204,11 +200,7 @@ private: int totalHeight; LfpDisplayCanvas* canvas; - Viewport* viewport; - - bool eventDisplayEnabled[8]; - - + Viewport* viewport; float range; @@ -272,12 +264,12 @@ public: }; -class eventDisplayInterface : public Component, +class EventDisplayInterface : public Component, public Button::Listener { public: - eventDisplayInterface(LfpDisplay*, LfpDisplayCanvas*, int chNum); - ~eventDisplayInterface(); + EventDisplayInterface(LfpDisplay*, LfpDisplayCanvas*, int chNum); + ~EventDisplayInterface(); void paint(Graphics& g); @@ -285,12 +277,12 @@ public: void checkEnabledState(); + bool isEnabled; + private: int channelNumber; - bool isEnabled; - LfpDisplay* display; LfpDisplayCanvas* canvas; diff --git a/Source/UI/UIComponent.cpp b/Source/UI/UIComponent.cpp index 4be5834a3..3c5d341cb 100755 --- a/Source/UI/UIComponent.cpp +++ b/Source/UI/UIComponent.cpp @@ -92,7 +92,7 @@ UIComponent::UIComponent(MainWindow* mainWindow_, ProcessorGraph* pgraph, AudioC mainWindow->setMenuBar(this); #endif - getEditorViewport()->loadState(File("/home/jsiegle/Programming/GUI/Builds/Linux/build/test.xml")); + //getEditorViewport()->loadState(File("/home/jsiegle/Programming/GUI/Builds/Linux/build/test.xml")); } -- GitLab