Values added to graph

- also, crosshairs added
This commit is contained in:
James Alliban 2014-01-12 04:43:19 +00:00
parent ec0b69726c
commit 1111d2f7e5
14 changed files with 133 additions and 67 deletions

View File

@ -1,12 +1,12 @@
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Toggle Video Visibility</Name> <Name>Toggle Video Visibility</Name>
<Value>1</Value> <Value>0</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Toggle Image Visibility</Name> <Name>Toggle Image Visibility</Name>
<Value>0</Value> <Value>1</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
@ -88,3 +88,18 @@
<Name>Circle Point Size</Name> <Name>Circle Point Size</Name>
<Value>52.302627563</Value> <Value>52.302627563</Value>
</Widget> </Widget>
<Widget>
<Kind>4</Kind>
<Name>Line Width</Name>
<Value>1.710526347</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Alpha ..</Name>
<Value>255.000000000</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Circle Size</Name>
<Value>15.460527420</Value>
</Widget>

View File

@ -6,7 +6,7 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>BarWidth</Name> <Name>BarWidth</Name>
<Value>5.631578922</Value> <Value>15.894737244</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>

View File

@ -1,7 +1,7 @@
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Bar graph</Name> <Name>Bar graph</Name>
<Value>0</Value> <Value>1</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
@ -11,7 +11,7 @@
<Widget> <Widget>
<Kind>2</Kind> <Kind>2</Kind>
<Name>Separate Body graph</Name> <Name>Separate Body graph</Name>
<Value>1</Value> <Value>0</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>6</Kind> <Kind>6</Kind>
@ -19,3 +19,28 @@
<HighValue>0.786184192</HighValue> <HighValue>0.786184192</HighValue>
<LowValue>0.059210528</LowValue> <LowValue>0.059210528</LowValue>
</Widget> </Widget>
<Widget>
<Kind>4</Kind>
<Name>Size</Name>
<Value>30.016448975</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Red</Name>
<Value>255.000000000</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Green</Name>
<Value>255.000000000</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Blue</Name>
<Value>255.000000000</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Alpha</Name>
<Value>255.000000000</Value>
</Widget>

View File

@ -21,7 +21,7 @@
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>
<Name>Graph bottom end (percent)</Name> <Name>Graph bottom end (percent)</Name>
<Value>0.875000000</Value> <Value>0.769736826</Value>
</Widget> </Widget>
<Widget> <Widget>
<Kind>4</Kind> <Kind>4</Kind>

View File

@ -46,6 +46,7 @@ void GUI::addKeyboardShortcutsGUI()
gui->addLabel("']' - NEXT GUI", OFX_UI_FONT_SMALL); gui->addLabel("']' - NEXT GUI", OFX_UI_FONT_SMALL);
gui->addLabel("'p' - TOGGLE PAUSE ANIMATION", OFX_UI_FONT_SMALL); gui->addLabel("'p' - TOGGLE PAUSE ANIMATION", OFX_UI_FONT_SMALL);
gui->addLabel("'f' - TOGGLE FULLSCREEN", OFX_UI_FONT_SMALL); gui->addLabel("'f' - TOGGLE FULLSCREEN", OFX_UI_FONT_SMALL);
gui->addLabel("'c' - CLEAR ALL GRAPH DATA", OFX_UI_FONT_SMALL);
finaliseCanvas(gui, true); finaliseCanvas(gui, true);
@ -67,6 +68,13 @@ 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->addLabel("GRAPH TEXT");
gui->addSpacer(length, 1);
gui->addSlider("Size", 5, 50, &app->scene.graphTextSize, 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);
ofAddListener(gui->newGUIEvent, this, &GUI::graphGlobalGUIEvent); ofAddListener(gui->newGUIEvent, this, &GUI::graphGlobalGUIEvent);
finaliseCanvas(gui, true); finaliseCanvas(gui, true);
@ -200,6 +208,10 @@ void GUI::addBackgroundGUI()
gui->addSlider("Hole Width Percent", 0, 2, &app->scene.hudHoleWidthPercentage, length, dim); gui->addSlider("Hole Width Percent", 0, 2, &app->scene.hudHoleWidthPercentage, length, dim);
gui->addSlider("Hole Height Percent", 0, 2, &app->scene.hudHoleHeightPercentage, length, dim); gui->addSlider("Hole Height Percent", 0, 2, &app->scene.hudHoleHeightPercentage, length, dim);
gui->addSlider("Circle Point Size", 0, 100, &app->scene.circlePointSize, length, dim); gui->addSlider("Circle Point Size", 0, 100, &app->scene.circlePointSize, length, dim);
gui->addLabel("CROSSHAIRS SETTINGS");
gui->addSlider("Line Width", 0, 10, &app->scene.crosshairLineWidth, length, dim);
gui->addSlider("Alpha ..", 0, 255, &app->scene.crosshairAlpha, length, dim);
gui->addSlider("Circle Size", 0, 100, &app->scene.crosshairCircleSize, length, dim);
ofAddListener(gui->newGUIEvent, this, &GUI::variousGUIEvent); ofAddListener(gui->newGUIEvent, this, &GUI::variousGUIEvent);
finaliseCanvas(gui, true); finaliseCanvas(gui, true);

