📄 smonitor_dev.c
字号:
body_margin_kick.rel.radius= large_r; body_margin_kick.use_intersects_area= false; body_margin_kick.set_color(c_white); body_margin_kick_fault.rel.radius = large_r; body_margin_kick_fault.use_intersects_area = false; body_margin_kick_fault.filled = true; body_margin_kick_fault.set_color( c_blue ); body_margin_tackle.rel.radius = large_r; body_margin_tackle.use_intersects_area = false; body_margin_tackle.filled = true; body_margin_tackle.set_color( c_pink ); body_margin_tackle_fault.rel.radius = large_r; body_margin_tackle_fault.use_intersects_area = false; body_margin_tackle_fault.filled = true; body_margin_tackle_fault.set_color( c_olive ); body_margin_catch_fault.rel.radius = large_r; body_margin_catch_fault.use_intersects_area = false; body_margin_catch_fault.filled = true; body_margin_catch_fault.set_color( c_blue ); body_margin_ball_collision.rel.radius= large_r; body_margin_ball_collision.use_intersects_area= false; body_margin_ball_collision.filled= true; body_margin_ball_collision.set_color(c_red); body_dir.rel.p2.x= large_r; body_dir.use_intersects_area= false; body_dir.set_color(c_black); head_dir.rel.p2.x= large_r; head_dir.use_intersects_area= false; head_dir.set_color(c_red); label.content.set_max_size(MAX_LABEL_LEN); label.content.set_cur_size(1); label.content.tab[0]= p_char; label.set_color(c_font);}void VisualPlayer::draw(DisplayBase * disp, const Area2d & area, const Frame2d & p_frame, bool chg) { changed= changed || chg; body_bg.actualize(p_frame,changed); if ( ! body_bg.intersects_area(area) ) return; body_bg.draw(disp,area,p_frame,false); //already actualized! if ( ball_collision ) body_margin_ball_collision.draw(disp,area,p_frame,changed); if ( show_kick_fault ) { body_margin_kick_fault.draw( disp, area, p_frame, changed ); } else if ( show_kick ) { body_margin_kick.draw( disp,area,p_frame,changed ); } else if ( show_catch_fault ) { body_margin_catch_fault.draw( disp, area, p_frame, changed ); } else if ( show_tackle_fault ) { body_margin_tackle_fault.draw( disp, area, p_frame, changed ); } else if ( show_tackle ) { body_margin_tackle.draw( disp, area, p_frame, changed ); } else { body_margin.draw( disp, area, p_frame, changed ); } body.draw(disp,area,p_frame,changed); body_dir.draw(disp,area,p_frame,changed); head_dir.draw(disp,area,p_frame * head_frame, changed || head_frame_chg); head_frame_chg= false; if (use_number) label.draw(disp,area,p_frame,changed); changed= false;}void VisualPlayer::actualize(const Frame2d& f, bool chg) { changed= changed || chg; body_bg.actualize(f,changed); body.actualize(f,changed); body_margin.actualize(f,changed); body_dir.actualize(f,changed); head_dir.actualize(f * head_frame, changed || head_frame_chg); //must be changed head_frame_chg= false; label.actualize(f,changed); changed= false;}void VisualPlayer::set_type(int t) { if ( type == t) return; //cout << "\n type " << type << "->" << t; type= t; double small_r= PlayerTypes::get_player_radius(type); double large_r= PlayerTypes::get_kick_radius(type); body_bg.rel.radius= large_r; body_bg.changed= true; body.rel.radius= small_r; body.changed= true; body_margin.rel.radius= large_r; body_margin.changed= true; body_margin_kick.rel.radius= large_r; body_margin_kick.changed= true; body_margin_kick_fault.rel.radius= large_r; body_margin_kick_fault.changed= true; body_margin_tackle.rel.radius= large_r; body_margin_tackle.changed= true; body_margin_tackle_fault.rel.radius= large_r; body_margin_tackle_fault.changed= true; body_margin_catch_fault.rel.radius= large_r; body_margin_catch_fault.changed= true; body_dir.rel.p2.x= large_r; body_dir.changed= true; head_dir.rel.p2.x= large_r; head_dir.changed= true;}void VisualPlayer::set_head_angle( const Angle & a) { head_frame_chg= true; head_frame.set_angle(a);}void VisualPlayer::set_label(const char * lab) { label.content.cur_size= 1; if ( !lab || *lab == '\0') return; while ( label.content.cur_size < label.content.max_size && *lab != '\0') { label.content.tab[label.content.cur_size]= *lab; lab++; label.content.cur_size++; }}void VisualPlayer::set_active(bool flag) { if (flag == is_active) return; is_active= flag; if (!is_active) { body_bg.set_color(c_invalid); return; } is_goalie= false; if (is_goalie) body_bg.set_color(c_goalie); else body_bg.set_color(c_player);}void VisualPlayer::set_goalie(bool flag) { if (flag == is_goalie) return; is_goalie= flag; if (!is_active) return; if (is_goalie) body_bg.set_color(c_goalie); else body_bg.set_color(c_player);}/******************************************************************************/const double VisualField::FIELD_LENGTH = 105.0;const double VisualField::FIELD_WIDTH = 68.0;//const double VisualField::FIELD_MARGIN = 5.0;const double VisualField::FIELD_CENTER_CIRCLE_R = 9.15;const double VisualField::FIELD_PENALTY_AREA_LENGTH = 16.5;const double VisualField::FIELD_PENALTY_AREA_WIDTH = 40.32;const double VisualField::FIELD_GOAL_AREA_LENGTH = 5.5;const double VisualField::FIELD_GOAL_AREA_WIDTH = 18.32;const double VisualField::FIELD_GOAL_WIDTH = 14.02;const double VisualField::FIELD_GOAL_DEPTH = 2.44;const double VisualField::FIELD_PENALTY_SPOT_DIST = 11.0;const double VisualField::FIELD_CORNER_ARC_R = 1.0;//const double FIELD_CORNER_KICK_MARGIN = 1.0;const double VisualField::HLEN = VisualField::FIELD_LENGTH / 2.0;const double VisualField::HWID = VisualField::FIELD_WIDTH / 2.0;const double VisualField::PEN_X = HLEN - FIELD_PENALTY_AREA_LENGTH;const double VisualField::PEN_Y = FIELD_PENALTY_AREA_WIDTH / 2.0;const double VisualField::GOAL_X = HLEN - FIELD_GOAL_AREA_LENGTH;const double VisualField::GOAL_Y = FIELD_GOAL_AREA_WIDTH / 2.0;const double VisualField::GPOST_RAD = 0.06;VisualField::VisualField() {}void VisualField::init(int my_key, int my_layer, const RGBcolor & my_c_line, const RGBcolor & my_c_goal, bool my_keepaway, double my_keepaway_length, double my_keepaway_width) { key= my_key; layer= my_layer; c_line= my_c_line; c_goal= my_c_goal; c_black= RGBcolor(0,0,0); c_white= RGBcolor(255,255,255); c_red= RGBcolor(255,0,0); keepaway = my_keepaway; keepaway_length = my_keepaway_length; keepaway_width = my_keepaway_width; changed= true; //penalty points Point2d pp[4]; pp[0]= Point2d(-HLEN+FIELD_PENALTY_SPOT_DIST,0); pp[1]= Point2d( HLEN-FIELD_PENALTY_SPOT_DIST,0); points.set_points(2,pp); points.set_color(c_line); points.use_intersects_area= false; //lines Line2d ll[20]; //field lines ll[0]= Line2d( Point2d(-HLEN,-HWID),Point2d( HLEN,-HWID)); ll[1]= Line2d( Point2d( HLEN,-HWID),Point2d( HLEN,+HWID)); ll[2]= Line2d( Point2d( HLEN,+HWID),Point2d(-HLEN,+HWID)); ll[3]= Line2d( Point2d(-HLEN,+HWID),Point2d(-HLEN,-HWID)); //middle line if (!keepaway) ll[4]= Line2d( Point2d( 0,-HWID),Point2d( 0,+HWID)); //left penalty area ll[5]= Line2d( Point2d(-HLEN,-PEN_Y),Point2d(-PEN_X,-PEN_Y)); ll[6]= Line2d( Point2d(-PEN_X,-PEN_Y),Point2d(-PEN_X, PEN_Y)); ll[7]= Line2d( Point2d(-PEN_X, PEN_Y),Point2d(-HLEN, PEN_Y)); //left goal area ll[8]= Line2d( Point2d(-HLEN,-GOAL_Y),Point2d(-GOAL_X,-GOAL_Y)); ll[9]= Line2d( Point2d(-GOAL_X,-GOAL_Y),Point2d(-GOAL_X, GOAL_Y)); ll[10]= Line2d( Point2d(-GOAL_X, GOAL_Y),Point2d(-HLEN, GOAL_Y)); //right penalty area ll[11]= Line2d( Point2d( HLEN,-PEN_Y),Point2d( PEN_X,-PEN_Y)); ll[12]= Line2d( Point2d( PEN_X,-PEN_Y),Point2d( PEN_X, PEN_Y)); ll[13]= Line2d( Point2d( PEN_X, PEN_Y),Point2d( HLEN, PEN_Y)); //right goal area ll[14]= Line2d( Point2d( HLEN,-GOAL_Y),Point2d( GOAL_X,-GOAL_Y)); ll[15]= Line2d( Point2d( GOAL_X,-GOAL_Y),Point2d( GOAL_X, GOAL_Y)); ll[16]= Line2d( Point2d( GOAL_X, GOAL_Y),Point2d( HLEN, GOAL_Y)); lines.set_lines(17,ll); lines.set_color(c_line); lines.use_intersects_area= false; //cirlces CircleArc2d ca[5]; //center circle if (!keepaway) ca[0]= CircleArc2d(Point2d(0.0,0.0),FIELD_CENTER_CIRCLE_R,0.0,2.0*M_PI); //edge circlearcs ca[1]= CircleArc2d(Point2d(-HLEN,-HWID),FIELD_CORNER_ARC_R,0.0,0.5*M_PI); ca[2]= CircleArc2d(Point2d( HLEN,-HWID),FIELD_CORNER_ARC_R,0.5*M_PI,M_PI); ca[3]= CircleArc2d(Point2d( HLEN, HWID),FIELD_CORNER_ARC_R,M_PI,1.5*M_PI); ca[4]= CircleArc2d(Point2d(-HLEN, HWID),FIELD_CORNER_ARC_R,1.5*M_PI,2.0*M_PI); circlearcs.set_circlearcs(5,ca); circlearcs.set_color(c_line); circlearcs.use_intersects_area= false; //keepaway region pp[0] = Point2d(keepaway_length*0.5,-keepaway_width*0.5); pp[1] = Point2d(-keepaway_length*0.5,-keepaway_width*0.5); pp[2] = Point2d(-keepaway_length*0.5,keepaway_width*0.5); pp[3] = Point2d(keepaway_length*0.5,keepaway_width*0.5); keep_area.set_points(4,pp); keep_area.set_color(c_line); keep_area.filled= false; keep_area.use_intersects_area= false; //left goal pp[0]= Point2d(-HLEN,-FIELD_GOAL_WIDTH*0.5 - GPOST_RAD); pp[1]= Point2d(-(HLEN+ FIELD_GOAL_DEPTH),-FIELD_GOAL_WIDTH*0.5 - GPOST_RAD); pp[2]= Point2d(-(HLEN+ FIELD_GOAL_DEPTH),+FIELD_GOAL_WIDTH*0.5 + GPOST_RAD); pp[3]= Point2d(-HLEN,FIELD_GOAL_WIDTH*0.5 + GPOST_RAD); goal_l.set_points(4,pp); goal_l.set_color(c_goal); goal_l.filled= true; goal_l.use_intersects_area= false; //right goal pp[0]= Point2d(HLEN,-FIELD_GOAL_WIDTH*0.5 - GPOST_RAD); pp[1]= Point2d(HLEN+ FIELD_GOAL_DEPTH,-FIELD_GOAL_WIDTH*0.5 - GPOST_RAD); pp[2]= Point2d(HLEN+ FIELD_GOAL_DEPTH,+FIELD_GOAL_WIDTH*0.5 + GPOST_RAD); pp[3]= Point2d(HLEN,FIELD_GOAL_WIDTH*0.5 + GPOST_RAD); goal_r.set_points(4,pp); goal_r.set_color(c_goal); goal_r.filled= true; goal_r.use_intersects_area= false; //vertical stripe pp[0]= Point2d(0,-FIELD_WIDTH*0.5); pp[1]= Point2d(20, -FIELD_WIDTH*0.5); pp[2]= Point2d(20, FIELD_WIDTH*0.5); pp[3]= Point2d(0, FIELD_WIDTH*0.5); vertical_stripe.set_points(4,pp); vertical_stripe.set_color(c_red); vertical_stripe.filled= true; vertical_stripe.use_intersects_area= false; use_vertical_stripe(false); Circle2d gpost_circles[ 4 ]; gpost_circles[ 0 ] = Circle2d( Point2d( HLEN-GPOST_RAD, FIELD_GOAL_WIDTH*0.5 + GPOST_RAD ), GPOST_RAD ); gpost_circles[ 1 ] = Circle2d( Point2d( HLEN-GPOST_RAD, -FIELD_GOAL_WIDTH*0.5 - GPOST_RAD ), GPOST_RAD ); gpost_circles[ 2 ] = Circle2d( Point2d( -HLEN+GPOST_RAD, FIELD_GOAL_WIDTH*0.5 + GPOST_RAD ), GPOST_RAD ); gpost_circles[ 3 ] = Circle2d( Point2d( -HLEN+GPOST_RAD, -FIELD_GOAL_WIDTH*0.5 - GPOST_RAD ), GPOST_RAD ); goal_posts.set_circles(4, gpost_circles); goal_posts.set_color(c_goal); goal_posts.filled= true; goal_posts.use_intersects_area= false;}void VisualField::draw(DisplayBase * disp, const Area2d & area, const Frame2d & p_frame, bool chg) { changed= changed || chg; vertical_stripe.draw(disp,area,p_frame,changed); points.draw(disp,area,p_frame,changed); goal_l.draw(disp,area,p_frame,changed); goal_r.draw(disp,area,p_frame,changed); if (keepaway) keep_area.draw(disp,area,p_frame,changed); lines.draw(disp,area,p_frame,changed); circlearcs.draw(disp,area,p_frame,changed); goal_posts.draw(disp,area,p_frame,changed); changed= false;}void VisualField::actualize(const Frame2d& f, bool chg) { changed= changed || chg; goal_l.actualize(f,changed); goal_r.actualize(f,changed); lines.actualize(f,changed); circlearcs.actualize(f,changed); goal_posts.actualize(f,changed); changed= false;}void VisualField::set_goal_width( double width ) { //cerr << "\nchanging goal width to " << width << flush; goal_l.rel.tab[0].y= -width*0.5 - GPOST_RAD; goal_l.rel.tab[1].y= -width*0.5 - GPOST_RAD; goal_l.rel.tab[2].y= +width*0.5 + GPOST_RAD; goal_l.rel.tab[3].y= +width*0.5 + GPOST_RAD; goal_l.changed= true; goal_r.rel.tab[0].y= -width*0.5 - GPOST_RAD; goal_r.rel.tab[1].y= -width*0.5 - GPOST_RAD; goal_r.rel.tab[2].y= +width*0.5 + GPOST_RAD; goal_r.rel.tab[3].y= +width*0.5 + GPOST_RAD; goal_r.changed= true; goal_posts.rel.tab[0].center.y = +width*0.5 + GPOST_RAD; goal_posts.rel.tab[1].center.y = -width*0.5 - GPOST_RAD; goal_posts.rel.tab[2].center.y = +width*0.5 + GPOST_RAD; goal_posts.rel.tab[3].center.y = -width*0.5 - GPOST_RAD; goal_posts.changed= true;}/******************************************************************************/const int SMonitorDevice::frame_canvas_left= 94;const int SMonitorDevice::frame_canvas_right= 95;const int SMonitorDevice::frame_ball= 96;const int SMonitorDevice::frame_varea= 97;const int SMonitorDevice::frame_shadow= 98;const int SMonitorDevice::BUTTON_START= 0;const int SMonitorDevice::BUTTON_RECONNECT= 1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -