Mercurial > hg > soniczoomios
diff eventLogger.mm @ 33:92dba082d957
Added trail and EVALUATION_POINT event type.
author | Robert Tubb <rt300@eecs.qmul.ac.uk> |
---|---|
date | Tue, 26 Mar 2013 18:41:42 +0000 |
parents | ab7c86d0f3d8 |
children | 790939017078 |
line wrap: on
line diff
--- a/eventLogger.mm Fri Mar 08 14:54:55 2013 +0000 +++ b/eventLogger.mm Tue Mar 26 18:41:42 2013 +0000 @@ -8,9 +8,30 @@ //--------------------------------------------------------------------------- #include "eventLogger.h" +#include "grid.h" + +extern Grid theGridView; EventLogger eventLogger; extern PresetManager presetManager; +//--------------------------------------------------------------------------- +void lEvent::draw(){ + // can't draw lines you fool + double size = 2.0; + TwoVector pos = theGridView.coordToPixel(TwoVector(val1,val2)); // euch -rely on grid view? + + if(eventType == SCROLL){ + ofSetColor(255,123,56); + ofRect(pos.x, pos.y,size,size); + }else if(eventType == EVALUATION_POINT){ + size = sliderID/150.0; // slider id is the hover time. sorry sorry. + if(size > 40) size = 40; + ofSetColor(25,123,216); + ofNoFill(); + ofEllipse(pos.x, pos.y, size, size); + + } +} //--------------------------------------------------------------------------- EventLogger::EventLogger(){ @@ -156,8 +177,10 @@ questionnaireCompleted = false; questionnaireUploaded = false; - ((testApp *)ofGetAppPtr())->showIntro(); - consentGiven = false; + //((testApp *)ofGetAppPtr())->showIntro(); + //consentGiven = false; + ((testApp *)ofGetAppPtr())->justStart(); + } @@ -209,7 +232,7 @@ } //----------------------------- void EventLogger::eventlogOK(){ - // IF UPLAODING FROM IPAD TO XCODE + // COMMENT THIS IF UPLAODING FROM IPAD TO XCODE theEvents.clear(); cout << "EVENT LOG UPLOAD SUCCESS\n"; nextUploadNumber++; @@ -244,7 +267,8 @@ //--------------------------------------------------------------------------- bool EventLogger::uploadEventLog(bool async){ - + // COMMENT THIS OUTRT !!!!!!!! + return false; // show indicator logUploadInProgress = true; cout << "^^^^^^^^ ATTEMPTING TO UPLOAD " << theEvents.size() << " EVENTS ^^^^^^^^ .\n"; @@ -268,8 +292,62 @@ } } //---------------------------------------------------------------------------- +bool eventWasInRegion(vector<lEvent>::iterator eiter, TwoVector regionTopLeft, TwoVector regionBottomRight){ + if( ((*eiter).val1 > regionTopLeft.x ) && ((*eiter).val2 > regionTopLeft.y ) && ((*eiter).val1 < regionBottomRight.x ) && ((*eiter).val2 < regionBottomRight.y )){ + return true; + }else{ + return false; + } + +} +//---------------------------------------------------------------------------- +void EventLogger::drawTrail(const TwoVector min, const TwoVector max){ + // horribly inefficient + vector<lEvent>::iterator eiter; + vector<lEvent>::iterator preveiter; + int i = 0; + + + + preveiter = theEvents.begin(); + for(eiter = --theEvents.end(); eiter > theEvents.begin(); eiter--){ -//---------------------------------------------------------------------------- + //cout << i << '\n'; + if( (*eiter).eventType == SCROLL || (*eiter).eventType == EVALUATION_POINT){ + i++; + if(i > SCROLL_TRAIL_LENGTH){ + return; + } + if(eventWasInRegion(eiter, min, max) || eventWasInRegion(preveiter, min, max)){ + // draw a line between prev and this + if(preveiter != theEvents.begin()){ + TwoVector start = theGridView.coordToPixel(TwoVector((*preveiter).val1,(*preveiter).val2)); + TwoVector end = theGridView.coordToPixel(TwoVector((*eiter).val1,(*eiter).val2)); + ofSetColor(255,255,255,96); + ofLine(start.x,start.y, end.x, end.y); + + }else{ + // draw line from listen point to last evt + TwoVector start = TwoVector(ofGetWidth()*0.5,ofGetHeight()*0.5); + TwoVector end = theGridView.coordToPixel(TwoVector((*eiter).val1,(*eiter).val2)); + ofSetColor(255,255,255,96); + ofLine(start.x,start.y, end.x, end.y); + // draw ever growing listen point + + } + + } + preveiter = eiter; + } + if( (*eiter).eventType == EVALUATION_POINT){ + if( ((*eiter).val1 > min.x ) && ((*eiter).val2 > min.y ) && ((*eiter).val1 < max.x ) && ((*eiter).val2 < max.y )){ + // draw it + (*eiter).draw(); + } + } + } + +} //--------------------------------------------------------------------------- // only called when doing supervised tests @@ -299,10 +377,42 @@ //timer.startInteractionClock(); [((testApp *)ofGetAppPtr())->tsc startTimer]; + + // press play?? +} +//--------------------------------------------------------------------------- +void EventLogger::thinnedScrollEvent(lEvent newEvent){ + static lEvent previousEvent(EMPTY_EVENT); // initialised as whatever + static int eventCounter = 0; + + // if first event then log it. it won't be, but still. + if(theEvents.size() == 0){ + theEvents.push_back(newEvent); + previousEvent = newEvent; + return; + } + + // if previous event is more than 300ms ago, or event type has changed, log both of them (lots of events on move+zoom combinations!!) + int gap = newEvent.eventTime - previousEvent.eventTime; + if(gap > 300){ + // log previous event as a evaluation point MAYBE TODO if previous event was logged as scroll chuck it out? + theEvents.push_back(lEvent(EVALUATION_POINT, previousEvent.val1, previousEvent.val2, gap)); + // and now new event as scroll + theEvents.push_back(newEvent); + eventCounter = 0; + + }else if(eventCounter >= EVENT_THIN_FACTOR){ // otherwise only record every Nth event + theEvents.push_back(newEvent); + eventCounter = 0; + + } + eventCounter++; + previousEvent = newEvent; + } //--------------------------------------------------------------------------- void EventLogger::thinnedLogEvent(lEvent newEvent){ - static lEvent previousEvent(APP_STARTED); // initialised as whatever. hopefully won't log + static lEvent previousEvent(EMPTY_EVENT); // initialised as whatever. hopefully won't log static int eventCounter = 0; // if first event then log it. it won't be, but still. @@ -334,7 +444,7 @@ } //--------------------------------------------------------------------------- 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 @@ -349,7 +459,8 @@ switch ( evtType ) { // data thinning here case SCROLL: - thinnedLogEvent(lEvent(evtType,centre.x,centre.y)); + thinnedScrollEvent(lEvent(evtType,centre.x,centre.y)); + //theEvents.push_back(lEvent(evtType,centre.x,centre.y)); break; case ZOOM: thinnedLogEvent(lEvent(evtType,scale)); @@ -503,3 +614,19 @@ logFile.close(); } +//---------------------------------------------------------------------------- +// TODO this path thing +vector<TwoVector> EventLogger::getRecentPath(int numEvents){ + vector<TwoVector> thePath; + + TwoVector lastScrollPos; + vector<lEvent>::iterator eventIndex; + eventIndex = theEvents.end(); + int numScrolls = 0; + while(numScrolls < numEvents){ + // go back check for scrolls, check for end of array etc. + thePath.push_back(lastScrollPos); + numScrolls++; + } + return thePath; +} \ No newline at end of file