Publisher text added rendered

- Colour key added to text boxes - the position and thickness is
adjustable in GUI
This commit is contained in:
James Alliban 2014-01-10 03:31:45 +00:00
parent 72b3f96b71
commit e4861134d1
11 changed files with 115 additions and 39 deletions

View File

@ -1,22 +1,22 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>X Margin</Name> <Name>X Margin</Name>
<Value>90.460525513</Value> <Value>64.144737244</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Y Margin</Name> <Name>Y Margin</Name>
<Value>87.171058655</Value> <Value>80.592102051</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Y Margin Bottom Offset</Name> <Name>Y Margin Bottom Offset</Name>
<Value>92.763160706</Value> <Value>54.276313782</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Line Length</Name> <Name>Line Length</Name>
<Value>380.098693848</Value> <Value>360.855255127</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
@ -28,6 +28,11 @@
<Name>Text Size</Name> <Name>Text Size</Name>
<Value>21.842105865</Value> <Value>21.842105865</Value>
</Widget> </Widget>
<Widget>
<Kind>4</Kind>
<Name>Value average amount</Name>
<Value>3.006578922</Value>
</Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Red</Name> <Name>Red</Name>
@ -48,3 +53,18 @@
<Name>Alpha</Name> <Name>Alpha</Name>
<Value>255.000000000</Value> <Value>255.000000000</Value>
</Widget> </Widget>
<Widget>
<Kind>4</Kind>
<Name>Top Colour Box X Offset</Name>
<Value>-33.552642822</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Bottom Colour Box X Offset</Name>
<Value>73.026336670</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Colour Box Thickness</Name>
<Value>6.319078922</Value>
</Widget>

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>1</Value> <Value>0</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>

View File

