Added coloured rectangles to graph text
Avoids overlapping text
This commit is contained in:
parent
78c8e50351
commit
c542bcf317
Binary file not shown.
@ -24,11 +24,6 @@
|
|||||||
<HighValue>0.779605269</HighValue>
|
<HighValue>0.779605269</HighValue>
|
||||||
<LowValue>0.059210528</LowValue>
|
<LowValue>0.059210528</LowValue>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget>
|
|
||||||
<Kind>4</Kind>
|
|
||||||
<Name>Size</Name>
|
|
||||||
<Value>29.424343109</Value>
|
|
||||||
</Widget>
|
|
||||||
<Widget>
|
<Widget>
|
||||||
<Kind>4</Kind>
|
<Kind>4</Kind>
|
||||||
<Name>Decimal points 0</Name>
|
<Name>Decimal points 0</Name>
|
||||||
@ -39,6 +34,11 @@
|
|||||||
<Name>Decimal points 1</Name>
|
<Name>Decimal points 1</Name>
|
||||||
<Value>2.332236767</Value>
|
<Value>2.332236767</Value>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Size</Name>
|
||||||
|
<Value>28.536182404</Value>
|
||||||
|
</Widget>
|
||||||
<Widget>
|
<Widget>
|
||||||
<Kind>4</Kind>
|
<Kind>4</Kind>
|
||||||
<Name>Red</Name>
|
<Name>Red</Name>
|
||||||
@ -59,3 +59,28 @@
|
|||||||
<Name>Alpha</Name>
|
<Name>Alpha</Name>
|
||||||
<Value>255.000000000</Value>
|
<Value>255.000000000</Value>
|
||||||
</Widget>
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Graph Text Rect Margin</Name>
|
||||||
|
<Value>9.394737244</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Graph Text RectRed</Name>
|
||||||
|
<Value>44.457237244</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Graph Text RectGreen</Name>
|
||||||
|
<Value>47.812500000</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Graph Text RectBlue</Name>
|
||||||
|
<Value>46.973682404</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Graph Text RectAlpha</Name>
|
||||||
|
<Value>140.921051025</Value>
|
||||||
|
</Widget>
|
||||||
|
|||||||
@ -72,15 +72,23 @@ void GUI::addGraphGlobalGUI()
|
|||||||
gui->addSpacer(length, 1);
|
gui->addSpacer(length, 1);
|
||||||
gui->addRangeSlider("Graph X begin/end (percent)", 0, 1, &AbstractGraph::minGraphPercent, &AbstractGraph::maxGraphPercent, length, dim);
|
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->addLabel("GRAPH TEXT");
|
||||||
gui->addSpacer(length, 1);
|
gui->addSpacer(length, 1);
|
||||||
gui->addSlider("Size", 5, 50, &app->scene.graphTextSize, length, dim);
|
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("Red", 0, 255, &app->scene.graphTextColour[0], length, dim);
|
||||||
gui->addSlider("Green", 0, 255, &app->scene.graphTextColour[1], 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("Blue", 0, 255, &app->scene.graphTextColour[2], length, dim);
|
||||||
gui->addSlider("Alpha", 0, 255, &app->scene.graphTextColour[3], 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);
|
ofAddListener(gui->newGUIEvent, this, &GUI::graphGlobalGUIEvent);
|
||||||
finaliseCanvas(gui, true);
|
finaliseCanvas(gui, true);
|
||||||
|
|||||||
@ -93,14 +93,34 @@ void Scene::drawGraphValues()
|
|||||||
text.setAlignment(FTGL_ALIGN_LEFT);
|
text.setAlignment(FTGL_ALIGN_LEFT);
|
||||||
ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]);
|
ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]);
|
||||||
text.setSize(graphTextSize);
|
text.setSize(graphTextSize);
|
||||||
text.drawString(
|
|
||||||
stringVal0 + " " + activeGraph->publisher0Data.back().unitMeasure,
|
string copy0 = stringVal0 + " " + activeGraph->publisher0Data.back().unitMeasure;
|
||||||
val0.x + 10,
|
bool isDescender = doesStringContainDescender(copy0);
|
||||||
val0.y);
|
ofRectangle rect = text.getStringBoundingBox(copy0, val0.x + 10, val0.y);
|
||||||
text.drawString(
|
ofSetColor(graphTextRectCol[0], graphTextRectCol[1], graphTextRectCol[2], graphTextRectCol[3]);
|
||||||
stringVal1 + " " + activeGraph->publisher1Data.back().unitMeasure,
|
|
||||||
val1.x + 10,
|
ofRect(rect.x - hudTextRectMargin,
|
||||||
val1.y);
|
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();
|
ofPopStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,4 +416,38 @@ string Scene::reduceDecimalCount(string num, int maxDecimal)
|
|||||||
{
|
{
|
||||||
return num;
|
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;
|
||||||
}
|
}
|
||||||
@ -29,6 +29,7 @@ public:
|
|||||||
void keyPressed(int key);
|
void keyPressed(int key);
|
||||||
string addCommasToNumberString(string num);
|
string addCommasToNumberString(string num);
|
||||||
string reduceDecimalCount(string num, int maxDecimal);
|
string reduceDecimalCount(string num, int maxDecimal);
|
||||||
|
bool doesStringContainDescender(string copy);
|
||||||
|
|
||||||
BarGraph barGraph;
|
BarGraph barGraph;
|
||||||
BodyGraph bodyGraph;
|
BodyGraph bodyGraph;
|
||||||
@ -87,6 +88,9 @@ public:
|
|||||||
string brStr;
|
string brStr;
|
||||||
float averageAmount;
|
float averageAmount;
|
||||||
|
|
||||||
|
float hudTextRectMargin;
|
||||||
|
float graphTextRectCol[4];
|
||||||
|
|
||||||
bool isClearOnNewMinMax;
|
bool isClearOnNewMinMax;
|
||||||
|
|
||||||
// text colour boxes
|
// text colour boxes
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user