Skip to content
Snippets Groups Projects
Commit 8dff84b6 authored by Stuart Layton's avatar Stuart Layton
Browse files

moved around the SpikeDisplayEditor GUI elements a bit, removed the Save...

moved around the SpikeDisplayEditor GUI elements a bit, removed the Save button and added selector buttons for each subchannel.
parent 329248b9
Branches
Tags
No related merge requests found
#include "SpikeDisplayEditor.h"
#include <string>
SpikeDisplayEditor::SpikeDisplayEditor (GenericProcessor* parentNode)
: VisualizerEditor(parentNode)
: VisualizerEditor(parentNode,200)
{
// Get the number of sub channels from the parentNode
// Assume all plots have the same number of subChannels
// Otherwise we'll have to track the number of subChannels
nSubChannels = 4;
desiredWidth = 250;
for (int i=0; i<nSubChannels; i++)
subChanSelected[i] = false;
initializeButtons();
}
SpikeDisplayEditor::~SpikeDisplayEditor()
{
deleteAllChildren();
}
void SpikeDisplayEditor::initializeButtons(){
int w = 18;
int h = 18;
int xPad = 5;
int yPad = 6;
int xInitial = 10;
int yInitial = 30;
int yInitial = 25;
int x = xInitial;
int y = yInitial;
panLabel = new Label("PanLabel", "Pan:");
panLabel->setBounds(x-xPad, y, w*2 + xPad, h);
panLabel->setJustificationType(Justification::centredLeft );
x+= 2*w+3*xPad;
zoomLabel = new Label("ZoomLabel", "Zoom:");
zoomLabel->setBounds(x-xPad,y,w*3+xPad, h);
zoomLabel->setJustificationType(Justification::centredLeft);
x = xInitial;
y += h + yPad/2;
panUpBtn = new ChannelSelectorButton("+", titleFont);
panUpBtn->setBounds(x, y, w, h);
panUpBtn->setClickingTogglesState(false);
......@@ -28,13 +56,7 @@ SpikeDisplayEditor::SpikeDisplayEditor (GenericProcessor* parentNode)
panDownBtn->setBounds(x, y, w, h);
panDownBtn->setClickingTogglesState(false);
panDownBtn->addListener(this);
x+= w+xPad;
panLabel = new Label("PanLabel", "Pan");
panLabel->setBounds(x, y, w*4, h);
//panLabel->setFont(titleFont);
x = xInitial;
y += h + yPad;
x+= w+xPad*2;
zoomInBtn = new ChannelSelectorButton("+", titleFont);
zoomInBtn->setBounds(x,y,w,h);
......@@ -46,66 +68,80 @@ SpikeDisplayEditor::SpikeDisplayEditor (GenericProcessor* parentNode)
zoomOutBtn->setBounds(x,y,w,h);
zoomOutBtn->setClickingTogglesState(false);
zoomOutBtn->addListener(this);
x += w + xPad;
x += w + xPad*3;
zoomLabel = new Label("ZoomLabel", "Zoom");
zoomLabel->setBounds(x,y,w*4, h);
//zoomLabel->setFont(titleFont);
x = xInitial;
y += h + yPad;
// Button *zoomOutBtn = new EditorButton("-");
clearBtn = new ChannelSelectorButton("Clear", titleFont);
clearBtn->setBounds(x, y, w*2 + xPad, h);
clearBtn->setClickingTogglesState(false);
clearBtn->addListener(this);
x += (w + xPad) *2;
/*
x = xInitial;
y += h + yPad;
//panLabel->setFont(titleFont);
saveImgBtn = new ChannelSelectorButton("Save", titleFont);
saveImgBtn->setBounds(x,y,w*2 + xPad, h);
saveImgBtn->setClickingTogglesState(false);
saveImgBtn->addListener(this);
x += (w + xPad) * 2;
*/
addAndMakeVisible(panUpBtn);
addAndMakeVisible(panDownBtn);
addAndMakeVisible(panLabel);
//zoomLabel->setFont(titleFont);
x = xInitial;
y += h + yPad;
// Button *zoomOutBtn = new EditorButton("-");
addAndMakeVisible(zoomInBtn);
addAndMakeVisible(zoomOutBtn);
addAndMakeVisible(zoomLabel);
addAndMakeVisible(clearBtn);
addAndMakeVisible(saveImgBtn);
subChanLabel = new Label("SubChan", "Sub Channel:");
subChanLabel->setBounds(x - xPad,y,w*8, h);
subChanLabel->setJustificationType(Justification::centredLeft);
y += h + yPad/2;
//x += w/2;
allSubChansBtn = new ChannelSelectorButton("All", titleFont);
allSubChansBtn->setBounds(x,y,w*2+xPad,h);
allSubChansBtn->addListener(this);
x += (w+xPad) * 2;
for (int i=0; i<nSubChannels; i++)
{
String s = "";
s += i;
subChanBtn[i] = new ChannelSelectorButton(s, titleFont);
subChanBtn[i]->setBounds(x,y,w,h);
subChanBtn[i]->addListener(this);
x += w + xPad;
/*
StringArray timeBaseValues;
timeBaseValues.add("100");
timeBaseValues.add("200");
timeBaseValues.add("500");
timeBaseValues.add("1000");
createRadioButtons(35, 50, 160, timeBaseValues, "Thresholds (s)");
}
StringArray displayGainValues;
displayGainValues.add("100");
displayGainValues.add("200");
displayGainValues.add("400");
displayGainValues.add("800");
createRadioButtons(35, 90, 160, displayGainValues, "Display Gain");
*/
addAndMakeVisible(panUpBtn);
addAndMakeVisible(panDownBtn);
addAndMakeVisible(panLabel);
}
addAndMakeVisible(zoomInBtn);
addAndMakeVisible(zoomOutBtn);
addAndMakeVisible(zoomLabel);
addAndMakeVisible(clearBtn);
//addAndMakeVisible(saveImgBtn);
SpikeDisplayEditor::~SpikeDisplayEditor()
{
deleteAllChildren();
}
addAndMakeVisible(subChanLabel);
addAndMakeVisible(allSubChansBtn);
for (int i=0; i<nSubChannels; i++)
addAndMakeVisible(subChanBtn[i]);
}
Visualizer* SpikeDisplayEditor::createNewCanvas()
{
......@@ -117,19 +153,53 @@ Visualizer* SpikeDisplayEditor::createNewCanvas()
void SpikeDisplayEditor::buttonCallback(Button* button)
{
std::cout<<"Got event from component:"<<button<<std::endl;
//std::cout<<"Got event from component:"<<button<<std::endl;
if (button == panUpBtn)
std::cout<<"Pan Up"<<std::endl;
else if (button == panDownBtn)
std::cout<<"Pan Down"<<std::endl;
else if (button == zoomInBtn)
std::cout<<"Zoom In"<<std::endl;
{
for (int i=0; i<nSubChannels; i++)
if (subChanSelected[i])
std::cout<<"Pan Up Chan:"<<i<<std::endl;
}
else if (button == panDownBtn){
for (int i=0; i<nSubChannels; i++)
if (subChanSelected[i])
std::cout<<"Pan Down Chan:"<<i<<std::endl;
}
else if (button == zoomInBtn){
for (int i=0; i<nSubChannels; i++)
if (subChanSelected[i])
std::cout<<"Zooming In Chan:"<<i<<std::endl;
}
else if (button == zoomOutBtn)
std::cout<<"Zoom Out"<<std::endl;
{
for (int i=0; i<nSubChannels; i++)
if (subChanSelected[i])
std::cout<<"Zooming Out Chan:"<<i<<std::endl;
}
else if (button == clearBtn){
std::cout<<"Clear!"<<std::endl;
canvas->setParameter(SPIKE_CMD_CLEAR_ALL, 0);
}
else if (button == saveImgBtn)
std::cout<<"Save!"<<std::endl;
// toggle all sub channel buttons
else if (button == allSubChansBtn)
{
bool b = allSubChansBtn->getToggleState();
for (int i=0; i<nSubChannels; i++)
subChanBtn[i]->setToggleState(b, true);
}
// Check the sub Channel selection buttons one by one
else{
for (int i=0; i<nSubChannels; i++)
if(button == subChanBtn[i])
{
std::cout<<"SubChannel:"<<i<< " set to:";
subChanSelected[i] = ((ChannelSelectorButton*) button)->getToggleState();
std::cout<< subChanSelected[i]<<std::endl;
}
}
}
......@@ -33,6 +33,7 @@
#include "../Visualization/SpikeDisplayCanvas.h"
#include "VisualizerEditor.h"
#define MAX_N_SUB_CHAN 8
class Visualizer;
class SpikeDisplayEditor : public VisualizerEditor
......@@ -57,6 +58,15 @@ private:
Label *panLabel;
Label *zoomLabel;
Button *allSubChansBtn;
int nSubChannels;
Label *subChanLabel;
Button *subChanBtn[MAX_N_SUB_CHAN];
bool subChanSelected[MAX_N_SUB_CHAN];
void initializeButtons();
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (SpikeDisplayEditor);
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment