Graph/HUD Numbers now tween when changing

This commit is contained in:
James Alliban 2014-01-24 21:47:11 +00:00
parent c542bcf317
commit 61d192ae2a
11 changed files with 100 additions and 20 deletions

View File

@ -1,12 +1,12 @@
<Widget>
<Kind>4</Kind>
<Name>Graph Item X Gap</Name>
<Value>9.144737244</Value>
<Value>8.848684311</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>BarWidth</Name>
<Value>15.894737244</Value>
<Value>6.263157845</Value>
</Widget>
<Widget>
<Kind>4</Kind>
@ -16,7 +16,7 @@
<Widget>
<Kind>4</Kind>
<Name>Data send speed (seconds)</Name>
<Value>4.485855103</Value>
<Value>1.671052575</Value>
</Widget>
<Widget>
<Kind>4</Kind>

View File

@ -27,12 +27,12 @@
<Widget>
<Kind>4</Kind>
<Name>Decimal points 0</Name>
<Value>5.174342155</Value>
<Value>4.049342155</Value>
</Widget>
<Widget>
<Kind>4</Kind>
<Name>Decimal points 1</Name>
<Value>2.332236767</Value>
<Value>2.805921078</Value>
</Widget>
<Widget>
<Kind>4</Kind>

View File

@ -26,7 +26,7 @@
<Widget>
<Kind>4</Kind>
<Name>Data send speed (seconds)</Name>
<Value>0.950986862</Value>
<Value>1.932894707</Value>
</Widget>
<Widget>
<Kind>4</Kind>

View File

@ -89,6 +89,27 @@ void Scene::drawGraphValues()
string stringVal0 = reduceDecimalCount(activeGraph->publisher0Data.back().stringValue, valDecimalPoints0);
string stringVal1 = reduceDecimalCount(activeGraph->publisher1Data.back().stringValue, valDecimalPoints1);
if (activeGraph->graphName == "BODY" || activeGraph->graphName == "SEPARATE_BODY")
{
//std::stringstream sstr(activeGraph->animatedVal0LLI);
//__int64 val;
//sstr >> val;
//printf("val:%lld\n", val);
if (activeGraph->animatedVal0LLI > 100000)
stringVal0 = reduceDecimalCount(ofToString(activeGraph->animatedVal0LLI), valDecimalPoints0);
else
stringVal0 = reduceDecimalCount(ofToString(activeGraph->animatedVal0), valDecimalPoints0);
if (activeGraph->animatedVal1LLI > 100000)
stringVal1 = reduceDecimalCount(ofToString(activeGraph->animatedVal1LLI), valDecimalPoints1);
else
stringVal1 = reduceDecimalCount(ofToString(activeGraph->animatedVal1), valDecimalPoints1);
stringVal0 = addCommasToNumberString(stringVal0);
stringVal1 = addCommasToNumberString(stringVal1);
}
ofPushStyle();
text.setAlignment(FTGL_ALIGN_LEFT);
ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]);
@ -178,12 +199,6 @@ void Scene::drawHUDBG()
void Scene::drawHUDCopy()
{
text.setLineLength(lineLength);
text.setLineSpacing(lineSpacing);
text.setSize(textSize);
drawTextBox(tlStr, "TOP LEFT");
drawTextBox(trStr, "TOP RIGHT");
vector<DataObject> *p0Data = &activeGraph->publisher0Data;
vector<DataObject> *p1Data = &activeGraph->publisher1Data;
@ -195,6 +210,35 @@ void Scene::drawHUDCopy()
string stringVal1 = reduceDecimalCount(activeGraph->publisher1Data.back().stringValue, valDecimalPoints1);
if (activeGraph->graphName == "BODY" || activeGraph->graphName == "SEPARATE_BODY")
{
if (activeGraph->animatedVal0LLI > 100000)
stringVal0 = reduceDecimalCount(ofToString(activeGraph->animatedVal0LLI), valDecimalPoints0);
else
stringVal0 = reduceDecimalCount(ofToString(activeGraph->animatedVal0), valDecimalPoints0);
if (activeGraph->animatedVal1LLI > 100000)
stringVal1 = reduceDecimalCount(ofToString(activeGraph->animatedVal1LLI), valDecimalPoints1);
else
stringVal1 = reduceDecimalCount(ofToString(activeGraph->animatedVal1), valDecimalPoints1);
stringVal0 = addCommasToNumberString(stringVal0);
stringVal1 = addCommasToNumberString(stringVal1);
}
tlStr = p0Data->back().info + "\n" + p0Data->back().unitMeasure + "\n" + stringVal0;
trStr = p0Data->back().info + "\n" + p0Data->back().unitMeasure + "\n" + stringVal1;
text.setLineLength(lineLength);
text.setLineSpacing(lineSpacing);
text.setSize(textSize);
drawTextBox(tlStr, "TOP LEFT");
drawTextBox(trStr, "TOP RIGHT");
int amountToAverage = MIN(p0Data->size(), averageAmount);
if (p0Data->size() > 2)
{
@ -338,9 +382,6 @@ void Scene::addNewData(vector<DataObject> newData)
barGraph.addNewData(newData);
bodyGraph.addNewData(newData);
separateBodyGraph.addNewData(newData);
tlStr = newData[0].info + "\n" + newData[0].unitMeasure + "\n" + reduceDecimalCount(ofToString(newData[0].stringValue), valDecimalPoints0);
trStr = newData[1].info + "\n" + newData[1].unitMeasure + "\n" + reduceDecimalCount(ofToString(newData[1].stringValue), valDecimalPoints1);
}
@ -373,7 +414,7 @@ string Scene::addCommasToNumberString(string num)
if (decimalLocation != -1)
{
integral = integral.substr(0 , decimalLocation);
fractional = integral.substr(decimalLocation);
fractional = num.substr(decimalLocation);
}
else
{

View File

@ -14,6 +14,8 @@ float AbstractGraph::maxGraphPercent;
void AbstractGraph::setup()
{
millisSinceLastPoint = 0;
animatedVal0LLI = 0;
animatedVal1LLI = 0;
}

View File

@ -53,4 +53,9 @@ public:
ofPoint graphTextPnt0;
ofPoint graphTextPnt1;
float animatedVal0;
float animatedVal1;
long long int animatedVal0LLI;
long long int animatedVal1LLI;
};

View File

@ -31,6 +31,12 @@ void BarGraph::draw()
float outputMin = (ofGetHeight() * 0.5) - ((ofGetHeight() * 0.5) * graphHeightMax);
float outputMax = (ofGetHeight() * 0.5) + ((ofGetHeight() * 0.5) * graphHeightMax);
ofPushMatrix();
//if (publisher0Data.size() >= maxData)
//ofTranslate(ofMap(normalisedTimeInc, 0, 1, 0, -graphItemXGap*0.5), 0);
for (int i = 0; i < publisher0Data.size() - 1; i++)
{
ofPushStyle();
@ -73,6 +79,8 @@ void BarGraph::draw()
ofPopStyle();
}
ofPopMatrix();
}
}

