diff --git a/of/Active Tripod/bin/Active_Tripod.lib b/of/Active Tripod/bin/Active_Tripod.lib index e5bbfb7..920dcf1 100644 Binary files a/of/Active Tripod/bin/Active_Tripod.lib and b/of/Active Tripod/bin/Active_Tripod.lib differ diff --git a/of/Active Tripod/bin/data/GUI/HUD TEXTguiPagesettings.xml b/of/Active Tripod/bin/data/GUI/HUD TEXTguiPagesettings.xml index 977081f..6b837a7 100644 --- a/of/Active Tripod/bin/data/GUI/HUD TEXTguiPagesettings.xml +++ b/of/Active Tripod/bin/data/GUI/HUD TEXTguiPagesettings.xml @@ -1,22 +1,22 @@ 4 X Margin - 90.460525513 + 64.144737244 4 Y Margin - 87.171058655 + 80.592102051 4 Y Margin Bottom Offset - 92.763160706 + 54.276313782 4 Line Length - 380.098693848 + 360.855255127 4 @@ -28,6 +28,11 @@ Text Size 21.842105865 + + 4 + Value average amount + 3.006578922 + 4 Red @@ -48,3 +53,18 @@ Alpha 255.000000000 + + 4 + Top Colour Box X Offset + -33.552642822 + + + 4 + Bottom Colour Box X Offset + 73.026336670 + + + 4 + Colour Box Thickness + 6.319078922 + 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/gui/GUI.cpp b/of/Active Tripod/src/gui/GUI.cpp index 36e66f0..e86248d 100644 --- a/of/Active Tripod/src/gui/GUI.cpp +++ b/of/Active Tripod/src/gui/GUI.cpp @@ -62,6 +62,7 @@ void GUI::addGraphGlobalGUI() graphNames.push_back("Line fade graph"); gui->addRadio("Graph Selection", graphNames, OFX_UI_ORIENTATION_VERTICAL, dim*2, dim*2); + gui->addSpacer(length, 1); gui->addRangeSlider("Graph X begin/end (percent)", 0, 1, &AbstractGraph::minGraphPercent, &AbstractGraph::maxGraphPercent, length, dim); @@ -80,12 +81,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->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); @@ -104,12 +106,13 @@ 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->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); @@ -150,6 +153,7 @@ void GUI::addBackgroundGUI() gui->addSlider("Green", 0, 2, &app->scene.green, length, dim); gui->addSlider("Blue", 0, 2, &app->scene.blue, length, dim); gui->addSlider("Alpha", 0, 2, &app->scene.alpha, length, dim); + gui->addSpacer(length, 1); gui->addLabel("HUD BACKGROUND SETTINGS"); gui->addSlider("Red .", 0, 255, &app->scene.hudColour[0], length, dim); @@ -176,11 +180,19 @@ 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->addSpacer(length, 1); gui->addSlider("Red", 0, 255, &app->scene.textColour[0], length, dim); gui->addSlider("Green", 0, 255, &app->scene.textColour[1], length, dim); gui->addSlider("Blue", 0, 255, &app->scene.textColour[2], length, dim); gui->addSlider("Alpha", 0, 255, &app->scene.textColour[3], length, dim); + + gui->addSpacer(length, 1); + gui->addLabel("COLOUR KEY"); + gui->addSlider("Top Colour Box X Offset", -300, 300, &app->scene.topColourBoxXOffset, length, dim); + gui->addSlider("Bottom Colour Box X Offset", -300, 300, &app->scene.bottomColourBoxXOffset, length, dim); + gui->addSlider("Colour Box Thickness", 1, 50, &app->scene.colourBoxThickness, length, dim); ofAddListener(gui->newGUIEvent, this, &GUI::variousGUIEvent); finaliseCanvas(gui, true); @@ -208,19 +220,6 @@ void GUI::addVariousGUI() - -void GUI::update() -{ - -} - - -void GUI::draw() -{ -} - - - void GUI::graphGlobalGUIEvent(ofxUIEventArgs &e) { string name = e.widget->getName(); diff --git a/of/Active Tripod/src/gui/GUI.h b/of/Active Tripod/src/gui/GUI.h index aef1cb4..cacd433 100644 --- a/of/Active Tripod/src/gui/GUI.h +++ b/of/Active Tripod/src/gui/GUI.h @@ -31,8 +31,7 @@ public: void graphGlobalGUIEvent(ofxUIEventArgs &e); void variousGUIEvent(ofxUIEventArgs &e); - virtual void update(); - virtual void draw(); + testApp* app; vector publishers; diff --git a/of/Active Tripod/src/testApp.cpp b/of/Active Tripod/src/testApp.cpp index f15f4a8..1fd0b2e 100644 --- a/of/Active Tripod/src/testApp.cpp +++ b/of/Active Tripod/src/testApp.cpp @@ -2,7 +2,7 @@ // TODO // ==== -// - Add video camera feed +// - Add spacebrew text to text boxes // - 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 diff --git a/of/Active Tripod/src/visual/Scene.cpp b/of/Active Tripod/src/visual/Scene.cpp index ed637b0..a816f0d 100644 --- a/of/Active Tripod/src/visual/Scene.cpp +++ b/of/Active Tripod/src/visual/Scene.cpp @@ -19,9 +19,6 @@ void Scene::setup() barGraph.setup(); bodyGraph.setup(); - //activeGraph = &barGraph; - - //text.loadFont("fonts/Roboto-Regular.ttf", 8); text.loadFont("fonts/Roboto-Light.ttf", 8); } @@ -35,7 +32,6 @@ void Scene::update() text.setLineLength(lineLength); text.setLineSpacing(lineSpacing); text.setSize(textSize); - } @@ -45,6 +41,7 @@ void Scene::draw() activeGraph->draw(); drawHUDBG(); drawHUDCopy(); + drawHUDColourBars(); } void Scene::drawVideo() @@ -96,14 +93,36 @@ void Scene::drawHUDBG() void Scene::drawHUDCopy() { - string tlStr = "TOP LEFT\nThis is some text\nthis is some more text\na little more"; drawTextBox(tlStr, "TOP LEFT"); - string trStr = "TOP RIGHT\nThis is some text\nthis is some more text\na little more\none more line"; drawTextBox(trStr, "TOP RIGHT"); - string blStr = "BOTTOM LEFT\nThis is some text\nthis is some more text"; - drawTextBox(blStr, "BOTTOM LEFT"); - string brStr = "BOTTOM RIGHT\nThis is some text\nthis is some more text\na little more"; - drawTextBox(brStr, "BOTTOM RIGHT"); + + vector *p0Data = &activeGraph->publisher0Data; + vector *p1Data = &activeGraph->publisher1Data; + + if (p0Data->size() > (int)averageAmount - 1) + { + float average0 = 0; + for (int i = 0; i < (int)averageAmount; i++) + average0 += p0Data->at(p0Data->size() - i - 1).value; + average0 /= (int)averageAmount; + + // (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" + + "Running average: " + ofToString(average0); + drawTextBox(blStr, "BOTTOM LEFT"); + + + float average1 = 0; + for (int i = 0; i < (int)averageAmount; i++) + average1 += p1Data->at(p1Data->size() - i - 1).value; + average1 /= (int)averageAmount; + + brStr = ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "m/s\n" + + ofToString(p1Data->back().value) + "\n" + + "Running average: " + ofToString(average1); + drawTextBox(brStr, "BOTTOM RIGHT"); + } } @@ -114,8 +133,8 @@ void Scene::drawTextBox(string copy, string align) ofPushMatrix(); if (align == "TOP LEFT") { - ofTranslate(xMargin, yMargin); text.setAlignment(FTGL_ALIGN_LEFT); + ofTranslate(xMargin, yMargin); } else if (align == "TOP RIGHT") { @@ -134,16 +153,45 @@ void Scene::drawTextBox(string copy, string align) } text.drawString(copy, 0, 0); + + //printf("%s text.getXHeight() = %f\n", align.c_str(), text.getStringBoundingBox(copy, xMargin, yMargin)); ofPopMatrix(); ofPopStyle(); } + +void Scene::drawHUDColourBars() +{ + ofPushStyle(); + + ofSetColor(activeGraph->col0[0], activeGraph->col0[1], activeGraph->col0[2], activeGraph->col0[3]); + ofRect(xMargin, yMargin + topColourBoxXOffset, lineLength, colourBoxThickness); + + ofSetColor(activeGraph->col0[0], activeGraph->col0[1], activeGraph->col0[2], activeGraph->col0[3]); + ofRect(xMargin, ofGetHeight() - yMargin - yMarginBottomOffset + bottomColourBoxXOffset, lineLength, colourBoxThickness); + + ofSetColor(activeGraph->col1[0], activeGraph->col1[1], activeGraph->col1[2], activeGraph->col1[3]); + ofRect(ofGetWidth() - xMargin - lineLength, yMargin + topColourBoxXOffset, lineLength, colourBoxThickness); + + ofSetColor(activeGraph->col1[0], activeGraph->col1[1], activeGraph->col1[2], activeGraph->col1[3]); + ofRect(ofGetWidth() - xMargin - lineLength, ofGetHeight() - yMargin - yMarginBottomOffset + bottomColourBoxXOffset, lineLength, colourBoxThickness); + + ofPopStyle(); +} + + + void Scene::addNewData(vector newData) { barGraph.addNewData(newData); bodyGraph.addNewData(newData); + + tlStr = newData[0].info + "\n" + ofToString(newData[0].value); + trStr = newData[1].info + "\n" + ofToString(newData[1].value); + + millisAtLastData = ofGetElapsedTimeMillis(); } diff --git a/of/Active Tripod/src/visual/Scene.h b/of/Active Tripod/src/visual/Scene.h index b1cc87e..570c09f 100644 --- a/of/Active Tripod/src/visual/Scene.h +++ b/of/Active Tripod/src/visual/Scene.h @@ -25,6 +25,7 @@ public: void drawVideo(); void drawHUDBG(); void drawHUDCopy(); + void drawHUDColourBars(); void drawTextBox(string copy, string align); void addNewData(vector newData); void keyPressed(int key); @@ -65,4 +66,15 @@ public: float lineSpacing; float textSize; float textColour[4]; + string tlStr; + string trStr; + string blStr; + string brStr; + long millisAtLastData; + float averageAmount; + + // text colour boxes + float topColourBoxXOffset; + float bottomColourBoxXOffset; + float colourBoxThickness; }; \ No newline at end of file diff --git a/of/Active Tripod/src/visual/graph/AbstractGraph.h b/of/Active Tripod/src/visual/graph/AbstractGraph.h index 386ff36..6ad1b01 100644 --- a/of/Active Tripod/src/visual/graph/AbstractGraph.h +++ b/of/Active Tripod/src/visual/graph/AbstractGraph.h @@ -30,4 +30,7 @@ public: float graphHeightMax; + float col0[4]; + float col1[4]; + }; \ No newline at end of file diff --git a/of/Active Tripod/src/visual/graph/BarGraph.h b/of/Active Tripod/src/visual/graph/BarGraph.h index 99d9a15..05d0bef 100644 --- a/of/Active Tripod/src/visual/graph/BarGraph.h +++ b/of/Active Tripod/src/visual/graph/BarGraph.h @@ -13,8 +13,6 @@ public: float barWidth; - float col0[4]; - float col1[4]; }; \ No newline at end of file diff --git a/of/Active Tripod/src/visual/graph/BodyGraph.h b/of/Active Tripod/src/visual/graph/BodyGraph.h index 2743edd..30c0732 100644 --- a/of/Active Tripod/src/visual/graph/BodyGraph.h +++ b/of/Active Tripod/src/visual/graph/BodyGraph.h @@ -14,7 +14,4 @@ public: float barWidth; float lineWidth; - - float col0[4]; - float col1[4]; }; \ No newline at end of file