Large numbers now being handled correctly...
- long long ints being used where necessary - Commas being added to numbers larger than 999 - No more values being rendered as 1.5332e+012
This commit is contained in:
parent
b3e6565bde
commit
e51abf7a53
Binary file not shown.
0
of/Active Tripod/bin/Active_Tripod_debug.ilk
Normal file
0
of/Active Tripod/bin/Active_Tripod_debug.ilk
Normal file
BIN
of/Active Tripod/bin/Active_Tripod_debug.lib
Normal file
BIN
of/Active Tripod/bin/Active_Tripod_debug.lib
Normal file
Binary file not shown.
@ -1,12 +1,12 @@
|
||||
<Widget>
|
||||
<Kind>2</Kind>
|
||||
<Name>Bar graph</Name>
|
||||
<Value>0</Value>
|
||||
<Value>1</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>2</Kind>
|
||||
<Name>Solid Body graph</Name>
|
||||
<Value>1</Value>
|
||||
<Value>0</Value>
|
||||
</Widget>
|
||||
<Widget>
|
||||
<Kind>2</Kind>
|
||||
|
||||
@ -116,7 +116,25 @@ void DataManager::onMessage( Spacebrew::Message & m )
|
||||
}
|
||||
if (data[i].substr(0, 6) == "value:")
|
||||
{
|
||||
dataObject.value = ofToFloat(data[i].substr(6, -1).c_str());
|
||||
string valString = data[i].substr(6, -1).c_str();
|
||||
dataObject.value = ofToFloat(valString);
|
||||
|
||||
if (dataObject.value > 1000000000)
|
||||
{
|
||||
// create long long int
|
||||
stringstream sstr(valString);
|
||||
__int64 val;
|
||||
sstr >> val;
|
||||
dataObject.longlongIntValue = val;
|
||||
dataObject.stringValue = addCommasToNumberString(valString);
|
||||
}
|
||||
else
|
||||
{
|
||||
dataObject.longlongIntValue = 0;
|
||||
dataObject.stringValue = (dataObject.value > 999) ? addCommasToNumberString(valString) : valString;
|
||||
}
|
||||
|
||||
printf("\ndataObject.longlongValue = %llli \n\n",dataObject.longlongIntValue);
|
||||
}
|
||||
if (data[i].substr(0, 4) == "min:")
|
||||
{
|
||||
@ -129,7 +147,6 @@ void DataManager::onMessage( Spacebrew::Message & m )
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -181,3 +198,39 @@ vector<string> DataManager::explode(const string &delimiter, const string &str)
|
||||
arr.push_back( str.substr(k, i-k) );
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
||||
string DataManager::addCommasToNumberString(string num)
|
||||
{
|
||||
printf("adding commas \n");
|
||||
string temp;
|
||||
string integral = num;
|
||||
string fractional;
|
||||
int decimalLocation = integral.find('.');
|
||||
|
||||
if (decimalLocation != -1)
|
||||
{
|
||||
integral = integral.substr(0 , decimalLocation);
|
||||
fractional = integral.substr(decimalLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
integral = num;
|
||||
fractional = "";
|
||||
}
|
||||
|
||||
int endstring = integral.length();
|
||||
int i;
|
||||
for(i = endstring - 3; i >= 0; i -= 3) {
|
||||
if (i > 0) {
|
||||
temp = ","+ integral.substr(i, 3) + temp;
|
||||
} else {
|
||||
temp = integral.substr(i, 3) + temp;
|
||||
}
|
||||
}
|
||||
if (i < 0) {
|
||||
temp = integral.substr(0, 3+i) + temp;
|
||||
}
|
||||
printf("adding commas - temp = %s\n", temp.c_str());
|
||||
return temp + fractional;
|
||||
}
|
||||
@ -13,6 +13,8 @@ struct DataObject
|
||||
{
|
||||
string info;
|
||||
float value;
|
||||
string stringValue;
|
||||
long long int longlongIntValue;
|
||||
float min;
|
||||
float max;
|
||||
string unitMeasure;
|
||||
@ -27,6 +29,7 @@ class DataManager
|
||||
void update();
|
||||
void draw();
|
||||
vector<string> explode( const string &delimiter, const string &str);
|
||||
string addCommasToNumberString(string num);
|
||||
|
||||
// listen to spacebrew Messages
|
||||
void onMessage( Spacebrew::Message & m );
|
||||
|
||||
@ -82,11 +82,11 @@ void Scene::drawGraphValues()
|
||||
ofSetColor(graphTextColour[0], graphTextColour[1], graphTextColour[2], graphTextColour[3]);
|
||||
text.setSize(graphTextSize);
|
||||
text.drawString(
|
||||
ofToString(activeGraph->publisher0Data.back().value) + " " + activeGraph->publisher0Data[activeGraph->publisher0Data.size() - 1].unitMeasure,
|
||||
activeGraph->publisher0Data.back().stringValue + " " + activeGraph->publisher0Data.back().unitMeasure,
|
||||
val0.x + 10,
|
||||
val0.y);
|
||||
text.drawString(
|
||||
ofToString(activeGraph->publisher1Data.back().value) + " " + activeGraph->publisher1Data[activeGraph->publisher1Data.size() - 1].unitMeasure,
|
||||
activeGraph->publisher1Data.back().stringValue + " " + activeGraph->publisher1Data.back().unitMeasure,
|
||||
val1.x + 10,
|
||||
val1.y);
|
||||
ofPopStyle();
|
||||
@ -156,30 +156,70 @@ void Scene::drawHUDCopy()
|
||||
vector<DataObject> *p0Data = &activeGraph->publisher0Data;
|
||||
vector<DataObject> *p1Data = &activeGraph->publisher1Data;
|
||||
|
||||
|
||||
|
||||
|
||||
int amountToAverage = MIN(p0Data->size(), averageAmount);
|
||||
if (p0Data->size() > 2)
|
||||
{
|
||||
float average0 = 0;
|
||||
for (int i = 0; i < (int)amountToAverage; i++)
|
||||
average0 += p0Data->at(p0Data->size() - i - 1).value;
|
||||
average0 /= (int)amountToAverage;
|
||||
if (p0Data->back().longlongIntValue > 0)
|
||||
{
|
||||
long long int average0 = 0;
|
||||
for (int i = 0; i < (int)amountToAverage; i++)
|
||||
average0 += p0Data->at(p0Data->size() - i - 1).value;
|
||||
average0 /= (int)amountToAverage;
|
||||
|
||||
// (p0Data->back() + p0Data->at(p0Data->size() - 2) + p0Data->at(p0Data->size() - 2))
|
||||
blStr = "Increase: " + ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" +
|
||||
"Current Value: " + ofToString(p0Data->back().value) + "\n" +
|
||||
"Running average: " + ofToString(average0);
|
||||
drawTextBox(blStr, "BOTTOM LEFT");
|
||||
string valueWithCommas = addCommasToNumberString(ofToString(average0));
|
||||
|
||||
blStr = "Increase: " + ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" +
|
||||
"Current Value: " + p0Data->back().stringValue + "\n" +
|
||||
"Running average: " + valueWithCommas;
|
||||
drawTextBox(blStr, "BOTTOM LEFT");
|
||||
}
|
||||
else
|
||||
{
|
||||
float average0 = 0;
|
||||
for (int i = 0; i < (int)amountToAverage; i++)
|
||||
average0 += p0Data->at(p0Data->size() - i - 1).value;
|
||||
average0 /= (int)amountToAverage;
|
||||
|
||||
string valueWithCommas = (average0 > 999) ? addCommasToNumberString(ofToString(average0)) : ofToString(average0);
|
||||
|
||||
blStr = "Increase: " + ofToString(p0Data->back().value - p0Data->at(p0Data->size() - 2).value) + "\n" +
|
||||
"Current Value: " + p0Data->back().stringValue + "\n" +
|
||||
"Running average: " + valueWithCommas;
|
||||
drawTextBox(blStr, "BOTTOM LEFT");
|
||||
}
|
||||
|
||||
|
||||
float average1 = 0;
|
||||
for (int i = 0; i < (int)amountToAverage; i++)
|
||||
average1 += p1Data->at(p1Data->size() - i - 1).value;
|
||||
average1 /= (int)amountToAverage;
|
||||
if (p1Data->back().longlongIntValue > 0)
|
||||
{
|
||||
float average1 = 0;
|
||||
for (int i = 0; i < (int)amountToAverage; i++)
|
||||
average1 += p1Data->at(p1Data->size() - i - 1).value;
|
||||
average1 /= (int)amountToAverage;
|
||||
|
||||
brStr = "Increase: " + ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "\n" +
|
||||
"Current Value: " + ofToString(p1Data->back().value) + "\n" +
|
||||
"Running average: " + ofToString(average1);
|
||||
drawTextBox(brStr, "BOTTOM RIGHT");
|
||||
string valueWithCommas = addCommasToNumberString(ofToString(average1));
|
||||
|
||||
brStr = "Increase: " + ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "\n" +
|
||||
"Current Value: " + p1Data->back().stringValue + "\n" +
|
||||
"Running average: " + valueWithCommas;
|
||||
drawTextBox(brStr, "BOTTOM RIGHT");
|
||||
}
|
||||
else
|
||||
{
|
||||
long long int average1 = 0;
|
||||
for (int i = 0; i < (int)amountToAverage; i++)
|
||||
average1 += p1Data->at(p1Data->size() - i - 1).value;
|
||||
average1 /= (int)amountToAverage;
|
||||
|
||||
string valueWithCommas = (average1 > 999) ? addCommasToNumberString(ofToString(average1)) : ofToString(average1);
|
||||
|
||||
brStr = "Increase: " + ofToString(p1Data->back().value - p1Data->at(p1Data->size() - 2).value) + "\n" +
|
||||
"Current Value: " + p1Data->back().stringValue + "\n" +
|
||||
"Running average: " + valueWithCommas;
|
||||
drawTextBox(brStr, "BOTTOM RIGHT");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,14 +287,13 @@ void Scene::addNewData(vector<DataObject> newData)
|
||||
bodyGraph.addNewData(newData);
|
||||
separateBodyGraph.addNewData(newData);
|
||||
|
||||
tlStr = newData[0].info + newData[0].unitMeasure + "\n" + ofToString(newData[0].value);
|
||||
trStr = newData[1].info + newData[1].unitMeasure + "\n" + ofToString(newData[1].value);
|
||||
tlStr = newData[0].info + newData[0].unitMeasure + "\n" + ofToString(newData[0].stringValue);
|
||||
trStr = newData[1].info + newData[1].unitMeasure + "\n" + ofToString(newData[1].stringValue);
|
||||
}
|
||||
|
||||
|
||||
void Scene::keyPressed(int key)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -264,3 +303,43 @@ void Scene::clearGraphData()
|
||||
bodyGraph.clear();
|
||||
separateBodyGraph.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
string Scene::addCommasToNumberString(string num)
|
||||
{
|
||||
string temp;
|
||||
string integral = num;
|
||||
string fractional;
|
||||
int decimalLocation = integral.find('.');
|
||||
|
||||
if (decimalLocation != -1)
|
||||
{
|
||||
integral = integral.substr(0 , decimalLocation);
|
||||
fractional = integral.substr(decimalLocation);
|
||||
}
|
||||
else
|
||||
{
|
||||
integral = num;
|
||||
fractional = "";
|
||||
}
|
||||
|
||||
int endstring = integral.length();
|
||||
int i;
|
||||
for(i = endstring - 3; i >= 0; i -= 3) {
|
||||
if (i > 0) {
|
||||
temp = ","+ integral.substr(i, 3) + temp;
|
||||
} else {
|
||||
temp = integral.substr(i, 3) + temp;
|
||||
}
|
||||
}
|
||||
if (i < 0) {
|
||||
temp = integral.substr(0, 3+i) + temp;
|
||||
}
|
||||
return temp + fractional;
|
||||
}
|
||||
@ -1,10 +1,4 @@
|
||||
//
|
||||
// GUI.h
|
||||
// emptyExample
|
||||
//
|
||||
// Created by James Alliban on 25/06/2013.
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
@ -33,7 +27,7 @@ public:
|
||||
void addNewData(vector<DataObject> newData);
|
||||
void clearGraphData();
|
||||
void keyPressed(int key);
|
||||
|
||||
string addCommasToNumberString(string num);
|
||||
|
||||
BarGraph barGraph;
|
||||
BodyGraph bodyGraph;
|
||||
|
||||
Binary file not shown.
@ -13,33 +13,25 @@ Cryptocurrency exchange rate on mtgox.com
|
||||
7 = Number of likes of the transmediale fan page on Facebook
|
||||
|
||||
8 = Haus der Kulturen Main Foyer - Noise Level
|
||||
9 = Total twitter updates
|
||||
|
||||
9 =
|
||||
10 = Haus der Kulturen Bar Area - Noise Level
|
||||
11 = HUAWEI Guangdong Stock Price on the Shenzen Exchange
|
||||
|
||||
11 =
|
||||
12 = Haus der Kulturen Beneath Main Foyer - Power Consumption (Amperes)
|
||||
13 = Google Inc. Stock Price on the NASDAQ Exchange
|
||||
|
||||
13 =
|
||||
14 = Haus der Kulturen Main Foyer - Power Consumption (Amperes)
|
||||
15 =
|
||||
16 = Haus der Kulturen Back Smoking Area - Air Quality
|
||||
17 =
|
||||
18 = Haus der Kulturen Mezanine Smoking Area - Air Quality
|
||||
19 = Percentage of books about media art out of all books on sale on ebay
|
||||
|
||||
19 =
|
||||
20 = Haus der Kulturen Mezanine Smoking Area - Air Quality
|
||||
21 = Number of photos tagged with berlin on Flickr
|
||||
|
||||
21 =
|
||||
22 =
|
||||
23 = Number of photos tagged with berlin on Instagram
|
||||
|
||||
23 =
|
||||
24 =
|
||||
25 = Number of photos tagged with transmediale on Instagram
|
||||
|
||||
25 =
|
||||
26 =
|
||||
27 = Number of downvotes on reddit.com/r/funny
|
||||
|
||||
27 =
|
||||
28 =
|
||||
29 =
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -1,4 +1,4 @@
|
||||
Build started 16/1/2014 4:59:12 AM.
|
||||
Build started 16/1/2014 2:57:32 PM.
|
||||
1>Project "C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\Utility_Box.vcxproj" on node 2 (Build target(s)).
|
||||
1>ClCompile:
|
||||
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\CL.exe /c /I..\..\..\libs\openFrameworks /I..\..\..\libs\openFrameworks\graphics /I..\..\..\libs\openFrameworks\app /I..\..\..\libs\openFrameworks\sound /I..\..\..\libs\openFrameworks\utils /I..\..\..\libs\openFrameworks\communication /I..\..\..\libs\openFrameworks\video /I..\..\..\libs\openFrameworks\types /I..\..\..\libs\openFrameworks\math /I..\..\..\libs\openFrameworks\3d /I..\..\..\libs\openFrameworks\gl /I..\..\..\libs\openFrameworks\events /I..\..\..\libs\glut\include /I..\..\..\libs\rtAudio\include /I..\..\..\libs\quicktime\include /I..\..\..\libs\freetype\include /I..\..\..\libs\freetype\include\freetype2 /I..\..\..\libs\freeImage\include /I..\..\..\libs\fmodex\include /I..\..\..\libs\videoInput\include /I..\..\..\libs\glew\include\ /I..\..\..\libs\glu\include /I..\..\..\libs\tess2\include /I..\..\..\libs\cairo\include\cairo /I..\..\..\libs\poco\include /I..\..\..\libs\glfw\include /I..\..\..\..\libs\openssl\include /I..\..\..\addons /Isrc /Isrc\data /Isrc\gui /Isrc\visual /Isrc\visual\graph /I..\..\..\addons\ofxLibwebsockets\libs\jsoncpp /I..\..\..\addons\ofxLibwebsockets\libs\jsoncpp\json /I..\..\..\addons\ofxLibwebsockets\libs\libwebsockets\include\ /I..\..\..\addons\ofxLibwebsockets\libs\openssl\openssl /I..\..\..\addons\ofxLibwebsockets\libs\ofxLibwebsockets\include /I..\..\..\addons\ofxLibwebsockets\libs\ofxLibwebsockets\include\ofxLibwebsockets /I..\..\..\addons\ofxLibwebsockets\libs\ofxLibwebsockets\src /I..\..\..\addons\ofxLibwebsockets\src /I..\..\..\addons\ofxLibwebsockets\libs\libwebsockets\include\win32port /I..\..\..\addons\ofxLibwebsockets\libs\libwebsockets\include\win32port\win32helpers /I..\..\..\addons\ofxSpacebrew\src /I..\..\..\addons\ofxUI\src /I..\..\..\addons\ofxXmlSettings\libs /I..\..\..\addons\ofxXmlSettings\src /I..\..\..\addons\ofxFTGL\src /I..\..\..\addons\ofxFTGL\libs\FTGL\include\FTGL /I..\..\..\addons\ofxFTGL\libs\FTGL\include /I..\..\..\addons\ofxFTGL\libs\FTGL /Zi /nologo /W3 /WX- /O2 /Oy- /D WIN32 /D NDEBUG /D _CONSOLE /D POCO_STATIC /D CAIRO_WIN32_STATIC_BUILD /D DISABLE_SOME_FLOATING_POINT /D _UNICODE /D UNICODE /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"obj\Release\\" /Fd"obj\Release\vc110.pdb" /Gd /TP /analyze- /errorReport:prompt src\testApp.cpp src\visual\Scene.cpp
|
||||
@ -118,4 +118,4 @@
|
||||
|
||||
Build succeeded.
|
||||
|
||||
Time Elapsed 00:00:10.33
|
||||
Time Elapsed 00:00:11.17
|
||||
|
||||
@ -1233,3 +1233,8 @@ C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Util
|
||||
C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.lib
|
||||
C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.exp
|
||||
C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.exp
|
||||
^C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\Utility_Box.vcxproj
|
||||
C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.lib
|
||||
C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.lib
|
||||
C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.exp
|
||||
C:\Users\James Alliban\Work\of_v0.8.0_vs_release\CRITICAL-INFRASTRUCTURE\of\Utility_Box\bin\Utility_Box.exp
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
|
||||
// TODO
|
||||
// ====
|
||||
// - Add a minimum time for each angle
|
||||
// - Add a minimum time for each angle to avoif unslightly quick switching
|
||||
// - optimise - don't calculate graph point values evey frame
|
||||
// - investigate backward graph animation (use alternating colours)
|
||||
// - Colour range - tween between 2-3 points
|
||||
|
||||
@ -6,11 +6,13 @@ void Camera::setup(int _camID)
|
||||
camID = _camID;
|
||||
lookAtNode.setPosition(0, 0, 0);
|
||||
setDistance(100);
|
||||
minSecondsBeforeSwapping = 2;
|
||||
}
|
||||
|
||||
|
||||
void Camera::update()
|
||||
{
|
||||
|
||||
positionVec.x = sin(ofGetElapsedTimef() * rotSpeed) * distance;
|
||||
//positionVec.y = 40;
|
||||
positionVec.z = cos(ofGetElapsedTimef() * rotSpeed) * distance;
|
||||
@ -19,3 +21,14 @@ void Camera::update()
|
||||
setPosition(positionVec);
|
||||
lookAt(lookAtNode);
|
||||
}
|
||||
|
||||
|
||||
void Camera::activate()
|
||||
{
|
||||
timeBecameActive = ofGetElapsedTimef();
|
||||
}
|
||||
|
||||
|
||||
void Camera::deactivate()
|
||||
{
|
||||
}
|
||||
@ -15,6 +15,8 @@ class Camera : public ofEasyCam
|
||||
public:
|
||||
void setup(int _camID);
|
||||
void update();
|
||||
void activate();
|
||||
void deactivate();
|
||||
|
||||
int camID;
|
||||
|
||||
@ -26,4 +28,6 @@ public:
|
||||
float distance;
|
||||
float rotSpeed;
|
||||
float swapProbability;
|
||||
float minSecondsBeforeSwapping;
|
||||
float timeBecameActive;
|
||||
};
|
||||
@ -144,6 +144,7 @@ void Scene::switchCamera()
|
||||
newCamID = (ofRandom(2) < 0.5) ? 0 : 1;
|
||||
|
||||
printf("************ changing cameras to %i ************** \n", newCamID);
|
||||
|
||||
activeCamera->deactivate();
|
||||
activeCamera = &cameras[newCamID];
|
||||
activeCamera->activate();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user