int grab_key5(int keycode, t_img *img) { if (keycode == 15) { set_plan(img); img->zoom = 1; img->flou = 0; img->nb_i = 50; clear_map(img); draw_map(img); mlx_put_image_to_window(img->mlx_ptr, img->win_ptr, img->img_ptr, 0, 0); } if (keycode == 69) { img->plan.x_a += img->plan.step_x * WIDTH / 4; img->plan.y_a += img->plan.step_y * HEIGHT / 4; img->plan.x_b -= img->plan.step_x * WIDTH / 4; img->plan.y_b -= img->plan.step_y * HEIGHT / 4; img->plan.step_x = (img->plan.x_b - img->plan.x_a) / WIDTH; img->plan.step_y = (img->plan.y_b - img->plan.y_a) / HEIGHT; clear_map(img); draw_map(img); mlx_put_image_to_window(img->mlx_ptr, img->win_ptr, img->img_ptr, 0, 0); } if (keycode == 3) img->flou = (img->flou) ? 0 : 1; return (0); }
int grab_key2(int keycode, t_img *img) { if (keycode == 53) { free(img); exit(0); } if (keycode == 8) { if (img->type == 's') img->type = 'm'; else if (img->type == 'm') img->type = 'j'; else if (img->type == 'j') img->type = 's'; set_plan(img); clear_map(img); draw_map(img); mlx_put_image_to_window(img->mlx_ptr, img->win_ptr, img->img_ptr, 0, 0); } if (keycode == 36) { img->start = 1; clear_map(img); grab_expose(img); } return (0); }
void ext_model::update( double time ) { view::update(time); double const fms_calc_step = cfg().model_params.msys_step; if(pilot_impl_) { double dt = last_time_ ? time - *last_time_ : 0.; #if 0 if (!cg::eq_zero(dt)) { geo_base_3 prev_pos = pilot_impl_->state().dyn_state.pos; if (dt > 0) { size_t steps = cg::floor(dt / fms_calc_step + fms_calc_step * .1); fms::pilot_simulation_ptr pilot_sim(pilot_impl_); for (size_t i = 0; i < steps; ++i) { pilot_sim->update(fms_calc_step); } } point_3 offset = prev_pos(pilot_impl_->state().dyn_state.pos); double course = pilot_impl_->state().dyn_state.course; double roll = pilot_impl_->roll(); cpr orien(course, polar_point_3(offset).pitch, roll); set_state(state_t(pilot_impl_->state(), orien.pitch, orien.roll, state_.version + 1), false); if (pilot_impl_->instrument() && pilot_impl_->instrument_ended()) { fms::plan_t plan; if (get_plan().size() > 1) { auto tmp_plan = fms::plan_t(get_plan().begin()+1, get_plan().end()); std::swap(plan, tmp_plan); } else if (pilot_impl_->instrument()->kind() == fms::INSTRUMENT_APPROACH && pilot_impl_->state().dyn_state.cfg != fms::CFG_GD) { plan.push_back(fms::create_direction_instrument(boost::none, get_instruments_env())) ; } set_plan(plan); } } #endif } last_time_ = time; }
void ext_model::activate() { if (!get_instrument() && !was_activated_) { ani::navigation_ptr navi = ani_ ? ani_->navigation_info() : ani::navigation_ptr(); fms::plan_t plan = fms::create_instruments_plan(get_state(), get_instruments_env()) ; set_plan(plan); was_activated_ = true; } }