void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'q': case 27: { optotrak.stopCollection(); Sleep(1000); exit(0); } break; case 'i': infoDrawn=!infoDrawn; break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisiblePatch ) { headEyeCoords.init(markers[17].p,markers[18].p, markers[1].p,markers[2].p,markers[3].p,interoculardistance ); headCalibrationDone=1; beepOk(); break; } // Second calibration, you must look a fixed fixation point if ( headCalibrationDone==1 && allVisiblePatch) { headEyeCoords.init( headEyeCoords.getP1().p,headEyeCoords.getP2().p, markers[1].p, markers[2].p,markers[3].p,interoculardistance ); headCalibrationDone=2; beepOk(); break; } if ( headCalibrationDone==2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1().p,headEyeCoords.getP2().p, markers[1].p, markers[2].p,markers[3].p,interoculardistance ); beepOk(); break; } } break; // Enter key: press to make the final calibration case 13: { if ( canCalibrate && headCalibrationDone == 2 && allVisiblePatch ) { headEyeCoords.init( headEyeCoords.getP1().p,headEyeCoords.getP2().p, markers[1].p, markers[2].p,markers[3].p,interoculardistance ); headCalibrationDone=3; infoDrawn=false; for (int i=0; i<3; i++) beepOk(); } } break; } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'q': case 27: { cleanup(); exit(0); } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisibleHead ) { headEyeCoords.init(markers.at(17).p,markers.at(18).p, markers.at(1).p,markers.at(2).p,markers.at(3).p,interoculardistance ); headCalibrationDone=1; beepOk(); break; } if ( headCalibrationDone==1 && allVisiblePatch ) { headCalibrationDone=3; beepOk(); } } break; case 'i': infoDraw=!infoDraw; break; case 'f': case 'F': { // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { platformIndex=markers.at(16).p; platformThumb=markers.at(15).p; fingerCalibrationDone=1; beepOk(); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { thumbCoords.init(platformThumb, markers.at(11).p, markers.at(12).p, markers.at(13).p); indexCoords.init(platformIndex, markers.at(7).p, markers.at(8).p, markers.at(9).p ); fingerCalibrationDone=2; beepOk(); break; } if ( fingerCalibrationDone==2 && allVisibleFingers ) { infoDraw=false; drawGLScene(); physicalRigidBodyTip = indexCoords.getP1().p; fingerCalibrationDone=3; switch ( block.at("Phase") ) { case 0: case 2: { factors = trial.getNext(); initStimulus(testStimHeight,testStimRadius); moveScreenAbsolute(factors.at("Distances"),homeFocalDistance,SCREENSPEED); initProjectionScreen(factors.at("Distances")); visualRodCenter = Vector3d(0,0,factors.at("Distances")); hapticRodCenter = rodAway; // keep it away moveRod(rodAway,RODSPEED); } break; case 1: { double zadaptmin = str2num<double>(parameters.find("AdaptZMin")); double zadaptmax = str2num<double>(parameters.find("AdaptZMax")); if (str2num<int>(parameters.find("AdaptMoveMonitor"))==1) visualRodCenter = Vector3d(0,0,mathcommon::unifRand(zadaptmin,zadaptmax)); else visualRodCenter = Vector3d(0,0,(zadaptmax+zadaptmin)/2); if ( str2num<int>(parameters.find("AdaptHapticFeedback"))==1 ) hapticRodCenter = visualRodCenter - Vector3d(0,0,adaptOffsets.at(block1TrialNumber)); else hapticRodCenter = rodAway; initProjectionScreen( visualRodCenter.z() ); initStimulus(str2num<double>(parameters.find("AdaptStimulusHeight")),str2num<double>(parameters.find("AdaptStimulusRadius"))); moveScreenAbsoluteAsynchronous(visualRodCenter.z(),homeFocalDistance,SCREENSPEED); moveRod(hapticRodCenter,RODSPEED); } break; } trialMode = HANDONSTARTMODE; fingerDistance = (indexCoords.getP1().p-thumbCoords.getP1().p).norm(); beepTrial(); trialFrame=0; globalTimer.start(); totalTime.start(); break; } } break; } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'q': case 27: { plato_stop(); exit(0); } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisibleHead ) { headEyeCoords.init(markers.at(17).p,markers.at(18).p, markers.at(1).p,markers.at(2).p,markers.at(3).p,interoculardistance ); headCalibrationDone=1; beepOk(); break; } if ( headCalibrationDone==1 && allVisiblePatch ) { headCalibrationDone=3; RoveretoMotorFunctions::moveObjectAbsolute( platformCalibration, rodTipHome, 3500); beepOk(); } } break; case 'i': infoDraw=!infoDraw; break; case 'f': case 'F': { if (headCalibrationDone < 3 ) break; // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { platformIndex=markers.at(16).p; platformThumb=markers.at(15).p; fingerCalibrationDone=1; beepOk(); break; } // Calibrate the index first if ( (fingerCalibrationDone==1) && allVisibleIndex ) { indexCoords.init(platformIndex, markers.at(7).p, markers.at(8).p, markers.at(9).p ); rigidStartIndex.setRigidBody(markers.at(7).p-platformIndex,markers.at(8).p-platformIndex,markers.at(9).p-platformIndex); fingerCalibrationDone=2; beepOk(); break; } // Calibrate the thumb then if ( (fingerCalibrationDone==2) && allVisibleThumb ) { rigidStartThumb.setRigidBody(markers.at(11).p-platformThumb,markers.at(12).p-platformThumb,markers.at(13).p-platformThumb); thumbCoords.init(platformThumb, markers.at(11).p, markers.at(12).p, markers.at(13).p); fingerCalibrationDone=3; beepOk(); break; } if ( fingerCalibrationDone==3 && allVisibleFingers ) { fingerCalibrationDone=4; infoDraw=false; paintGL(); physicalRigidBodyTip = indexCoords.getP1().p; trialMode = HANDONSTARTMODE; fingerDistance = (indexCoords.getP1().p-thumbCoords.getP1().p).norm(); moveStimulusObject(visualStimCenter,3500); beepTrial(); trialFrame=0; drawingTrialFrame=0; globalTimer.start(); plato_write(PLATO_LEFT_RIGHT_OPEN); break; } } break; } }
void handleKeypress(unsigned char key, int x, int y) { switch (key) { //Quit program case 'q': case 27: { exit(0); } break; case ' ': { // Here we record the head shape - coordinates of eyes and markers, but centered in (0,0,0) if ( headCalibrationDone==0 && allVisibleHead ) { headEyeCoords.init(markers.at(18).p-Vector3d(ChinRestWidth,0,0),markers.at(18).p, markers.at(1).p,markers.at(2).p,markers.at(3).p,interoculardistance ); headCalibrationDone=1; beepOk(); break; } if ( headCalibrationDone==1 && allVisiblePatch ) { headCalibrationDone=3; beepOk(); } } break; case 'i': infoDraw=!infoDraw; break; case 'f': case 'F': { // Here we record the finger tip physical markers if ( allVisiblePlatform && (fingerCalibrationDone==0) ) { platformIndex=markers.at(16).p; platformThumb=markers.at(15).p; fingerCalibrationDone=1; beepOk(); break; } if ( (fingerCalibrationDone==1) && allVisibleFingers ) { thumbCoords.init(platformThumb, markers.at(11).p, markers.at(12).p, markers.at(13).p); indexCoords.init(platformIndex, markers.at(7).p, markers.at(8).p, markers.at(9).p ); fingerCalibrationDone=2; // XXX sposto l'oggetto a home per permettere le dita di calibrarsi // TriesteMotorFunctions::homeObject(3500); //// XXX commentato: A TS no servi beepOk(); break; } if ( fingerCalibrationDone==2 && allVisibleFingers ) { infoDraw=false; drawGLScene(); physicalRigidBodyTip = indexCoords.getP1().p; fingerCalibrationDone=3; switch ( block.at("Phase") ) { case 0: { cerr << "Key 721 case 0" << endl; factors = trial.getNext(); deltaXRods = mathcommon::unifRand(str2num<double>(parameters.find("DeltaXMin")),str2num<double>(parameters.find("DeltaXMax"))); initStimulus(factors.at("StimulusHeight"),deltaXRods,factors.at("RelDepth")); // moveMonitorAbsolute(factors.at("Distances"),homeFocalDistance,SCREENSPEED); initProjectionScreen(factors.at("Distances")); visualRodCenter = Vector3d(0,0,factors.at("Distances")); hapticRodCenter = rodAway; // keep it away // moveRod(rodAway,RODSPEED); cerr << "Key 730 case 0" << endl; } beepOk(); break; case 2: { factors = trial.getNext(); deltaXRods = mathcommon::unifRand(str2num<double>(parameters.find("DeltaXMin")),str2num<double>(parameters.find("DeltaXMax"))); initStimulus(factors.at("StimulusHeight"),deltaXRods,factors.at("RelDepth")); // moveMonitorAbsolute(factors.at("Distances"),homeFocalDistance,SCREENSPEED); initProjectionScreen(factors.at("Distances")); visualRodCenter = Vector3d(0,0,factors.at("Distances")); hapticRodCenter = rodAway; // keep it away // moveRod(rodAway,RODSPEED); } break; case 1: { cerr << "Key 735 case 1" << endl; double zadaptmin = str2num<double>(parameters.find("AdaptZMin")); double zadaptmax = str2num<double>(parameters.find("AdaptZMax")); if (str2num<int>(parameters.find("AdaptMoveMonitor"))==1) visualRodCenter = Vector3d(0,0,mathcommon::unifRand(zadaptmin,zadaptmax)); else visualRodCenter = Vector3d(0,0,(zadaptmax+zadaptmin)/2); if ( str2num<int>(parameters.find("AdaptHapticFeedback"))==1 ) hapticRodCenter = visualRodCenter - Vector3d(0,0,adaptOffsets.at(block1TrialNumber)); else hapticRodCenter = rodAway; initProjectionScreen( visualRodCenter.z() ); initStimulus(str2num<double>(parameters.find("AdaptStimulusHeight")),adaptStimRadius*2,adaptStimRadius*2); moveMonitorAbsoluteAsynchronous(visualRodCenter.z(),homeFocalDistance,SCREENSPEED); moveRod(hapticRodCenter,RODSPEED); } break; } cerr << "Key 756 " << endl; trialMode = HANDONSTARTMODE; cerr << "Key 758 " << endl; fingerDistance = (indexCoords.getP1().p-thumbCoords.getP1().p).norm(); cerr << "Key 760 " << endl; beepTrial(); cerr << "Key 762 " << endl; trialFrame=0; globalTimer.start(); totalTime.start(); break; } } break; } }