1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
#include "obtsDevice.h"
obtsDevice::obtsDevice()
{
}
obtsDevice::obtsDevice(string &imsi,ofImage *_icon,ofVec2f _coords)
{
IMSI=imsi;
coords=_coords;
icon=_icon;
connect();
printf("new device: IMSI%s\n",IMSI.c_str());
}
void obtsDevice::connect(){
connectionHistory.push_back(timeseg(ofGetElapsedTimef(),0.0f));
}
void obtsDevice::disconnect(){
connectionHistory[connectionHistory.size()-1].endTime=ofGetElapsedTimef();
}
obtsDevice::~obtsDevice()
{
//dtor
}
void obtsDevice::draw(float timeScale)
{
//draw a line at the angular position of the device
//z=0 is the 'surface' i.e. now.
//the device know the time now and when it was created
//needs to know the time the app began in order to scale the line vertically
//dynamic scaling or fixed vertical scale?
//for dynamic, just scale vertically based on time
//for fixed/dynamic, pass a scaling parameter when drawing
float rf=sin((coords.y/(ofGetWidth()*0.9))*TWO_PI);
ofSetColor(0x8f*rf,0x8f*rf,0x8f*rf);
float now=ofGetElapsedTimef();
for (vector<timeseg>::iterator i=connectionHistory.begin();i!=connectionHistory.end();i++){
float startPos=(-now+(*i).startTime)/timeScale;
float endPos=(*i).endTime>0.0f?(-now+(*i).endTime)/timeScale:0.0f;
ofLine(cos(coords.x)*coords.y,sin(coords.x)*coords.y,startPos,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
//printf("%f drawing %f,%f,%f to %f,%f,%f\n",ofGetElapsedTimef(),cos(coords.x)*coords.y,sin(coords.x)*coords.y,startPos,cos(coords.x)*coords.y,sin(coords.x)*coords.y,endPos);
}
}
|