New graph type in place - Separate Body Graph
This commit is contained in:
parent
3067d52e98
commit
5ed4e96a1d
@ -112,6 +112,7 @@
|
|||||||
<ClCompile Include="src\visual\graph\AbstractGraph.cpp" />
|
<ClCompile Include="src\visual\graph\AbstractGraph.cpp" />
|
||||||
<ClCompile Include="src\visual\graph\BarGraph.cpp" />
|
<ClCompile Include="src\visual\graph\BarGraph.cpp" />
|
||||||
<ClCompile Include="src\visual\graph\BodyGraph.cpp" />
|
<ClCompile Include="src\visual\graph\BodyGraph.cpp" />
|
||||||
|
<ClCompile Include="src\visual\graph\SeparateBodyGraph.cpp" />
|
||||||
<ClCompile Include="src\visual\Scene.cpp" />
|
<ClCompile Include="src\visual\Scene.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@ -190,6 +191,7 @@
|
|||||||
<ClInclude Include="src\visual\graph\AbstractGraph.h" />
|
<ClInclude Include="src\visual\graph\AbstractGraph.h" />
|
||||||
<ClInclude Include="src\visual\graph\BarGraph.h" />
|
<ClInclude Include="src\visual\graph\BarGraph.h" />
|
||||||
<ClInclude Include="src\visual\graph\BodyGraph.h" />
|
<ClInclude Include="src\visual\graph\BodyGraph.h" />
|
||||||
|
<ClInclude Include="src\visual\graph\SeparateBodyGraph.h" />
|
||||||
<ClInclude Include="src\visual\Scene.h" />
|
<ClInclude Include="src\visual\Scene.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -76,6 +76,9 @@
|
|||||||
<ClCompile Include="src\visual\graph\BodyGraph.cpp">
|
<ClCompile Include="src\visual\graph\BodyGraph.cpp">
|
||||||
<Filter>src\visual\graph</Filter>
|
<Filter>src\visual\graph</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\visual\graph\SeparateBodyGraph.cpp">
|
||||||
|
<Filter>src\visual\graph</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="src">
|
<Filter Include="src">
|
||||||
@ -374,6 +377,9 @@
|
|||||||
<ClInclude Include="src\visual\graph\BodyGraph.h">
|
<ClInclude Include="src\visual\graph\BodyGraph.h">
|
||||||
<Filter>src\visual\graph</Filter>
|
<Filter>src\visual\graph</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\visual\graph\SeparateBodyGraph.h">
|
||||||
|
<Filter>src\visual\graph</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ResourceCompile Include="icon.rc">
|
<ResourceCompile Include="icon.rc">
|
||||||
|
|||||||
Binary file not shown.
@ -1,7 +1,7 @@
|
|||||||
<Widget>
|
<Widget>
|
||||||
<Kind>2</Kind>
|
<Kind>2</Kind>
|
||||||
<Name>Bar graph</Name>
|
<Name>Bar graph</Name>
|
||||||
<Value>1</Value>
|
<Value>0</Value>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget>
|
<Widget>
|
||||||
<Kind>2</Kind>
|
<Kind>2</Kind>
|
||||||
@ -10,8 +10,8 @@
|
|||||||
</Widget>
|
</Widget>
|
||||||
<Widget>
|
<Widget>
|
||||||
<Kind>2</Kind>
|
<Kind>2</Kind>
|
||||||
<Name>Line fade graph</Name>
|
<Name>Separate Body graph</Name>
|
||||||
<Value>0</Value>
|
<Value>1</Value>
|
||||||
</Widget>
|
</Widget>
|
||||||
<Widget>
|
<Widget>
|
||||||
<Kind>6</Kind>
|
<Kind>6</Kind>
|
||||||
|
|||||||
@ -0,0 +1,70 @@
|
|||||||
|
<Widget>
|
||||||
|
<Kind>2</Kind>
|
||||||
|
<Name>Toggle Draw Lines</Name>
|
||||||
|
<Value>1</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Graph Item X Gap</Name>
|
||||||
|
<Value>6.480263233</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Line width</Name>
|
||||||
|
<Value>5.190789700</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Graph Height Max</Name>
|
||||||
|
<Value>325.000000000</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Graph bottom end (percent)</Name>
|
||||||
|
<Value>0.875000000</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data send speed (seconds)</Name>
|
||||||
|
<Value>3.045723677</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data0 red</Name>
|
||||||
|
<Value>0.000000000</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data0 green</Name>
|
||||||
|
<Value>72.138153076</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data0 blue</Name>
|
||||||
|
<Value>164.407897949</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data0 alpha</Name>
|
||||||
|
<Value>179.506576538</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data1 red</Name>
|
||||||
|
<Value>187.894729614</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data1 green</Name>
|
||||||
|
<Value>46.134868622</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data1 blue</Name>
|
||||||
|
<Value>32.713817596</Value>
|
||||||
|
</Widget>
|
||||||
|
<Widget>
|
||||||
|
<Kind>4</Kind>
|
||||||
|
<Name>Data1 alpha</Name>
|
||||||
|
<Value>187.894729614</Value>
|
||||||
|
</Widget>
|
||||||
@ -47,7 +47,6 @@ void DataManager::setupSpacebrew()
|
|||||||
|
|
||||||
void DataManager::update()
|
void DataManager::update()
|
||||||
{
|
{
|
||||||
|
|
||||||
if (isDataSimulated)
|
if (isDataSimulated)
|
||||||
{
|
{
|
||||||
if (ofGetFrameNum() % (int)simulationSpeed == 0)
|
if (ofGetFrameNum() % (int)simulationSpeed == 0)
|
||||||
@ -118,22 +117,22 @@ void DataManager::onMessage( Spacebrew::Message & m )
|
|||||||
{
|
{
|
||||||
if (data[i].substr(0, 5) == "info:")
|
if (data[i].substr(0, 5) == "info:")
|
||||||
{
|
{
|
||||||
printf("- - info = %s\n", data[i].substr(5, -1).c_str());
|
//printf("- - info = %s\n", data[i].substr(5, -1).c_str());
|
||||||
dataObject.info = data[i].substr(5, -1).c_str();
|
dataObject.info = data[i].substr(5, -1).c_str();
|
||||||
}
|
}
|
||||||
if (data[i].substr(0, 6) == "value:")
|
if (data[i].substr(0, 6) == "value:")
|
||||||
{
|
{
|
||||||
printf("- - value = %s\n", data[i].substr(6, -1).c_str());
|
//printf("- - value = %s\n", data[i].substr(6, -1).c_str());
|
||||||
dataObject.value = ofToFloat(data[i].substr(6, -1).c_str());
|
dataObject.value = ofToFloat(data[i].substr(6, -1).c_str());
|
||||||
}
|
}
|
||||||
if (data[i].substr(0, 4) == "min:")
|
if (data[i].substr(0, 4) == "min:")
|
||||||
{
|
{
|
||||||
printf("- - min = %s\n", data[i].substr(4, -1).c_str());
|
//printf("- - min = %s\n", data[i].substr(4, -1).c_str());
|
||||||
dataObject.min = ofToFloat(data[i].substr(4, -1).c_str());
|
dataObject.min = ofToFloat(data[i].substr(4, -1).c_str());
|
||||||
}
|
}
|
||||||
if (data[i].substr(0, 4) == "max:")
|
if (data[i].substr(0, 4) == "max:")
|
||||||
{
|
{
|
||||||
printf("- - max = %s\n", data[i].substr(4, -1).c_str());
|
//printf("- - max = %s\n", data[i].substr(4, -1).c_str());
|
||||||
dataObject.max = ofToFloat(data[i].substr(4, -1).c_str());
|
dataObject.max = ofToFloat(data[i].substr(4, -1).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@ void GUI::setup()
|
|||||||
addGraphGlobalGUI();
|
addGraphGlobalGUI();
|
||||||
addBarGraphDesignGUI();
|
addBarGraphDesignGUI();
|
||||||
addBodyGraphDesignGUI();
|
addBodyGraphDesignGUI();
|
||||||
|
addSeparateBodyGraphDesignGUI();
|
||||||
addGraphSimulationGUI();
|
addGraphSimulationGUI();
|
||||||
addBackgroundGUI();
|
addBackgroundGUI();
|
||||||
addHUDTextGUI();
|
addHUDTextGUI();
|
||||||
@ -59,7 +60,7 @@ void GUI::addGraphGlobalGUI()
|
|||||||
vector<string> graphNames;
|
vector<string> graphNames;
|
||||||
graphNames.push_back("Bar graph");
|
graphNames.push_back("Bar graph");
|
||||||
graphNames.push_back("Solid Body graph");
|
graphNames.push_back("Solid Body graph");
|
||||||
graphNames.push_back("Line fade graph");
|
graphNames.push_back("Separate Body 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);
|
||||||
|
|
||||||
@ -127,6 +128,34 @@ void GUI::addBodyGraphDesignGUI()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GUI::addSeparateBodyGraphDesignGUI()
|
||||||
|
{
|
||||||
|
string title = "SEPARATE BODY GRAPH DESIGN";
|
||||||
|
ofxUICanvas* gui = getNewGUI(title);
|
||||||
|
|
||||||
|
gui->addToggle("Toggle Draw Lines", &app->scene.separateBodyGraph.isDrawLines, toggleDim, toggleDim);
|
||||||
|
gui->addSlider("Graph Item X Gap", 5, 50, &app->scene.separateBodyGraph.graphItemXGap, length, dim);
|
||||||
|
gui->addSlider("Line width", 1, 50, &app->scene.separateBodyGraph.lineWidth, length, dim);
|
||||||
|
gui->addSlider("Graph Height Max", 100, 1000, &app->scene.separateBodyGraph.graphHeightMax, length, dim);
|
||||||
|
gui->addSlider("Graph bottom end (percent)", 0, 2, &app->scene.separateBodyGraph.graphEndPercent, length, dim);
|
||||||
|
gui->addSlider("Data send speed (seconds)", 0.1, 20, &app->scene.separateBodyGraph.sendDataSpeed, length, dim);
|
||||||
|
|
||||||
|
gui->addSpacer(length, 1);
|
||||||
|
gui->addSlider("Data0 red", 0, 255, &app->scene.separateBodyGraph.col0[0], length, dim);
|
||||||
|
gui->addSlider("Data0 green", 0, 255, &app->scene.separateBodyGraph.col0[1], length, dim);
|
||||||
|
gui->addSlider("Data0 blue", 0, 255, &app->scene.separateBodyGraph.col0[2], length, dim);
|
||||||
|
gui->addSlider("Data0 alpha", 0, 255, &app->scene.separateBodyGraph.col0[3], length, dim);
|
||||||
|
|
||||||
|
gui->addSpacer(length, 1);
|
||||||
|
gui->addSlider("Data1 red", 0, 255, &app->scene.separateBodyGraph.col1[0], length, dim);
|
||||||
|
gui->addSlider("Data1 green", 0, 255, &app->scene.separateBodyGraph.col1[1], length, dim);
|
||||||
|
gui->addSlider("Data1 blue", 0, 255, &app->scene.separateBodyGraph.col1[2], length, dim);
|
||||||
|
gui->addSlider("Data1 alpha", 0, 255, &app->scene.separateBodyGraph.col1[3], length, dim);
|
||||||
|
|
||||||
|
finaliseCanvas(gui, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GUI::addGraphSimulationGUI()
|
void GUI::addGraphSimulationGUI()
|
||||||
{
|
{
|
||||||
string title = "SIMULATION";
|
string title = "SIMULATION";
|
||||||
@ -243,10 +272,10 @@ void GUI::graphGlobalGUIEvent(ofxUIEventArgs &e)
|
|||||||
printf("------------------- Solid Body graph\n");
|
printf("------------------- Solid Body graph\n");
|
||||||
if (toggle->getValue()) app->scene.activeGraph = &app->scene.bodyGraph;
|
if (toggle->getValue()) app->scene.activeGraph = &app->scene.bodyGraph;
|
||||||
}
|
}
|
||||||
else if (name == "Line fade graph")
|
else if (name == "Separate Body graph")
|
||||||
{
|
{
|
||||||
printf("------------------- Line fade graph\n");
|
printf("------------------- Line fade graph\n");
|
||||||
//app->scene.activeGraph = &app->scene.lineGraph;
|
if (toggle->getValue()) app->scene.activeGraph = &app->scene.separateBodyGraph;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -23,6 +23,7 @@ public:
|
|||||||
void addGraphGlobalGUI();
|
void addGraphGlobalGUI();
|
||||||
void addBarGraphDesignGUI();
|
void addBarGraphDesignGUI();
|
||||||
void addBodyGraphDesignGUI();
|
void addBodyGraphDesignGUI();
|
||||||
|
void addSeparateBodyGraphDesignGUI();
|
||||||
void addGraphSimulationGUI();
|
void addGraphSimulationGUI();
|
||||||
void addBackgroundGUI();
|
void addBackgroundGUI();
|
||||||
void addHUDTextGUI();
|
void addHUDTextGUI();
|
||||||
|
|||||||
@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// ====
|
// ====
|
||||||
// - Make system to slow down data - The screen should show 15-20 minutes worth of data
|
|
||||||
// - Make 3rd graph - separate fade
|
|
||||||
// - Crosshairs in HUD
|
// - Crosshairs in HUD
|
||||||
// - Create graph animation system
|
// - 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
|
// - Create a single config file to be loaded from online location. It will contain IP address and host name
|
||||||
// - Add 'clear all data' button to UI
|
|
||||||
// - If min or max values change - clear graph - ask bout this
|
// - If min or max values change - clear graph - ask bout this
|
||||||
//
|
//
|
||||||
//--------------------------------------------------------------
|
//--------------------------------------------------------------
|
||||||
|
|||||||
@ -18,6 +18,7 @@ void Scene::setup()
|
|||||||
rgbShader.load("shaders/RGBShader");
|
rgbShader.load("shaders/RGBShader");
|
||||||
barGraph.setup();
|
barGraph.setup();
|
||||||
bodyGraph.setup();
|
bodyGraph.setup();
|
||||||
|
separateBodyGraph.setup();
|
||||||
|
|
||||||
text.loadFont("fonts/Roboto-Light.ttf", 8);
|
text.loadFont("fonts/Roboto-Light.ttf", 8);
|
||||||
}
|
}
|
||||||
@ -197,6 +198,7 @@ void Scene::addNewData(vector<DataObject> newData)
|
|||||||
{
|
{
|
||||||
barGraph.addNewData(newData);
|
barGraph.addNewData(newData);
|
||||||
bodyGraph.addNewData(newData);
|
bodyGraph.addNewData(newData);
|
||||||
|
separateBodyGraph.addNewData(newData);
|
||||||
|
|
||||||
tlStr = newData[0].info + "\n" + ofToString(newData[0].value);
|
tlStr = newData[0].info + "\n" + ofToString(newData[0].value);
|
||||||
trStr = newData[1].info + "\n" + ofToString(newData[1].value);
|
trStr = newData[1].info + "\n" + ofToString(newData[1].value);
|
||||||
@ -215,4 +217,5 @@ void Scene::clearGraphData()
|
|||||||
{
|
{
|
||||||
barGraph.clear();
|
barGraph.clear();
|
||||||
bodyGraph.clear();
|
bodyGraph.clear();
|
||||||
|
separateBodyGraph.clear();
|
||||||
}
|
}
|
||||||
@ -11,6 +11,7 @@
|
|||||||
#include "ofMain.h"
|
#include "ofMain.h"
|
||||||
#include "BarGraph.h"
|
#include "BarGraph.h"
|
||||||
#include "BodyGraph.h"
|
#include "BodyGraph.h"
|
||||||
|
#include "SeparateBodyGraph.h"
|
||||||
#include "DataManager.h"
|
#include "DataManager.h"
|
||||||
#include "ofxFTGL.h"
|
#include "ofxFTGL.h"
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ public:
|
|||||||
|
|
||||||
BarGraph barGraph;
|
BarGraph barGraph;
|
||||||
BodyGraph bodyGraph;
|
BodyGraph bodyGraph;
|
||||||
|
SeparateBodyGraph separateBodyGraph;
|
||||||
|
|
||||||
ofShader rgbShader;
|
ofShader rgbShader;
|
||||||
ofVideoGrabber vidGrabber;
|
ofVideoGrabber vidGrabber;
|
||||||
ofImage bgImg;
|
ofImage bgImg;
|
||||||
|
|||||||
@ -20,7 +20,6 @@ void AbstractGraph::setup()
|
|||||||
void AbstractGraph::update()
|
void AbstractGraph::update()
|
||||||
{
|
{
|
||||||
maxData = (ofGetWidth() * (AbstractGraph::maxGraphPercent - AbstractGraph::minGraphPercent)) / graphItemXGap;
|
maxData = (ofGetWidth() * (AbstractGraph::maxGraphPercent - AbstractGraph::minGraphPercent)) / graphItemXGap;
|
||||||
printf("ofGetWidth():%i, maxData:%i, graphItemXGap:%f, screen active:%f \n", ofGetWidth(), maxData, graphItemXGap, (AbstractGraph::maxGraphPercent - AbstractGraph::minGraphPercent));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
171
of/Active Tripod/src/visual/graph/SeparateBodyGraph.cpp
Normal file
171
of/Active Tripod/src/visual/graph/SeparateBodyGraph.cpp
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
//
|
||||||
|
// Created by James Alliban on 11/01/2014.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "SeparateBodyGraph.h"
|
||||||
|
#include "testApp.h"
|
||||||
|
|
||||||
|
|
||||||
|
void SeparateBodyGraph::setup()
|
||||||
|
{
|
||||||
|
AbstractGraph::setup();
|
||||||
|
app = (testApp*)ofGetAppPtr();
|
||||||
|
graphName = "SEPARATE_BODY";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SeparateBodyGraph::update()
|
||||||
|
{
|
||||||
|
AbstractGraph::update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SeparateBodyGraph::draw()
|
||||||
|
{
|
||||||
|
if (app->gui.getVisible())
|
||||||
|
{
|
||||||
|
float timePerScreenfull = (float)maxData * sendDataSpeed;
|
||||||
|
ofDrawBitmapString("Time to fill screen:" + ofToString(timePerScreenfull), 500, 150);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (publisher0Data.size() > 1)
|
||||||
|
{
|
||||||
|
//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();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ofMesh body0 = getMesh(publisher0Data, col0);
|
||||||
|
ofMesh body1 = getMesh(publisher1Data, col1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent;
|
||||||
|
float outputMin = (ofGetHeight() * 0.5) - graphHeightMax;
|
||||||
|
float outputMax = (ofGetHeight() * 0.5) + graphHeightMax;
|
||||||
|
|
||||||
|
|
||||||
|
// draw lines
|
||||||
|
ofPushStyle();
|
||||||
|
ofPolyline poly0;
|
||||||
|
ofPolyline poly1;
|
||||||
|
for (int i = 0; i < publisher0Data.size() - 1; i++)
|
||||||
|
{
|
||||||
|
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)));
|
||||||
|
|
||||||
|
|
||||||
|
poly1.addVertex(ofPoint(
|
||||||
|
i * graphItemXGap + xOffset,
|
||||||
|
ofMap(publisher1Data[i].value, publisher1Data[i].min, publisher1Data[i].max, outputMin, outputMax)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ofVec2f centroid0 = poly0.getCentroid2D();
|
||||||
|
ofVec2f centroid1 = poly1.getCentroid2D();
|
||||||
|
|
||||||
|
printf("centroid0.y:%f, centroid1.y:%f\n", centroid0.y, centroid1.y);
|
||||||
|
|
||||||
|
float av0;
|
||||||
|
float av1;
|
||||||
|
|
||||||
|
for (int i = 0; i < poly0.size(); i++)
|
||||||
|
{
|
||||||
|
av0 += poly0[i].y;
|
||||||
|
av1 += poly1[i].y;
|
||||||
|
}
|
||||||
|
av0 /= poly0.size();
|
||||||
|
av1 /= poly1.size();
|
||||||
|
|
||||||
|
printf("av0:%f, av1:%f\n", av0, av1);
|
||||||
|
|
||||||
|
int lineAlpha = 255;
|
||||||
|
if (!isDrawLines) lineAlpha = 0;
|
||||||
|
|
||||||
|
if (av0 < av1)
|
||||||
|
{
|
||||||
|
body0.drawFaces();
|
||||||
|
ofSetColor(col0[0],col0[1],col0[2], lineAlpha);
|
||||||
|
poly0.draw();
|
||||||
|
|
||||||
|
body1.drawFaces();
|
||||||
|
ofSetColor(col1[0],col1[1],col1[2], lineAlpha);
|
||||||
|
poly1.draw();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
body1.drawFaces();
|
||||||
|
ofSetColor(col1[0],col1[1],col1[2], lineAlpha);
|
||||||
|
poly1.draw();
|
||||||
|
|
||||||
|
body0.drawFaces();
|
||||||
|
ofSetColor(col0[0],col0[1],col0[2], lineAlpha);
|
||||||
|
poly0.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDrawLines)
|
||||||
|
{
|
||||||
|
if (av0 > av1)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ofPopStyle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ofMesh SeparateBodyGraph::getMesh(vector<DataObject> publisherData, float* col)
|
||||||
|
{
|
||||||
|
ofMesh bodyMesh;
|
||||||
|
float xOffset = ofGetWidth() * AbstractGraph::minGraphPercent;
|
||||||
|
float outputMin = (ofGetHeight() * 0.5) - graphHeightMax;
|
||||||
|
float outputMax = (ofGetHeight() * 0.5) + graphHeightMax;
|
||||||
|
|
||||||
|
// draw main part of graph (xOffset)
|
||||||
|
bodyMesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
|
||||||
|
for (int i = 0; i < publisherData.size() - 1; i++)
|
||||||
|
{
|
||||||
|
bodyMesh.addVertex(ofVec3f(
|
||||||
|
i * graphItemXGap + xOffset,
|
||||||
|
ofMap(publisherData[i].value, publisherData[i].min, publisherData[i].max, outputMin, outputMax),
|
||||||
|
0));
|
||||||
|
bodyMesh.addVertex(ofVec3f(
|
||||||
|
i * graphItemXGap + xOffset,
|
||||||
|
ofGetHeight() * graphEndPercent,
|
||||||
|
0));
|
||||||
|
|
||||||
|
bodyMesh.addColor(ofColor(col[0],col[1],col[2], col[3]));
|
||||||
|
bodyMesh.addColor(ofColor(col[0],col[1],col[2], 0));
|
||||||
|
}
|
||||||
|
return bodyMesh;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void SeparateBodyGraph::addNewData(vector<DataObject> newData)
|
||||||
|
{
|
||||||
|
AbstractGraph::addNewData(newData);
|
||||||
|
}
|
||||||
24
of/Active Tripod/src/visual/graph/SeparateBodyGraph.h
Normal file
24
of/Active Tripod/src/visual/graph/SeparateBodyGraph.h
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "ofMain.h"
|
||||||
|
#include "AbstractGraph.h"
|
||||||
|
|
||||||
|
class testApp;
|
||||||
|
|
||||||
|
class SeparateBodyGraph : public AbstractGraph
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void setup();
|
||||||
|
virtual void update();
|
||||||
|
virtual void draw();
|
||||||
|
virtual void addNewData(vector<DataObject> newData);
|
||||||
|
ofMesh getMesh(vector<DataObject> publisherData, float* col);
|
||||||
|
|
||||||
|
testApp *app;
|
||||||
|
|
||||||
|
float lineWidth;
|
||||||
|
|
||||||
|
bool isDrawLines;
|
||||||
|
float graphEndPercent;
|
||||||
|
};
|
||||||
Loading…
x
Reference in New Issue
Block a user