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

modified the SpikeDisplayEditor and SpikeDisplayCanvas objects to make use of...

modified the SpikeDisplayEditor and SpikeDisplayCanvas objects to make use of the new setParameter(int,int,int,float) method defined in the Visualizer class. Additionally the SpikeDisplayEditor now responds to Pan/Zoom and clear commands. However Pan/Zoom only work on the first plot. Additionally on the "all" button for the  sub-channel selector buttons now responds intelligently. ie. if you enable all it turns on, if you disable one it turns off.
parent 6c196463
Branches
Tags
No related merge requests found
......@@ -13,7 +13,7 @@ SpikeDisplayEditor::SpikeDisplayEditor (GenericProcessor* parentNode)
nSubChannels = 4;
for (int i=0; i<nSubChannels; i++)
subChanSelected[i] = false;
subChanSelected[i] = true;
initializeButtons();
......@@ -109,6 +109,7 @@ void SpikeDisplayEditor::initializeButtons(){
allSubChansBtn = new ChannelSelectorButton("All", titleFont);
allSubChansBtn->setBounds(x,y,w*2+xPad,h);
allSubChansBtn->addListener(this);
allSubChansBtn->setToggleState(true, false);
x += (w+xPad) * 2;
for (int i=0; i<nSubChannels; i++)
......@@ -119,12 +120,12 @@ void SpikeDisplayEditor::initializeButtons(){
subChanBtn[i] = new ChannelSelectorButton(s, titleFont);
subChanBtn[i]->setBounds(x,y,w,h);
subChanBtn[i]->addListener(this);
subChanBtn[i]->setToggleState(true, false);
x += w + xPad;
}
addAndMakeVisible(panUpBtn);
addAndMakeVisible(panDownBtn);
addAndMakeVisible(panLabel);
......@@ -154,29 +155,28 @@ Visualizer* SpikeDisplayEditor::createNewCanvas()
void SpikeDisplayEditor::buttonCallback(Button* button)
{
//std::cout<<"Got event from component:"<<button<<std::endl;
if (button == panUpBtn)
{
std::cout<<"Pan UP!"<<std::endl;
int pIdx = 0;
if (button == panUpBtn){
for (int i=0; i<nSubChannels; i++)
if (subChanSelected[i]){
std::cout<<"Pan Up Chan:"<<i<<std::endl;
}
if (subChanSelected[i])
canvas->setParameter(SPIKE_CMD_PAN_AXES, pIdx, i, 1);
}
else if (button == panDownBtn){
for (int i=0; i<nSubChannels; i++)
if (subChanSelected[i])
std::cout<<"Pan Down Chan:"<<i<<std::endl;
if (subChanSelected[i])
canvas->setParameter(SPIKE_CMD_PAN_AXES, pIdx, i, -1);
}
else if (button == zoomInBtn){
for (int i=0; i<nSubChannels; i++)
if (subChanSelected[i])
std::cout<<"Zooming In Chan:"<<i<<std::endl;
canvas->setParameter(SPIKE_CMD_ZOOM_AXES, pIdx, i, -1);
}
else if (button == zoomOutBtn)
{
for (int i=0; i<nSubChannels; i++)
if (subChanSelected[i])
std::cout<<"Zooming Out Chan:"<<i<<std::endl;
canvas->setParameter(SPIKE_CMD_ZOOM_AXES, pIdx, i, 1);
}
else if (button == clearBtn){
......@@ -196,6 +196,8 @@ void SpikeDisplayEditor::buttonCallback(Button* button)
}
// Check the sub Channel selection buttons one by one
else{
// If the user has clicked a sub channel button then the all channels button should be untoggled if toggled
allSubChansBtn->setToggleState(false, false);
for (int i=0; i<nSubChannels; i++)
if(button == subChanBtn[i])
{
......@@ -203,5 +205,17 @@ void SpikeDisplayEditor::buttonCallback(Button* button)
subChanSelected[i] = ((ChannelSelectorButton*) button)->getToggleState();
std::cout<< subChanSelected[i]<<std::endl;
}
// If the user has toggled all of the sub channels on, then set AllChans to on
bool allChansToggled = true;
for (int i=0; i<nSubChannels; i++)
{
if (subChanBtn[i]->getToggleState()!=allChansToggled){
allChansToggled = false;
break;
}
}
allSubChansBtn->setToggleState(allChansToggled, false);
}
}
......@@ -165,9 +165,12 @@ void SpikeDisplayCanvas::update()
}
// Used for Plot specific commands, this commands target a specific PLOT and have
// no additional information, IE PARAM-> CLEAR val->plot6
// for more complex messages use the other version of setParameter
void SpikeDisplayCanvas::setParameter(int param, float val)
{
//std::cout<<"Got Param:"<< param<< " with value:"<<val<<std::endl;
std::cout<<"Got Param:"<< param<< " with value:"<<val<<std::endl;
switch (param)
{
case SPIKE_CMD_CLEAR_ALL :
......@@ -181,9 +184,21 @@ void SpikeDisplayCanvas::setParameter(int param, float val)
default:
std::cout<<"Unkown Commad specified! "<<param<<std::endl;
}
}
void SpikeDisplayCanvas::setParameter(int param, int p2, int p3, float value){
std::cout<<"Got Parameter:"<<param<<" p2:"<<p2<<" p3:"<<p3<<" value:"<<value<<std::endl;
switch (param){
case SPIKE_CMD_PAN_AXES:
panPlot(p2, p3, value<=0);
break;
case SPIKE_CMD_ZOOM_AXES:
zoomPlot(p2, p3, value<=0);
break;
}
}
void SpikeDisplayCanvas::refreshState()
{
// called when the component's tab becomes visible again
......@@ -278,19 +293,19 @@ void SpikeDisplayCanvas::mouseDownInCanvas(const MouseEvent& e)
// void SpikeDisplayCanvas::mouseDrag(const MouseEvent& e) {mouseDragInCanvas(e);}
// void SpikeDisplayCanvas::mouseMove(const MouseEvent& e) {mouseMoveInCanvas(e);}
void SpikeDisplayCanvas::mouseUp(const MouseEvent& e) {
std::cout<<"Mouse Event!"<<std::endl;
// std::cout<<"Mouse Event!"<<std::endl;
bool inout = false;
// bool inout = false;
if (e.getMouseDownX() < getWidth()/2)
inout = false;
else
inout = true;
// if (e.getMouseDownX() < getWidth()/2)
// inout = false;
// else
// inout = true;
if (e.getMouseDownY() < getHeight()/2)
zoomPlot(0,0, inout);
else
panPlot(0,0,inout);
// if (e.getMouseDownY() < getHeight()/2)
// zoomPlot(0,0, inout);
// else
// panPlot(0,0,inout);
}
void SpikeDisplayCanvas::mouseWheelMove(const MouseEvent& e, float wheelIncrementX, float wheelIncrementY) {
......
......@@ -55,6 +55,7 @@ public:
void update();
void setParameter(int, float);
void setParameter(int, int, int, float);
void panPlot(int, int, bool);
void zoomPlot(int, int, bool);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment