Body graph now more visually configurable

- Added toggle for visibility of body and line visibility in body graph
This commit is contained in:
James Alliban 2014-01-11 03:36:19 +00:00
parent e4861134d1
commit 2874d497b4
15 changed files with 96 additions and 71 deletions

View File

@ -15,3 +15,4 @@ ofxSpacebrew
ofxLibwebsockets ofxLibwebsockets
ofxUI ofxUI
ofxXmlSettings ofxXmlSettings
ofxFTGL

BIN
of/Active Tripod/bin.zip Normal file

Binary file not shown.

View File

@ -1,12 +1,12 @@
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Toggle Video Visibility</Name> <Name>Toggle Video Visibility</Name>
<Value>1</Value> <Value>0</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Toggle Image Visibility</Name> <Name>Toggle Image Visibility</Name>
<Value>0</Value> <Value>1</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
@ -46,22 +46,22 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Red .</Name> <Name>Red .</Name>
<Value>40.263156891</Value> <Value>20.970394135</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Green .</Name> <Name>Green .</Name>
<Value>40.263156891</Value> <Value>21.809211731</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Blue .</Name> <Name>Blue .</Name>
<Value>39.424343109</Value> <Value>22.648025513</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Alpha .</Name> <Name>Alpha .</Name>
<Value>207.187500000</Value> <Value>255.000000000</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>

View File

@ -1,17 +1,17 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Graph Item X Gap</Name> <Name>Graph Item X Gap</Name>
<Value>21.875000000</Value> <Value>13.733552933</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>BarWidth</Name> <Name>BarWidth</Name>
<Value>17.000000000</Value> <Value>8.157895088</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Graph Height Max</Name> <Name>Graph Height Max</Name>
<Value>407.894744873</Value> <Value>440.460510254</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>

View File

@ -1,3 +1,13 @@
<Widget>
<Kind>2</Kind>
<Name>Toggle Draw Body</Name>
<Value>1</Value>
</Widget>
<Widget>
<Kind>2</Kind>
<Name>Toggle Draw Lines</Name>
<Value>1</Value>
</Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Graph Item X Gap</Name> <Name>Graph Item X Gap</Name>
@ -31,12 +41,12 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Data0 alpha</Name> <Name>Data0 alpha</Name>
<Value>155.180923462</Value> <Value>186.217102051</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Data1 red</Name> <Name>Data1 red</Name>
<Value>164.407897949</Value> <Value>167.763153076</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
@ -51,5 +61,5 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Data1 alpha</Name> <Name>Data1 alpha</Name>
<Value>170.279602051</Value> <Value>184.539474487</Value>
</Widget> </Widget>

View File

@ -1,12 +1,12 @@
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Bar graph</Name> <Name>Bar graph</Name>
<Value>1</Value> <Value>0</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Solid Body graph</Name> <Name>Solid Body graph</Name>
<Value>0</Value> <Value>1</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>

View File

@ -31,7 +31,7 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Value average amount</Name> <Name>Value average amount</Name>
<Value>3.006578922</Value> <Value>20.000000000</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>

View File

@ -1,7 +1,7 @@
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Toggle Data Simulation</Name> <Name>Toggle Data Simulation</Name>
<Value>0</Value> <Value>1</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>

View File

@ -30,7 +30,7 @@ void DataManager::setup()
void DataManager::setupSpacebrew() 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 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"; string description = "Description goes here. Not sure why. Let me know if you see this and tell me if you need it";

View File

