2014-01-09 17:07:26 +00:00
|
|
|
//
|
|
|
|
|
// Created by James Alliban on 08/01/2014.
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "BodyGraph.h"
|
2014-01-11 06:13:04 +00:00
|
|
|
#include "testApp.h"
|
2014-01-09 17:07:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void BodyGraph::setup()
|
|
|
|
|
{
|
|
|
|
|
AbstractGraph::setup();
|
2014-01-11 06:13:04 +00:00
|
|
|
app = (testApp*)ofGetAppPtr();
|
|
|
|
|
graphName = "BODY";
|
2014-01-09 17:07:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BodyGraph::update()
|
|
|
|
|
{
|
2014-01-11 06:13:04 +00:00
|
|
|
AbstractGraph::update();
|
|
|
|
|
}
|
2014-01-09 17:07:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void BodyGraph::draw()
|
|
|
|
|
{
|
2014-01-11 06:13:04 +00:00
|
|
|
if (app->gui.getVisible())
|
|
|
|
|
{
|
|
|
|
|
float timePerScreenfull = (float)maxData * sendDataSpeed;
|
|
|
|
|
printf("timePerScreenfull:%f, maxData:%i, sendDataSpeed:%f \n", timePerScreenfull, maxData, sendDataSpeed);
|
|
|
|
|
ofDrawBitmapString("Time to fill screen:" + ofToString(timePerScreenfull), 500, 150);
|
|
|
|
|
}
|
|
|
|
|
|
2014-01-09 17:07:26 +00:00
|
|
|
if (publisher0Data.size() > 1)
|
|
|
|
|
{
|
2014-01-10 00:10:06 +00:00
|
|
|
float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent;
|
2014-01-11 20:00:46 +00:00
|
|
|
float outputMin = (ofGetHeight() * 0.5) - ((ofGetHeight() * 0.5) * graphHeightMax);
|
|
|
|
|
float outputMax = (ofGetHeight() * 0.5) + ((ofGetHeight() * 0.5) * graphHeightMax);
|
2014-01-09 17:07:26 +00:00
|
|
|
|
2014-01-11 03:36:19 +00:00
|
|
|
if (isDrawBody)
|
2014-01-09 17:07:26 +00:00
|
|
|
{
|
2014-01-11 03:36:19 +00:00
|
|
|
// draw main part of graph (xOffset)
|
|
|
|
|
ofMesh body;
|
|
|
|
|
body.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
|
|
|
|
|
for (int i = 0; i < publisher0Data.size() - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
body.addVertex(ofVec3f(
|
|
|
|
|
i * graphItemXGap + xOffset,
|
|
|
|
|
ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax),
|
|
|
|
|
0));
|
|
|
|
|
body.addVertex(ofVec3f(
|
|
|
|
|
i * graphItemXGap + xOffset,
|
|
|
|
|
ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax),
|
|
|
|
|
0));
|
2014-01-09 17:07:26 +00:00
|
|
|
|
2014-01-11 03:36:19 +00:00
|
|
|
body.addColor(ofColor(col0[0],col0[1],col0[2], col0[3]));
|
|
|
|
|
body.addColor(ofColor(col1[0],col1[1],col1[2], col1[3]));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
body.drawFaces();
|
2014-01-09 17:07:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-01-11 03:36:19 +00:00
|
|
|
if (isDrawLines)
|
2014-01-09 17:07:26 +00:00
|
|
|
{
|
2014-01-11 03:36:19 +00:00
|
|
|
// draw lines
|
|
|
|
|
ofPushStyle();
|
|
|
|
|
ofPolyline poly0;
|
|
|
|
|
ofPolyline poly1;
|
|
|
|
|
for (int i = 0; i < publisher0Data.size() - 1; i++)
|
2014-01-09 17:07:26 +00:00
|
|
|
{
|
2014-01-11 03:36:19 +00:00
|
|
|
if (i < publisher0Data.size() - 1)
|
|
|
|
|
{
|
|
|
|
|
ofSetLineWidth(lineWidth);
|
|
|
|
|
poly0.addVertex(ofPoint(
|
|
|
|
|
i * graphItemXGap + xOffset,
|
|
|
|
|
ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax)));
|
2014-01-10 00:10:06 +00:00
|
|
|
|
|
|
|
|
|
2014-01-11 03:36:19 +00:00
|
|
|
poly1.addVertex(ofPoint(
|
|
|
|
|
i * graphItemXGap + xOffset,
|
|
|
|
|
ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax)));
|
|
|
|
|
}
|
2014-01-09 17:07:26 +00:00
|
|
|
}
|
2014-01-10 00:10:06 +00:00
|
|
|
|
2014-01-11 03:36:19 +00:00
|
|
|
ofSetColor(col0[0],col0[1],col0[2], 255);
|
|
|
|
|
poly0.draw();
|
|
|
|
|
ofSetColor(col1[0],col1[1],col1[2], 255);
|
|
|
|
|
poly1.draw();
|
|
|
|
|
ofPopStyle();
|
|
|
|
|
}
|
2014-01-09 17:07:26 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void BodyGraph::addNewData(vector<DataObject> newData)
|
|
|
|
|
{
|
|
|
|
|
AbstractGraph::addNewData(newData);
|
|
|
|
|
}
|