From c3192ee441511d309dc9073db182ae2d4a1354f4 Mon Sep 17 00:00:00 2001 From: jsiegle <jsiegle@mit.edu> Date: Mon, 8 Apr 2013 14:18:36 -0400 Subject: [PATCH] Run astyle on source code --- Source/Processors/DataThreads/DataBuffer.cpp | 8 +- .../Processors/DataThreads/RHD2000Thread.cpp | 125 +++-- Source/Processors/Editors/GenericEditor.h | 2 +- Source/Processors/Editors/RHD2000Editor.cpp | 140 ++--- Source/Processors/Editors/RHD2000Editor.h | 28 +- .../Processors/Editors/VisualizerEditor.cpp | 301 +++++----- Source/Processors/SourceNode.cpp | 18 +- .../Visualization/LfpDisplayCanvas.cpp | 101 ++-- .../Visualization/LfpDisplayCanvas.h | 2 +- .../Visualization/SpikeDisplayCanvas.cpp | 228 ++++---- .../Visualization/SpikeDisplayCanvas.h | 183 ++++--- Source/UI/ControlPanel.cpp | 10 +- Source/UI/CustomLookAndFeel.cpp | 516 +++++++++--------- Source/UI/InfoLabel.cpp | 2 +- Source/UI/ProcessorList.cpp | 4 +- 15 files changed, 860 insertions(+), 808 deletions(-) diff --git a/Source/Processors/DataThreads/DataBuffer.cpp b/Source/Processors/DataThreads/DataBuffer.cpp index 19bae80e2..dcc8a2b37 100755 --- a/Source/Processors/DataThreads/DataBuffer.cpp +++ b/Source/Processors/DataThreads/DataBuffer.cpp @@ -41,11 +41,11 @@ void DataBuffer::clear() void DataBuffer::resize(int chans, int size) { - buffer.setSize(chans, size); - timestampBuffer = new uint64[size]; - eventCodeBuffer = new int16[size]; + buffer.setSize(chans, size); + timestampBuffer = new uint64[size]; + eventCodeBuffer = new int16[size]; - numChans = chans; + numChans = chans; } void DataBuffer::addToBuffer(float* data, uint64* timestamps, int16* eventCodes, int numItems) diff --git a/Source/Processors/DataThreads/RHD2000Thread.cpp b/Source/Processors/DataThreads/RHD2000Thread.cpp index 282812fd7..737beb5d8 100644 --- a/Source/Processors/DataThreads/RHD2000Thread.cpp +++ b/Source/Processors/DataThreads/RHD2000Thread.cpp @@ -48,7 +48,7 @@ RHD2000Thread::RHD2000Thread(SourceNode* sn) : DataThread(sn), isTransmitting(fa numChannelsPerDataStream.insertMultiple(0,0,4); // initialize data buffer for 32 channels - dataBuffer = new DataBuffer(32, 10000); + dataBuffer = new DataBuffer(32, 10000); initializeBoard(); @@ -92,7 +92,8 @@ void RHD2000Thread::initializeBoard() evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortA, Rhd2000EvalBoard::AuxCmd3, 0); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortB, Rhd2000EvalBoard::AuxCmd3, 0); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortC, Rhd2000EvalBoard::AuxCmd3, 0); - evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortD, Rhd2000EvalBoard::AuxCmd3, 0);evalBoard->flush(); // flush in case it crashed with data remaining + evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortD, Rhd2000EvalBoard::AuxCmd3, 0); + evalBoard->flush(); // flush in case it crashed with data remaining // Since our longest command sequence is 60 commands, run the SPI interface for // 60 samples @@ -110,19 +111,19 @@ void RHD2000Thread::initializeBoard() // Read the resulting single data block from the USB interface. We don't // need to do anything with this, since it was only used for ADC calibration - Rhd2000DataBlock *dataBlock = new Rhd2000DataBlock(evalBoard->getNumEnabledDataStreams()); + Rhd2000DataBlock* dataBlock = new Rhd2000DataBlock(evalBoard->getNumEnabledDataStreams()); evalBoard->readDataBlock(dataBlock); // Now that ADC calibration has been performed, we switch to the command sequence // that does not execute ADC calibration. evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortA, Rhd2000EvalBoard::AuxCmd3, - fastSettleEnabled ? 2 : 1); + fastSettleEnabled ? 2 : 1); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortB, Rhd2000EvalBoard::AuxCmd3, - fastSettleEnabled ? 2 : 1); + fastSettleEnabled ? 2 : 1); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortC, Rhd2000EvalBoard::AuxCmd3, - fastSettleEnabled ? 2 : 1); + fastSettleEnabled ? 2 : 1); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortD, Rhd2000EvalBoard::AuxCmd3, - fastSettleEnabled ? 2 : 1); + fastSettleEnabled ? 2 : 1); // Set default configuration for all eight DACs on interface board. @@ -174,7 +175,7 @@ void RHD2000Thread::initializeBoard() int ledArray[8] = {1, 0, 0, 0, 0, 0, 0, 0}; evalBoard->setLedDisplay(ledArray); - + } void RHD2000Thread::scanPorts() @@ -199,21 +200,21 @@ void RHD2000Thread::scanPorts() evalBoard->enableDataStream(3, true); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortA, - Rhd2000EvalBoard::AuxCmd3, 0); + Rhd2000EvalBoard::AuxCmd3, 0); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortB, - Rhd2000EvalBoard::AuxCmd3, 0); + Rhd2000EvalBoard::AuxCmd3, 0); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortC, - Rhd2000EvalBoard::AuxCmd3, 0); + Rhd2000EvalBoard::AuxCmd3, 0); evalBoard->selectAuxCommandBank(Rhd2000EvalBoard::PortD, - Rhd2000EvalBoard::AuxCmd3, 0); + Rhd2000EvalBoard::AuxCmd3, 0); // Since our longest command sequence is 60 commands, we run the SPI // interface for 60 samples. evalBoard->setMaxTimeStep(60); evalBoard->setContinuousRunMode(false); - Rhd2000DataBlock *dataBlock = - new Rhd2000DataBlock(evalBoard->getNumEnabledDataStreams()); + Rhd2000DataBlock* dataBlock = + new Rhd2000DataBlock(evalBoard->getNumEnabledDataStreams()); Array<int> sumGoodDelays; sumGoodDelays.insertMultiple(0,0,4); @@ -230,10 +231,10 @@ void RHD2000Thread::scanPorts() Array<int> optimumDelay; optimumDelay.insertMultiple(0,0,4); - // Run SPI command sequence at all 16 possible FPGA MISO delay settings - // to find optimum delay for each SPI interface cable. - for (delay = 0; delay < 16; ++delay) - { + // Run SPI command sequence at all 16 possible FPGA MISO delay settings + // to find optimum delay for each SPI interface cable. + for (delay = 0; delay < 16; ++delay) + { evalBoard->setCableDelay(Rhd2000EvalBoard::PortA, delay); evalBoard->setCableDelay(Rhd2000EvalBoard::PortB, delay); evalBoard->setCableDelay(Rhd2000EvalBoard::PortC, delay); @@ -243,7 +244,8 @@ void RHD2000Thread::scanPorts() evalBoard->run(); // Wait for the 60-sample run to complete. - while (evalBoard->isRunning()) { + while (evalBoard->isRunning()) + { ; } @@ -252,15 +254,20 @@ void RHD2000Thread::scanPorts() // Read the Intan chip ID number from each RHD2000 chip found. // Record delay settings that yield good communication with the chip. - for (stream = 0; stream < 4; ++stream) { + for (stream = 0; stream < 4; ++stream) + { id = deviceId(dataBlock, stream); std::cout << "Device ID found: " << id << std::endl; - if (id > 0) { + if (id > 0) + { sumGoodDelays.set(stream,sumGoodDelays[stream] + 1); - if (indexFirstGoodDelay[stream] == -1) { + if (indexFirstGoodDelay[stream] == -1) + { indexFirstGoodDelay.set(stream, delay); chipId.set(stream,id); - } else if (indexSecondGoodDelay[stream] == -1) { + } + else if (indexSecondGoodDelay[stream] == -1) + { indexSecondGoodDelay.set(stream,delay); chipId.set(stream,id); } @@ -269,12 +276,13 @@ void RHD2000Thread::scanPorts() } // Now, disable data streams where we did not find chips present. - for (stream = 0; stream < 4; ++stream) + for (stream = 0; stream < 4; ++stream) { - if (chipId[stream] > 0) + if (chipId[stream] > 0) { enableHeadstage(stream, true); - } else + } + else { enableHeadstage(stream, false); } @@ -282,38 +290,42 @@ void RHD2000Thread::scanPorts() // Set cable delay settings that yield good communication with each // RHD2000 chip. - for (stream = 0; stream < 4; ++stream) { - if (sumGoodDelays[stream] == 1 || sumGoodDelays[stream] == 2) { + for (stream = 0; stream < 4; ++stream) + { + if (sumGoodDelays[stream] == 1 || sumGoodDelays[stream] == 2) + { optimumDelay.set(stream,indexFirstGoodDelay[stream]); - } else if (sumGoodDelays[stream] > 2) { + } + else if (sumGoodDelays[stream] > 2) + { optimumDelay.set(stream,indexSecondGoodDelay[stream]); } } evalBoard->setCableDelay(Rhd2000EvalBoard::PortA, - optimumDelay[0]); + optimumDelay[0]); evalBoard->setCableDelay(Rhd2000EvalBoard::PortB, - optimumDelay[1]); + optimumDelay[1]); evalBoard->setCableDelay(Rhd2000EvalBoard::PortC, - optimumDelay[2]); + optimumDelay[2]); evalBoard->setCableDelay(Rhd2000EvalBoard::PortD, - optimumDelay[3]); + optimumDelay[3]); cableLengthPortA = - evalBoard->estimateCableLengthMeters(optimumDelay[0]); + evalBoard->estimateCableLengthMeters(optimumDelay[0]); cableLengthPortB = - evalBoard->estimateCableLengthMeters(optimumDelay[1]); + evalBoard->estimateCableLengthMeters(optimumDelay[1]); cableLengthPortC = - evalBoard->estimateCableLengthMeters(optimumDelay[2]); + evalBoard->estimateCableLengthMeters(optimumDelay[2]); cableLengthPortD = - evalBoard->estimateCableLengthMeters(optimumDelay[3]); + evalBoard->estimateCableLengthMeters(optimumDelay[3]); } int RHD2000Thread::deviceId(Rhd2000DataBlock* dataBlock, int stream) { - bool intanChipPresent; + bool intanChipPresent; // First, check ROM registers 32-36 to verify that they hold 'INTAN'. // This is just used to verify that we are getting good data over the SPI @@ -326,9 +338,12 @@ int RHD2000Thread::deviceId(Rhd2000DataBlock* dataBlock, int stream) // If the SPI communication is bad, return -1. Otherwise, return the Intan // chip ID number stored in ROM regstier 63. - if (!intanChipPresent) { + if (!intanChipPresent) + { return -1; - } else { + } + else + { return dataBlock->auxiliaryData[stream][2][19]; // chip ID (Register 63) } } @@ -379,20 +394,22 @@ bool RHD2000Thread::foundInputSource() bool RHD2000Thread::enableHeadstage(int hsNum, bool enabled) { - + evalBoard->enableDataStream(hsNum, enabled); if (enabled) { numChannelsPerDataStream.set(hsNum, 32); - } else { + } + else + { numChannelsPerDataStream.set(hsNum, 0); } std::cout << "Enabled channels: " << numChannelsPerDataStream[0] << - " " << numChannelsPerDataStream[1] << - " " << numChannelsPerDataStream[2] << - " " << numChannelsPerDataStream[3] << std::endl; + " " << numChannelsPerDataStream[1] << + " " << numChannelsPerDataStream[2] << + " " << numChannelsPerDataStream[3] << std::endl; std::cout << "Enabled data streams: " << evalBoard->getNumEnabledDataStreams() << std::endl; @@ -415,26 +432,26 @@ bool RHD2000Thread::isHeadstageEnabled(int hsNum) void RHD2000Thread::setCableLength(int hsNum, float length) { - // Set the MISO sampling delay, which is dependent on the sample rate. + // Set the MISO sampling delay, which is dependent on the sample rate. - switch (hsNum) + switch (hsNum) { - case 0: + case 0: evalBoard->setCableLengthFeet(Rhd2000EvalBoard::PortA, length); break; - case 1: + case 1: evalBoard->setCableLengthFeet(Rhd2000EvalBoard::PortB, length); break; - case 2: + case 2: evalBoard->setCableLengthFeet(Rhd2000EvalBoard::PortC, length); break; - case 3: + case 3: evalBoard->setCableLengthFeet(Rhd2000EvalBoard::PortD, length); break; default: break; } - + } bool RHD2000Thread::startAcquisition() @@ -485,7 +502,9 @@ bool RHD2000Thread::stopAcquisition() if (waitForThreadToExit(500)) { std::cout << "Thread exited." << std::endl; - } else { + } + else + { std::cout << "Thread failed to exit, continuing anyway..." << std::endl; } diff --git a/Source/Processors/Editors/GenericEditor.h b/Source/Processors/Editors/GenericEditor.h index a2a092bf8..f709a5670 100755 --- a/Source/Processors/Editors/GenericEditor.h +++ b/Source/Processors/Editors/GenericEditor.h @@ -223,7 +223,7 @@ public: Font titleFont; /** True if data acquisition has begun. */ - bool acquisitionIsActive; + bool acquisitionIsActive; protected: diff --git a/Source/Processors/Editors/RHD2000Editor.cpp b/Source/Processors/Editors/RHD2000Editor.cpp index 6b9d4428c..5a4feaa6b 100644 --- a/Source/Processors/Editors/RHD2000Editor.cpp +++ b/Source/Processors/Editors/RHD2000Editor.cpp @@ -26,98 +26,100 @@ #include "../DataThreads/RHD2000Thread.h" -RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, - RHD2000Thread* board_, - bool useDefaultParameterEditors=true - ) +RHD2000Editor::RHD2000Editor(GenericProcessor* parentNode, + RHD2000Thread* board_, + bool useDefaultParameterEditors=true + ) : GenericEditor(parentNode, useDefaultParameterEditors), board(board_) { - desiredWidth = 400; + desiredWidth = 400; - int width = desiredWidth/4 - 10; + int width = desiredWidth/4 - 10; - for (int i = 0; i < 4; i++) - { - HeadstageOptionsInterface* hsOptions = new HeadstageOptionsInterface(board, this, i); - headstageOptionsInterfaces.add(hsOptions); + for (int i = 0; i < 4; i++) + { + HeadstageOptionsInterface* hsOptions = new HeadstageOptionsInterface(board, this, i); + headstageOptionsInterfaces.add(hsOptions); - addAndMakeVisible(hsOptions); + addAndMakeVisible(hsOptions); - hsOptions->setBounds(8+i*width,30, width, 85); - } + hsOptions->setBounds(8+i*width,30, width, 85); + } } RHD2000Editor::~RHD2000Editor() { - + } // -------------------------------------------------------------------- -HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_, - RHD2000Editor* editor_, - int hsNum) : - board(board_), editor(editor_), hsNumber(hsNum), isEnabled(false) +HeadstageOptionsInterface::HeadstageOptionsInterface(RHD2000Thread* board_, + RHD2000Editor* editor_, + int hsNum) : + board(board_), editor(editor_), hsNumber(hsNum), isEnabled(false) { - switch (hsNumber) - { - case 0 : - name = "A"; - break; - case 1: - name = "B"; - break; - case 2: - name = "C"; - break; - case 3: - name = "D"; - break; - default: - name = "X"; - } - - isEnabled = board->isHeadstageEnabled(hsNumber); - - enabledButton = new UtilityButton("enabled", Font("Small Text", 13, Font::plain)); - enabledButton->addListener(this); - enabledButton->setRadius(3.0f); - enabledButton->setBounds(10,30,70,25); - addAndMakeVisible(enabledButton); - - + switch (hsNumber) + { + case 0 : + name = "A"; + break; + case 1: + name = "B"; + break; + case 2: + name = "C"; + break; + case 3: + name = "D"; + break; + default: + name = "X"; + } + + isEnabled = board->isHeadstageEnabled(hsNumber); + + enabledButton = new UtilityButton("enabled", Font("Small Text", 13, Font::plain)); + enabledButton->addListener(this); + enabledButton->setRadius(3.0f); + enabledButton->setBounds(10,30,70,25); + addAndMakeVisible(enabledButton); + + } HeadstageOptionsInterface::~HeadstageOptionsInterface() { -} +} void HeadstageOptionsInterface::buttonClicked(Button* button) { - if (!(editor->acquisitionIsActive)) - { + if (!(editor->acquisitionIsActive)) + { + + //std::cout << "Acquisition is not active" << std::endl; + if (isEnabled) + { + isEnabled = false; + } + else + { + isEnabled = true; + } - //std::cout << "Acquisition is not active" << std::endl; - if (isEnabled) - { - isEnabled = false; - } else { - isEnabled = true; - } + board->enableHeadstage(hsNumber, isEnabled); - board->enableHeadstage(hsNumber, isEnabled); + repaint(); - repaint(); + editor->getEditorViewport()->makeEditorVisible(editor, false, true); + } - editor->getEditorViewport()->makeEditorVisible(editor, false, true); - } - } // void HeadstageOptionsInterface::mouseUp(const MouseEvent& event) @@ -127,24 +129,24 @@ void HeadstageOptionsInterface::buttonClicked(Button* button) // if (event.eventComponent == this) // { - + // } // } void HeadstageOptionsInterface::paint(Graphics& g) { - g.setColour(Colours::lightgrey); + g.setColour(Colours::lightgrey); - g.fillRoundedRectangle(5,0,getWidth()-10,getHeight(),4.0f); + g.fillRoundedRectangle(5,0,getWidth()-10,getHeight(),4.0f); - if (isEnabled) - g.setColour(Colours::black); - else - g.setColour(Colours::grey); + if (isEnabled) + g.setColour(Colours::black); + else + g.setColour(Colours::grey); - g.setFont(Font("Small Text",20,Font::plain)); + g.setFont(Font("Small Text",20,Font::plain)); - g.drawText(name, 8, 5, 200, 15, Justification::left, false); + g.drawText(name, 8, 5, 200, 15, Justification::left, false); } \ No newline at end of file diff --git a/Source/Processors/Editors/RHD2000Editor.h b/Source/Processors/Editors/RHD2000Editor.h index 3367ed3d0..0c053f6e6 100644 --- a/Source/Processors/Editors/RHD2000Editor.h +++ b/Source/Processors/Editors/RHD2000Editor.h @@ -49,9 +49,9 @@ public: private: - OwnedArray<HeadstageOptionsInterface> headstageOptionsInterfaces; + OwnedArray<HeadstageOptionsInterface> headstageOptionsInterfaces; - RHD2000Thread* board; + RHD2000Thread* board; JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(RHD2000Editor); @@ -59,29 +59,29 @@ private: class HeadstageOptionsInterface : public Component, - public Button::Listener + public Button::Listener { public: - HeadstageOptionsInterface(RHD2000Thread*, RHD2000Editor*, int hsNum); - ~HeadstageOptionsInterface(); + HeadstageOptionsInterface(RHD2000Thread*, RHD2000Editor*, int hsNum); + ~HeadstageOptionsInterface(); - //void mouseUp(const MouseEvent& event); + //void mouseUp(const MouseEvent& event); - void paint(Graphics& g); + void paint(Graphics& g); - void buttonClicked(Button* button); + void buttonClicked(Button* button); private: - int hsNumber; - String name; + int hsNumber; + String name; - bool isEnabled; + bool isEnabled; - RHD2000Thread* board; - RHD2000Editor* editor; + RHD2000Thread* board; + RHD2000Editor* editor; - ScopedPointer<UtilityButton> enabledButton; + ScopedPointer<UtilityButton> enabledButton; }; diff --git a/Source/Processors/Editors/VisualizerEditor.cpp b/Source/Processors/Editors/VisualizerEditor.cpp index e62ae7026..1355aad82 100755 --- a/Source/Processors/Editors/VisualizerEditor.cpp +++ b/Source/Processors/Editors/VisualizerEditor.cpp @@ -24,10 +24,10 @@ #include "VisualizerEditor.h" SelectorButton::SelectorButton(const String& name_) - : Button(name_) + : Button(name_) { - setClickingTogglesState (true); - setTooltip ("Toggle a state."); + setClickingTogglesState(true); + setTooltip("Toggle a state."); } @@ -35,206 +35,219 @@ SelectorButton::~SelectorButton() { } -void SelectorButton::paintButton(Graphics &g, bool isMouseOver, bool isButtonDown) +void SelectorButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown) { if (getToggleState() == true) g.setColour(Colours::white); - else + else g.setColour(Colours::darkgrey); if (isMouseOver) g.setColour(Colours::yellow); - if (getName().equalsIgnoreCase("window")) - { - // window icon - g.drawRect(0,0,getWidth(),getHeight(),1.0); - g.fillRect(0,0,getWidth(),3.0); - } else { - // tab icon - g.drawVerticalLine(5,0,getHeight()); - g.fillRoundedRectangle(5,2,4,getHeight()-4,4.0f); - g.fillRect(5,2,4,getHeight()-4); - } - + if (getName().equalsIgnoreCase("window")) + { + // window icon + g.drawRect(0,0,getWidth(),getHeight(),1.0); + g.fillRect(0,0,getWidth(),3.0); + } + else + { + // tab icon + g.drawVerticalLine(5,0,getHeight()); + g.fillRoundedRectangle(5,2,4,getHeight()-4,4.0f); + g.fillRect(5,2,4,getHeight()-4); + } + } -VisualizerEditor::VisualizerEditor (GenericProcessor* parentNode, int width, bool useDefaultParameterEditors=true) - : GenericEditor(parentNode, useDefaultParameterEditors=true), - dataWindow(0), canvas(0), tabText("Tab"), isPlaying(false), tabIndex(-1) +VisualizerEditor::VisualizerEditor(GenericProcessor* parentNode, int width, bool useDefaultParameterEditors=true) + : GenericEditor(parentNode, useDefaultParameterEditors=true), + dataWindow(0), canvas(0), tabText("Tab"), isPlaying(false), tabIndex(-1) { - desiredWidth = width; + desiredWidth = width; - initializeSelectors(); + initializeSelectors(); } -VisualizerEditor::VisualizerEditor (GenericProcessor* parentNode, bool useDefaultParameterEditors=true) - : GenericEditor(parentNode, useDefaultParameterEditors), - dataWindow(0), canvas(0), isPlaying(false), tabIndex(-1) +VisualizerEditor::VisualizerEditor(GenericProcessor* parentNode, bool useDefaultParameterEditors=true) + : GenericEditor(parentNode, useDefaultParameterEditors), + dataWindow(0), canvas(0), isPlaying(false), tabIndex(-1) { - desiredWidth = 180; - initializeSelectors(); + desiredWidth = 180; + initializeSelectors(); } -void VisualizerEditor::initializeSelectors(){ +void VisualizerEditor::initializeSelectors() +{ + + windowSelector = new SelectorButton("window"); + windowSelector->addListener(this); + windowSelector->setBounds(desiredWidth - 40,7,14,10); - windowSelector = new SelectorButton("window"); - windowSelector->addListener(this); - windowSelector->setBounds(desiredWidth - 40,7,14,10); + windowSelector->setToggleState(false,false); + addAndMakeVisible(windowSelector); - windowSelector->setToggleState(false,false); - addAndMakeVisible(windowSelector); + tabSelector = new SelectorButton("tab"); + tabSelector->addListener(this); + tabSelector->setBounds(desiredWidth - 20,7,15,10); - tabSelector = new SelectorButton("tab"); - tabSelector->addListener(this); - tabSelector->setBounds(desiredWidth - 20,7,15,10); - - addAndMakeVisible(tabSelector); - tabSelector->setToggleState(false,false); + addAndMakeVisible(tabSelector); + tabSelector->setToggleState(false,false); } VisualizerEditor::~VisualizerEditor() { - if (tabIndex > -1) - { - getDataViewport()->destroyTab(tabIndex); - } + if (tabIndex > -1) + { + getDataViewport()->destroyTab(tabIndex); + } - deleteAllChildren(); + deleteAllChildren(); } void VisualizerEditor::enable() { - std::cout << " Enabling VisualizerEditor" << std::endl; - if (canvas != 0) - canvas->beginAnimation(); - - isPlaying = true; + std::cout << " Enabling VisualizerEditor" << std::endl; + if (canvas != 0) + canvas->beginAnimation(); + + isPlaying = true; } void VisualizerEditor::disable() { - if (canvas != 0) - canvas->endAnimation(); + if (canvas != 0) + canvas->endAnimation(); - isPlaying = false; + isPlaying = false; } void VisualizerEditor::updateVisualizer() { - if (canvas != 0) - canvas->update(); + if (canvas != 0) + canvas->update(); } void VisualizerEditor::editorWasClicked() { - if (tabIndex > -1) - { - std::cout << "Setting tab index to " << tabIndex << std::endl; - getDataViewport()->selectTab(tabIndex); - } + if (tabIndex > -1) + { + std::cout << "Setting tab index to " << tabIndex << std::endl; + getDataViewport()->selectTab(tabIndex); + } } void VisualizerEditor::buttonEvent(Button* button) { - int gId = button->getRadioGroupId(); - - if (gId > 0) { - if (canvas != 0) - { - canvas->setParameter(gId-1, button->getName().getFloatValue()); - } - - } else { - - if (canvas == 0) { - - canvas = createNewCanvas(); - - if (isPlaying) - canvas->beginAnimation(); - } - - if (button == windowSelector) - { - - if (tabSelector->getToggleState() && windowSelector->getToggleState()) - { - tabSelector->setToggleState(false, false); - getDataViewport()->destroyTab(tabIndex); - tabIndex = -1; - } - - if (dataWindow == 0) { - - dataWindow = new DataWindow(windowSelector, tabText); - dataWindow->setContentNonOwned(canvas, false); - dataWindow->setVisible(true); - canvas->refreshState(); - - } else { - - dataWindow->setVisible(windowSelector->getToggleState()); - - if (windowSelector->getToggleState()) - { - dataWindow->setContentNonOwned(canvas, false); - canvas->setBounds(0,0,canvas->getParentWidth(), canvas->getParentHeight()); - canvas->refreshState(); - } else { - dataWindow->setContentNonOwned(0, false); - } - - } - - } - else if (button == tabSelector) - { - if (tabSelector->getToggleState() && tabIndex < 0) - { - - if (windowSelector->getToggleState()) - { - dataWindow->setContentNonOwned(0, false); - windowSelector->setToggleState(false, false); - dataWindow->setVisible(false); - } - - tabIndex = getDataViewport()->addTabToDataViewport(tabText, canvas, this); - - - } else if (!tabSelector->getToggleState() && tabIndex > -1) - { - getDataViewport()->destroyTab(tabIndex); - tabIndex = -1; - - } - } - - } - - buttonCallback(button); - - if (button == drawerButton) - { - std::cout<<"Drawer button clicked"<<std::endl; - windowSelector->setBounds(desiredWidth - 40,7,14,10); - tabSelector->setBounds(desiredWidth - 20,7,15,10); - - } + int gId = button->getRadioGroupId(); + + if (gId > 0) + { + if (canvas != 0) + { + canvas->setParameter(gId-1, button->getName().getFloatValue()); + } + + } + else + { + + if (canvas == 0) + { + + canvas = createNewCanvas(); + + if (isPlaying) + canvas->beginAnimation(); + } + + if (button == windowSelector) + { + + if (tabSelector->getToggleState() && windowSelector->getToggleState()) + { + tabSelector->setToggleState(false, false); + getDataViewport()->destroyTab(tabIndex); + tabIndex = -1; + } + + if (dataWindow == 0) + { + + dataWindow = new DataWindow(windowSelector, tabText); + dataWindow->setContentNonOwned(canvas, false); + dataWindow->setVisible(true); + canvas->refreshState(); + + } + else + { + + dataWindow->setVisible(windowSelector->getToggleState()); + + if (windowSelector->getToggleState()) + { + dataWindow->setContentNonOwned(canvas, false); + canvas->setBounds(0,0,canvas->getParentWidth(), canvas->getParentHeight()); + canvas->refreshState(); + } + else + { + dataWindow->setContentNonOwned(0, false); + } + + } + + } + else if (button == tabSelector) + { + if (tabSelector->getToggleState() && tabIndex < 0) + { + + if (windowSelector->getToggleState()) + { + dataWindow->setContentNonOwned(0, false); + windowSelector->setToggleState(false, false); + dataWindow->setVisible(false); + } + + tabIndex = getDataViewport()->addTabToDataViewport(tabText, canvas, this); + + + } + else if (!tabSelector->getToggleState() && tabIndex > -1) + { + getDataViewport()->destroyTab(tabIndex); + tabIndex = -1; + + } + } + + } + + buttonCallback(button); + + if (button == drawerButton) + { + std::cout<<"Drawer button clicked"<<std::endl; + windowSelector->setBounds(desiredWidth - 40,7,14,10); + tabSelector->setBounds(desiredWidth - 20,7,15,10); + + } } diff --git a/Source/Processors/SourceNode.cpp b/Source/Processors/SourceNode.cpp index 2c4f6da89..8570c6cff 100755 --- a/Source/Processors/SourceNode.cpp +++ b/Source/Processors/SourceNode.cpp @@ -51,28 +51,30 @@ SourceNode::SourceNode(const String& name_) else if (getName().equalsIgnoreCase("File Reader")) { - // sendActionMessage("Select a file..."); + // sendActionMessage("Select a file..."); - FileChooser chooseFileReaderFile ("Please select the file you want to load...", - File::getSpecialLocation (File::userHomeDirectory), - "*"); + FileChooser chooseFileReaderFile("Please select the file you want to load...", + File::getSpecialLocation(File::userHomeDirectory), + "*"); if (chooseFileReaderFile.browseForFileToOpen()) { // Use the selected file - File fileToRead (chooseFileReaderFile.getResult()); + File fileToRead(chooseFileReaderFile.getResult()); String fileName(fileToRead.getFullPathName()); dataThread = new FileReaderThread(this, fileName.getCharPointer()); - } else { + } + else + { // If cancelled, assume it's in the executable directory dataThread = new FileReaderThread(this, "./data_stream_16ch_2"); } - //dataThread = new FileReaderThread(this, "./data_stream_16ch_2"); + //dataThread = new FileReaderThread(this, "./data_stream_16ch_2"); //sendActionMessage("File loaded."); - + } else if (getName().equalsIgnoreCase("RHD2000 USB Board")) { diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.cpp b/Source/Processors/Visualization/LfpDisplayCanvas.cpp index a56a32c11..9542236eb 100755 --- a/Source/Processors/Visualization/LfpDisplayCanvas.cpp +++ b/Source/Processors/Visualization/LfpDisplayCanvas.cpp @@ -140,15 +140,16 @@ void LfpDisplayCanvas::update() void LfpDisplayCanvas::comboBoxChanged(ComboBox* cb) { - if (cb == timebaseSelection) - { - timebase = timebases[cb->getSelectedId()-1].getFloatValue(); - } else if (cb == rangeSelection) - { - displayGain = 150.0f / voltageRanges[cb->getSelectedId()-1].getFloatValue(); // not sure this is right. - } + if (cb == timebaseSelection) + { + timebase = timebases[cb->getSelectedId()-1].getFloatValue(); + } + else if (cb == rangeSelection) + { + displayGain = 150.0f / voltageRanges[cb->getSelectedId()-1].getFloatValue(); // not sure this is right. + } - timescale->setTimebase(timebase); + timescale->setTimebase(timebase); } @@ -308,15 +309,15 @@ void LfpDisplayCanvas::paint(Graphics& g) g.fillRect(0, 0, getWidth(), getHeight()); g.setColour(Colour(40,40,40)); - + int w = getWidth()-scrollBarThickness; for (int i = 1; i < 10; i++) { - if (i == 5) - g.drawLine(w/10*i,0,w/10*i,getHeight()-60,3.0f); - else - g.drawLine(w/10*i,0,w/10*i,getHeight()-60,1.0f); + if (i == 5) + g.drawLine(w/10*i,0,w/10*i,getHeight()-60,3.0f); + else + g.drawLine(w/10*i,0,w/10*i,getHeight()-60,1.0f); } g.drawLine(0,getHeight()-60,getWidth(),getHeight()-60,3.0f); @@ -342,7 +343,7 @@ void LfpDisplayCanvas::refresh() LfpTimescale::LfpTimescale(LfpDisplayCanvas* c) : canvas(c) { - font = Font("Default", 16, Font::plain); + font = Font("Default", 16, Font::plain); } LfpTimescale::~LfpTimescale() @@ -353,15 +354,15 @@ LfpTimescale::~LfpTimescale() void LfpTimescale::paint(Graphics& g) { - g.setGradientFill(ColourGradient(Colour(50,50,50),0,0, - Colour(25,25,25),0,getHeight(), - false)); + g.setGradientFill(ColourGradient(Colour(50,50,50),0,0, + Colour(25,25,25),0,getHeight(), + false)); g.fillAll(); - g.setColour(Colours::black); + g.setColour(Colours::black); - g.drawLine(0,getHeight(),getWidth(),getHeight()); + g.drawLine(0,getHeight(),getWidth(),getHeight()); g.setFont(font); @@ -369,30 +370,30 @@ void LfpTimescale::paint(Graphics& g) for (int i = 1; i < 10; i++) { - if (i == 5) - g.drawLine(getWidth()/10*i,0,getWidth()/10*i,getHeight(),3.0f); - else - g.drawLine(getWidth()/10*i,0,getWidth()/10*i,getHeight(),1.0f); + if (i == 5) + g.drawLine(getWidth()/10*i,0,getWidth()/10*i,getHeight(),3.0f); + else + g.drawLine(getWidth()/10*i,0,getWidth()/10*i,getHeight(),1.0f); - g.drawText(labels[i-1],getWidth()/10*i+1,0,100,getHeight(),Justification::left, false); + g.drawText(labels[i-1],getWidth()/10*i+1,0,100,getHeight(),Justification::left, false); } } void LfpTimescale::setTimebase(float t) { - timebase = t; + timebase = t; - labels.clear(); + labels.clear(); - for (float i = 1.0f; i < 10.0; i++) - { - String labelString = String(timebase/10.0f*i); + for (float i = 1.0f; i < 10.0; i++) + { + String labelString = String(timebase/10.0f*i); - labels.add(labelString.substring(1,4)); - } + labels.add(labelString.substring(1,4)); + } - repaint(); + repaint(); } @@ -409,12 +410,12 @@ LfpDisplay::LfpDisplay(LfpDisplayCanvas* c, Viewport* v) : for (int i = 0; i < 10; i++) { - channelColours.add(Colour(200,200,255-i*25)); + channelColours.add(Colour(200,200,255-i*25)); } for (int i = 10; i > -1; i--) { - channelColours.add(Colour(200,200,255-i*25)); + channelColours.add(Colour(200,200,255-i*25)); } } @@ -528,9 +529,9 @@ LfpChannelDisplay::LfpChannelDisplay(LfpDisplayCanvas* c, int channelNumber) : canvas(c), isSelected(false), chan(channelNumber) { - channelFont = Font("Default", 50, Font::plain); + channelFont = Font("Default", 50, Font::plain); - lineColour = Colour(255,255,255); + lineColour = Colour(255,255,255); } @@ -542,9 +543,9 @@ LfpChannelDisplay::~LfpChannelDisplay() void LfpChannelDisplay::paint(Graphics& g) { - //g.fillAll(Colours::grey); + //g.fillAll(Colours::grey); - g.setColour(Colours::yellow); + g.setColour(Colours::yellow); g.drawLine(canvas->screenBufferIndex, 0, canvas->screenBufferIndex, getHeight()); @@ -552,19 +553,19 @@ void LfpChannelDisplay::paint(Graphics& g) if (isSelected) { - g.setColour(Colours::lightgrey); - g.fillRect(0,center-50,10,100); - g.drawLine(0,center+50,getWidth(),center+50); - g.drawLine(0,center-50,getWidth(),center-50); - - g.setColour(Colour(25,25,25)); - g.drawLine(0,center+25,10,center+25); - g.drawLine(0,center-25,10,center-25); - + g.setColour(Colours::lightgrey); + g.fillRect(0,center-50,10,100); + g.drawLine(0,center+50,getWidth(),center+50); + g.drawLine(0,center-50,getWidth(),center-50); + + g.setColour(Colour(25,25,25)); + g.drawLine(0,center+25,10,center+25); + g.drawLine(0,center-25,10,center-25); + } - - g.setColour(Colour(40,40,40)); + + g.setColour(Colour(40,40,40)); g.drawLine(0, getHeight()/2, getWidth(), getHeight()/2); int stepSize = 1; @@ -600,5 +601,5 @@ void LfpChannelDisplay::deselect() void LfpChannelDisplay::setColour(Colour c) { - lineColour = c; + lineColour = c; } diff --git a/Source/Processors/Visualization/LfpDisplayCanvas.h b/Source/Processors/Visualization/LfpDisplayCanvas.h index 93335a9f0..4895d92b1 100755 --- a/Source/Processors/Visualization/LfpDisplayCanvas.h +++ b/Source/Processors/Visualization/LfpDisplayCanvas.h @@ -42,7 +42,7 @@ class LfpChannelDisplay; */ class LfpDisplayCanvas : public Visualizer, - public ComboBox::Listener + public ComboBox::Listener { public: diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp index 8c7c0d4af..139bf3bec 100755 --- a/Source/Processors/Visualization/SpikeDisplayCanvas.cpp +++ b/Source/Processors/Visualization/SpikeDisplayCanvas.cpp @@ -73,7 +73,7 @@ void SpikeDisplayCanvas::update() for (int i = 0; i < nPlots; i++) { - spikeDisplay->addSpikePlot(processor->getNumberOfChannelsForElectrode(i), i); + spikeDisplay->addSpikePlot(processor->getNumberOfChannelsForElectrode(i), i); } //initializeSpikePlots(); @@ -139,14 +139,14 @@ void SpikeDisplayCanvas::processSpikeEvents() int electrodeNum = newSpike.source; - // generateSimulatedSpike(&simSpike, 0, 0); + // generateSimulatedSpike(&simSpike, 0, 0); - // for (int i = 0; i < newSpike.nChannels * newSpike.nSamples; i++) - // { - // simSpike.data[i] = newSpike.data[i%80] + 5000;// * 3 - 10000; - // } + // for (int i = 0; i < newSpike.nChannels * newSpike.nSamples; i++) + // { + // simSpike.data[i] = newSpike.data[i%80] + 5000;// * 3 - 10000; + // } - // simSpike.nSamples = 40; + // simSpike.nSamples = 40; spikeDisplay->plotSpike(newSpike, electrodeNum); @@ -175,16 +175,16 @@ SpikeDisplay::~SpikeDisplay() void SpikeDisplay::clear() { - if (spikePlots.size() > 0) - spikePlots.clear(); + if (spikePlots.size() > 0) + spikePlots.clear(); } void SpikeDisplay::addSpikePlot(int numChannels, int electrodeNum) { - std::cout << "Adding new spike plot." << std::endl; + std::cout << "Adding new spike plot." << std::endl; - SpikePlot* spikePlot = new SpikePlot(canvas, electrodeNum, 1000 + numChannels); + SpikePlot* spikePlot = new SpikePlot(canvas, electrodeNum, 1000 + numChannels); spikePlots.add(spikePlot); addAndMakeVisible(spikePlot); } @@ -192,99 +192,103 @@ void SpikeDisplay::addSpikePlot(int numChannels, int electrodeNum) void SpikeDisplay::paint(Graphics& g) { - g.fillAll(Colours::grey); + g.fillAll(Colours::grey); } void SpikeDisplay::resized() { - // this is kind of a mess -- is there any way to optimize it? + // this is kind of a mess -- is there any way to optimize it? - if (spikePlots.size() > 0) - { - - int w = getWidth(); - - int numColumns = 1; - int column, row; - - int stereotrodeStart = 0; - int tetrodeStart = 0; - - int singlePlotIndex = -1; - int stereotrodePlotIndex = -1; - int tetrodePlotIndex = -1; - int index; - - float width, height; - - for (int i = 0; i < spikePlots.size(); i++) - { + if (spikePlots.size() > 0) + { - if (spikePlots[i]->nChannels == 1) - { - index = ++singlePlotIndex; - numColumns = (int) jmax(w / spikePlots[i]->minWidth, 1.0f); - width = jmin((float) w / (float) numColumns, (float) getWidth()); - height = width * spikePlots[i]->aspectRatio; + int w = getWidth(); - } else if (spikePlots[i]->nChannels == 2) - { - index = ++stereotrodePlotIndex; - numColumns = (int) jmax(w / spikePlots[i]->minWidth, 1.0f); - width = jmin((float) w / (float) numColumns, (float) getWidth()); - height = width * spikePlots[i]->aspectRatio; + int numColumns = 1; + int column, row; - } else if (spikePlots[i]->nChannels == 4) - { - index = ++tetrodePlotIndex; - numColumns = (int) jmax(w / spikePlots[i]->minWidth, 1.0f); - width = jmin((float) w / (float) numColumns, (float) getWidth()); - height = width * spikePlots[i]->aspectRatio; - } + int stereotrodeStart = 0; + int tetrodeStart = 0; - column = index % numColumns; + int singlePlotIndex = -1; + int stereotrodePlotIndex = -1; + int tetrodePlotIndex = -1; + int index; - row = index / numColumns; + float width, height; - spikePlots[i]->setBounds(width*column, row*height, width, height); + for (int i = 0; i < spikePlots.size(); i++) + { - if (spikePlots[i]->nChannels == 1) - { - stereotrodeStart = (int)(height*(float(row)+1)); - } else if (spikePlots[i]->nChannels == 2) - { - tetrodeStart = (int)(height*(float(row)+1)); - } + if (spikePlots[i]->nChannels == 1) + { + index = ++singlePlotIndex; + numColumns = (int) jmax(w / spikePlots[i]->minWidth, 1.0f); + width = jmin((float) w / (float) numColumns, (float) getWidth()); + height = width * spikePlots[i]->aspectRatio; + + } + else if (spikePlots[i]->nChannels == 2) + { + index = ++stereotrodePlotIndex; + numColumns = (int) jmax(w / spikePlots[i]->minWidth, 1.0f); + width = jmin((float) w / (float) numColumns, (float) getWidth()); + height = width * spikePlots[i]->aspectRatio; + + } + else if (spikePlots[i]->nChannels == 4) + { + index = ++tetrodePlotIndex; + numColumns = (int) jmax(w / spikePlots[i]->minWidth, 1.0f); + width = jmin((float) w / (float) numColumns, (float) getWidth()); + height = width * spikePlots[i]->aspectRatio; + } + + column = index % numColumns; + + row = index / numColumns; + + spikePlots[i]->setBounds(width*column, row*height, width, height); + + if (spikePlots[i]->nChannels == 1) + { + stereotrodeStart = (int)(height*(float(row)+1)); + } + else if (spikePlots[i]->nChannels == 2) + { + tetrodeStart = (int)(height*(float(row)+1)); + } - } + } - for (int i = 0; i < spikePlots.size(); i++) - { + for (int i = 0; i < spikePlots.size(); i++) + { - int x = spikePlots[i]->getX(); - int y = spikePlots[i]->getY(); - int w2 = spikePlots[i]->getWidth(); - int h2 = spikePlots[i]->getHeight(); + int x = spikePlots[i]->getX(); + int y = spikePlots[i]->getY(); + int w2 = spikePlots[i]->getWidth(); + int h2 = spikePlots[i]->getHeight(); - if (spikePlots[i]->nChannels == 2) - { - spikePlots[i]->setBounds(x, y+stereotrodeStart, w2, h2); + if (spikePlots[i]->nChannels == 2) + { + spikePlots[i]->setBounds(x, y+stereotrodeStart, w2, h2); - } else if (spikePlots[i]->nChannels == 4) - { - spikePlots[i]->setBounds(x, y+stereotrodeStart+tetrodeStart, w2, h2); - } + } + else if (spikePlots[i]->nChannels == 4) + { + spikePlots[i]->setBounds(x, y+stereotrodeStart+tetrodeStart, w2, h2); + } - } + } - totalHeight = 5000; // don't even deal with making the display the correct height + totalHeight = 5000; // don't even deal with making the display the correct height - if (totalHeight < getHeight()) - { - canvas->resized(); - } - } + if (totalHeight < getHeight()) + { + canvas->resized(); + } + } } @@ -295,7 +299,7 @@ void SpikeDisplay::mouseDown(const MouseEvent& event) void SpikeDisplay::plotSpike(const SpikeObject& spike, int electrodeNum) { - spikePlots[electrodeNum]->processSpikeObject(spike); + spikePlots[electrodeNum]->processSpikeObject(spike); } @@ -309,10 +313,10 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p) : font = Font("Default", 15, Font::plain); - switch (p) + switch (p) { case SINGLE_PLOT: - // std::cout<<"SpikePlot as SINGLE_PLOT"<<std::endl; + // std::cout<<"SpikePlot as SINGLE_PLOT"<<std::endl; nWaveAx = 1; nProjAx = 0; nChannels = 1; @@ -320,7 +324,7 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p) : aspectRatio = 1.0f; break; case STEREO_PLOT: - // std::cout<<"SpikePlot as STEREO_PLOT"<<std::endl; + // std::cout<<"SpikePlot as STEREO_PLOT"<<std::endl; nWaveAx = 2; nProjAx = 1; nChannels = 2; @@ -328,7 +332,7 @@ SpikePlot::SpikePlot(SpikeDisplayCanvas* sdc, int elecNum, int p) : aspectRatio = 0.5f; break; case TETRODE_PLOT: - // std::cout<<"SpikePlot as TETRODE_PLOT"<<std::endl; + // std::cout<<"SpikePlot as TETRODE_PLOT"<<std::endl; nWaveAx = 4; nProjAx = 6; nChannels = 4; @@ -361,12 +365,12 @@ SpikePlot::~SpikePlot() void SpikePlot::paint(Graphics& g) { - g.setColour(Colours::white); + g.setColour(Colours::white); g.drawRect(0,0,getWidth(),getHeight()); g.setFont(font); - g.drawText(String(electrodeNumber+1),10,0,50,20,Justification::left,false); + g.drawText(String(electrodeNumber+1),10,0,50,20,Justification::left,false); } @@ -397,16 +401,16 @@ void SpikePlot::initAxes() for (int i = 0; i < nWaveAx; i++) { - WaveAxes* wAx = new WaveAxes(WAVE1 + i); - wAxes.add(wAx); - addAndMakeVisible(wAx); + WaveAxes* wAx = new WaveAxes(WAVE1 + i); + wAxes.add(wAx); + addAndMakeVisible(wAx); } for (int i = 0; i < nProjAx; i++) { - ProjectionAxes* pAx = new ProjectionAxes(PROJ1x2 + i); - pAxes.add(pAx); - addAndMakeVisible(pAx); + ProjectionAxes* pAx = new ProjectionAxes(PROJ1x2 + i); + pAxes.add(pAx); + addAndMakeVisible(pAx); } setLimitsOnAxes(); // initialize thel limits on the axes @@ -415,12 +419,12 @@ void SpikePlot::initAxes() void SpikePlot::resized() { - float width = getWidth()-10; - float height = getHeight()-20; + float width = getWidth()-10; + float height = getHeight()-20; - float axesWidth, axesHeight; + float axesWidth, axesHeight; - // to compute the axes positions we need to know how many columns of proj and wave axes should exist + // to compute the axes positions we need to know how many columns of proj and wave axes should exist // using these two values we can calculate the positions of all of the sub axes int nProjCols, nWaveCols; @@ -457,7 +461,7 @@ void SpikePlot::resized() void SpikePlot::setLimitsOnAxes() { - //std::cout<<"SpikePlot::setLimitsOnAxes()"<<std::endl; + //std::cout<<"SpikePlot::setLimitsOnAxes()"<<std::endl; for (int i = 0; i < nWaveAx; i++) wAxes[i]->setYLims(limits[i][0], limits[i][1]); @@ -603,7 +607,7 @@ void SpikePlot::n2ProjIdx(int proj, int* p1, int* p2) WaveAxes::WaveAxes(int channel) : GenericAxes(channel), drawGrid(true) { - font = Font("Small Text",10,Font::plain); + font = Font("Small Text",10,Font::plain); } void WaveAxes::paint(Graphics& g) @@ -616,13 +620,13 @@ void WaveAxes::paint(Graphics& g) // if no spikes have been received then don't plot anything if (!gotFirstSpike) { - return; + return; } float h = getHeight(); // draw the grid lines for the waveforms - if (drawGrid) - drawWaveformGrid(s.threshold[chan], s.gain[chan], g); + if (drawGrid) + drawWaveformGrid(s.threshold[chan], s.gain[chan], g); //compute the spatial width for each waveform sample float dx = (getWidth()-10)/s.nSamples; @@ -631,7 +635,7 @@ void WaveAxes::paint(Graphics& g) // type corresponds to channel so we need to calculate the starting // sample based upon which channel is getting plotted int sampIdx = s.nSamples * type; // - + // draw the individual waveform points g.setColour(Colours::white); @@ -639,10 +643,10 @@ void WaveAxes::paint(Graphics& g) for (int i = 0; i < s.nSamples-1; i++) { - //std::cout << s.data[sampIdx] << std::endl; - g.drawLine(x, h/2 + (s.data[sampIdx]-32768)/100, x+dx, h/2 + (s.data[sampIdx+1]-32768)/100); - sampIdx += dSamples; - x += dx; + //std::cout << s.data[sampIdx] << std::endl; + g.drawLine(x, h/2 + (s.data[sampIdx]-32768)/100, x+dx, h/2 + (s.data[sampIdx+1]-32768)/100); + sampIdx += dSamples; + x += dx; } // draw the threshold line and labels @@ -651,7 +655,7 @@ void WaveAxes::paint(Graphics& g) void WaveAxes::drawWaveformGrid(int threshold, int gain, Graphics& g) { - double voltRange = ylims[1] - ylims[0]; + double voltRange = ylims[1] - ylims[0]; double pixelRange = getHeight(); //This is a totally arbitrary value that seemed to lok the best for me int minPixelsPerTick = 25; @@ -720,7 +724,7 @@ void WaveAxes::drawWaveformGrid(int threshold, int gain, Graphics& g) void WaveAxes::clear() { - + } diff --git a/Source/Processors/Visualization/SpikeDisplayCanvas.h b/Source/Processors/Visualization/SpikeDisplayCanvas.h index 116ea3d89..8c3ede255 100755 --- a/Source/Processors/Visualization/SpikeDisplayCanvas.h +++ b/Source/Processors/Visualization/SpikeDisplayCanvas.h @@ -59,7 +59,7 @@ class WaveAxes; class SpikePlot; /** - + Displays spike waveforms and projections. @see SpikeDisplayNode, SpikeDisplayEditor, Visualizer @@ -69,81 +69,84 @@ class SpikePlot; class SpikeDisplayCanvas : public Visualizer { -public: - SpikeDisplayCanvas(SpikeDisplayNode* n); - ~SpikeDisplayCanvas(); +public: + SpikeDisplayCanvas(SpikeDisplayNode* n); + ~SpikeDisplayCanvas(); - void paint(Graphics& g); + void paint(Graphics& g); - void refresh(); + void refresh(); - void processSpikeEvents(); + void processSpikeEvents(); - void beginAnimation(); - void endAnimation(); + void beginAnimation(); + void endAnimation(); - void refreshState(); + void refreshState(); - void setParameter(int, float) {} - void setParameter(int, int, int, float){} + void setParameter(int, float) {} + void setParameter(int, int, int, float) {} - void update(); + void update(); - void resized(); + void resized(); private: - SpikeDisplayNode* processor; - MidiBuffer* spikeBuffer; + SpikeDisplayNode* processor; + MidiBuffer* spikeBuffer; + + ScopedPointer<SpikeDisplay> spikeDisplay; + ScopedPointer<Viewport> viewport; - ScopedPointer<SpikeDisplay> spikeDisplay; - ScopedPointer<Viewport> viewport; + bool newSpike; + SpikeObject spike; - bool newSpike; - SpikeObject spike; + int scrollBarThickness; - int scrollBarThickness; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SpikeDisplayCanvas); - JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpikeDisplayCanvas); - }; class SpikeDisplay : public Component { public: - SpikeDisplay(SpikeDisplayCanvas*, Viewport*); - ~SpikeDisplay(); + SpikeDisplay(SpikeDisplayCanvas*, Viewport*); + ~SpikeDisplay(); - void clear(); - void addSpikePlot(int numChannels, int electrodeNum); + void clear(); + void addSpikePlot(int numChannels, int electrodeNum); - void paint(Graphics& g); + void paint(Graphics& g); - void resized(); + void resized(); - void mouseDown(const MouseEvent& event); + void mouseDown(const MouseEvent& event); - void plotSpike(const SpikeObject& spike, int electrodeNum); + void plotSpike(const SpikeObject& spike, int electrodeNum); - int getTotalHeight() {return totalHeight;} + int getTotalHeight() + { + return totalHeight; + } private: - //void computeColumnLayout(); -//void initializeSpikePlots(); - //void repositionSpikePlots(); + //void computeColumnLayout(); + //void initializeSpikePlots(); + //void repositionSpikePlots(); - int numColumns; + int numColumns; - int totalHeight; + int totalHeight; - SpikeDisplayCanvas* canvas; - Viewport* viewport; + SpikeDisplayCanvas* canvas; + Viewport* viewport; - OwnedArray<SpikePlot> spikePlots; + OwnedArray<SpikePlot> spikePlots; - // float tetrodePlotMinWidth, stereotrodePlotMinWidth, singleElectrodePlotMinWidth; - // float tetrodePlotRatio, stereotrodePlotRatio, singleElectrodePlotRatio; + // float tetrodePlotMinWidth, stereotrodePlotMinWidth, singleElectrodePlotMinWidth; + // float tetrodePlotRatio, stereotrodePlotRatio, singleElectrodePlotRatio; }; @@ -156,56 +159,56 @@ private: class SpikePlot : public Component { public: - SpikePlot(SpikeDisplayCanvas*, int elecNum, int plotType); - virtual ~SpikePlot(); + SpikePlot(SpikeDisplayCanvas*, int elecNum, int plotType); + virtual ~SpikePlot(); - void paint(Graphics& g); - void resized(); + void paint(Graphics& g); + void resized(); - void select(); - void deselect(); + void select(); + void deselect(); - void processSpikeObject(const SpikeObject& s); + void processSpikeObject(const SpikeObject& s); - SpikeDisplayCanvas* canvas; + SpikeDisplayCanvas* canvas; - bool isSelected; + bool isSelected; - int electrodeNumber; + int electrodeNumber; - int nChannels; + int nChannels; - void initAxes(); - void getBestDimensions(int*, int*); + void initAxes(); + void getBestDimensions(int*, int*); - void clear(); - void zoom(int, bool); - void pan(int, bool); + void clear(); + void zoom(int, bool); + void pan(int, bool); - float minWidth; - float aspectRatio; + float minWidth; + float aspectRatio; private: - - int plotType; - int nWaveAx; - int nProjAx; - bool limitsChanged; + int plotType; + int nWaveAx; + int nProjAx; - double limits[MAX_N_CHAN][2]; + bool limitsChanged; - OwnedArray<ProjectionAxes> pAxes; - OwnedArray<WaveAxes> wAxes; + double limits[MAX_N_CHAN][2]; - void initLimits(); - void setLimitsOnAxes(); - void updateAxesPositions(); + OwnedArray<ProjectionAxes> pAxes; + OwnedArray<WaveAxes> wAxes; - void n2ProjIdx(int i, int* p1, int* p2); + void initLimits(); + void setLimitsOnAxes(); + void updateAxesPositions(); - Font font; + void n2ProjIdx(int i, int* p1, int* p2); + + Font font; }; @@ -241,7 +244,7 @@ public: void makeLabel(int val, int gain, bool convert, char* s); protected: - double xlims[2]; + double xlims[2]; double ylims[2]; SpikeObject s; @@ -267,24 +270,24 @@ protected: class WaveAxes : public GenericAxes { public: - WaveAxes(int channel); - ~WaveAxes() {} + WaveAxes(int channel); + ~WaveAxes() {} - void paint(Graphics& g); + void paint(Graphics& g); - void clear(); + void clear(); private: - Colour waveColour; - Colour thresholdColour; - Colour gridColour; + Colour waveColour; + Colour thresholdColour; + Colour gridColour; - bool drawGrid; + bool drawGrid; - void drawWaveformGrid(int threshold, int gain, Graphics& g); + void drawWaveformGrid(int threshold, int gain, Graphics& g); - Font font; + Font font; }; @@ -299,17 +302,17 @@ private: class ProjectionAxes : public GenericAxes { public: - ProjectionAxes(int projectionNum); - ~ProjectionAxes() {} + ProjectionAxes(int projectionNum); + ~ProjectionAxes() {} - void paint(Graphics& g); + void paint(Graphics& g); - void clear(); + void clear(); private: - Colour pointColour; - Colour gridColour; + Colour pointColour; + Colour gridColour; }; diff --git a/Source/UI/ControlPanel.cpp b/Source/UI/ControlPanel.cpp index af7589df1..5d7660e64 100755 --- a/Source/UI/ControlPanel.cpp +++ b/Source/UI/ControlPanel.cpp @@ -90,8 +90,8 @@ RecordButton::~RecordButton() CPUMeter::CPUMeter() : Label("CPU Meter","0.0"), cpu(0.0f), lastCpu(0.0f) { - - font = Font("Small Text", 12, Font::plain); + + font = Font("Small Text", 12, Font::plain); // MemoryInputStream mis(BinaryData::silkscreenserialized, BinaryData::silkscreenserializedSize, false); // Typeface::Ptr typeface = new CustomTypeface(mis); @@ -129,7 +129,7 @@ DiskSpaceMeter::DiskSpaceMeter() { - font = Font("Small Text", 12, Font::plain); + font = Font("Small Text", 12, Font::plain); // MemoryInputStream mis(BinaryData::silkscreenserialized, BinaryData::silkscreenserializedSize, false); // Typeface::Ptr typeface = new CustomTypeface(mis); @@ -167,7 +167,7 @@ void DiskSpaceMeter::paint(Graphics& g) Clock::Clock() : isRunning(false), isRecording(false) { - clockFont = Font("Default Light", 30, Font::plain); + clockFont = Font("Default Light", 30, Font::plain); // MemoryInputStream mis(BinaryData::cpmonolightserialized, BinaryData::cpmonolightserializedSize, false); // Typeface::Ptr typeface = new CustomTypeface(mis); @@ -348,7 +348,7 @@ ControlPanel::ControlPanel(ProcessorGraph* graph_, AudioComponent* audio_) if (1) { - font = Font("Paragraph", 13, Font::plain); + font = Font("Paragraph", 13, Font::plain); // MemoryInputStream mis(BinaryData::misoserialized, BinaryData::misoserializedSize, false); // Typeface::Ptr typeface = new CustomTypeface(mis); diff --git a/Source/UI/CustomLookAndFeel.cpp b/Source/UI/CustomLookAndFeel.cpp index 0990c9375..173a555cd 100755 --- a/Source/UI/CustomLookAndFeel.cpp +++ b/Source/UI/CustomLookAndFeel.cpp @@ -24,68 +24,69 @@ #include "CustomLookAndFeel.h" CustomLookAndFeel::CustomLookAndFeel() : - // third argument to MIS means don't copy the binary data to make a new stream - cpmonoExtraLightStream(BinaryData::cpmonoextralightserialized, - BinaryData::cpmonoextralightserializedSize, - false), - cpmonoLightStream(BinaryData::cpmonolightserialized, - BinaryData::cpmonolightserializedSize, - false), - cpmonoPlainStream(BinaryData::cpmonoplainserialized, - BinaryData::cpmonoplainserializedSize, - false), - cpmonoBoldStream(BinaryData::cpmonoboldserialized, - BinaryData::cpmonoboldserializedSize, - false), - cpmonoBlackStream(BinaryData::cpmonoblackserialized, - BinaryData::cpmonoblackserializedSize, - false), - misoRegularStream(BinaryData::misoserialized, - BinaryData::misoserializedSize, - false), - silkscreenStream(BinaryData::silkscreenserialized, - BinaryData::silkscreenserializedSize, - false), - // heap allocation is necessary here, because otherwise the typefaces are - // deleted too soon (there's a singleton typefacecache that holds references - // to them whenever they're used). - cpmonoExtraLight(new CustomTypeface(cpmonoExtraLightStream)), - cpmonoLight(new CustomTypeface(cpmonoLightStream)), - cpmonoPlain(new CustomTypeface(cpmonoPlainStream)), - cpmonoBold(new CustomTypeface(cpmonoBoldStream)), - cpmonoBlack(new CustomTypeface(cpmonoBlackStream)), - misoRegular(new CustomTypeface(misoRegularStream)), - silkscreen(new CustomTypeface(silkscreenStream)) + // third argument to MIS means don't copy the binary data to make a new stream + cpmonoExtraLightStream(BinaryData::cpmonoextralightserialized, + BinaryData::cpmonoextralightserializedSize, + false), + cpmonoLightStream(BinaryData::cpmonolightserialized, + BinaryData::cpmonolightserializedSize, + false), + cpmonoPlainStream(BinaryData::cpmonoplainserialized, + BinaryData::cpmonoplainserializedSize, + false), + cpmonoBoldStream(BinaryData::cpmonoboldserialized, + BinaryData::cpmonoboldserializedSize, + false), + cpmonoBlackStream(BinaryData::cpmonoblackserialized, + BinaryData::cpmonoblackserializedSize, + false), + misoRegularStream(BinaryData::misoserialized, + BinaryData::misoserializedSize, + false), + silkscreenStream(BinaryData::silkscreenserialized, + BinaryData::silkscreenserializedSize, + false), + // heap allocation is necessary here, because otherwise the typefaces are + // deleted too soon (there's a singleton typefacecache that holds references + // to them whenever they're used). + cpmonoExtraLight(new CustomTypeface(cpmonoExtraLightStream)), + cpmonoLight(new CustomTypeface(cpmonoLightStream)), + cpmonoPlain(new CustomTypeface(cpmonoPlainStream)), + cpmonoBold(new CustomTypeface(cpmonoBoldStream)), + cpmonoBlack(new CustomTypeface(cpmonoBlackStream)), + misoRegular(new CustomTypeface(misoRegularStream)), + silkscreen(new CustomTypeface(silkscreenStream)) { - // UNCOMMENT AFTER UPDATE - // typefaceMap.set(String("Default Extra Light"), cpmonoExtraLight); - // typefaceMap.set(String("Default Light"), cpmonoLight); - // typefaceMap.set(String("Default"), cpmonoPlain); - // typefaceMap.set(String("Default Bold"), cpmonoBold); - // typefaceMap.set(String("Default Black"), cpmonoBlack); - // typefaceMap.set(String("Paragraph"), misoRegular); - // typefaceMap.set(String("Silkscreen"), silkscreen); - - enum { - PROCESSOR_COLOR = 0x801, - FILTER_COLOR = 0x802, - SINK_COLOR = 0x803, - SOURCE_COLOR = 0x804, - UTILITY_COLOR = 0x805, - }; - - setColour(PROCESSOR_COLOR, Colour(59, 59, 59)); - setColour(FILTER_COLOR, Colour(255, 89, 0)); - setColour(SINK_COLOR, Colour(255, 149, 0)); - setColour(SOURCE_COLOR, Colour(255, 0, 0)); - setColour(UTILITY_COLOR, Colour(90, 80, 80)); - - setColour(PopupMenu::backgroundColourId, Colours::darkgrey); - setColour(PopupMenu::textColourId, Colours::white); - setColour(PopupMenu::highlightedBackgroundColourId, Colours::grey); - setColour(PopupMenu::highlightedTextColourId, Colours::yellow); + // UNCOMMENT AFTER UPDATE + // typefaceMap.set(String("Default Extra Light"), cpmonoExtraLight); + // typefaceMap.set(String("Default Light"), cpmonoLight); + // typefaceMap.set(String("Default"), cpmonoPlain); + // typefaceMap.set(String("Default Bold"), cpmonoBold); + // typefaceMap.set(String("Default Black"), cpmonoBlack); + // typefaceMap.set(String("Paragraph"), misoRegular); + // typefaceMap.set(String("Silkscreen"), silkscreen); + + enum + { + PROCESSOR_COLOR = 0x801, + FILTER_COLOR = 0x802, + SINK_COLOR = 0x803, + SOURCE_COLOR = 0x804, + UTILITY_COLOR = 0x805, + }; + + setColour(PROCESSOR_COLOR, Colour(59, 59, 59)); + setColour(FILTER_COLOR, Colour(255, 89, 0)); + setColour(SINK_COLOR, Colour(255, 149, 0)); + setColour(SOURCE_COLOR, Colour(255, 0, 0)); + setColour(UTILITY_COLOR, Colour(90, 80, 80)); + + setColour(PopupMenu::backgroundColourId, Colours::darkgrey); + setColour(PopupMenu::textColourId, Colours::white); + setColour(PopupMenu::highlightedBackgroundColourId, Colours::grey); + setColour(PopupMenu::highlightedTextColourId, Colours::yellow); } @@ -95,7 +96,7 @@ CustomLookAndFeel::~CustomLookAndFeel() {} // FONT/TYPEFACE METHODS : //============================================================================== -const Typeface::Ptr CustomLookAndFeel::getTypefaceForFont (const Font& font) +const Typeface::Ptr CustomLookAndFeel::getTypefaceForFont(const Font& font) { String typefaceName = font.getTypefaceName(); @@ -104,25 +105,32 @@ const Typeface::Ptr CustomLookAndFeel::getTypefaceForFont (const Font& font) if (typefaceName.equalsIgnoreCase("Default Extra Light")) { return cpmonoExtraLight; - } else if (typefaceName.equalsIgnoreCase("Default Light")) + } + else if (typefaceName.equalsIgnoreCase("Default Light")) { return cpmonoLight; - } else if (typefaceName.equalsIgnoreCase("Default")) + } + else if (typefaceName.equalsIgnoreCase("Default")) { return cpmonoPlain; - } else if (typefaceName.equalsIgnoreCase("Default Bold")) + } + else if (typefaceName.equalsIgnoreCase("Default Bold")) { return cpmonoBold; - } else if (typefaceName.equalsIgnoreCase("Default Black")) + } + else if (typefaceName.equalsIgnoreCase("Default Black")) { return cpmonoBlack; - } else if (typefaceName.equalsIgnoreCase("Paragraph")) + } + else if (typefaceName.equalsIgnoreCase("Paragraph")) { return misoRegular; - } else if (typefaceName.equalsIgnoreCase("Small Text")) + } + else if (typefaceName.equalsIgnoreCase("Small Text")) { return silkscreen; - } else // default + } + else // default { return LookAndFeel::getTypefaceForFont(font); } @@ -135,68 +143,68 @@ const Typeface::Ptr CustomLookAndFeel::getTypefaceForFont (const Font& font) } //================================================================== -// SCROLL BAR METHODS : +// SCROLL BAR METHODS : //================================================================== -void CustomLookAndFeel::drawScrollbarButton (Graphics& g, - ScrollBar& scrollbar, - int width, int height, - int buttonDirection, - bool isScrollBarVertical, - bool isMouseOverButton, - bool isButtonDown) +void CustomLookAndFeel::drawScrollbarButton(Graphics& g, + ScrollBar& scrollbar, + int width, int height, + int buttonDirection, + bool isScrollBarVertical, + bool isMouseOverButton, + bool isButtonDown) { - Path p; + Path p; - float w1 = 0.25f; - float w2 = 0.75f; + float w1 = 0.25f; + float w2 = 0.75f; if (buttonDirection == 0) - p.addTriangle (width * 0.5f, height * 0.2f, - width * w1, height * 0.7f, - width * w2, height * 0.7f); + p.addTriangle(width * 0.5f, height * 0.2f, + width * w1, height * 0.7f, + width * w2, height * 0.7f); else if (buttonDirection == 1) - p.addTriangle (width * 0.8f, height * 0.5f, - width * 0.3f, height * w1, - width * 0.3f, height * w2); + p.addTriangle(width * 0.8f, height * 0.5f, + width * 0.3f, height * w1, + width * 0.3f, height * w2); else if (buttonDirection == 2) - p.addTriangle (width * 0.5f, height * 0.8f, - width * w1, height * 0.3f, - width * w2, height * 0.3f); + p.addTriangle(width * 0.5f, height * 0.8f, + width * w1, height * 0.3f, + width * w2, height * 0.3f); else if (buttonDirection == 3) - p.addTriangle (width * 0.2f, height * 0.5f, - width * 0.7f, height * w1, - width * 0.7f, height * w2); + p.addTriangle(width * 0.2f, height * 0.5f, + width * 0.7f, height * w1, + width * 0.7f, height * w2); if (isButtonDown) - g.setColour (Colours::white); + g.setColour(Colours::white); else - g.setColour (Colours::darkgrey); + g.setColour(Colours::darkgrey); - g.fillPath (p); + g.fillPath(p); if (isMouseOverButton) - g.strokePath (p, PathStrokeType (1.0f)); - + g.strokePath(p, PathStrokeType(1.0f)); + } -void CustomLookAndFeel::drawScrollbar (Graphics& g, - ScrollBar& scrollbar, - int x, int y, - int width, int height, - bool isScrollbarVertical, - int thumbStartPosition, - int thumbSize, - bool isMouseOver, - bool isMouseDown) - - { +void CustomLookAndFeel::drawScrollbar(Graphics& g, + ScrollBar& scrollbar, + int x, int y, + int width, int height, + bool isScrollbarVertical, + int thumbStartPosition, + int thumbSize, + bool isMouseOver, + bool isMouseDown) + +{ Path thumbPath; - const float slotIndent = jmin (width, height) > 15 ? 1.0f : 0.0f; + const float slotIndent = jmin(width, height) > 15 ? 1.0f : 0.0f; const float thumbIndent = slotIndent + 4.0f; const float thumbIndentx2 = thumbIndent * 2.0f; @@ -204,49 +212,49 @@ void CustomLookAndFeel::drawScrollbar (Graphics& g, { if (thumbSize > 0) - thumbPath.addRoundedRectangle (x + thumbIndent, - thumbStartPosition + thumbIndent, - width - thumbIndentx2, - thumbSize - thumbIndentx2, - (width - thumbIndentx2) * 0.3f); + thumbPath.addRoundedRectangle(x + thumbIndent, + thumbStartPosition + thumbIndent, + width - thumbIndentx2, + thumbSize - thumbIndentx2, + (width - thumbIndentx2) * 0.3f); } else { - + if (thumbSize > 0) - thumbPath.addRoundedRectangle (thumbStartPosition + thumbIndent, - y + thumbIndent, - thumbSize - thumbIndentx2, - height - thumbIndentx2, - (height - thumbIndentx2) * 0.3f); + thumbPath.addRoundedRectangle(thumbStartPosition + thumbIndent, + y + thumbIndent, + thumbSize - thumbIndentx2, + height - thumbIndentx2, + (height - thumbIndentx2) * 0.3f); } - - g.setColour (Colours::darkgrey); - g.fillPath (thumbPath); - } + g.setColour(Colours::darkgrey); + g.fillPath(thumbPath); + +} //================================================================== -// SLIDER METHODS : +// SLIDER METHODS : //================================================================== -void CustomLookAndFeel::drawLinearSliderThumb (Graphics& g, - int x, int y, - int width, int height, - float sliderPos, - float minSliderPos, - float maxSliderPos, - const Slider::SliderStyle style, - Slider& slider) +void CustomLookAndFeel::drawLinearSliderThumb(Graphics& g, + int x, int y, + int width, int height, + float sliderPos, + float minSliderPos, + float maxSliderPos, + const Slider::SliderStyle style, + Slider& slider) { - const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2); + const float sliderRadius = (float)(getSliderThumbRadius(slider) - 2); - Colour knobColour (Colours::darkgrey);//LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId), - // slider.hasKeyboardFocus (false) && slider.isEnabled(), - // slider.isMouseOverOrDragging() && slider.isEnabled(), - // slider.isMouseButtonDown() && slider.isEnabled())); + Colour knobColour(Colours::darkgrey); //LookAndFeelHelpers::createBaseColour (slider.findColour (Slider::thumbColourId), + // slider.hasKeyboardFocus (false) && slider.isEnabled(), + // slider.isMouseOverOrDragging() && slider.isEnabled(), + // slider.isMouseButtonDown() && slider.isEnabled())); const float outlineThickness = slider.isEnabled() ? 2.0f : 0.5f; @@ -265,209 +273,209 @@ void CustomLookAndFeel::drawLinearSliderThumb (Graphics& g, ky = y + height * 0.5f; } - drawSliderKnob (g, - kx - sliderRadius, - ky - sliderRadius, - sliderRadius * 2.0f, - knobColour, outlineThickness); + drawSliderKnob(g, + kx - sliderRadius, + ky - sliderRadius, + sliderRadius * 2.0f, + knobColour, outlineThickness); } else { if (style == Slider::ThreeValueVertical) { - drawSliderKnob (g, x + width * 0.5f - sliderRadius, - sliderPos - sliderRadius, - sliderRadius * 2.0f, - knobColour, outlineThickness); + drawSliderKnob(g, x + width * 0.5f - sliderRadius, + sliderPos - sliderRadius, + sliderRadius * 2.0f, + knobColour, outlineThickness); } else if (style == Slider::ThreeValueHorizontal) { - drawSliderKnob (g,sliderPos - sliderRadius, - y + height * 0.5f - sliderRadius, - sliderRadius * 2.0f, - knobColour, outlineThickness); + drawSliderKnob(g,sliderPos - sliderRadius, + y + height * 0.5f - sliderRadius, + sliderRadius * 2.0f, + knobColour, outlineThickness); } if (style == Slider::TwoValueVertical || style == Slider::ThreeValueVertical) { - const float sr = jmin (sliderRadius, width * 0.4f); + const float sr = jmin(sliderRadius, width * 0.4f); - drawGlassPointer (g, jmax (0.0f, x + width * 0.5f - sliderRadius * 2.0f), - minSliderPos - sliderRadius, - sliderRadius * 2.0f, knobColour, outlineThickness, 1); + drawGlassPointer(g, jmax(0.0f, x + width * 0.5f - sliderRadius * 2.0f), + minSliderPos - sliderRadius, + sliderRadius * 2.0f, knobColour, outlineThickness, 1); - drawGlassPointer (g, jmin (x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr, - sliderRadius * 2.0f, knobColour, outlineThickness, 3); + drawGlassPointer(g, jmin(x + width - sliderRadius * 2.0f, x + width * 0.5f), maxSliderPos - sr, + sliderRadius * 2.0f, knobColour, outlineThickness, 3); } else if (style == Slider::TwoValueHorizontal || style == Slider::ThreeValueHorizontal) { - const float sr = jmin (sliderRadius, height * 0.4f); + const float sr = jmin(sliderRadius, height * 0.4f); - drawGlassPointer (g, minSliderPos - sr, - jmax (0.0f, y + height * 0.5f - sliderRadius * 2.0f), - sliderRadius * 2.0f, knobColour, outlineThickness, 2); + drawGlassPointer(g, minSliderPos - sr, + jmax(0.0f, y + height * 0.5f - sliderRadius * 2.0f), + sliderRadius * 2.0f, knobColour, outlineThickness, 2); - drawGlassPointer (g, maxSliderPos - sliderRadius, - jmin (y + height - sliderRadius * 2.0f, y + height * 0.5f), - sliderRadius * 2.0f, knobColour, outlineThickness, 4); + drawGlassPointer(g, maxSliderPos - sliderRadius, + jmin(y + height - sliderRadius * 2.0f, y + height * 0.5f), + sliderRadius * 2.0f, knobColour, outlineThickness, 4); } } } -void CustomLookAndFeel::drawLinearSliderBackground (Graphics& g, - int x, int y, - int width, int height, - float sliderPos, - float minSliderPos, - float maxSliderPos, - const Slider::SliderStyle /*style*/, - Slider& slider) +void CustomLookAndFeel::drawLinearSliderBackground(Graphics& g, + int x, int y, + int width, int height, + float sliderPos, + float minSliderPos, + float maxSliderPos, + const Slider::SliderStyle /*style*/, + Slider& slider) { - const float sliderRadius = (float) (getSliderThumbRadius (slider) - 2); + const float sliderRadius = (float)(getSliderThumbRadius(slider) - 2); Path indent; - // Path backgroundPath; + // Path backgroundPath; if (slider.isHorizontal()) { const float iy = y + height * 0.5f - sliderRadius * 0.5f; const float ih = sliderRadius; - indent.addRoundedRectangle (x - sliderRadius * 0.5f, iy, - width + sliderRadius, ih, - 5.0f); + indent.addRoundedRectangle(x - sliderRadius * 0.5f, iy, + width + sliderRadius, ih, + 5.0f); - // backgroundPath.addRoundedRectangle (x - sliderRadius * 0.5f, iy, - // (width + sliderRadius)*minSliderPos, ih, - // 5.0f); + // backgroundPath.addRoundedRectangle (x - sliderRadius * 0.5f, iy, + // (width + sliderRadius)*minSliderPos, ih, + // 5.0f); - // g.setColour(Colours::orange); - // g.fillPath (backgroundPath); + // g.setColour(Colours::orange); + // g.fillPath (backgroundPath); } else { const float ix = x + width * 0.5f - sliderRadius * 0.5f; const float iw = sliderRadius; - indent.addRoundedRectangle (ix, y - sliderRadius * 0.5f, - iw, height + sliderRadius, - 5.0f); + indent.addRoundedRectangle(ix, y - sliderRadius * 0.5f, + iw, height + sliderRadius, + 5.0f); - // backgroundPath.addRoundedRectangle (ix, y - sliderRadius * 0.5f, - // iw, (height + sliderRadius)*sliderPos, - // 5.0f); + // backgroundPath.addRoundedRectangle (ix, y - sliderRadius * 0.5f, + // iw, (height + sliderRadius)*sliderPos, + // 5.0f); - // g.setColour(Colours::orange); - // g.fillPath (backgroundPath); + // g.setColour(Colours::orange); + // g.fillPath (backgroundPath); //g.fillPath (indent); } - g.setColour (Colours::darkgrey); - g.strokePath (indent, PathStrokeType (0.5f)); + g.setColour(Colours::darkgrey); + g.strokePath(indent, PathStrokeType(0.5f)); } -int CustomLookAndFeel::getSliderThumbRadius (Slider& slider) +int CustomLookAndFeel::getSliderThumbRadius(Slider& slider) { - return jmin (7, - slider.getHeight() / 2, - slider.getWidth() / 2) + 2; + return jmin(7, + slider.getHeight() / 2, + slider.getWidth() / 2) + 2; } -void CustomLookAndFeel::drawSliderKnob (Graphics& g, - const float x, const float y, - const float diameter, - const Colour& colour, - const float outlineThickness) throw() +void CustomLookAndFeel::drawSliderKnob(Graphics& g, + const float x, const float y, + const float diameter, + const Colour& colour, + const float outlineThickness) throw() { if (diameter <= outlineThickness) return; g.setColour(Colours::darkgrey); - - g.fillEllipse (x, y, diameter, diameter); - g.setColour(Colours::black); - g.drawEllipse (x, y, diameter, diameter, outlineThickness); + g.fillEllipse(x, y, diameter, diameter); + + g.setColour(Colours::black); + g.drawEllipse(x, y, diameter, diameter, outlineThickness); } -void CustomLookAndFeel::drawGlassPointer (Graphics& g, - const float x, const float y, - const float diameter, - const Colour& colour, const float outlineThickness, - const int direction) throw() +void CustomLookAndFeel::drawGlassPointer(Graphics& g, + const float x, const float y, + const float diameter, + const Colour& colour, const float outlineThickness, + const int direction) throw() { if (diameter <= outlineThickness) return; Path p; - p.startNewSubPath (x + diameter * 0.5f, y); - p.lineTo (x + diameter, y + diameter * 0.6f); - p.lineTo (x + diameter, y + diameter); - p.lineTo (x, y + diameter); - p.lineTo (x, y + diameter * 0.6f); + p.startNewSubPath(x + diameter * 0.5f, y); + p.lineTo(x + diameter, y + diameter * 0.6f); + p.lineTo(x + diameter, y + diameter); + p.lineTo(x, y + diameter); + p.lineTo(x, y + diameter * 0.6f); p.closeSubPath(); - p.applyTransform (AffineTransform::rotation (direction * (float_Pi * 0.5f), x + diameter * 0.5f, y + diameter * 0.5f)); + p.applyTransform(AffineTransform::rotation(direction * (float_Pi * 0.5f), x + diameter * 0.5f, y + diameter * 0.5f)); { - ColourGradient cg (Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y, - Colours::white.overlaidWith (colour.withMultipliedAlpha (0.3f)), 0, y + diameter, false); + ColourGradient cg(Colours::white.overlaidWith(colour.withMultipliedAlpha(0.3f)), 0, y, + Colours::white.overlaidWith(colour.withMultipliedAlpha(0.3f)), 0, y + diameter, false); - cg.addColour (0.4, Colours::white.overlaidWith (colour)); + cg.addColour(0.4, Colours::white.overlaidWith(colour)); - g.setGradientFill (cg); - g.fillPath (p); + g.setGradientFill(cg); + g.fillPath(p); } - ColourGradient cg (Colours::transparentBlack, - x + diameter * 0.5f, y + diameter * 0.5f, - Colours::black.withAlpha (0.5f * outlineThickness * colour.getFloatAlpha()), - x - diameter * 0.2f, y + diameter * 0.5f, true); + ColourGradient cg(Colours::transparentBlack, + x + diameter * 0.5f, y + diameter * 0.5f, + Colours::black.withAlpha(0.5f * outlineThickness * colour.getFloatAlpha()), + x - diameter * 0.2f, y + diameter * 0.5f, true); - cg.addColour (0.5, Colours::transparentBlack); - cg.addColour (0.7, Colours::black.withAlpha (0.07f * outlineThickness)); + cg.addColour(0.5, Colours::transparentBlack); + cg.addColour(0.7, Colours::black.withAlpha(0.07f * outlineThickness)); - g.setGradientFill (cg); - g.fillPath (p); + g.setGradientFill(cg); + g.fillPath(p); - g.setColour (Colours::black.withAlpha (0.5f * colour.getFloatAlpha())); - g.strokePath (p, PathStrokeType (outlineThickness)); + g.setColour(Colours::black.withAlpha(0.5f * colour.getFloatAlpha())); + g.strokePath(p, PathStrokeType(outlineThickness)); } /// ------ combo box ---------------/// -void CustomLookAndFeel::drawComboBox (Graphics& g, int width, int height, - const bool isButtonDown, - int buttonX, int buttonY, - int buttonW, int buttonH, - ComboBox& box) +void CustomLookAndFeel::drawComboBox(Graphics& g, int width, int height, + const bool isButtonDown, + int buttonX, int buttonY, + int buttonW, int buttonH, + ComboBox& box) { - g.fillAll (Colours::lightgrey);//box.findColour (ComboBox::backgroundColourId)); + g.fillAll(Colours::lightgrey); //box.findColour (ComboBox::backgroundColourId)); - if (box.isEnabled() && box.hasKeyboardFocus (false)) + if (box.isEnabled() && box.hasKeyboardFocus(false)) { - g.setColour (Colours::lightgrey);//box.findColour (TextButton::buttonColourId)); - g.drawRect (0, 0, width, height, 2); + g.setColour(Colours::lightgrey); //box.findColour (TextButton::buttonColourId)); + g.drawRect(0, 0, width, height, 2); } else { - g.setColour (box.findColour (ComboBox::outlineColourId)); - g.drawRect (0, 0, width, height); + g.setColour(box.findColour(ComboBox::outlineColourId)); + g.drawRect(0, 0, width, height); } const float outlineThickness = box.isEnabled() ? (isButtonDown ? 1.2f : 0.5f) : 0.3f; - const Colour baseColour (Colours::orange);/*LookAndFeelHelpers::createBaseColour (box.findColour (ComboBox::buttonColourId), + const Colour baseColour(Colours::orange);/*LookAndFeelHelpers::createBaseColour (box.findColour (ComboBox::buttonColourId), box.hasKeyboardFocus (true), false, isButtonDown) .withMultipliedAlpha (box.isEnabled() ? 1.0f : 0.5f));*/ - drawGlassLozenge (g, - buttonX + outlineThickness, buttonY + outlineThickness, - buttonW - outlineThickness * 2.0f, buttonH - outlineThickness * 2.0f, - baseColour, outlineThickness, -1.0f, - true, true, true, true); + drawGlassLozenge(g, + buttonX + outlineThickness, buttonY + outlineThickness, + buttonW - outlineThickness * 2.0f, buttonH - outlineThickness * 2.0f, + baseColour, outlineThickness, -1.0f, + true, true, true, true); if (box.isEnabled()) { @@ -475,16 +483,16 @@ void CustomLookAndFeel::drawComboBox (Graphics& g, int width, int height, const float arrowH = 0.2f; Path p; - p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH), - buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f, - buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f); + p.addTriangle(buttonX + buttonW * 0.5f, buttonY + buttonH * (0.45f - arrowH), + buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.45f, + buttonX + buttonW * arrowX, buttonY + buttonH * 0.45f); - p.addTriangle (buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH), - buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f, - buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f); + p.addTriangle(buttonX + buttonW * 0.5f, buttonY + buttonH * (0.55f + arrowH), + buttonX + buttonW * (1.0f - arrowX), buttonY + buttonH * 0.55f, + buttonX + buttonW * arrowX, buttonY + buttonH * 0.55f); - g.setColour (box.findColour (ComboBox::arrowColourId)); - g.fillPath (p); + g.setColour(box.findColour(ComboBox::arrowColourId)); + g.fillPath(p); } diff --git a/Source/UI/InfoLabel.cpp b/Source/UI/InfoLabel.cpp index ca2935589..86798c9c2 100755 --- a/Source/UI/InfoLabel.cpp +++ b/Source/UI/InfoLabel.cpp @@ -26,7 +26,7 @@ InfoLabel::InfoLabel() { - labelFont = Font("Paragraph", 24, Font::plain); + labelFont = Font("Paragraph", 24, Font::plain); // MemoryInputStream mis(BinaryData::misoserialized, // BinaryData::misoserializedSize, diff --git a/Source/UI/ProcessorList.cpp b/Source/UI/ProcessorList.cpp index 404ffdc09..2c569cea1 100755 --- a/Source/UI/ProcessorList.cpp +++ b/Source/UI/ProcessorList.cpp @@ -41,8 +41,8 @@ ProcessorList::ProcessorList() xBuffer(1), yBuffer(1) { - listFontLight = Font("Default Light", 25, Font::plain); - listFontPlain = Font("Default", 20, Font::plain); + listFontLight = Font("Default Light", 25, Font::plain); + listFontPlain = Font("Default", 20, Font::plain); // MemoryInputStream mis1(BinaryData::cpmonolightserialized, // BinaryData::cpmonolightserializedSize, -- GitLab