Body graph now more visually configurable
- Added toggle for visibility of body and line visibility in body graph
This commit is contained in:
@@ -30,7 +30,7 @@ void DataManager::setup()
|
||||
|
||||
void DataManager::setupSpacebrew()
|
||||
{
|
||||
string host = "54.200.6.109"; // Spacebrew::SPACEBREW_CLOUD; // "localhost";
|
||||
string host = "54.194.189.129"; // Spacebrew::SPACEBREW_CLOUD; // "localhost";
|
||||
string name = "CRITICAL INFRASTRUCTURE";
|
||||
string description = "Description goes here. Not sure why. Let me know if you see this and tell me if you need it";
|
||||
|
||||
|
||||
@@ -103,6 +103,8 @@ void GUI::addBodyGraphDesignGUI()
|
||||
string title = "BODY GRAPH DESIGN";
|
||||
ofxUICanvas* gui = getNewGUI(title);
|
||||
|
||||
gui->addToggle("Toggle Draw Body", &app->scene.bodyGraph.isDrawBody, toggleDim, toggleDim);
|
||||
gui->addToggle("Toggle Draw Lines", &app->scene.bodyGraph.isDrawLines, toggleDim, toggleDim);
|
||||
gui->addSlider("Graph Item X Gap", 5, 50, &app->scene.bodyGraph.graphItemXGap, length, dim);
|
||||
gui->addSlider("Line width", 1, 50, &app->scene.bodyGraph.lineWidth, length, dim);
|
||||
gui->addSlider("Graph Height Max", 100, 1000, &app->scene.bodyGraph.graphHeightMax, length, dim);
|
||||
@@ -180,7 +182,7 @@ void GUI::addHUDTextGUI()
|
||||
gui->addSlider("Line Length", 50, 500, &app->scene.lineLength, length, dim);
|
||||
gui->addSlider("Line Spacing", 0, 10, &app->scene.lineSpacing, length, dim);
|
||||
gui->addSlider("Text Size", 10, 100, &app->scene.textSize, length, dim);
|
||||
gui->addSlider("Value average amount", 2, 20, &app->scene.averageAmount, length, dim);
|
||||
gui->addSlider("Value average amount", 2, 150, &app->scene.averageAmount, length, dim);
|
||||
|
||||
gui->addSpacer(length, 1);
|
||||
gui->addSlider("Red", 0, 255, &app->scene.textColour[0], length, dim);
|
||||
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
// TODO
|
||||
// ====
|
||||
// - Add spacebrew text to text boxes
|
||||
// - Add colour boxes to text
|
||||
// - Make HUD BG hole size a percentage rather than pixels
|
||||
// - Add option to resize video draw size (rather than making it fullscreen) and init size
|
||||
// - Make system to slow down data - The screen should show 15-20 minutes worth of data
|
||||
// - add ability to remove the lines or body from body graph
|
||||
// - Make 3rd graph - separate fade
|
||||
// - Crosshairs in HUD
|
||||
// - Create graph animation system
|
||||
// - Create a single config file to be loaded from online location. It will contain IP address and host name
|
||||
// - Add 'clear all data' button to UI
|
||||
//
|
||||
//--------------------------------------------------------------
|
||||
void testApp::setup()
|
||||
|
||||
@@ -99,27 +99,28 @@ void Scene::drawHUDCopy()
|
||||
vector<DataObject> *p0Data = &activeGraph->publisher0Data;
|
||||
vector<DataObject> *p1Data = &activeGraph->publisher1Data;
|
||||
|
||||
if (p0Data->size() > (int)averageAmount - 1)
|
||||
int amountToAverage = MIN(p0Data->size(), averageAmount);
|
||||
if (p0Data->size() > 2)
|
||||
{
|
||||
float average0 = 0;
|
||||
for (int i = 0; i < (int)averageAmount; i++)
|
||||
for (int i = 0; i < (int)amountToAverage; i++)
|
||||
average0 += p0Data->at(p0Data->size() - i - 1).value;
|
||||
average0 /= (int)averageAmount;
|
||||
average0 /= (int)amountToAverage;
|
||||
|
||||
// (p0Data->back() + p0Data->at(p0Data->size() - 2) + p0Data->at(p0Data->size() - 2))
|
||||
blStr = ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" +
|
||||
ofToString(p0Data->back().value) + "\n" +
|
||||
blStr = "Increase: " + ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" +
|
||||
"Current Value: " + ofToString(p0Data->back().value) + "\n" +
|
||||
"Running average: " + ofToString(average0);
|
||||
drawTextBox(blStr, "BOTTOM LEFT");
|
||||
|
||||
|
||||
float average1 = 0;
|
||||
for (int i = 0; i < (int)averageAmount; i++)
|
||||
for (int i = 0; i < (int)amountToAverage; i++)
|
||||
average1 += p1Data->at(p1Data->size() - i - 1).value;
|
||||
average1 /= (int)averageAmount;
|
||||
average1 /= (int)amountToAverage;
|
||||
|
||||
brStr = ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "m/s\n" +
|
||||
ofToString(p1Data->back().value) + "\n" +
|
||||
brStr = "Increase: " + ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "\n" +
|
||||
"Current Value: " + ofToString(p1Data->back().value) + "\n" +
|
||||
"Running average: " + ofToString(average1);
|
||||
drawTextBox(brStr, "BOTTOM RIGHT");
|
||||
}
|
||||
|
||||
@@ -38,52 +38,58 @@ void BodyGraph::draw()
|
||||
float outputMin = (ofGetHeight() * 0.5) - graphHeightMax;
|
||||
float outputMax = (ofGetHeight() * 0.5) + graphHeightMax;
|
||||
|
||||
// draw main part of graph (body)
|
||||
ofMesh body;
|
||||
body.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
|
||||
for (int i = 0; i < publisher0Data.size() - 1; i++)
|
||||
if (isDrawBody)
|
||||
{
|
||||
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));
|
||||
|
||||
body.addColor(ofColor(col0[0],col0[1],col0[2], col0[3]));
|
||||
body.addColor(ofColor(col1[0],col1[1],col1[2], col1[3]));
|
||||
}
|
||||
|
||||
body.drawFaces();
|
||||
|
||||
|
||||
// draw lines
|
||||
ofPushStyle();
|
||||
ofPolyline poly0;
|
||||
ofPolyline poly1;
|
||||
for (int i = 0; i < publisher0Data.size() - 1; i++)
|
||||
{
|
||||
if (i < publisher0Data.size() - 1)
|
||||
// draw main part of graph (xOffset)
|
||||
ofMesh body;
|
||||
body.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
|
||||
for (int i = 0; i < publisher0Data.size() - 1; i++)
|
||||
{
|
||||
ofSetLineWidth(lineWidth);
|
||||
poly0.addVertex(ofPoint(
|
||||
i * graphItemXGap + xOffset,
|
||||
ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax)));
|
||||
|
||||
|
||||
poly1.addVertex(ofPoint(
|
||||
i * graphItemXGap + xOffset,
|
||||
ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax)));
|
||||
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));
|
||||
|
||||
body.addColor(ofColor(col0[0],col0[1],col0[2], col0[3]));
|
||||
body.addColor(ofColor(col1[0],col1[1],col1[2], col1[3]));
|
||||
}
|
||||
|
||||
body.drawFaces();
|
||||
}
|
||||
|
||||
ofSetColor(col0[0],col0[1],col0[2], 255);
|
||||
poly0.draw();
|
||||
ofSetColor(col1[0],col1[1],col1[2], 255);
|
||||
poly1.draw();
|
||||
ofPopStyle();
|
||||
|
||||
if (isDrawLines)
|
||||
{
|
||||
// draw lines
|
||||
ofPushStyle();
|
||||
ofPolyline poly0;
|
||||
ofPolyline poly1;
|
||||
for (int i = 0; i < publisher0Data.size() - 1; i++)
|
||||
{
|
||||
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)));
|
||||
|
||||
|
||||
poly1.addVertex(ofPoint(
|
||||
i * graphItemXGap + xOffset,
|
||||
ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax)));
|
||||
}
|
||||
}
|
||||
|
||||
ofSetColor(col0[0],col0[1],col0[2], 255);
|
||||
poly0.draw();
|
||||
ofSetColor(col1[0],col1[1],col1[2], 255);
|
||||
poly1.draw();
|
||||
ofPopStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,4 +14,7 @@ public:
|
||||
|
||||
float barWidth;
|
||||
float lineWidth;
|
||||
|
||||
bool isDrawBody;
|
||||
bool isDrawLines;
|
||||
};
|
||||
Reference in New Issue
Block a user