@ -62,6 +62,7 @@ void GUI::addGraphGlobalGUI()
graphNames.push_back("Line fade graph"); graphNames.push_back("Line fade graph");
gui->addRadio("Graph Selection", graphNames, OFX_UI_ORIENTATION_VERTICAL, dim*2, dim*2); gui->addRadio("Graph Selection", graphNames, OFX_UI_ORIENTATION_VERTICAL, dim*2, dim*2);
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);
@ -80,12 +81,13 @@ void GUI::addBarGraphDesignGUI()
gui->addSlider("Graph Item X Gap", 5, 50, &app->scene.barGraph.graphItemXGap, length, dim); 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("BarWidth", 2, 50, &app->scene.barGraph.barWidth, length, dim);
gui->addSlider("Graph Height Max", 100, 1000, &app->scene.barGraph.graphHeightMax, 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 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 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 blue", 0, 255, &app->scene.barGraph.col0[2], length, dim);
gui->addSlider("Data0 alpha", 0, 255, &app->scene.barGraph.col0[3], length, dim); gui->addSlider("Data0 alpha", 0, 255, &app->scene.barGraph.col0[3], length, dim);
gui->addSpacer(length, 1); gui->addSpacer(length, 1);
gui->addSlider("Data1 red", 0, 255, &app->scene.barGraph.col1[0], length, dim); 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 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("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);
gui->addSpacer(length, 1);
gui->addSpacer(length, 1);
gui->addSlider("Data0 red", 0, 255, &app->scene.bodyGraph.col0[0], length, dim); 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 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 blue", 0, 255, &app->scene.bodyGraph.col0[2], length, dim);
gui->addSlider("Data0 alpha", 0, 255, &app->scene.bodyGraph.col0[3], length, dim); gui->addSlider("Data0 alpha", 0, 255, &app->scene.bodyGraph.col0[3], length, dim);
gui->addSpacer(length, 1); gui->addSpacer(length, 1);
gui->addSlider("Data1 red", 0, 255, &app->scene.bodyGraph.col1[0], length, dim); 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 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("Green", 0, 2, &app->scene.green, length, dim);
gui->addSlider("Blue", 0, 2, &app->scene.blue, length, dim); gui->addSlider("Blue", 0, 2, &app->scene.blue, length, dim);
gui->addSlider("Alpha", 0, 2, &app->scene.alpha, length, dim); gui->addSlider("Alpha", 0, 2, &app->scene.alpha, length, dim);
gui->addSpacer(length, 1); gui->addSpacer(length, 1);
gui->addLabel("HUD BACKGROUND SETTINGS"); gui->addLabel("HUD BACKGROUND SETTINGS");
gui->addSlider("Red .", 0, 255, &app->scene.hudColour[0], length, dim); gui->addSlider("Red .", 0, 255, &app->scene.hudColour[0], length, dim);
@ -176,12 +180,20 @@ 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->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);
gui->addSlider("Green", 0, 255, &app->scene.textColour[1], 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("Blue", 0, 255, &app->scene.textColour[2], length, dim);
gui->addSlider("Alpha", 0, 255, &app->scene.textColour[3], 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); ofAddListener(gui->newGUIEvent, this, &GUI::variousGUIEvent);
finaliseCanvas(gui, true); finaliseCanvas(gui, true);
} }
@ -208,19 +220,6 @@ void GUI::addVariousGUI()
void GUI::update()
{
}
void GUI::draw()
{
}
void GUI::graphGlobalGUIEvent(ofxUIEventArgs &e) void GUI::graphGlobalGUIEvent(ofxUIEventArgs &e)
{ {
string name = e.widget->getName(); string name = e.widget->getName();

View File

@ -31,8 +31,7 @@ public:
void graphGlobalGUIEvent(ofxUIEventArgs &e); void graphGlobalGUIEvent(ofxUIEventArgs &e);
void variousGUIEvent(ofxUIEventArgs &e); void variousGUIEvent(ofxUIEventArgs &e);
virtual void update();
virtual void draw();
testApp* app; testApp* app;
vector<string> publishers; vector<string> publishers;

View File

@ -2,7 +2,7 @@
// TODO // TODO
// ==== // ====
// - Add video camera feed // - Add spacebrew text to text boxes
// - Add colour boxes to text // - Add colour boxes to text
// - 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
// - Make 3rd graph - separate fade // - Make 3rd graph - separate fade

View File

@ -19,9 +19,6 @@ void Scene::setup()
barGraph.setup(); barGraph.setup();
bodyGraph.setup(); bodyGraph.setup();
//activeGraph = &barGraph;
//text.loadFont("fonts/Roboto-Regular.ttf", 8);
text.loadFont("fonts/Roboto-Light.ttf", 8); text.loadFont("fonts/Roboto-Light.ttf", 8);
} }
@ -35,7 +32,6 @@ void Scene::update()
text.setLineLength(lineLength); text.setLineLength(lineLength);
text.setLineSpacing(lineSpacing); text.setLineSpacing(lineSpacing);
text.setSize(textSize); text.setSize(textSize);
} }
@ -45,6 +41,7 @@ void Scene::draw()
activeGraph->draw(); activeGraph->draw();
drawHUDBG(); drawHUDBG();
drawHUDCopy(); drawHUDCopy();
drawHUDColourBars();
} }
void Scene::drawVideo() void Scene::drawVideo()
@ -96,15 +93,37 @@ void Scene::drawHUDBG()
void Scene::drawHUDCopy() void Scene::drawHUDCopy()
{ {
string tlStr = "TOP LEFT\nThis is some text\nthis is some more text\na little more";
drawTextBox(tlStr, "TOP LEFT"); 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"); drawTextBox(trStr, "TOP RIGHT");
string blStr = "BOTTOM LEFT\nThis is some text\nthis is some more text";
vector<DataObject> *p0Data = &activeGraph->publisher0Data;
vector<DataObject> *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"); drawTextBox(blStr, "BOTTOM LEFT");
string brStr = "BOTTOM RIGHT\nThis is some text\nthis is some more text\na little more";
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"); drawTextBox(brStr, "BOTTOM RIGHT");
} }
}
void Scene::drawTextBox(string copy, string align) void Scene::drawTextBox(string copy, string align)
@ -114,8 +133,8 @@ void Scene::drawTextBox(string copy, string align)
ofPushMatrix(); ofPushMatrix();
if (align == "TOP LEFT") if (align == "TOP LEFT")
{ {
ofTranslate(xMargin, yMargin);
text.setAlignment(FTGL_ALIGN_LEFT); text.setAlignment(FTGL_ALIGN_LEFT);
ofTranslate(xMargin, yMargin);
} }
else if (align == "TOP RIGHT") else if (align == "TOP RIGHT")
{ {
@ -135,15 +154,44 @@ void Scene::drawTextBox(string copy, string align)
text.drawString(copy, 0, 0); text.drawString(copy, 0, 0);
//printf("%s text.getXHeight() = %f\n", align.c_str(), text.getStringBoundingBox(copy, xMargin, yMargin));
ofPopMatrix(); ofPopMatrix();
ofPopStyle(); 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<DataObject> newData) void Scene::addNewData(vector<DataObject> newData)
{ {
barGraph.addNewData(newData); barGraph.addNewData(newData);
bodyGraph.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();
} }

View File

@ -25,6 +25,7 @@ public:
void drawVideo(); void drawVideo();
void drawHUDBG(); void drawHUDBG();
void drawHUDCopy(); void drawHUDCopy();
void drawHUDColourBars();
void drawTextBox(string copy, string align); void drawTextBox(string copy, string align);
void addNewData(vector<DataObject> newData); void addNewData(vector<DataObject> newData);
void keyPressed(int key); void keyPressed(int key);
@ -65,4 +66,15 @@ public:
float lineSpacing; float lineSpacing;
float textSize; float textSize;
float textColour[4]; float textColour[4];
string tlStr;
string trStr;
string blStr;
string brStr;
long millisAtLastData;
float averageAmount;
// text colour boxes
float topColourBoxXOffset;
float bottomColourBoxXOffset;
float colourBoxThickness;
}; };

View File

@ -30,4 +30,7 @@ public:
float graphHeightMax; float graphHeightMax;
float col0[4];
float col1[4];
}; };

View File

@ -13,8 +13,6 @@ public:
float barWidth; float barWidth;
float col0[4];
float col1[4];
}; };

View File

@ -14,7 +14,4 @@ public:
float barWidth; float barWidth;
float lineWidth; float lineWidth;
float col0[4];
float col1[4];
}; };