コード例 #1
0
ファイル: glwidget.cpp プロジェクト: HaiJiaoXinHeng/meshlab
void GLWidget::keyPressEvent (QKeyEvent * e)
{
  e->ignore ();
  if (e->key () == Qt::Key_Control) track.ButtonDown (QT2VCG (Qt::NoButton, Qt::ControlModifier));
  if (e->key () == Qt::Key_Shift)  track.ButtonDown (QT2VCG (Qt::NoButton, Qt::ShiftModifier));
  if (e->key () == Qt::Key_Alt)  track.ButtonDown (QT2VCG (Qt::NoButton, Qt::AltModifier));

  TwKeyPressQt(e);
  updateGL ();
}
コード例 #2
0
ファイル: trackball_sdl.cpp プロジェクト: Hao-HUST/NBIS
/* The main event Loop */
int sdlLoop() {
  bool quit=false;

  bool redraw_needed = false; // true whan a scene needs a redraw
  
 	SDL_Event event;
	while( !quit ) {

    SDL_WaitEvent(&event);
    switch( event.type ) {
      case SDL_QUIT:  quit = true; break; 
      case SDL_VIDEORESIZE : myReshapeFunc(event.resize.w,event.resize.h); break;
      case SDL_KEYDOWN: 
        switch (event.key.keysym.sym) {
			    case SDLK_ESCAPE: exit(0); break;	
			    case SDLK_F1: drawMode= (drawMode+1)%5; printf("Current Mode %i\n",drawMode); break;	
			    case SDLK_HOME: track.Reset(); break;
          case SDLK_SPACE: 
            trackballMode= (trackballMode+1)%2; printf("Trackball Mode %i\n",drawMode); 
            SetTrackball(trackballMode);
            break;	
          default: track.ButtonDown( SDL2VCG( event.key.keysym.sym) );
			  }
			  redraw_needed = true;
        break;
      case SDL_KEYUP: 
			  track.ButtonUp( SDL2VCG( event.key.keysym.sym) ); break;
      case SDL_MOUSEBUTTONDOWN:   
	      switch(event.button.button) {
          case SDL_BUTTON_WHEELUP:    track.MouseWheel( 1); redraw_needed = true; break;
          case SDL_BUTTON_WHEELDOWN:  track.MouseWheel(-1); redraw_needed = true; break;
          default: track.MouseDown(event.button.x, (height - event.button.y), SDL2VCG(event.button.button) ); break;
        } break;
      case SDL_MOUSEBUTTONUP:   
        track.MouseUp(event.button.x, (height - event.button.y), SDL2VCG(event.button.button) ); break;       
        break;
      case SDL_MOUSEMOTION: 
	      while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTIONMASK));
	      track.MouseMove(event.button.x, (height - event.button.y));
 			  redraw_needed = true;
	      break;
	    case SDL_TIMER:
        if (onTimer())  redraw_needed = true;
        if (redraw_needed) sendRedraw(); // justs sends a redraw event!
 			  redraw_needed = false;
        break;
      case SDL_VIDEOEXPOSE:
        // any rendering is done ONLY here.
		    display();
		    drainRedrawEvents();
		    break;
      default: break;
      }

	}

  SDL_Quit();
  return -1;
}
コード例 #3
0
ファイル: trimesh_sdl.cpp プロジェクト: GuoXinxiao/meshlab
// The Event Loop Processor
int sdl_idle() {
  bool quit=false;
 	SDL_Event event;
	while( !quit ) {  
    SDL_WaitEvent(&event);
    switch( event.type ) {
      case SDL_QUIT:  quit = true; break; 
      case SDL_VIDEORESIZE : 			myReshapeFunc(event.resize.w,event.resize.h); 			break;
      case SDL_KEYDOWN:                                        
			  switch(event.key.keysym.sym) {
			    case SDLK_RCTRL:
			    case SDLK_LCTRL: track.ButtonDown(vcg::Trackball::KEY_CTRL); break;
			    case SDLK_q: exit(0); break;	
			    case SDLK_SPACE: drawMode=((drawMode+1)%6); printf("Current Mode %i\n",drawMode); break;	
			  }  break;
      case SDL_KEYUP: 
			  switch(event.key.keysym.sym) {
			    case SDLK_RCTRL:
			    case SDLK_LCTRL: track.ButtonUp(vcg::Trackball::KEY_CTRL); break;
			  }	break;
      case SDL_MOUSEBUTTONDOWN:   
	      switch(event.button.button) {
          case SDL_BUTTON_WHEELUP:    track.MouseWheel( 1); break;
          case SDL_BUTTON_WHEELDOWN:  track.MouseWheel(-1); break;
          case SDL_BUTTON_LEFT:	      track.MouseDown(event.button.x, (height - event.button.y), vcg::Trackball::BUTTON_LEFT); break;
          case SDL_BUTTON_RIGHT:	    track.MouseDown(event.button.x, (height - event.button.y), vcg::Trackball::BUTTON_RIGHT);break;
        } break;
      case SDL_MOUSEBUTTONUP:          
	      switch(event.button.button) {
          case SDL_BUTTON_LEFT:	      track.MouseUp(event.button.x, (height - event.button.y), vcg::Trackball::BUTTON_LEFT); break;
          case SDL_BUTTON_RIGHT:	    track.MouseUp(event.button.x, (height - event.button.y), vcg::Trackball::BUTTON_RIGHT);break;
        } break;
      case SDL_MOUSEMOTION: 
	      while(SDL_PeepEvents(&event, 1, SDL_GETEVENT, SDL_MOUSEMOTIONMASK));
	      track.MouseMove(event.button.x, (height - event.button.y));
	      break;  
      case SDL_VIDEOEXPOSE:
      default: break;
      }
		display();
	}

  SDL_Quit();
  return -1;
}