View File

@ -2,11 +2,9 @@
// TODO // TODO
// ==== // ====
// - Crosshairs in HUD
// - Create graph animation system
// - make maxGraphHeight percentage instead of pixels
// - Create a single config file to be loaded from online location. It will contain IP address and host name
// - If min or max values change - clear graph - ask bout this // - If min or max values change - clear graph - ask bout this
// - Create a single config file to be loaded from online location. It will contain IP address and host name
// - Create graph animation system
// //
//-------------------------------------------------------------- //--------------------------------------------------------------
void testApp::setup() void testApp::setup()

View File

@ -29,10 +29,6 @@ void Scene::update()
vidGrabber.update(); vidGrabber.update();
activeGraph->update(); activeGraph->update();
text.setLineLength(lineLength);
text.setLineSpacing(lineSpacing);
text.setSize(textSize);
} }
@ -40,6 +36,8 @@ void Scene::draw()
{ {
drawVideo(); drawVideo();
activeGraph->draw(); activeGraph->draw();
drawGraphValues();
drawCrosshairs();
drawHUDBG(); drawHUDBG();
drawHUDCopy(); drawHUDCopy();
drawHUDColourBars(); drawHUDColourBars();
@ -71,6 +69,36 @@ void Scene::drawVideo()
rgbShader.end(); rgbShader.end();
} }
void Scene::drawGraphValues()
{
if (activeGraph->publisher0Data.size() < 2) return;
ofPoint val0 = activeGraph->currentPub0Point;
ofPoint val1 = activeGraph->currentPub1Point;
ofPushStyle();
text.setAlignment(FTGL_ALIGN_LEFT);
ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]);
text.setSize(graphTextSize);
text.drawString(ofToString(activeGraph->publisher0Data.back().value), val0.x + 10, val0.y);
text.drawString(ofToString(activeGraph->publisher1Data.back().value), val1.x + 10, val1.y);
ofPopStyle();
}
void Scene::drawCrosshairs()
{
ofPushStyle();
ofSetLineWidth(crosshairLineWidth);
ofSetColor(hudColour[0], hudColour[1], hudColour[2], crosshairAlpha);
ofLine(ofGetWidth() * 0.5, 0, ofGetWidth() * 0.5, ofGetHeight()); // vert
ofLine(0, ofGetHeight() * 0.5, ofGetWidth(), ofGetHeight() * 0.5); // horz
ofCircle(ofGetWidth() * 0.5, ofGetHeight() * 0.5, crosshairCircleSize);
ofPopStyle();
}
void Scene::drawHUDBG() void Scene::drawHUDBG()
{ {
ofPushStyle(); ofPushStyle();
@ -103,12 +131,16 @@ void Scene::drawHUDBG()
void Scene::drawHUDCopy() void Scene::drawHUDCopy()
{ {
text.setLineLength(lineLength);
text.setLineSpacing(lineSpacing);
text.setSize(textSize);
drawTextBox(tlStr, "TOP LEFT"); drawTextBox(tlStr, "TOP LEFT");
drawTextBox(trStr, "TOP RIGHT"); drawTextBox(trStr, "TOP RIGHT");
vector<DataObject> *p0Data = &activeGraph->publisher0Data; vector<DataObject> *p0Data = &activeGraph->publisher0Data;
vector<DataObject> *p1Data = &activeGraph->publisher1Data; vector<DataObject> *p1Data = &activeGraph->publisher1Data;
int amountToAverage = MIN(p0Data->size(), averageAmount); int amountToAverage = MIN(p0Data->size(), averageAmount);
if (p0Data->size() > 2) if (p0Data->size() > 2)
{ {

View File

@ -24,6 +24,8 @@ public:
void update(); void update();
void draw(); void draw();
void drawVideo(); void drawVideo();
void drawGraphValues();
void drawCrosshairs();
void drawHUDBG(); void drawHUDBG();
void drawHUDCopy(); void drawHUDCopy();
void drawHUDColourBars(); void drawHUDColourBars();
@ -58,7 +60,16 @@ public:
float videoHeightPercentage; float videoHeightPercentage;
bool isVideoVisible; bool isVideoVisible;
bool isImageVisible; bool isImageVisible;
// graph text
float graphTextColour[4];
float graphTextSize;
// crosshairs
float crosshairLineWidth;
float crosshairAlpha;
float crosshairCircleSize;
// HUD background vars // HUD background vars
float hudColour[4]; float hudColour[4];
float circlePointSize; float circlePointSize;

View File

@ -29,6 +29,7 @@ void AbstractGraph::draw()
} }
void AbstractGraph::addNewData(vector<DataObject> newData) void AbstractGraph::addNewData(vector<DataObject> newData)
{ {
publisher0Data.push_back(newData[0]); publisher0Data.push_back(newData[0]);

View File

@ -27,6 +27,9 @@ public:
static float minGraphPercent; static float minGraphPercent;
static float maxGraphPercent; static float maxGraphPercent;
ofPoint currentPub0Point;
ofPoint currentPub1Point;
float graphItemXGap; float graphItemXGap;

View File

@ -27,29 +27,6 @@ void BarGraph::draw()
if (publisher0Data.size() > 1) if (publisher0Data.size() > 1)
{ {
for (int i = 0; i < publisher0Data.size() - 1; i++)
{
if (i < publisher0Data.size() - 2)
{
//ofPushStyle();
//ofSetColor(0, 0, 0);
//ofLine(i * graphItemXGap, publisher0Data[i], (i + 1) * graphItemXGap, publisher0Data[i + 1]);
//ofSetColor(0, 0, 0);
//ofLine(i * graphItemXGap, publisher1Data[i], (i + 1) * graphItemXGap, publisher1Data[i + 1]);
//ofPopStyle();
}
}
for (int i = 0; i < publisher0Data.size() - 1; i++)
{
//ofPushStyle();
//ofSetColor(255, 0, 0);
//ofCircle(i * graphItemXGap, publisher0Data[i], 5);
//ofSetColor(0, 255, 0);
//ofCircle(i * graphItemXGap, publisher1Data[i], 5);
//ofPopStyle();
}
float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent; float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent;
float outputMin = (ofGetHeight() * 0.5) - ((ofGetHeight() * 0.5) * graphHeightMax); float outputMin = (ofGetHeight() * 0.5) - ((ofGetHeight() * 0.5) * graphHeightMax);
float outputMax = (ofGetHeight() * 0.5) + ((ofGetHeight() * 0.5) * graphHeightMax); float outputMax = (ofGetHeight() * 0.5) + ((ofGetHeight() * 0.5) * graphHeightMax);
@ -58,7 +35,6 @@ void BarGraph::draw()
{ {
ofPushStyle(); ofPushStyle();
ofMesh bar; ofMesh bar;
float rectTLX = i * graphItemXGap - (barWidth * 0.5) + xOffset; float rectTLX = i * graphItemXGap - (barWidth * 0.5) + xOffset;
float rectTLY = ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax); float rectTLY = ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax);
@ -72,9 +48,11 @@ void BarGraph::draw()
float rectBRX = i * graphItemXGap - (barWidth * 0.5) + barWidth + xOffset; float rectBRX = i * graphItemXGap - (barWidth * 0.5) + barWidth + xOffset;
float rectBRY = ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax); float rectBRY = ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax);
if (i == publisher0Data.size() - 2)
//printf("val:%f, min:%f, max:%f - new val:%f \n", publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, rectTLY); {
//printf("val:%f, min:%f, max:%f - new val:%f \n", publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, rectBLY); currentPub0Point = ofPoint(rectTRX, rectTRY);
currentPub1Point = ofPoint(rectBRX, rectBRY);
}
bar.addVertex(ofVec3f(rectTLX, rectTLY, 0)); bar.addVertex(ofVec3f(rectTLX, rectTLY, 0));
bar.addVertex(ofVec3f(rectTRX, rectTRY, 0)); bar.addVertex(ofVec3f(rectTRX, rectTRY, 0));
@ -93,10 +71,6 @@ void BarGraph::draw()
bar.drawFaces(); bar.drawFaces();
//ofSetColor(255, 255, 0);
//ofRect(i * graphItemXGap - (barWidth * 0.5), publisher0Data[i], barWidth, publisher1Data[i] - publisher0Data[i]);
//ofSetColor(0, 0, 0);
//ofLine(i * graphItemXGap, publisher0Data[i], i * graphItemXGap, publisher1Data[i]);
ofPopStyle(); ofPopStyle();
} }
} }

View File

@ -54,6 +54,14 @@ void BodyGraph::draw()
body.addColor(ofColor(col0[0],col0[1],col0[2], col0[3])); body.addColor(ofColor(col0[0],col0[1],col0[2], col0[3]));
body.addColor(ofColor(col1[0],col1[1],col1[2], col1[3])); body.addColor(ofColor(col1[0],col1[1],col1[2], col1[3]));
if (i == publisher0Data.size() - 2)
{
currentPub0Point = ofPoint(i * graphItemXGap + xOffset,
ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax));
currentPub1Point = ofPoint(i * graphItemXGap + xOffset,
ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax));
}
} }
body.drawFaces(); body.drawFaces();

