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

removed old plotting files (Tetrode, Stereotrode, Electrode) plots. They have...

removed old plotting files (Tetrode, Stereotrode, Electrode) plots. They have all be replaced with SpikePlot.{h,cpp}
parent b443724a
No related branches found
No related tags found
No related merge requests found
#include "ElectrodePlot.h"
#include "../SpikeObject.h"
#include "PlotUtils.h"
ElectrodePlot::ElectrodePlot():
BaseUIElement(), limitsChanged(true)
{
}
ElectrodePlot::ElectrodePlot(int x, int y, int w, int h):
BaseUIElement(x,y,w,h,1), limitsChanged(true)
{
initAxes();
}
ElectrodePlot::~ElectrodePlot(){
}
// Each plot needs to update its children axes when its redraw gets called.
// it also needs to call the parent plot when children axes get added it
// should place them in the correct location because it KNOWS where WAVE1 and PROJ1x3
// should go by default. This isn't as general as it should be but its a good push in
// the right direction
void ElectrodePlot::redraw(){
//std::cout<<"ElectrodePlot() starting drawing"<<std::endl;\
BaseUIElement::clearNextDraw = true;
BaseUIElement::redraw();
axes.redraw();
}
// This would normally happen for collection of axes but an electrode plot doesn't have a collection instead its a single axes
void ElectrodePlot::processSpikeObject(SpikeObject s){
//std::cout<<"ElectrdePlot::processSpikeObject()"<<std::endl;
axes.updateSpikeData(s);
}
void ElectrodePlot::setEnabled(bool e){
BaseUIElement::enabled = e;
axes.setEnabled(e);
}
bool ElectrodePlot::getEnabled(){
return BaseUIElement::enabled;
}
void ElectrodePlot::initAxes(){
initLimits();
int minX = BaseUIElement::xpos;
int minY = BaseUIElement::ypos;
double axesWidth = BaseUIElement::width;
double axesHeight = BaseUIElement::height;
axes = WaveAxes(minX, minY, axesWidth, axesHeight, WAVE1);
//axes.setEnabled(false);
axes.setYLims(-1*pow(2,11), pow(2,14)*1.6);
axes.setWaveformColor(1.0, 1.0, 1.0);
}
void ElectrodePlot::setPosition(int x, int y, double w, double h){
BaseUIElement::setPosition(x,y,w,h);
int minX = BaseUIElement::xpos;
int minY = BaseUIElement::ypos;
double axesWidth = BaseUIElement::width;
double axesHeight = BaseUIElement::height;
axes.setPosition(minX, minY, axesWidth, axesHeight);
}
int ElectrodePlot::getNumberOfAxes(){
return 1;;
}
void ElectrodePlot::initLimits(){
for (int i=0; i<4; i++)
{
limits[i][0] = -1*pow(2,11);
limits[i][1] = pow(2,14);
}
}
void ElectrodePlot::getPreferredDimensions(double *w, double *h){
*w = 75;
*h = 75;
}
// void ElectrodePlot::mouseDown(int x, int y){
// // selectedAxesN = -1;
// // std::list<GenericAxes>::iterator i;
// // int idx=-1;
// // bool hit = false;
// // selectedAxes = NULL;
// // for (i=axesList.begin(); i!=axesList.end(); ++i)
// // {
// // if (i->hitTest(x,y))
// // {
// // selectedAxes = addressof(*i);
// // selectedAxesN = i->getType();
// // hit = true;
// // // break;
// // }
// // idx++;
// // }
// // if (!hit)
// // selectedAxes = NULL;
// // if (selectedAxes != NULL)
// // std::cout<<"ElectrodePlot::mouseDown() hit:"<<selectedAxes<<" AxesType:"<<selectedaxes.getType()<<std::endl;
// // else
// // std::cout<<"ElectrodePlot::mouseDown() NO HIT!"<<std::endl;
// }
// void ElectrodePlot::mouseDragX(int dx, bool shift, bool ctrl){
// // if (selectedAxes == NULL || dx==0)
// // return;
// // // zoomAxes(selectedaxes.getType(), true, dx>0);
// // if (shift)
// // zoomAxes(selectedAxesN, true, dx);
// // if (ctrl)
// // panAxes(selectedAxesN, true, dx);
// }
// void ElectrodePlot::mouseDragY(int dy, bool shift, bool ctrl){
// if (selectedAxes == NULL || dy==0)
// return;
// if(shift)
// zoomAxes(selectedAxesN, false, dy);
// if(ctrl)
// panAxes(selectedAxesN, false, dy);
// }
// void ElectrodePlot::zoomAxes(int n, bool xdim, int zoom){
// // std::cout<<"ElectrodePlot::zoomAxes() n:"<< n<<" xdim"<< xdim<<" in:"<<zoomin<<std::endl;
// // If trying to zoom an invalid axes type
// if (n<WAVE1 || n>PROJ3x4)
// return;
// if (n<=WAVE4)
// zoomWaveform(n, xdim, zoom);
// else
// zoomProjection(n, xdim, zoom);
// }
// void ElectrodePlot::zoomWaveform(int n, bool xdim, int zoom){
// // waveform plots don't have a xlimits
// if (xdim)
// return;
// // std::cout<<"Zooming Waveform:"<<n<<" zoomin:"<<zoomin<<" ";
// double min, max;
// if(xdim)
// return;
// min = limits[n][0];
// max = limits[n][1];
// double mean = (max + min)/2.0f;
// double delta = max - mean;
// delta = delta / pow(.99, -1*zoom);
// min = mean - delta;
// max = mean + delta;
// limits[n][0] = min;
// limits[n][1] = max;
// limitsChanged = true;
// }
// void ElectrodePlot::panAxes(int n, bool xdim, int panval){
// // std::cout<<"ElectrodePlot::zoomAxes() n:"<< n<<" xdim"<< xdim<<" in:"<<zoomin<<std::endl;
// // If trying to zoom an invalid axes type
// if (n<WAVE1 || n>PROJ3x4)
// return;
// if (n<=WAVE4)
// panWaveform(n, xdim, panval);
// else
// panProjection(n, xdim, panval);
// }
// void ElectrodePlot::panWaveform(int n, bool xdim, int pan){
// // waveform plots don't have a xlimits
// if (xdim)
// return;
// // std::cout<<"Panning Waveform:"<<n<<" pan:"<<pan<<" "<<std::endl;
// double min, max;
// if(xdim)
// return;
// min = limits[n][0];
// max = limits[n][1];
// double dy = max-min;
// // Need to grab something if pan event is driven by the keyboard, which means that all the plots are getting panned so this should be okay
// if (selectedAxes == NULL)
// selectedAxes = &axesList.front();
// double yPixels = (BaseUIElement::height - titleHeight)/2.0;
// double pixelWidth = -1 * dy/yPixels;
// double delta = pan * pixelWidth;
// min = min + delta;
// max = max + delta;
// limits[n][0] = min;
// limits[n][1] = max;
// limitsChanged = true;
// }
bool ElectrodePlot::processKeyEvent(SimpleKeyEvent k){
// std::cout<<"Key:"<<(char)k.key<<std::endl;
// switch(k.key)
// {
// case '=':
// for (int i=0; i<=WAVE4; i++)
// zoomWaveform(i, false, 3);
// break;
// case '+':
// for (int i=0; i<=WAVE4; i++)
// panWaveform(i, false, 3);
// break;
// case '-':
// for (int i=0; i<=WAVE4; i++)
// zoomWaveform(i, false, -3);
// break;
// case '_':
// for (int i=0; i<=WAVE4; i++)
// panWaveform(i, false, -3);
// break;
// case 'C':
// clearOnNextDraw(true);
// break;
// }
return true;
}
#ifndef ELECTRODE_PLOT_H
#define ELECTRODE_PLOT_H
#if defined(__linux__)
#include <GL/glut.h>
#else
#include <GLUT/glut.h>
#endif
#include <list>
#include <math.h>
#include "WaveAxes.h"
#include "BaseUIElement.h"
#include "PlotUtils.h"
#include "SimpleKeyEvent.h"
class ElectrodePlot : public BaseUIElement
{
bool enabled;
bool limitsChanged;
double limits[1][2];
WaveAxes axes;
// void zoomAxes(int n, bool xdim, int zoomval);
// void zoomProjection (int n, bool xdim, int zoomval);
// void zoomWaveform (int n, bool xdim, int zoomval);
// void panAxes(int n, bool xdim, int panval);
// void panProjection (int n, bool xdim, int panval);
// void panWaveform(int n, bool xdim, int panval);
void initLimits();
public:
ElectrodePlot();
ElectrodePlot(int x, int y,int w,int h);
virtual ~ElectrodePlot();
void initAxes();
void redraw();
void setEnabled(bool enabled);
bool getEnabled();
void setPosition(int,int,double,double);
void getPreferredDimensions(double*, double*);
int getNumberOfAxes();
void mouseDown(int x, int y);
void mouseDragX(int dx, bool shift, bool ctr);
void mouseDragY(int dy, bool shift, bool ctr);
bool processKeyEvent(SimpleKeyEvent k);
void processSpikeObject(SpikeObject s);
};
#endif
#include "StereotrodePlot.h"
#include "../SpikeObject.h"
#include "PlotUtils.h"
StereotrodePlot::StereotrodePlot():
BaseUIElement(), limitsChanged(true)
{
}
StereotrodePlot::StereotrodePlot(int x, int y, int w, int h):
BaseUIElement(x,y,w,h,0), limitsChanged(true)
{
initAxes();
}
StereotrodePlot::~StereotrodePlot(){
}
// Each plot needs to update its children axes when its redraw gets called.
// it also needs to call the parent plot when children axes get added it
// should place them in the correct location because it KNOWS where WAVE1 and PROJ1x3
// should go by default. This isn't as general as it should be but its a good push in
// the right direction
void StereotrodePlot::redraw(){
//std::cout<<"StereotrodePlot() starting drawing"<<std::endl;\
//BaseUIElement::clearNextDraw = true;
//BaseUIElement::redraw();
for (int i=0; i<nWaveAx; i++)
wAxes[i].redraw();
// wAxes[1].redraw();
for (int i=0; i<nProjAx; i++)
pAxes[i].redraw();
}
// This would normally happen for collection of axes but an electrode plot doesn't have a collection instead its a single axes
void StereotrodePlot::processSpikeObject(SpikeObject s){
//std::cout<<"ElectrdePlot::processSpikeObject()"<<std::endl;
for (int i=0; i<nWaveAx; i++)
wAxes[i].updateSpikeData(s);
// wAxes[1].updateSpikeData(s);
for (int i=0; i<nProjAx; i++)
pAxes[i].updateSpikeData(s);
}
void StereotrodePlot::setEnabled(bool e){
BaseUIElement::enabled = e;
for (int i=0; i<nWaveAx; i++)
wAxes[i].setEnabled(e);
// wAxes[1].setEnabled(e);
for (int i=0; i<nProjAx; i++)
pAxes[i].setEnabled(e);
}
bool StereotrodePlot::getEnabled(){
return BaseUIElement::enabled;
}
void StereotrodePlot::initAxes(){
initLimits();
for (int i=0; i<nWaveAx; i++){
wAxes[i] = WaveAxes(0, 0, 1, 1, WAVE1 + i); // add i to increment the wave channel
wAxes[i].setWaveformColor(1.0, 1.0, 1.0);
}
// wAxes[1] = WaveAxes(0, 0, 1, 1, WAVE2);
// wAxes[0].setWaveformColor(1.0, 1.0, 1.0);
// wAxes[1].setWaveformColor(1.0, 1.0, 1.0);
for (int i=0; i<nProjAx; i++){
pAxes[i] = ProjectionAxes(0, 0, 1, 1, PROJ1x2 + i);
pAxes[i].setPointColor(1.0, 1.0, 1.0);
}
updateAxesPositions();
setLimitsOnAxes();
}
void StereotrodePlot::updateAxesPositions(){
int minX = BaseUIElement::xpos;
int minY = BaseUIElement::ypos;
double axesWidth = BaseUIElement::width/2;
double axesHeight = BaseUIElement::height;
for (int i=0; i<nWaveAx; i++)
wAxes[i].setPosition(minX + (i%2) * axesWidth/2, minY + (i/2) * axesHeight, axesWidth/2, axesHeight);
// wAxes[1].setPosition(minX + axesWidth/2, minY, axesWidth/2, axesHeight);
for (int i=0; i<nProjAx; i++)
pAxes[0].setPosition(minX + (1 + i%2) * axesWidth, minY + (i/2) * axesHeight, axesWidth, axesHeight);
}
void StereotrodePlot::setLimitsOnAxes(){
std::cout<<"StereotrodePlot::setLimitsOnAxes()"<<std::endl;
for (int i=0; i<nWaveAx; i++)
wAxes[i].setYLims(limits[0][0], limits[0][1]);
// wAxes[1].setYLims(limits[1][0], limits[1][1]);
for (int i=0; i<nProjAx; i++){
pAxes[i].setYLims(limits[0][0], limits[0][1]);
pAxes[i].setXLims(limits[1][0], limits[1][1]);
}
}
void StereotrodePlot::setPosition(int x, int y, double w, double h){
// std::cout<<"StereotrodePlot::setPosition()"<<std::endl;
BaseUIElement::setPosition(x,y,w,h);
updateAxesPositions();
}
int StereotrodePlot::getNumberOfAxes(){
return 3;
}
void StereotrodePlot::initLimits(){
for (int i=0; i<nChannel; i++)
{
limits[i][0] = 3705;//-1*pow(2,11);
limits[i][1] = 6201;//pow(2,14)*1.6;
}
}
void StereotrodePlot::getPreferredDimensions(double *w, double *h){
*w = 150;
*h = 75;
}
void StereotrodePlot::clear(){
std::cout<<"StereotrodePlot::clear()"<<std::endl;
pAxes[0].clear();
}
bool StereotrodePlot::processKeyEvent(SimpleKeyEvent k){
return true;
}
void StereotrodePlot::pan(int dim, bool up){
std::cout<<"StereotrodePlot::pan() dim:"<<dim<<std::endl;
if (dim>1 || dim<0)
return;
int mean = (limits[dim][0] + limits[dim][1])/2;
int dLim = limits[dim][1] - mean;
if (up)
mean = mean + dLim/20;
else
mean = mean - dLim/20;
limits[dim][0] = mean-dLim;
limits[dim][1] = mean+dLim;
setLimitsOnAxes();
}
void StereotrodePlot::zoom(int dim, bool in){
std::cout<<"StereotrodePlot::zoom()"<<std::endl;
if (dim>1 || dim<0)
return;
int mean = (limits[dim][0] + limits[dim][1])/2;
int dLim = limits[dim][1] - mean;
if (in)
dLim = dLim * .90;
else
dLim = dLim / .90;
limits[dim][0] = mean-dLim;
limits[dim][1] = mean+dLim;
setLimitsOnAxes();
}
#ifndef STEROETRODE_PLOT_H_
#define STEROETRODE_PLOT_H_
#if defined(__linux__)
#include <GL/glut.h>
#else
#include <GLUT/glut.h>
#endif
#include <list>
#include <math.h>
#include "WaveAxes.h"
#include "ProjectionAxes.h"
#include "BaseUIElement.h"
#include "PlotUtils.h"
#include "SimpleKeyEvent.h"
class StereotrodePlot : public BaseUIElement{
bool enabled;
bool limitsChanged;
static const int MAX_N_CHAN = 4;
static const int nChannel = 2;
static const int nWaveAx = 2;
static const int nProjAx = 1;
double limits[MAX_N_CHAN][2];
WaveAxes wAxes[nWaveAx];
ProjectionAxes pAxes[nProjAx];
// void zoomAxes(int n, bool xdim, int zoomval);
// void zoomProjection (int n, bool xdim, int zoomval);
// void zoomWaveform (int n, bool xdim, int zoomval);
// void panAxes(int n, bool xdim, int panval);
// void panProjection (int n, bool xdim, int panval);
// void panWaveform(int n, bool xdim, int panval);
void initLimits();
void setLimitsOnAxes();
void updateAxesPositions();
public:
StereotrodePlot();
StereotrodePlot(int x, int y,int w,int h);
virtual ~StereotrodePlot();
void initAxes();
void redraw();
void setEnabled(bool enabled);
bool getEnabled();
void setPosition(int,int,double,double);
void getPreferredDimensions(double*, double*);
int getNumberOfAxes();
void mouseDown(int x, int y);
void mouseDragX(int dx, bool shift, bool ctr);
void mouseDragY(int dy, bool shift, bool ctr);
bool processKeyEvent(SimpleKeyEvent k);
void processSpikeObject(SpikeObject s);
void clear();
void zoom(int, bool);
void pan(int, bool);
};
#endif
#include "TetrodePlot.h"
#include "../SpikeObject.h"
#include "PlotUtils.h"
TetrodePlot::TetrodePlot():
BaseUIElement(), limitsChanged(true)
{
}
TetrodePlot::TetrodePlot(int x, int y, int w, int h):
BaseUIElement(x,y,w,h,0), limitsChanged(true)
{
initAxes();
}
TetrodePlot::~TetrodePlot(){
}
// Each plot needs to update its children axes when its redraw gets called.
// it also needs to call the parent plot when children axes get added it
// should place them in the correct location because it KNOWS where WAVE1 and PROJ1x3
// should go by default. This isn't as general as it should be but its a good push in
// the right direction
void TetrodePlot::redraw(){
//BaseUIElement::clearNextDraw = true;
//BaseUIElement::redraw();
for (int i = 0; i < 4; i++)
wAxes[i].redraw();
for (int i = 0; i < 6; i++)
pAxes[i].redraw();
}
// This would normally happen for collection of axes but an electrode plot doesn't have a collection instead its a single axes
void TetrodePlot::processSpikeObject(SpikeObject s){
// std::cout<<"TetrodePlot::processSpikeObject()"<<std::endl;
for (int i = 0; i < 4; i++)
wAxes[i].updateSpikeData(s);
for (int i = 0; i < 6; i++)
pAxes[i].updateSpikeData(s);
}
void TetrodePlot::setEnabled(bool e){
BaseUIElement::enabled = e;
for (int i = 0; i < 4; i++)
wAxes[i].setEnabled(e);
for (int i = 0; i < 6; i++)
pAxes[i].setEnabled(e);
}
bool TetrodePlot::getEnabled(){
return BaseUIElement::enabled;
}
void TetrodePlot::initAxes(){
initLimits();
int minX = BaseUIElement::xpos;
int minY = BaseUIElement::ypos;
double axesWidth = BaseUIElement::width/4;
double axesHeight = BaseUIElement::height/2;
// wAxes[0] = WaveAxes(minX, minY, axesWidth/2, axesHeight, WAVE1);
// wAxes[1] = WaveAxes(minX + axesWidth/2, minY, axesWidth/2, axesHeight, WAVE2);
// wAxes[2] = WaveAxes(minX, minY + axesHeight, axesWidth/2, axesHEight, WAVE3);
// wAxes[3] = WaveAxes(minX + axesWidth/2, minY + axesHeight, axesWidth/2, axesHEight, WAVE4);
for (int i=0; i<4; i++)
wAxes[i] = WaveAxes(minX + (i/2)*(axesWidth/2), minY + (i%2)*(axesHeight), axesWidth/2, axesHeight, WAVE1 + i);
for (int i=0; i<6; i++)
pAxes[i] = ProjectionAxes(minX + (1 + i/2)*axesWidth, minY + (i%2)*(axesHeight), axesWidth, axesHeight, PROJ1x2+i);
for (int i=0; i<4; i++)
wAxes[i].setWaveformColor(1.0, 1.0, 1.0);
for (int i=0; i<6; i++)
pAxes[i].setPointColor(1.0, 1.0, 1.0);
setLimitsOnAxes();
}
void TetrodePlot::setLimitsOnAxes(){
std::cout<<"TetrodePlot::setLimitsOnAxes()"<<std::endl;
for (int i=0; i<4; i++)
wAxes[i].setYLims(limits[0][0], limits[0][1]);
for (int i=0; i<6; i++){
pAxes[i].setYLims(limits[0][0], limits[0][1]);
pAxes[i].setXLims(limits[1][0], limits[1][1]);
}
}
void TetrodePlot::setPosition(int x, int y, double w, double h){
// std::cout<<"TetrodePlot::setPosition()"<<std::endl;
BaseUIElement::setPosition(x,y,w,h);
int minX = BaseUIElement::xpos;
int minY = BaseUIElement::ypos;
double axesWidth = BaseUIElement::width/4;
double axesHeight = BaseUIElement::height/2;
for (int i=0; i<4; i++)
wAxes[i] = WaveAxes(minX + (i/2)*(axesWidth/2), minY + (i%2)*(axesHeight), axesWidth/2, axesHeight, WAVE1 + i);
for (int i=0; i<6; i++)
pAxes[i] = ProjectionAxes(minX + (1 + i/2)*axesWidth, minY + (i%2)*(axesHeight), axesWidth, axesHeight, PROJ1x2+i);
}
int TetrodePlot::getNumberOfAxes(){
return 10;
}
void TetrodePlot::initLimits(){
for (int i=0; i<2; i++)
{
limits[i][0] = -1*pow(2,11);
limits[i][1] = pow(2,14)*1.6;
}
}
void TetrodePlot::getPreferredDimensions(double *w, double *h){
*w = 75;
*h = 75;
}
void TetrodePlot::clear(){
std::cout<<"TetrodePlot::clear()"<<std::endl;
for (int i=0; i<6; i++)
pAxes[i].clear();
}
bool TetrodePlot::processKeyEvent(SimpleKeyEvent k){
return true;
}
void TetrodePlot::pan(int dim, bool up){
std::cout<<"TetrodePlot::pan() dim:"<<dim<<std::endl;
if (dim>1 || dim<0)
return;
int mean = (limits[dim][0] + limits[dim][1])/2;
int dLim = limits[dim][1] - mean;
if (up)
mean = mean + dLim/20;
else
mean = mean - dLim/20;
limits[dim][0] = mean-dLim;
limits[dim][1] = mean+dLim;
setLimitsOnAxes();
}
void TetrodePlot::zoom(int dim, bool in){
std::cout<<"TetrodePlot::zoom()"<<std::endl;
if (dim>1 || dim<0)
return;
int mean = (limits[dim][0] + limits[dim][1])/2;
int dLim = limits[dim][1] - mean;
if (in)
dLim = dLim * .90;
else
dLim = dLim / .90;
limits[dim][0] = mean-dLim;
limits[dim][1] = mean+dLim;
setLimitsOnAxes();
}
#ifndef TETRODE_PLOT_H_
#define TETRODE_PLOT_H_
#if defined(__linux__)
#include <GL/glut.h>
#else
#include <GLUT/glut.h>
#endif
#include <list>
#include <math.h>
#include "WaveAxes.h"
#include "ProjectionAxes.h"
#include "BaseUIElement.h"
#include "PlotUtils.h"
#include "SimpleKeyEvent.h"
class TetrodePlot : public BaseUIElement{
bool enabled;
bool limitsChanged;
double limits[2][2];
WaveAxes wAxes[4];
ProjectionAxes pAxes[6];
// void zoomAxes(int n, bool xdim, int zoomval);
// void zoomProjection (int n, bool xdim, int zoomval);
// void zoomWaveform (int n, bool xdim, int zoomval);
// void panAxes(int n, bool xdim, int panval);
// void panProjection (int n, bool xdim, int panval);
// void panWaveform(int n, bool xdim, int panval);
void initLimits();
void setLimitsOnAxes();
public:
TetrodePlot();
TetrodePlot(int x, int y,int w,int h);
virtual ~TetrodePlot();
void initAxes();
void redraw();
void setEnabled(bool enabled);
bool getEnabled();
void setPosition(int,int,double,double);
void getPreferredDimensions(double*, double*);
int getNumberOfAxes();
void mouseDown(int x, int y);
void mouseDragX(int dx, bool shift, bool ctr);
void mouseDragY(int dy, bool shift, bool ctr);
bool processKeyEvent(SimpleKeyEvent k);
void processSpikeObject(SpikeObject s);
void clear();
void zoom(int, bool);
void pan(int, bool);
};
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment