diff --git a/of/Active Tripod/bin/Active_Tripod.lib b/of/Active Tripod/bin/Active_Tripod.lib index 5fbc4bb..75a6190 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/GRAPH GLOBALguiPagesettings.xml b/of/Active Tripod/bin/data/GUI/GRAPH GLOBALguiPagesettings.xml index 3e679a7..9b630a1 100644 --- a/of/Active Tripod/bin/data/GUI/GRAPH GLOBALguiPagesettings.xml +++ b/of/Active Tripod/bin/data/GUI/GRAPH GLOBALguiPagesettings.xml @@ -24,11 +24,6 @@ 0.779605269 0.059210528 - - 4 - Size - 29.424343109 - 4 Decimal points 0 @@ -39,6 +34,11 @@ Decimal points 1 2.332236767 + + 4 + Size + 28.536182404 + 4 Red @@ -59,3 +59,28 @@ Alpha 255.000000000 + + 4 + Graph Text Rect Margin + 9.394737244 + + + 4 + Graph Text RectRed + 44.457237244 + + + 4 + Graph Text RectGreen + 47.812500000 + + + 4 + Graph Text RectBlue + 46.973682404 + + + 4 + Graph Text RectAlpha + 140.921051025 + diff --git a/of/Active Tripod/src/gui/GUI.cpp b/of/Active Tripod/src/gui/GUI.cpp index ffb96ed..0f8b14b 100644 --- a/of/Active Tripod/src/gui/GUI.cpp +++ b/of/Active Tripod/src/gui/GUI.cpp @@ -72,15 +72,23 @@ void GUI::addGraphGlobalGUI() gui->addSpacer(length, 1); gui->addRangeSlider("Graph X begin/end (percent)", 0, 1, &AbstractGraph::minGraphPercent, &AbstractGraph::maxGraphPercent, length, dim); + gui->addSpacer(length, 1); + gui->addSlider("Decimal points 0", 1, 10, &app->scene.valDecimalPoints0, length, dim); + gui->addSlider("Decimal points 1", 1, 10, &app->scene.valDecimalPoints1, length, dim); + gui->addLabel("GRAPH TEXT"); gui->addSpacer(length, 1); gui->addSlider("Size", 5, 50, &app->scene.graphTextSize, length, dim); - gui->addSlider("Decimal points 0", 1, 10, &app->scene.valDecimalPoints0, length, dim); - gui->addSlider("Decimal points 1", 1, 10, &app->scene.valDecimalPoints1, length, dim); gui->addSlider("Red", 0, 255, &app->scene.graphTextColour[0], length, dim); gui->addSlider("Green", 0, 255, &app->scene.graphTextColour[1], length, dim); gui->addSlider("Blue", 0, 255, &app->scene.graphTextColour[2], length, dim); gui->addSlider("Alpha", 0, 255, &app->scene.graphTextColour[3], length, dim); + gui->addSpacer(length, 1); + gui->addSlider("Graph Text Rect Margin", 1, 30, &app->scene.hudTextRectMargin, length, dim); + gui->addSlider("Graph Text RectRed", 0, 255, &app->scene.graphTextRectCol[0], length, dim); + gui->addSlider("Graph Text RectGreen", 0, 255, &app->scene.graphTextRectCol[1], length, dim); + gui->addSlider("Graph Text RectBlue", 0, 255, &app->scene.graphTextRectCol[2], length, dim); + gui->addSlider("Graph Text RectAlpha", 0, 255, &app->scene.graphTextRectCol[3], length, dim); ofAddListener(gui->newGUIEvent, this, &GUI::graphGlobalGUIEvent); finaliseCanvas(gui, true); diff --git a/of/Active Tripod/src/visual/Scene.cpp b/of/Active Tripod/src/visual/Scene.cpp index 05f4581..6a0e7ed 100644 --- a/of/Active Tripod/src/visual/Scene.cpp +++ b/of/Active Tripod/src/visual/Scene.cpp @@ -93,14 +93,34 @@ void Scene::drawGraphValues() text.setAlignment(FTGL_ALIGN_LEFT); ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]); text.setSize(graphTextSize); - text.drawString( - stringVal0 + " " + activeGraph->publisher0Data.back().unitMeasure, - val0.x + 10, - val0.y); - text.drawString( - stringVal1 + " " + activeGraph->publisher1Data.back().unitMeasure, - val1.x + 10, - val1.y); + + string copy0 = stringVal0 + " " + activeGraph->publisher0Data.back().unitMeasure; + bool isDescender = doesStringContainDescender(copy0); + ofRectangle rect = text.getStringBoundingBox(copy0, val0.x + 10, val0.y); + ofSetColor(graphTextRectCol[0], graphTextRectCol[1], graphTextRectCol[2], graphTextRectCol[3]); + + ofRect(rect.x - hudTextRectMargin, + rect.y - rect.height - hudTextRectMargin - ((isDescender) ? text.getDescender() : 0), + rect.width + (hudTextRectMargin*2), + rect.height + (hudTextRectMargin*2) - ((isDescender) ? text.getDescender()*0.5 : 0)); + + ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]); + text.drawString(copy0, val0.x + 10, val0.y); + + + string copy1 = stringVal1 + " " + activeGraph->publisher1Data.back().unitMeasure; + isDescender = doesStringContainDescender(copy1); + rect = text.getStringBoundingBox(copy1, val1.x + 10, val1.y); + ofSetColor(graphTextRectCol[0], graphTextRectCol[1], graphTextRectCol[2], graphTextRectCol[3]); + + ofRect(rect.x - hudTextRectMargin, + rect.y - rect.height - hudTextRectMargin - ((isDescender) ? text.getDescender() : 0), + rect.width + (hudTextRectMargin*2), + rect.height + (hudTextRectMargin*2) - ((isDescender) ? text.getDescender()*0.5 : 0)); + + ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]); + text.drawString(copy1, val1.x + 10, val1.y); + ofPopStyle(); } @@ -396,4 +416,38 @@ string Scene::reduceDecimalCount(string num, int maxDecimal) { return num; } +} + + + +bool Scene::doesStringContainDescender(string copy) +{ + //if (letter == 'b' || + // letter == 'd' || + // letter == 'f' || + // letter == 'h' || + // letter == 'i' || + // letter == 'j' || + // letter == 'k' || + // letter == 'l' || + // letter == 't' || + // ((int)letter > 32 && (int)letter < 91)) + //{ + // doesTextContainAscender = true; + //} + + for (int i = 0; i < copy.size(); i++) + { + char letter = copy[i]; + //printf("letter:%c\n", letter); + if (letter == 'g' || + letter == 'j' || + letter == 'p' || + letter == 'q' || + letter == 'y') + { + return true; + } + } + return false; } \ No newline at end of file diff --git a/of/Active Tripod/src/visual/Scene.h b/of/Active Tripod/src/visual/Scene.h index 967bd13..34b7d94 100644 --- a/of/Active Tripod/src/visual/Scene.h +++ b/of/Active Tripod/src/visual/Scene.h @@ -29,6 +29,7 @@ public: void keyPressed(int key); string addCommasToNumberString(string num); string reduceDecimalCount(string num, int maxDecimal); + bool doesStringContainDescender(string copy); BarGraph barGraph; BodyGraph bodyGraph; @@ -87,6 +88,9 @@ public: string brStr; float averageAmount; + float hudTextRectMargin; + float graphTextRectCol[4]; + bool isClearOnNewMinMax; // text colour boxes