# HG changeset patch # User Robert Tubb # Date 1358344468 0 # Node ID a7d6a13287fac329a0dd601647eb0c95557430b1 # Parent 346807b478603e869e65faebfb297f061e98944a removed old files diff -r 346807b47860 -r a7d6a13287fa 2dvector.h.orig --- a/2dvector.h.orig Wed Jan 16 13:44:07 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,80 +0,0 @@ -/* - * 2dvector.h - * simplespring - * - * Created by Robert Tubb on 01/06/2011. - * Copyright 2011 __MyCompanyName__. All rights reserved. - * - */ -#ifndef _2DVECTORH -#define _2DVECTORH -#include - -class TwoVector{ -public: - double x, y; - TwoVector(); - TwoVector(double ax, double ay); - -// public methods - double norm(); - void setCoord(double ax, double ay); - TwoVector minus(const TwoVector& otherPoint); - TwoVector operator-(const TwoVector& otherPoint); - TwoVector operator+(const TwoVector& otherPoint); - - TwoVector operator*(const TwoVector& otherPoint); - TwoVector operator*(const double& scalar); // scalar is right operand - TwoVector operator/(const double& scalar); // scalar is right operand - - //TwoVector operator=(TwoVector otherPoint); - - - - - double distanceTo(const TwoVector& otherPoint); - - - -}; -using namespace std; -// output text formatting: (x,y) in super precise output -inline ostream& operator<<(ostream& ostr, const TwoVector& tvec){ - ostr.setf(ios_base::fixed,ios_base::floatfield); - ostr.precision(6); - - ostr << "(" << tvec.x << "," << tvec.y << ")"; - return ostr; -} -inline istream& operator>>(istream& istr, TwoVector& tvec){ - // um - - char l_paren , comma, r_paren; - - - if(istr.bad()){ - cout << "BAD INPUT"; - return istr; - } - - istr.setf(ios_base::fixed,ios_base::floatfield); - istr.precision(1); - - istr >> l_paren >> tvec.x >> comma >> tvec.y >> r_paren; - if(l_paren != '('){ - cout << "BAD INPUT ("; - return istr; - } - - if(comma != ','){ - cout << "BAD INPUT ,"; - return istr; - } - - if(r_paren != ')'){ - cout << "BAD INPUT )"; - return istr; - } - return istr; -} -#endif // #ifndef _2DVECTORH \ No newline at end of file diff -r 346807b47860 -r a7d6a13287fa 2dvector.mm.orig --- a/2dvector.mm.orig Wed Jan 16 13:44:07 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,85 +0,0 @@ -/* - * 2dvector.cpp - * simplespring - * - * Created by Robert Tubb on 01/06/2011. - * Copyright 2011 __MyCompanyName__. All rights reserved. - * - */ - -#include "2dvector.h" - - -TwoVector::TwoVector(){ - x = 0.0; - y = 0.0; - //cout << "def constr set vector to zeros" << endl; -} - -TwoVector::TwoVector(double ax, double ay){ - x = ax; - y = ay; - //cout << "spec constr set vector to " << ax << "," << ay << endl; -} - -double TwoVector::norm(){ - double norm; - norm = sqrt(x * x + y * y); - return norm; - -} - -void TwoVector::setCoord(double ax, double ay){ - x = ax; - y = ay; - -} - -TwoVector TwoVector::minus(const TwoVector& otherPoint){ - TwoVector diff; - diff.setCoord(x - otherPoint.x, y - otherPoint.y); - return diff; -} - -TwoVector TwoVector::operator-(const TwoVector& otherPoint){ - TwoVector diff; - diff.setCoord(x - otherPoint.x, y - otherPoint.y); - return diff; -} - -TwoVector TwoVector::operator*(const TwoVector& otherPoint){ // if multiplying two vectors - elementwise - TwoVector diff; - diff.setCoord(x * otherPoint.x, y * otherPoint.y); - return diff; -} - -TwoVector TwoVector::operator*(const double& scalar){ - TwoVector prod; - prod.setCoord(x * scalar, y * scalar); - return prod; -} -TwoVector TwoVector::operator/(const double& scalar){ - TwoVector res; - res.setCoord(x / scalar, y / scalar); - return res; -} - -TwoVector TwoVector::operator+(const TwoVector& otherPoint){ - TwoVector diff; - diff.setCoord(otherPoint.x + x, otherPoint.y + y); - return diff; -} - -/* -TwoVector TwoVector::operator=(TwoVector otherPoint){ - TwoVector result; - result.setCoord(otherPoint.x, otherPoint.y); - return result; -} -*/ -double TwoVector::distanceTo(const TwoVector& otherPoint){ - TwoVector diff; - diff.setCoord(otherPoint.x - x, otherPoint.y - y); - return diff.norm(); -} - diff -r 346807b47860 -r a7d6a13287fa eventLogger.h.orig --- a/eventLogger.h.orig Wed Jan 16 13:44:07 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -// -// eventLogger.h -// oscSenderExample -// -// Created by Robert Tubb on 05/11/2012. -// -// -// This class handle everything to do with loggin user actions, -// uploading logs to server, and storing locally if not uploaded - -#ifndef __oscSenderExample__eventLogger__ -#define __oscSenderExample__eventLogger__ - - -#include "ofMain.h" -#include "ofxiPhone.h" -#include "2dvector.h" -#include "ofxiPhoneExtras.h" -#include -#include -#include -#include -#include "2dvector.h" -enum leventType {SAVE_PRESET, SAVE_DESET, SCROLL, SCROLL_STOPPED, ZOOM, CHANGE_SLIDER, SWAP_VIEW, SET_MIN_ZOOM, SET_MAX_ZOOM}; - -class lEvent{ -public: - // try and make this as compact as possible. - leventType eventType; - double val1; // x coord, scale if zoom - double val2; // y coord, 0 if zoom - int sliderID; - lEvent(leventType eType, double v1, double v2 = 0.0,int sID = 0){ - eventType = eType; - val1 = v1; - val2 = v2; - sliderID = sID; - } -}; -//--------------------------------------------------------------------------- -inline istream& operator>>(istream & is, lEvent& e){ - is.setf(ios_base::fixed,ios_base::floatfield); - is.precision(1); - - char delim; - int eType; - - is >> eType >> delim >> e.val1 >> delim >> e.val2 >> delim >> e.sliderID; - - e.eventType = (leventType)eType; - - return is; -} - -//--------------------------------------------------------------------------- -inline ostream& operator<<(ostream & os, const lEvent& e){ - os.setf(ios_base::fixed,ios_base::floatfield); - os.precision(1); - - os << e.eventType << ',' << e.val1 << ',' << e.val2 << ',' << e.sliderID << '\n'; - - return os; - } - //--------------------------------------------------------------------------- - -class EventLogger{ -public: - // what we need... - /* - time, type, value - */ - bool loggingEnabled; - bool firstTimeOpened; - - vector theEvents; - - string userID; // get something from hardware?? - - EventLogger(); - void logEvent(const leventType& evtType,const TwoVector& centre = TwoVector(), const double& scale = 1.0, const int& sliderID = -1, const double& sliderVal = 0.0); - void logEvent(const leventType& evtType,const int& sliderID, const double& sliderVal); - void sendHttp(); - - void printAll(){ - cout << "ALL LOGGED EVENTS!: \n"; - vector::iterator evIter; - for(evIter = theEvents.begin(); evIter < theEvents.end(); evIter++){ - cout << *evIter; - - } - }; -}; - - - - -#endif /* defined(__oscSenderExample__eventLogger__) */ diff -r 346807b47860 -r a7d6a13287fa eventLogger.mm.orig --- a/eventLogger.mm.orig Wed Jan 16 13:44:07 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,93 +0,0 @@ -// -// eventLogger.mm -// oscSenderExample -// -// Created by Robert Tubb on 05/11/2012. -// -// - - -#include "eventLogger.h" - - -EventLogger eventLogger; - -EventLogger::EventLogger(){ - - // if first time opened request a user ID from the server... use time? - loggingEnabled = true; - firstTimeOpened = true; - - - if (firstTimeOpened){ - userID = ofGetSystemTimeMicros( ); - } - - - - - -} - -void EventLogger::logEvent(const leventType& evtType,const TwoVector& centre, const double& scale, const int& sliderID, const double& sliderVal){ - //cout << "log: " << evtType << "\n"; - - // scroll has 2 double coords - // zoom has 1 double scale - // save preset has 2 coords - // switch view has view type - // slider change has int slider index and 1 int value - - // get time for key index - - // thinFactor - if(!loggingEnabled) return; - switch ( evtType ) { - case SAVE_PRESET: - theEvents.push_back(lEvent(evtType,centre.x,centre.y)); - // Code - break; - case SAVE_DESET: - theEvents.push_back(lEvent(evtType,centre.x,centre.y)); - break; - case SCROLL: - theEvents.push_back(lEvent(evtType,centre.x,centre.y)); - break; - case SCROLL_STOPPED: - theEvents.push_back(lEvent(evtType,centre.x,centre.y)); - break; - case ZOOM: - theEvents.push_back(lEvent(evtType,scale)); - break; - case CHANGE_SLIDER: - theEvents.push_back(lEvent(evtType,sliderVal , 0.0 , sliderID)); - break; - default: - // Code - break; - } - - -} -void EventLogger::logEvent(const leventType& evtType,const int& sliderID, const double& sliderVal){ - if(!loggingEnabled) return; - // sliderThinFactor - switch ( evtType ) { - case CHANGE_SLIDER: - theEvents.push_back(lEvent(evtType,sliderVal , 0.0 , sliderID)); - break; - default: - // Code - break; - } -} -void EventLogger::sendHttp(){ - - string url = "http://www.rootnot.co.uk/cgi-bin/zoomlogs.cgi"; - ofURLFileLoader fileLoader; - ofHttpResponse resp; - resp = fileLoader.get(url); - cout << "HTTP STATUS " << resp.status << "\n"; - cout << "HTTP ERROR " << resp.error << "\n"; - cout << "HTTP DATA " << resp.data << "\n"; -} \ No newline at end of file