@ -103,6 +103,8 @@ void GUI::addBodyGraphDesignGUI()
string title = "BODY GRAPH DESIGN"; string title = "BODY GRAPH DESIGN";
ofxUICanvas* gui = getNewGUI(title); 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("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("Line width", 1, 50, &app->scene.bodyGraph.lineWidth, length, dim);
gui->addSlider("Graph Height Max", 100, 1000, &app->scene.bodyGraph.graphHeightMax, 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 Length", 50, 500, &app->scene.lineLength, length, dim);
gui->addSlider("Line Spacing", 0, 10, &app->scene.lineSpacing, 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("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->addSpacer(length, 1);
gui->addSlider("Red", 0, 255, &app->scene.textColour[0], length, dim); gui->addSlider("Red", 0, 255, &app->scene.textColour[0], length, dim);

View File

@ -2,13 +2,15 @@
// TODO // TODO
// ==== // ====
// - Add spacebrew text to text boxes // - Make HUD BG hole size a percentage rather than pixels
// - Add colour boxes to text // - 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 // - 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 // - Make 3rd graph - separate fade
// - Crosshairs in HUD // - Crosshairs in HUD
// - Create graph animation system // - Create graph animation system
// - Create a single config file to be loaded from online location. It will contain IP address and host name // - 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() void testApp::setup()

View File

@ -99,27 +99,28 @@ void Scene::drawHUDCopy()
vector<DataObject> *p0Data = &activeGraph->publisher0Data; vector<DataObject> *p0Data = &activeGraph->publisher0Data;
vector<DataObject> *p1Data = &activeGraph->publisher1Data; vector<DataObject> *p1Data = &activeGraph->publisher1Data;
if (p0Data->size() > (int)averageAmount - 1) int amountToAverage = MIN(p0Data->size(), averageAmount);
if (p0Data->size() > 2)
{ {
float average0 = 0; 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 += 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)) // (p0Data->back() + p0Data->at(p0Data->size() - 2) + p0Data->at(p0Data->size() - 2))
blStr = ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" + blStr = "Increase: " + ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" +
ofToString(p0Data->back().value) + "\n" + "Current Value: " + ofToString(p0Data->back().value) + "\n" +
"Running average: " + ofToString(average0); "Running average: " + ofToString(average0);
drawTextBox(blStr, "BOTTOM LEFT"); drawTextBox(blStr, "BOTTOM LEFT");
float average1 = 0; 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 += 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" + brStr = "Increase: " + ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "\n" +
ofToString(p1Data->back().value) + "\n" + "Current Value: " + ofToString(p1Data->back().value) + "\n" +
"Running average: " + ofToString(average1); "Running average: " + ofToString(average1);
drawTextBox(brStr, "BOTTOM RIGHT"); drawTextBox(brStr, "BOTTOM RIGHT");
} }

View File

@ -38,52 +38,58 @@ void BodyGraph::draw()
float outputMin = (ofGetHeight() * 0.5) - graphHeightMax; float outputMin = (ofGetHeight() * 0.5) - graphHeightMax;
float outputMax = (ofGetHeight() * 0.5) + graphHeightMax; float outputMax = (ofGetHeight() * 0.5) + graphHeightMax;
// draw main part of graph (body) if (isDrawBody)
ofMesh body;
body.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
for (int i = 0; i < publisher0Data.size() - 1; i++)
{ {
body.addVertex(ofVec3f( // draw main part of graph (xOffset)
i * graphItemXGap + xOffset, ofMesh body;
ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax), body.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
0)); for (int i = 0; i < publisher0Data.size() - 1; i++)
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)
{ {
ofSetLineWidth(lineWidth); body.addVertex(ofVec3f(
poly0.addVertex(ofPoint(
i * graphItemXGap + xOffset, i * graphItemXGap + xOffset,
ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax))); ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax),
0));
body.addVertex(ofVec3f(
poly1.addVertex(ofPoint(
i * graphItemXGap + xOffset, i * graphItemXGap + xOffset,
ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax))); 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(); if (isDrawLines)
ofSetColor(col1[0],col1[1],col1[2], 255); {
poly1.draw(); // draw lines
ofPopStyle(); 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();
}
} }
} }

View File

@ -14,4 +14,7 @@ public:
float barWidth; float barWidth;
float lineWidth; float lineWidth;
bool isDrawBody;
bool isDrawLines;
}; };