void rightswipe() { int loc, i, j, s, cnt, ch; ch = 2; for(j=0;j<4;j++) { s = 9999; cnt = 3; loc = 0; while(loc<=cnt) { if(a[j][cnt]==0) { swipe(ch,cnt,loc,j); loc++; } else if(s == a[j][cnt]) { a[j][cnt+1] = 2*s; s = 9999; swipe(ch,cnt,loc,j); loc++; } else { s = a[j][cnt]; cnt--; } } } }
void DisplayGroupGraphicsView::gestureEvent( QGestureEvent* evt ) { QGesture* gesture = 0; if( ( gesture = evt->gesture( Qt::SwipeGesture ))) { evt->accept( Qt::SwipeGesture ); swipe( static_cast< QSwipeGesture* >( gesture )); } else if( ( gesture = evt->gesture( PanGestureRecognizer::type( )))) { evt->accept( PanGestureRecognizer::type( )); pan( static_cast< PanGesture* >( gesture )); } else if( ( gesture = evt->gesture( PinchGestureRecognizer::type( )))) { evt->accept( PinchGestureRecognizer::type( )); pinch( static_cast< PinchGesture* >( gesture )); } else if( ( gesture = evt->gesture( Qt::TapGesture ))) { evt->accept( Qt::TapGesture ); tap( static_cast< QTapGesture* >( gesture )); } else if( ( gesture = evt->gesture( Qt::TapAndHoldGesture ))) { evt->accept( Qt::TapAndHoldGesture ); tapAndHold( static_cast< QTapAndHoldGesture* >( gesture )); } }
void DisplayGroupGraphicsView::gestureEvent( QGestureEvent* event ) { if( QGesture* gesture = event->gesture( Qt::SwipeGesture )) { event->accept( Qt::SwipeGesture ); swipe( static_cast< QSwipeGesture* >( gesture )); } else if( QGesture* gesture = event->gesture( Qt::PanGesture )) { event->accept( Qt::PanGesture ); pan( static_cast< QPanGesture* >( gesture )); } else if( QGesture* gesture = event->gesture( Qt::PinchGesture )) { event->accept( Qt::PinchGesture ); pinch( static_cast< QPinchGesture* >( gesture )); } else if( QGesture* gesture = event->gesture( Qt::TapGesture )) { event->accept( Qt::TapGesture ); tap( static_cast< QTapGesture* >( gesture )); } else if( QGesture* gesture = event->gesture( Qt::TapAndHoldGesture )) { event->accept( Qt::TapAndHoldGesture ); tapAndHold( static_cast< QTapAndHoldGesture* >( gesture )); } }
void Menu::interpretGesture(std::list<Finger> fingerList) { touchedSurface = false; for (std::list<Finger>::iterator it = fingerList.begin() ; it != fingerList.end() ; ++it) { if (!touched) { beginGestureX = it->x; beginGestureY = it->y; touched = true; } if (touched) { endGestureX = it->x; endGestureY = it->y; } touchedSurface = true; } if (beginGestureX != 0) { int distX = beginGestureX - endGestureX; int distY = beginGestureY - endGestureY; int distance = sqrt(distX * distX + distY * distY); // if (distance > 100) // { swipe(); // } // else // { // select(); // } } if (!touchedSurface) { ++nbTouched; } if (nbTouched > 2) { beginGestureX = 0; beginGestureY = 0; endGestureX = 0; endGestureY = 0; nbTouched = 0; touched = false; processingGesture = false; } }
void Sender::run() { Timer swipeTimer; swipeTimer.reset(); swipeTimer.resize(2); swipeTimer.mark(0, true); while (1) { // serialize packets to bytes serialize(); // mark time swipeTimer.mark(1, true); // send buffer if enough time has passed if (swipeTimer.lapMs(1) >= Const::NETWORK_SWIPE_TIME_MS) { // send out all the bytes swipe(); // mark time swipeTimer.mark(0, true); } } }
int main(int argc, char **argv) { int length, frame_shift = FRAME_SHIFT, atype = ATYPE, otype = OTYPE; double *x, thresh_rapt = THRESH_RAPT, thresh_swipe = THRESH_SWIPE, thresh_reaper = THRESH_REAPER, sample_freq = SAMPLE_FREQ, L = LOW, H = HIGH; FILE *fp = stdin; float_list *top, *cur, *prev; void rapt(float_list * flist, int length, double sample_freq, int frame_shift, double min, double max, double threshold, int otype); void swipe(float_list * input, int length, double sample_freq, int frame_shift, double min, double max, double threshold, int otype); void reaper(float_list * input, int length, double sample_freq, int frame_shift, double min, double max, double threshold, int otype); if ((cmnd = strrchr(argv[0], '/')) == NULL) cmnd = argv[0]; else cmnd++; while (--argc) if (**++argv == '-') { switch (*(*argv + 1)) { case 'a': atype = atoi(*++argv); --argc; break; case 's': sample_freq = atof(*++argv); --argc; break; case 'p': frame_shift = atoi(*++argv); --argc; break; case 't': if ((*(*argv + 2)) == '0') { thresh_rapt = atof(*++argv); --argc; } else if ((*(*argv + 2)) == '1') { thresh_swipe = atof(*++argv); --argc; } else { thresh_reaper = atof(*++argv); --argc; } break; case 'L': L = atof(*++argv); --argc; break; case 'H': H = atof(*++argv); --argc; break; case 'o': otype = atoi(*++argv); --argc; break; case 'h': usage(0); default: fprintf(stderr, "%s : Invalid option '%c'!\n", cmnd, *(*argv + 1)); usage(1); } } else { fp = getfp(*argv, "rb"); } sample_freq *= 1000.0; x = dgetmem(1); top = prev = (float_list *) malloc(sizeof(float_list)); length = 0; prev->next = NULL; while (freadf(x, sizeof(*x), 1, fp) == 1) { cur = (float_list *) malloc(sizeof(float_list)); cur->f = (float) x[0]; length++; prev->next = cur; cur->next = NULL; prev = cur; } if (atype == 0) { rapt(top->next, length, sample_freq, frame_shift, L, H, thresh_rapt, otype); } else if (atype == 1) { swipe(top->next, length, sample_freq, frame_shift, L, H, thresh_swipe, otype); } else { reaper(top->next, length, sample_freq, frame_shift, L, H, thresh_reaper, otype); } return (0); }
void upswipe() { int loc, i, j, s, cnt, ch; ch = 1; for(j=0;j<4;j++) { s = 9999; cnt = 0; loc = 3; while(loc>=cnt) { if(a[cnt][j]==0) { swipe(ch,cnt,loc,j); loc--; } else if(s == a[cnt][j]) { a[cnt-1][j] = 2*s; s = 9999; swipe(ch,cnt,loc,j); loc--; } else { s = a[cnt][j]; cnt++; } } } }
/** \todo Removals should be done "en vrac", not one by one. Multiscanner::raw_scan_collection_t is bad because it uses the robot's pose, not each sensor's at the time of capture. */ size_t Mapper2d:: SwipedUpdate(const Frame & pose, const Multiscanner::raw_scan_collection_t & scans, double max_remove_distance, draw_callback * cb) { m_freespace_buffer.clear(); m_obstacle_buffer.clear(); m_swipe_check_buffer.clear(); swipe_cb swipe(m_swipe_check_buffer, m_freespace_buffer, *m_travmap); ssize_t const bbx0(m_travmap->grid.xbegin()); ssize_t const bbx1(m_travmap->grid.xend()); ssize_t const bby0(m_travmap->grid.ybegin()); ssize_t const bby1(m_travmap->grid.yend()); // compute sets of swiped and obstacle cells for (size_t is(0); is < scans.size(); ++is) { double const spx(scans[is]->scanner_pose.X()); double const spy(scans[is]->scanner_pose.Y()); double const spt(scans[is]->scanner_pose.Theta()); Scan::array_t const & scan_data(scans[is]->data); const index_t i0(gridframe.GlobalIndex(spx, spy)); for (size_t ir(0); ir < scan_data.size(); ++ir) { index_t const ihit(gridframe.GlobalIndex(scan_data[ir].globx, scan_data[ir].globy)); index_t iswipe; if (scan_data[ir].rho <= max_remove_distance) { // swipe up to the laser point iswipe = ihit; } else { // swipe along ray, but stop after max_remove_distance double const theta(spt + scan_data[ir].phi); iswipe = gridframe.GlobalIndex(spx + max_remove_distance * cos(theta), spy + max_remove_distance * sin(theta)); } gridframe.DrawDDALine(i0.v0, i0.v1, iswipe.v0, iswipe.v1, bbx0, bbx1, bby0, bby1, swipe); if (scan_data[ir].in_range) { // always insert them into m_obstacle_buffer, do not check // m_travmap->IsWObst(ihit.v0, ihit.v1), because otherwise // neighboring rays can erase known W-obstacles PDEBUG("in range W-obst: global %g %g index %zd %zd\n", scan_data[ir].globx, scan_data[ir].globy, ihit.v0, ihit.v1); m_obstacle_buffer.insert(ihit); } } } // remove new obstacles from swiped set (due to grid effects, it // would otherwise be possible for a later ray to erase an // obstacle seen by an earlier ray) for (index_buffer_t::const_iterator io(m_obstacle_buffer.begin()); io != m_obstacle_buffer.end(); ++io) m_freespace_buffer.erase(*io); return UpdateObstacles(&m_obstacle_buffer, false, &m_freespace_buffer, cb); }