Configurable crosshairs added

- Unit measure appended to graph values
This commit is contained in:
James Alliban
2014-01-12 20:08:05 +00:00
parent 1111d2f7e5
commit 96cadd932f
130 changed files with 5563 additions and 315 deletions
+10 -11
View File
@@ -93,10 +93,6 @@ void DataManager::update()
void DataManager::draw()
{
ofPushStyle();
ofSetColor(255, 0, 0);
ofCircle(sin(ofGetElapsedTimef() * 0.5) * 300 + 300, 100, 20);
ofPopStyle();
}
@@ -107,9 +103,8 @@ void DataManager::onMessage( Spacebrew::Message & m )
printf("new message - %s\n", m.valueString().c_str());
// split the formatted string into a list of different data types
vector<string> data = explode(",", m.valueString());
//for(int i = 0; i < data.size(); i++)
// cout <<i << " ["<< data[i] <<"] " <<endl;
for(int i = 0; i < data.size(); i++)
cout <<i << " ["<< data[i] <<"] " <<endl;
// make a new data object and add the different data sources to it
DataObject dataObject;
@@ -117,26 +112,30 @@ void DataManager::onMessage( Spacebrew::Message & m )
{
if (data[i].substr(0, 5) == "info:")
{
//printf("- - info = %s\n", data[i].substr(5, -1).c_str());
dataObject.info = data[i].substr(5, -1).c_str();
}
if (data[i].substr(0, 6) == "value:")
{
//printf("- - value = %s\n", data[i].substr(6, -1).c_str());
dataObject.value = ofToFloat(data[i].substr(6, -1).c_str());
}
if (data[i].substr(0, 4) == "min:")
{
//printf("- - min = %s\n", data[i].substr(4, -1).c_str());
dataObject.min = ofToFloat(data[i].substr(4, -1).c_str());
}
if (data[i].substr(0, 4) == "max:")
{
//printf("- - max = %s\n", data[i].substr(4, -1).c_str());
dataObject.max = ofToFloat(data[i].substr(4, -1).c_str());
}
if (data[i].substr(0, 5) == "unit:")
{
dataObject.unitMeasure = data[i].substr(5, -1).c_str();
printf("------------ dataObject.unitMeasure = %s", data[i].substr(5, -1).c_str());
}
}
//vector<string> unitMeasure = explode("\n", data[0]);
//printf("Unit Measure = %s \n", unitMeasure[unitMeasure.size() - 1].c_str());
//dataObject.unitMeasure = unitMeasure[unitMeasure.size() - 1];
if (m.name == publisher0Name)
{
+1
View File
@@ -15,6 +15,7 @@ struct DataObject
float value;
float min;
float max;
string unitMeasure;
};
class DataManager
+17 -7
View File
@@ -23,7 +23,8 @@ void GUI::setup()
addBodyGraphDesignGUI();
addSeparateBodyGraphDesignGUI();
addGraphSimulationGUI();
addBackgroundGUI();
addVideoGUI();
addHUDGUI();
addHUDTextGUI();
addVariousGUI();
@@ -178,9 +179,9 @@ void GUI::addGraphSimulationGUI()
}
void GUI::addBackgroundGUI()
void GUI::addVideoGUI()
{
string title = "BACKGROUND";
string title = "VIDEO";
ofxUICanvas* gui = getNewGUI(title);
gui->addToggle("Toggle Video Visibility", &app->scene.isVideoVisible, toggleDim, toggleDim);
@@ -198,6 +199,15 @@ 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);
finaliseCanvas(gui, true);
}
void GUI::addHUDGUI()
{
string title = "HUD";
ofxUICanvas* gui = getNewGUI(title);
gui->addSpacer(length, 1);
gui->addLabel("HUD BACKGROUND SETTINGS");
@@ -212,8 +222,9 @@ void GUI::addBackgroundGUI()
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);
gui->addSlider("Vertical line size (percent)", 0, 1, &app->scene.crosshairVertScale, length, dim);
gui->addSlider("Horizontal line size (percent)", 0, 1, &app->scene.crosshairHorizScale, length, dim);
ofAddListener(gui->newGUIEvent, this, &GUI::variousGUIEvent);
finaliseCanvas(gui, true);
}
@@ -239,11 +250,10 @@ void GUI::addHUDTextGUI()
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("Top Colour Box Y Offset", -300, 300, &app->scene.topColourBoxXOffset, length, dim);
gui->addSlider("Bottom Colour Box Y 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);
}
+2 -1
View File
@@ -25,7 +25,8 @@ public:
void addBodyGraphDesignGUI();
void addSeparateBodyGraphDesignGUI();
void addGraphSimulationGUI();
void addBackgroundGUI();
void addVideoGUI();
void addHUDGUI();
void addHUDTextGUI();
void addVariousGUI();
+21 -6
View File
@@ -81,8 +81,14 @@ void Scene::drawGraphValues()
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);
text.drawString(
ofToString(activeGraph->publisher0Data.back().value) + " " + activeGraph->publisher0Data[activeGraph->publisher0Data.size() - 1].unitMeasure,
val0.x + 10,
val0.y);
text.drawString(
ofToString(activeGraph->publisher1Data.back().value) + " " + activeGraph->publisher1Data[activeGraph->publisher1Data.size() - 1].unitMeasure,
val1.x + 10,
val1.y);
ofPopStyle();
}
@@ -92,8 +98,17 @@ 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
ofLine(ofGetWidth() * 0.5,
ofGetHeight() * 0.5 - ((ofGetHeight() * 0.5) * crosshairVertScale),
ofGetWidth() * 0.5,
ofGetHeight() * 0.5 + ((ofGetHeight() * 0.5) * crosshairVertScale)); // vert
ofLine(ofGetWidth() * 0.5 - ((ofGetWidth() * 0.5) * crosshairHorizScale),
ofGetHeight() * 0.5,
ofGetWidth() * 0.5 + ((ofGetWidth() * 0.5) * crosshairHorizScale),
ofGetHeight() * 0.5); // horz
ofCircle(ofGetWidth() * 0.5, ofGetHeight() * 0.5, crosshairCircleSize);
ofPopStyle();
}
@@ -232,8 +247,8 @@ void Scene::addNewData(vector<DataObject> newData)
bodyGraph.addNewData(newData);
separateBodyGraph.addNewData(newData);
tlStr = newData[0].info + "\n" + ofToString(newData[0].value);
trStr = newData[1].info + "\n" + ofToString(newData[1].value);
tlStr = newData[0].info + newData[0].unitMeasure + "\n" + ofToString(newData[0].value);
trStr = newData[1].info + newData[1].unitMeasure + "\n" + ofToString(newData[1].value);
millisAtLastData = ofGetElapsedTimeMillis();
}
+2
View File
@@ -69,6 +69,8 @@ public:
float crosshairLineWidth;
float crosshairAlpha;
float crosshairCircleSize;
float crosshairVertScale;
float crosshairHorizScale;
// HUD background vars
float hudColour[4];
@@ -13,7 +13,6 @@ float AbstractGraph::maxGraphPercent;
void AbstractGraph::setup()
{
printf("AbstractGraph::setup()\n");
}
@@ -26,7 +26,7 @@ void BodyGraph::draw()
if (app->gui.getVisible())
{
float timePerScreenfull = (float)maxData * sendDataSpeed;
printf("timePerScreenfull:%f, maxData:%i, sendDataSpeed:%f \n", timePerScreenfull, maxData, sendDataSpeed);
//printf("timePerScreenfull:%f, maxData:%i, sendDataSpeed:%f \n", timePerScreenfull, maxData, sendDataSpeed);
ofDrawBitmapString("Time to fill screen:" + ofToString(timePerScreenfull), 500, 150);
}
@@ -78,7 +78,6 @@ void BodyGraph::draw()
{
if (i < publisher0Data.size() - 1)
{
ofSetLineWidth(lineWidth);
poly0.addVertex(ofPoint(
i * graphItemXGap + xOffset,
ofMap(publisher0Data[i].value, publisher0Data[i].min, publisher0Data[i].max, outputMin, outputMax)));
@@ -90,6 +89,7 @@ void BodyGraph::draw()
}
}
ofSetLineWidth(lineWidth);
ofSetColor(col0[0],col0[1],col0[2], 255);
poly0.draw();
ofSetColor(col1[0],col1[1],col1[2], 255);