void OpenCVDisplay::drawCircle( int x, int y, int radius, int red, int green, int blue ) throw(DisplayException) {
	if( image )
		cvCircle(image, cvPoint(x,y), radius, CV_RGB(red, green, blue), CV_FILLED);
	else 
		throw DisplayException("Display front-end (OpenCV) needs to be initialised to a correct size before drawing!");		

}
Exemplo n.º 2
0
Display::Display(unsigned int init_width, unsigned int init_height, std::string& init_title) :
			width(init_width), height(init_height), title(init_title), isClosed(false), center(glm::vec2(width / 2.0, height / 2.0))
{
	SDL_Init(SDL_INIT_EVERYTHING);

	SDL_GL_SetAttribute(SDL_GL_RED_SIZE, COLOR_SIZE);
	SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, COLOR_SIZE);
	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, COLOR_SIZE);
	SDL_GL_SetAttribute(SDL_GL_ALPHA_SIZE, ALPHA_SIZE);
	SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 3 * COLOR_SIZE + ALPHA_SIZE);
	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, USE_DOUBLE_BUFFER);

	//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
	//SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 4);

	window = SDL_CreateWindow(title.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
	context = SDL_GL_CreateContext(window);

	glewExperimental = GL_TRUE;
	GLenum status = glewInit();
	if (status != GLEW_OK)
	{
		throw DisplayException("Failed to initialize OpenGL.");
	}
}
void OpenCVDisplay::show() throw(DisplayException) {
	if( image ){
		cvShowImage("image", image);
		cvWaitKey();
	} else
		throw DisplayException("Display front-end (OpenCV) needs to be initialised to a correct size before calling the show() method!");		
}
Exemplo n.º 4
0
Ncurses::Ncurses(int x, int y)
{
  try
    {
      if (check_env() == -1)
	throw (DisplayException("Environement variable needed"));
    }
  catch (const Exception e)
    {
      std::cerr << e.what() << std::endl;
    }
  initscr();
  start_color();
  curs_set(FALSE);
  keypad(stdscr, TRUE);
  noecho();
  nodelay(stdscr, TRUE);
  _x = x + 2;
  _y = y + 2;
  _dtime = 150000;
  _game = newwin(_y, _x, 0, 0);
  set_color_pair();
  draw_border();
  handle_resize();
  wrefresh(_game);
  
}
Exemplo n.º 5
0
void ConfirmQuit() throw()
{
    try
    {
        if( Confirm("Are you really sure you want to quit the program ?"))
            AppWindow->hide();
	    
	//Suppression fichiers conviv.txt, tol.txt et trunc.txt à la fermeture
	std::string command = "rm $CONV_ROOT/src/ui/python/work/conviv.e $CONV_ROOT/src/ui/python/work/tol.txt $CONV_ROOT/src/ui/python/work/trunc.txt";
	system(command.c_str()); 
       
    }
    catch( const exception &e )
    {
        DisplayException(e);
    }
    catch(...)
    {
        const exception e("Unhandled error in ConfirmQuit");
        DisplayException(e);
    }
}
Exemplo n.º 6
0
void EHandler::SignalException(const char *mesg, int Level)
{
  // By default a message will be displayed
  DisplayException(mesg); 

  switch(Level) {
    case FATAL:    // Fatal error, terminate program immediately
      Terminate();
      break;

    case DISPLAY: // Dummy handler that does nothing
      return;
      
    default:
      Terminate();
      break;
  }
}
void OpenCVDisplay::drawRectangle( int x, int y, int width, int height, int red, int green, int blue ) throw(DisplayException) {
	if( image )
		cvRectangle(image, cvPoint(x,y), cvPoint(x+width,y+height), CV_RGB(red, green, blue), CV_FILLED);
	else 
		throw DisplayException("Display front-end (OpenCV) needs to be initialised to a correct size before drawing!");		
}
void OpenCVDisplay::initializeImage( int width, int height ) throw(DisplayException) {
	releaseImage();
	image = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
	if(!image)
		throw DisplayException("Could not create an OpenCV image!");
}