From 759936b322887f48224e30608041d5e19c621120 Mon Sep 17 00:00:00 2001 From: James Alliban Date: Fri, 10 Jan 2014 00:10:06 +0000 Subject: [PATCH] Body graph now using live data --- of/Active Tripod/bin/Active_Tripod.lib | Bin 78700 -> 78700 bytes .../data/GUI/BACKGROUNDguiPagesettings.xml | 2 +- .../GUI/BODY GRAPH DESIGNguiPagesettings.xml | 11 +++-- .../data/GUI/SIMULATIONguiPagesettings.xml | 2 +- of/Active Tripod/src/data/DataManager.cpp | 8 ++-- of/Active Tripod/src/gui/GUI.cpp | 6 ++- of/Active Tripod/src/testApp.cpp | 30 +++--------- of/Active Tripod/src/visual/Scene.cpp | 6 +++ of/Active Tripod/src/visual/Scene.h | 2 + .../src/visual/graph/BodyGraph.cpp | 44 +++++++++++++----- 10 files changed, 66 insertions(+), 45 deletions(-) diff --git a/of/Active Tripod/bin/Active_Tripod.lib b/of/Active Tripod/bin/Active_Tripod.lib index f67f17109f718f9f1078a2192f21ee5271c41312..c0eb44eb5f2c97a787caf678be70c205f3d117e1 100644 GIT binary patch delta 7067 zcmZu#c~I2X9p@>R90D#Z%Oz|S5IGk-u*RCLwT`t!O~%nqV+qN$o#-er$+WSKRiDif;}H);jK(OUeb?vhV-x;jzW4X@z20x{-Uz&V zBXDkVP?4w5Q(WWj|El_LYuT%V^}kha7d^Phqv*6^mCNPno2LHW4Eqh~7_hy#?zMOl z5D-eoFGxXGd%mzgnxB)WozHya?objL8enTL&m#Jp_k3kOB0PVw=jX_I!LC@ z$y=jxDz6!3vUJhXR!6vKw;ZnZ5^wm%!X%ow1(@?_CD+5b-6YpZ7Z-)msLzenXG$WM zOLXTF6AP2s`b6Ut>At@e>2hdgk$ZB53=!tLZ@AcJ9SB_VG-L_Ow+%($&lKg(HUQ0` z?<9iG<2JHr%eHtLT^vg1d+GH$Z{QN#|_uV(Flw;d_ub zR>X`w*62$Vp6o$`qva>u^#}DT6 z_3?4^m4lG?>V98v5d97d@rPgm3%%+PRx>C;hd}{?lMf?KP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8bou=_dS!MPeYqK#^U0CD7js|1 zdw6n|FqyNz!({SWNRQ%8w~kv#^*Y7J zfW5xBJ<}dS33uhmLj(fDQy)PFC3*bFE(u-`6TU}C7{bQyO|$jaV98?)Ds0s~hAq3X zqki})>M=uw2k#Sju+P_LPjJ5QC7tmUX9+I`_7pD$`+NnpK+YdHcF{?#PCEAG5c=;H zv=-~v+=8q?DShToX*3j6dVDJ?jT6_@Y7WOGHN1Uz3-@!+U1)y)Q2K12@vJ~aedIhJ ztyjZqX&vBNiS+W%BH5S@<~vZM%=~bI@a#=HBvj_FB_3@~2g)J|L8N;8*gQheY)Hkl zGgAJwJ0fdWS{Pz~ljg$}E1PjHp^IGS(VV*+5B-*d6TK$DwB05&g> zV1@PLg>?ub7zjvB2{KZgB!NP#%SkpVm^fHOFv-?M(3`@>2NSFTk3=enjjmM+&x1)W z@Janp#EL_V2R-ZTTnI5^t)+@WjTDCWy5Er) zTvtCav0+grRgD1ba1`;awhxhS@K{Pb3G95986;>_MjH(jr%Q}U2vub<#+81vu$WG! z68bXA0?qDZb_U9k4xN{vUBX#@qDdIt znVD#`Z18JgPs9AN`aGgq|8wrE6Z2$}1R6awkXBCa#1^N+r4Vzmx^$v`ynKbrIw0#} z*%@u+N;9pVTl6>RV{sc&8o&wUj?Qd`rE5vVb8G@O{YCNQeE;g)X75t>N YOrhYSZxscyvjrqmE1?~po}~Z(0emr&;{X5v diff --git a/of/Active Tripod/bin/data/GUI/BACKGROUNDguiPagesettings.xml b/of/Active Tripod/bin/data/GUI/BACKGROUNDguiPagesettings.xml index 44e7a76..09efc90 100644 --- a/of/Active Tripod/bin/data/GUI/BACKGROUNDguiPagesettings.xml +++ b/of/Active Tripod/bin/data/GUI/BACKGROUNDguiPagesettings.xml @@ -51,7 +51,7 @@ 4 Alpha . - 255.000000000 + 207.187500000 4 diff --git a/of/Active Tripod/bin/data/GUI/BODY GRAPH DESIGNguiPagesettings.xml b/of/Active Tripod/bin/data/GUI/BODY GRAPH DESIGNguiPagesettings.xml index 973d0d7..1a411e3 100644 --- a/of/Active Tripod/bin/data/GUI/BODY GRAPH DESIGNguiPagesettings.xml +++ b/of/Active Tripod/bin/data/GUI/BODY GRAPH DESIGNguiPagesettings.xml @@ -6,7 +6,12 @@ 4 Line width - 25.661184311 + 7.286184311 + + + 4 + Graph Height Max + 443.421051025 4 @@ -26,7 +31,7 @@ 4 Data0 alpha - 230.674346924 + 155.180923462 4 @@ -46,5 +51,5 @@ 4 Data1 alpha - 185.378295898 + 170.279602051 diff --git a/of/Active Tripod/bin/data/GUI/SIMULATIONguiPagesettings.xml b/of/Active Tripod/bin/data/GUI/SIMULATIONguiPagesettings.xml index 65a6ee7..1908c35 100644 --- a/of/Active Tripod/bin/data/GUI/SIMULATIONguiPagesettings.xml +++ b/of/Active Tripod/bin/data/GUI/SIMULATIONguiPagesettings.xml @@ -1,7 +1,7 @@ 2 Toggle Data Simulation - 1 + 0 4 diff --git a/of/Active Tripod/src/data/DataManager.cpp b/of/Active Tripod/src/data/DataManager.cpp index faf8642..8592abd 100644 --- a/of/Active Tripod/src/data/DataManager.cpp +++ b/of/Active Tripod/src/data/DataManager.cpp @@ -77,7 +77,7 @@ void DataManager::update() { isPublisher0DataReceived = false; isPublisher1DataReceived = false; - app->scene.activeGraph->addNewData(newData); + app->scene.addNewData(newData); } } } @@ -122,10 +122,10 @@ void DataManager::onMessage( Spacebrew::Message & m ) printf("- - min = %s\n", data[i].substr(4, -1).c_str()); dataObject.min = ofToFloat(data[i].substr(4, -1).c_str()); } - if (data[i].substr(0, 5) == " max:") + if (data[i].substr(0, 4) == "max:") { - printf("- - max = %s\n", data[i].substr(5, -1).c_str()); - dataObject.max = ofToFloat(data[i].substr(5, -1).c_str()); + printf("- - max = %s\n", data[i].substr(4, -1).c_str()); + dataObject.max = ofToFloat(data[i].substr(4, -1).c_str()); } } diff --git a/of/Active Tripod/src/gui/GUI.cpp b/of/Active Tripod/src/gui/GUI.cpp index f9f355d..6529621 100644 --- a/of/Active Tripod/src/gui/GUI.cpp +++ b/of/Active Tripod/src/gui/GUI.cpp @@ -80,12 +80,13 @@ void GUI::addBarGraphDesignGUI() gui->addSlider("Graph Item X Gap", 5, 50, &app->scene.barGraph.graphItemXGap, length, dim); gui->addSlider("BarWidth", 2, 50, &app->scene.barGraph.barWidth, length, dim); gui->addSlider("Graph Height Max", 100, 1000, &app->scene.barGraph.graphHeightMax, length, dim); - + gui->addSpacer(length, 1); gui->addSlider("Data0 red", 0, 255, &app->scene.barGraph.col0[0], length, dim); gui->addSlider("Data0 green", 0, 255, &app->scene.barGraph.col0[1], length, dim); gui->addSlider("Data0 blue", 0, 255, &app->scene.barGraph.col0[2], length, dim); gui->addSlider("Data0 alpha", 0, 255, &app->scene.barGraph.col0[3], length, dim); + gui->addSpacer(length, 1); gui->addSlider("Data1 red", 0, 255, &app->scene.barGraph.col1[0], length, dim); gui->addSlider("Data1 green", 0, 255, &app->scene.barGraph.col1[1], length, dim); gui->addSlider("Data1 blue", 0, 255, &app->scene.barGraph.col1[2], length, dim); @@ -102,11 +103,14 @@ void GUI::addBodyGraphDesignGUI() 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); + gui->addSpacer(length, 1); gui->addSlider("Data0 red", 0, 255, &app->scene.bodyGraph.col0[0], length, dim); gui->addSlider("Data0 green", 0, 255, &app->scene.bodyGraph.col0[1], length, dim); gui->addSlider("Data0 blue", 0, 255, &app->scene.bodyGraph.col0[2], length, dim); gui->addSlider("Data0 alpha", 0, 255, &app->scene.bodyGraph.col0[3], length, dim); + gui->addSpacer(length, 1); gui->addSlider("Data1 red", 0, 255, &app->scene.bodyGraph.col1[0], length, dim); gui->addSlider("Data1 green", 0, 255, &app->scene.bodyGraph.col1[1], length, dim); gui->addSlider("Data1 blue", 0, 255, &app->scene.bodyGraph.col1[2], length, dim); diff --git a/of/Active Tripod/src/testApp.cpp b/of/Active Tripod/src/testApp.cpp index fcab03d..f15f4a8 100644 --- a/of/Active Tripod/src/testApp.cpp +++ b/of/Active Tripod/src/testApp.cpp @@ -2,31 +2,14 @@ // TODO // ==== -// -// - Map graph min/max -// - Stop graph going beyond 80% of the screen -// - Add separate colour sliders for body graph -// - In body graph use one long line instead of loads of lines -// - Make 2nd graph - body -// - Make 3rd graph - separate fade -// - Add colour boxes to text - DON'T use graph colours - add sliders -// - Crosshairs in HUD // - Add video camera feed -// - Create text parsing system -// - Tidy up the first graph -// - Create animation system +// - Add colour boxes to text // - Make system to slow down data - The screen should show 15-20 minutes worth of data +// - 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 // -// -// -// -// NOTES -// ===== -// - Check that the local data sources always have the same amount of data. - - - //-------------------------------------------------------------- void testApp::setup() { @@ -45,7 +28,7 @@ void testApp::setup() isPaused = false; } -//-------------------------------------------------------------- + void testApp::update() { if (isPaused) return; @@ -54,7 +37,7 @@ void testApp::update() scene.update(); } -//-------------------------------------------------------------- + void testApp::draw() { dataManager.draw(); @@ -62,7 +45,6 @@ void testApp::draw() } -//-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button) { diff --git a/of/Active Tripod/src/visual/Scene.cpp b/of/Active Tripod/src/visual/Scene.cpp index 8597358..797d841 100644 --- a/of/Active Tripod/src/visual/Scene.cpp +++ b/of/Active Tripod/src/visual/Scene.cpp @@ -132,6 +132,12 @@ void Scene::drawTextBox(string copy, string align) } +void Scene::addNewData(vector newData) +{ + barGraph.addNewData(newData); + bodyGraph.addNewData(newData); +} + void Scene::keyPressed(int key) { diff --git a/of/Active Tripod/src/visual/Scene.h b/of/Active Tripod/src/visual/Scene.h index 5e5950d..c403f00 100644 --- a/of/Active Tripod/src/visual/Scene.h +++ b/of/Active Tripod/src/visual/Scene.h @@ -11,6 +11,7 @@ #include "ofMain.h" #include "BarGraph.h" #include "BodyGraph.h" +#include "DataManager.h" #include "ofxFTGL.h" class testApp; @@ -25,6 +26,7 @@ public: void drawHUDBG(); void drawHUDCopy(); void drawTextBox(string copy, string align); + void addNewData(vector newData); void keyPressed(int key); BarGraph barGraph; diff --git a/of/Active Tripod/src/visual/graph/BodyGraph.cpp b/of/Active Tripod/src/visual/graph/BodyGraph.cpp index 8a8e9db..716f8bc 100644 --- a/of/Active Tripod/src/visual/graph/BodyGraph.cpp +++ b/of/Active Tripod/src/visual/graph/BodyGraph.cpp @@ -33,13 +33,24 @@ void BodyGraph::draw() // ofPopStyle(); //} + + float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent; + 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++) { - //body.addVertex(ofVec3f(i * graphItemXGap, publisher0Data[i], 0)); - //body.addVertex(ofVec3f(i * graphItemXGap, publisher1Data[i], 0)); + 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])); @@ -48,20 +59,31 @@ void BodyGraph::draw() body.drawFaces(); + // draw lines + ofPushStyle(); + ofPolyline poly0; + ofPolyline poly1; for (int i = 0; i < publisher0Data.size() - 1; i++) { - if (i < publisher0Data.size() - 2) + if (i < publisher0Data.size() - 1) { - //ofPushStyle(); - //ofSetLineWidth(lineWidth); - //ofSetColor(col0[0],col0[1],col0[2], 255); - //ofLine(i * graphItemXGap, publisher0Data[i], (i + 1) * graphItemXGap, publisher0Data[i + 1]); - //ofSetColor(col1[0],col1[1],col1[2], 255); - //ofLine(i * graphItemXGap, publisher1Data[i], (i + 1) * graphItemXGap, publisher1Data[i + 1]); - //ofPopStyle(); + 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(); } }