View File

@ -33,12 +33,17 @@ void SeparateBodyGraph::draw()
{ {
ofMesh body0 = getMesh(publisher0Data, col0); ofMesh body0 = getMesh(publisher0Data, col0);
ofMesh body1 = getMesh(publisher1Data, col1); ofMesh body1 = getMesh(publisher1Data, col1);
if (body0.getVertices().size() > 2)
{
currentPub0Point = ofPoint(body0.getVertex(body0.getVertices().size() - 2).x, body0.getVertex(body0.getVertices().size() - 2).y);
currentPub1Point = ofPoint(body0.getVertex(body1.getVertices().size() - 2).x, body1.getVertex(body1.getVertices().size() - 2).y);
}
float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent; float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent;
float outputMin = (ofGetHeight() * 0.5) - ((ofGetHeight() * 0.5) * graphHeightMax); float outputMin = (ofGetHeight() * 0.5) - ((ofGetHeight() * 0.5) * graphHeightMax);
float outputMax = (ofGetHeight() * 0.5) + ((ofGetHeight() * 0.5) * graphHeightMax); float outputMax = (ofGetHeight() * 0.5) + ((ofGetHeight() * 0.5) * graphHeightMax);
// draw lines // draw lines
ofPushStyle(); ofPushStyle();
ofPolyline poly0; ofPolyline poly0;
@ -64,8 +69,6 @@ void SeparateBodyGraph::draw()
ofVec2f centroid0 = poly0.getCentroid2D(); ofVec2f centroid0 = poly0.getCentroid2D();
ofVec2f centroid1 = poly1.getCentroid2D(); ofVec2f centroid1 = poly1.getCentroid2D();
printf("centroid0.y:%f, centroid1.y:%f\n", centroid0.y, centroid1.y);
float av0; float av0;
float av1; float av1;
@ -77,8 +80,6 @@ void SeparateBodyGraph::draw()
av0 /= poly0.size(); av0 /= poly0.size();
av1 /= poly1.size(); av1 /= poly1.size();
printf("av0:%f, av1:%f\n", av0, av1);
int lineAlpha = 255; int lineAlpha = 255;
if (!isDrawLines) lineAlpha = 0; if (!isDrawLines) lineAlpha = 0;
@ -102,20 +103,6 @@ void SeparateBodyGraph::draw()
ofSetColor(col0[0],col0[1],col0[2], lineAlpha); ofSetColor(col0[0],col0[1],col0[2], lineAlpha);
poly0.draw(); poly0.draw();
} }
if (isDrawLines)
{
if (av0 > av1)
{
}
else
{
}
}
ofPopStyle(); ofPopStyle();
} }