SpikeStream Application Library  0.2
MembranePotentialGraphWidget.cpp
Go to the documentation of this file.
00001 //SpikeStream includes
00002 #include "MembranePotentialGraphWidget.h"
00003 #include "Util.h"
00004 using namespace spikestream;
00005 
00006 //Qt includes
00007 #include <QDebug>
00008 
00010 MembranePotentialGraphWidget::MembranePotentialGraphWidget(QWidget* parent) : AbstractGraphWidget(parent) {
00011         plotColor = qRgb(255, 0, 0);
00012         setYRange(-130, 50);
00013         buildBufferImage();
00014 
00015         newXPos = 0;
00016         newYPos = 0;
00017         oldXPos = 0;
00018         oldYPos = 0;
00019 }
00020 
00021 
00023 MembranePotentialGraphWidget::~MembranePotentialGraphWidget(){
00024 
00025 }
00026 
00027 
00028 
00029 /*----------------------------------------------------------*/
00030 /*------               PUBLIC METHODS                 ------*/
00031 /*----------------------------------------------------------*/
00032 
00034 void MembranePotentialGraphWidget::addData(float membranePotential, timestep_t timeStep){
00035         oldXPos = newXPos;
00036         oldYPos = newYPos;
00037 
00038         newXPos = timeStep % numTimeSteps +  yAxisPadding + 1;
00039 
00040         //Make sure membrane potential does not go out of range
00041         newYPos = imageHeight - Util::rInt(membranePotential - getMinY());
00042         if(newYPos > imageHeight)
00043                 newYPos = imageHeight;
00044         if(newYPos < 0)
00045                 newYPos = 0;
00046 
00047         //Advance the time step
00048         increaseTimeStep(timeStep);
00049         repaint();
00050 }
00051 
00052 
00054 void MembranePotentialGraphWidget::paintData(QPainter &painter){
00055         painter.setPen( QPen(plotColor) );
00056         //Only draw line if it is a sequential point
00057         if(newXPos - oldXPos == 1)
00058                 painter.drawLine(oldXPos, oldYPos, newXPos, newYPos);
00059 }
00060 
00061 
00063 void MembranePotentialGraphWidget::paintLabels(QPainter& painter){
00064 }
 All Classes Files Functions Variables Typedefs Friends Defines