diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/obtsDevice.cpp | 47 | ||||
| -rw-r--r-- | src/obtsDevice.h | 48 |
2 files changed, 95 insertions, 0 deletions
diff --git a/src/obtsDevice.cpp b/src/obtsDevice.cpp new file mode 100644 index 0000000..70e60c3 --- /dev/null +++ b/src/obtsDevice.cpp @@ -0,0 +1,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);
+ }
+}
diff --git a/src/obtsDevice.h b/src/obtsDevice.h new file mode 100644 index 0000000..884600b --- /dev/null +++ b/src/obtsDevice.h @@ -0,0 +1,48 @@ +#ifndef OBTSDEVICE_H
+#define OBTSDEVICE_H
+
+#include "ofMain.h"
+
+/*
+created with icon, colour, linesize etc
+in order to draw need to know:
+
+time now: in order to draw relatively (this is not actual time as it can draw historically)
+scale: fixed (defined at object creation)
+or always zoom out? (begin time defined at object creation)
+
+events: connect(is create) disconnect() call(* obtsDevice) hangup() sms(* obtsDevice)
+functions: draw(time) getPosition(time)
+
+variables: pointer to icon image
+
+*/
+
+struct timeseg{
+ timeseg(float _st,float _et){
+ startTime=_st;
+ endTime=_et;
+ }
+ float startTime;
+ float endTime;
+};
+
+
+class obtsDevice
+{
+ public:
+ obtsDevice();
+ obtsDevice(string &imsi,ofImage *_icon,ofVec2f _coords);
+ virtual ~obtsDevice();
+ void draw(float timeScale); //units per second
+ void connect();
+ void disconnect();
+ protected:
+ private:
+ string IMSI;
+ ofVec2f coords; //angular coords
+ vector<timeseg> connectionHistory;
+ ofImage *icon;
+};
+
+#endif // OBTSDEVICE_H
|