View File

@ -77,6 +77,16 @@ void BodyGraph::draw()
endPoint1.x,
endPoint1.y,
0));
//float mahousive = 1000000000;
//animatedVal0 = ofMap(endPoint0.y * mahousive, outputMin * mahousive, outputMax * mahousive, publisher0Data.back().min * mahousive, publisher0Data.back().max * mahousive);
//animatedVal0LLI = ofMap(endPoint0.y * mahousive, outputMin * mahousive, outputMax * mahousive, publisher0Data.back().min * mahousive, publisher0Data.back().max * mahousive);
animatedVal0 = ofMap(endPoint0.y, outputMin, outputMax, publisher0Data.back().min, publisher0Data.back().max);
animatedVal0LLI = ofMap(endPoint0.y, outputMin, outputMax, publisher0Data.back().min, publisher0Data.back().max);
animatedVal1 = ofMap(endPoint1.y, outputMin, outputMax, publisher1Data.back().min, publisher1Data.back().max);
animatedVal1LLI = ofMap(endPoint1.y, outputMin, outputMax, publisher1Data.back().min, publisher1Data.back().max);
}
body.addColor(ofColor(col0[0],col0[1],col0[2], col0[3]));
body.addColor(ofColor(col1[0],col1[1],col1[2], col1[3]));

View File

@ -31,8 +31,8 @@ void SeparateBodyGraph::draw()
if (publisher0Data.size() > 1)
{
ofMesh body0 = getMesh(publisher0Data, col0);
ofMesh body1 = getMesh(publisher1Data, col1);
ofMesh body0 = getMesh(publisher0Data, col0, 0);
ofMesh body1 = getMesh(publisher1Data, col1, 1);
if (body0.getVertices().size() > 2)
{
@ -44,6 +44,7 @@ void SeparateBodyGraph::draw()
float outputMin = (ofGetHeight() * 0.5) - ((ofGetHeight() * 0.5) * graphHeightMax);
float outputMax = (ofGetHeight() * 0.5) + ((ofGetHeight() * 0.5) * graphHeightMax);
// draw lines
ofPushStyle();
ofPolyline poly0;
@ -114,7 +115,7 @@ void SeparateBodyGraph::draw()
}
ofMesh SeparateBodyGraph::getMesh(vector<DataObject> publisherData, float* col)
ofMesh SeparateBodyGraph::getMesh(vector<DataObject> publisherData, float* col, int graphID)
{
ofMesh bodyMesh;
float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent;
@ -143,6 +144,19 @@ ofMesh SeparateBodyGraph::getMesh(vector<DataObject> publisherData, float* col)
endPoint0.y = ofMap(normalisedTimeInc, 0, 1, prevY0, targetY0);
endPoint0.x = (i-1) * graphItemXGap + xOffset + (graphItemXGap * normalisedTimeInc);
if (graphID == 0)
{
animatedVal0 = ofMap(endPoint0.y, outputMin, outputMax, publisher0Data.back().min, publisher0Data.back().max);
animatedVal0LLI = ofMap(endPoint0.y, outputMin, outputMax, publisher0Data.back().min, publisher0Data.back().max);
//animatedVal0 = 99111222333;
//animatedVal0LLI = 99111222333;
}
else
{
animatedVal1 = ofMap(endPoint0.y, outputMin, outputMax, publisher1Data.back().min, publisher1Data.back().max);
animatedVal1LLI = ofMap(endPoint0.y, outputMin, outputMax, publisher1Data.back().min, publisher1Data.back().max);
}
bodyMesh.addVertex(ofVec3f(
endPoint0.x,
endPoint0.y,

View File

@ -13,7 +13,7 @@ public:
virtual void update();
virtual void draw();
virtual void addNewData(vector<DataObject> newData);
ofMesh getMesh(vector<DataObject> publisherData, float* col);
ofMesh getMesh(vector<DataObject> publisherData, float* col, int graphID);
testApp *app;