⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 2dview.c

📁 robocup rcssmonitor-11.1.1.zip
💻 C
📖 第 1 页 / 共 4 页
字号:
  if (cl.get("keys",dum) >= 0) {    RUN::show_key_bindings(std::cout);    exit(0);  }  if (cl.get("copyleft",dum) >= 0) {    RUN::show_copyright_notice(std::cout);    exit(0);  }  cl.get("conf_file",conf_file,MAX_NAME_LEN);  if ( strlen(conf_file) ) {    std::cout << "\nreading options from file: " << conf_file;    ValueParser vp(conf_file);    //vp.set_verbose(true);    process_options(vp);    INPUTDEV->process_options(conf_file);  }  process_options(cl);  INPUTDEV->process_options(argc,argv);  return res;}void convert_area_2_area_under_window_constrains(Area2d & a, int win_size_x, int win_size_y) {  double ratio_x= a.size_x / double(win_size_x);  double ratio_y= a.size_y / double(win_size_y);  if (ratio_x > ratio_y)    a.size_y= win_size_y * ratio_x;  else    a.size_x= win_size_x * ratio_y;}void init_4_tree_and_display() {  DDD= new DisplayX11(WIN::disp,WIN::pixmap,WIN::gc);   DDD->ASetWindowArea(WIN::win_width,WIN::win_height);  RUN::conv_area.set_win_size(WIN::win_width,WIN::win_height);    RUN::conv_area.set_area( Options::plane );  RUN::conv_area.update();  RUN::conv_area.get_area( Options::plane );  DDD->ASetPlainArea( Options::plane );#if 0/*****************************************************************************/  for (int i= 1; i<= 2; i++) {    DrawFrame *d= new DrawFrame(i);    d->layer= i;    RUN::tree.insert_in_frame(i-1, d );  }  RUN::tree.translate_in_frame(0,1,10.0,0.0);  RUN::tree.translate_in_frame(1,2,0.0,10.0);  std::cout << "\n----";  std::cout << t;  std::cout << "\n----";#endif}Rectangle::Rectangle() {  active= false;  use_ratio= false;  use_center= false;  set_origin(0,0); conform(); }Rectangle::Rectangle(int window_width, int window_height) {  //use_center= true;  use_center= false;  set_ratio(window_width,window_height);  set_origin(0,0); conform(); }void Rectangle::set_ratio(int window_width, int window_height) {  use_ratio= true;  win_width= window_width;  win_height= window_height;}void Rectangle::conform() {  if (use_ratio) {    double ratio_width= fabs( double(p2x-p1x) / double(win_width) );     double ratio_height= fabs( double(p2y-p1y) / double(win_height) );         if ( ratio_width > ratio_height ) {      if (p2y > p1y)	p2y= p1y+ (int)rint( double(win_height) * ratio_width );      else	p2y= p1y- (int)rint( double(win_height) * ratio_width );    }    else {      if (p2x > p1x)	p2x= p1x+ (int)rint( double(win_width) * ratio_height );      else	p2x= p1x- (int)rint( double(win_width) * ratio_height );    }  }  width= abs(p1x-p2x);  height= abs(p1y-p2y);  if (use_center) { //center    x= p1x - width;    y= p1y - height;    width*= 2;    height*= 2;  }  else {    x= p1x<p2x?p1x:p2x;    y= p1y<p2y?p1y:p2y;  }}void print_event_type(const XEvent & event) {  switch(event.type) {  case KeyPress        : std::cout << "\n KeyPress        "; break;           case KeyRelease      : std::cout << "\n KeyRelease      "; break;   case ButtonPress     : std::cout << "\n ButtonPress     "; break;   case ButtonRelease   : std::cout << "\n ButtonRelease   "; break;   case MotionNotify    : std::cout << "\n MotionNotify    "; break;   case EnterNotify     : std::cout << "\n EnterNotify     "; break;   case LeaveNotify     : std::cout << "\n LeaveNotify     "; break;   case FocusIn         : std::cout << "\n FocusIn         "; break;   case FocusOut        : std::cout << "\n FocusOut        "; break;   case KeymapNotify    : std::cout << "\n KeymapNotify    "; break;   case Expose          : std::cout << "\n Expose          "; break;   case GraphicsExpose  : std::cout << "\n GraphicsExpose  "; break;   case NoExpose        : std::cout << "\n NoExpose        "; break;   case VisibilityNotify: std::cout << "\n VisibilityNotify"; break;   case CreateNotify    : std::cout << "\n CreateNotify    "; break;   case DestroyNotify   : std::cout << "\n DestroyNotify   "; break;   case UnmapNotify     : std::cout << "\n UnmapNotify     "; break;   case MapNotify       : std::cout << "\n MapNotify       "; break;   case MapRequest      : std::cout << "\n MapRequest      "; break;   case ReparentNotify  : std::cout << "\n ReparentNotify  "; break;   case ConfigureNotify : std::cout << "\n ConfigureNotify "; break;   case ConfigureRequest: std::cout << "\n ConfigureRequest"; break;   case GravityNotify   : std::cout << "\n GravityNotify   "; break;   case ResizeRequest   : std::cout << "\n ResizeRequest   "; break;   case CirculateNotify : std::cout << "\n CirculateNotify "; break;   case CirculateRequest: std::cout << "\n CirculateRequest"; break;   case PropertyNotify  : std::cout << "\n PropertyNotify  "; break;   case SelectionClear  : std::cout << "\n SelectionClear  "; break;   case SelectionRequest: std::cout << "\n SelectionRequest"; break;   case SelectionNotify : std::cout << "\n SelectionNotify "; break;   case ColormapNotify  : std::cout << "\n ColormapNotify  "; break;   case ClientMessage   : std::cout << "\n ClientMessage   "; break;   case MappingNotify   : std::cout << "\n MappingNotify   "; break;   default:               std::cout << "\n UNKNOWN EVENT";  }  std::cout << std::flush;}void init_window_hints(Display *disp, Window win) {#if 1  XSizeHints hint;  XWMHints wmhints;  //  wmhints.flags = InputHint;  wmhints.input = True;  XSetWMHints(disp, win, &wmhints);  //  hint.flags = PMinSize;// | PBaseSize;  hint.min_width= 400;  hint.min_height= 260;  //hint.base_width= 200;  //hint.base_height= 300;  XSetWMNormalHints(disp, win, &hint);#endif#if 0  XSizeHints size_hints;                                                                                          XWMHints wm_hints;                                                                                              XClassHint class_hints;    size_hints.min_width= 400;  size_hints.min_height= 260;  //size_hints.width= Options::window_size_x;  //size_hints.height= Options::window_size_y;  size_hints.flags = /*PSize |*/ PMinSize;                      //if (Options::window_left_x || Options::window_top_y) {  //  size_hints.x = Options::window_left_x;  //  size_hints.y = Options::window_top_y;  //  size_hints.flags |= PPosition;                                                                                //}  //int screen = DefaultScreen(disp);  size_hints.x = 200;//(XDisplayWidth(disp, screen)-size_hints.width)/2;  size_hints.y = 20;//(XDisplayWidth(disp, screen)-size_hints.width)/2;  size_hints.flags |= PPosition;  wm_hints.initial_state = NormalState;                                                                           wm_hints.input = True;                                                                                          //wm_hints.icon_pixmap = icon_pixmap;                                                                             //wm_hints.icon_mask = iconmask_pixmap;                                                                           wm_hints.flags = StateHint | /*IconPixmapHint | IconMaskHint |*/ InputHint;                                                                                                                                                         class_hints.res_name = PACKAGE;  class_hints.res_class = PACKAGE_VERSION;                                    XTextProperty windowName, iconName;  XTextProperty * PwindowName= &windowName;  XTextProperty * PiconName= &iconName;  char * window_name= PACKAGE_VERSION;  char * icon_name= PACKAGE;  if (!XStringListToTextProperty(&window_name, 1, &windowName))    PwindowName= NULL;  if (!XStringListToTextProperty(&icon_name, 1, &iconName))    PiconName= NULL;  XSetWMProperties(disp, win, NULL,NULL,/* PwindowName, PiconName,*/                   NULL, 0, &size_hints, &wm_hints,                                                                                &class_hints);  if (PwindowName)    XFree(windowName.value);  if (PiconName)    XFree(iconName.value);#endif#if 0  int x_return, y_return;  int width_return;  int height_return;  int gravity_return;  char user_geom[]="+5+0";  char def_geom[]="+0+0";  XWMGeometry(disp,DefaultScreen(disp), user_geom, def_geom,	      5, &hint, &x_return, &y_return, &width_return, &height_return, &gravity_return);  std::cout << "\nx= " << x_return       << "\ny= " << y_return       << "\nwidth= " << width_return       << "\nheight= " << height_return       << "\ngravity= " << gravity_return << std::flush;#endif}void init_window_input(Display *disp, Window win) {#if 1  XSelectInput (disp, win,		KeyPressMask 		| KeyReleaseMask 		| StructureNotifyMask		| ExposureMask 		| ButtonPressMask 		| ButtonReleaseMask 		| ButtonMotionMask                //| PointerMotionMask  //nur fuer den smonitor Modus, um immer die aktuelle Pointer Position zu wissen, ///doch nicht notwedig event.xkey.{x,y} erreicht das selbe		//| Button1PressMask | Button1ReleaseMask | Button1MotionMask 		//| Button2PressMask | Button2ReleaseMask | Button2MotionMask 		);#else  XSelectInput(disp,win,	       KeyPressMask                     	       | KeyReleaseMask                   	       | ButtonPressMask                  	       | ButtonReleaseMask                	       | EnterWindowMask                  	       | LeaveWindowMask                  	       | PointerMotionMask                	       | PointerMotionHintMask            	       | Button1MotionMask                	       | Button2MotionMask                	       | Button3MotionMask                	       | ButtonMotionMask                 	       | KeymapStateMask                 	       | ExposureMask                     	       | VisibilityChangeMask             	       | StructureNotifyMask              	       | ResizeRedirectMask               	       | PropertyChangeMask               	       );#endif    }void XEvent_to_InputEvent(const XEvent & xevent, InputEvent & input_event) {  int x= 0;  int y= 0;  int len;  KeySym key;  static char text[30];  input_event.init();  switch (xevent.type) {  case KeyPress        :   case KeyRelease      :    //cout << "\n KeyPress or Release        ";     x= xevent.xkey.x;    y= xevent.xkey.y;    len = XLookupString ((XKeyEvent *)&xevent, text, 10, &key, 0);    input_event.key= text[0];    break;           case ButtonPress     :    x= xevent.xbutton.x;    y= xevent.xbutton.y;    input_event.time= xevent.xbutton.time;    input_event.mouse_button= xevent.xbutton.button;    input_event.mouse_button_state= InputEvent::MOUSE_BUTTON_PRESSED;    //cout << "\nPRESSED " << input_event.time << flush;    break;  case ButtonRelease   :    x= xevent.xbutton.x;    y= xevent.xbutton.y;    input_event.time= xevent.xbutton.time;    input_event.mouse_button= xevent.xbutton.button;    input_event.mouse_button_state= InputEvent::MOUSE_BUTTON_RELEASED;    //cout << "\nRELEASE " << input_event.time << flush;    break;  case MotionNotify    :     x= xevent.xbutton.x;    y= xevent.xbutton.y;    input_event.time= xevent.xbutton.time;    input_event.mouse_button= xevent.xbutton.button;    input_event.mouse_button_state= InputEvent::MOUSE_BUTTON_MOTION;    //cout << "\nMOTION " << input_event.time << flush;    break;#if 0  case EnterNotify     : std::cout << "\n EnterNotify     "; break;   case LeaveNotify     : std::cout << "\n LeaveNotify     "; break;   case FocusIn         : std::cout << "\n FocusIn         "; break;   case FocusOut        : std::cout << "\n FocusOut        "; break;   case KeymapNotify    : std::cout << "\n KeymapNotify    "; break;   case Expose          : std::cout << "\n Expose          "; break;   case GraphicsExpose  : std::cout << "\n GraphicsExpose  "; break;   case NoExpose        : std::cout << "\n NoExpose        "; break;   case VisibilityNotify: std::cout << "\n VisibilityNotify"; break;   case CreateNotify    : std::cout << "\n CreateNotify    "; break;   case DestroyNotify   : std::cout << "\n DestroyNotify   "; break;   case UnmapNotify     : std::cout << "\n UnmapNotify     "; break;   case MapNotify       : std::cout << "\n MapNotify       "; break;   case MapRequest      : std::cout << "\n MapRequest      "; break;   case ReparentNotify  : std::cout << "\n ReparentNotify  "; break;   case ConfigureNotify : std::cout << "\n ConfigureNotify "; break;   case ConfigureRequest: std::cout << "\n ConfigureRequest"; break;   case GravityNotify   : std::cout << "\n GravityNotify   "; break;   case ResizeRequest   : std::cout << "\n ResizeRequest   "; break;   case CirculateNotify : std::cout << "\n CirculateNotify "; break;   case CirculateRequest: std::cout << "\n CirculateRequest"; break;   case PropertyNotify  : std::cout << "\n PropertyNotify  "; break;   case SelectionClear  : std::cout << "\n SelectionClear  "; break;   case SelectionRequest: std::cout << "\n SelectionRequest"; break;   case SelectionNotify : std::cout << "\n SelectionNotify "; break;   case ColormapNotify  : std::cout << "\n ColormapNotify  "; break;   case ClientMessage   : std::cout << "\n ClientMessage   "; break;   case MappingNotify   : std::cout << "\n MappingNotify   "; break;   default:               std::cout << "\n UNKNOWN EVENT";#endif  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -