#include "expert_interface.se.h"#include "interface.h"#include <iostream>#include <cmath>#include <stdexcept>#include <FL/Fl.H>#include <FL/Fl_Widget.H>#include <FL/Fl_Value_Input.H>#include <FL/Fl_Value_Output.H>#include <FL/Fl_Button.H>#include <FL/Fl_Menu_Button.H>#include <FL/Fl_File_Chooser.H>#include <FL/Fl_Output.H>#include <FL/Fl_Light_Button.H>#include <FL/Fl_Counter.H>#include <GL/gl.h>#include <GL/glu.h>#include <FL/glut.H>#include "pv_scene.h"#include "pv_mouse.h"#include "pv_tools.h"#include "pv_bicyclist.h"Include dependency graph for interface.cxx:

Functions | |
| void | restart_button_callback (Fl_Widget *widget, void *data) |
| void | init1_func (int argc, char **argv) |
| void | init2_func () |
| void | update_interface_values () |
| void | run_simulation_func (int value) |
| void | mouse_func (int button, int state, int x, int y) |
| void | motion_func (int x, int y) |
| void | passive_motion_func (int x, int y) |
| void | init3_func (int argc, char **argv) |
| void | display_func (void) |
| void | reshape_func (GLsizei w, GLsizei h) |
| void | play_button_callback (Fl_Widget *widget, void *data) |
| void | step_button_callback (Fl_Widget *widget, void *data) |
| void | display_ratio_counter_callback (Fl_Widget *widget, void *data) |
| void | speed_up_counter_callback (Fl_Widget *widget, void *data) |
| void | camera_menu_linked_callback (Fl_Widget *widget, void *data) |
| void | camera_menu_centered_callback (Fl_Widget *widget, void *data) |
| void | camera_menu_free_callback (Fl_Widget *widget, void *data) |
| void | points_light_button_callback (Fl_Widget *widget, void *data) |
| void | path_light_button_callback (Fl_Widget *widget, void *data) |
| void | spline_light_button_callback (Fl_Widget *widget, void *data) |
| void | window_callback (Fl_Widget *widget, void *data) |
| void | trajectory_file_output_callback (Fl_Widget *widget, void *data) |
| void | trajectory_file_chooser_callback (Fl_File_Chooser *widget, void *data) |
| void | load_trajectory_file_callback (Fl_Widget *widget, void *data) |
| void | desired_speed_x_output_callback (Fl_Widget *widget, void *data) |
| void | desired_speed_y_output_callback (Fl_Widget *widget, void *data) |
| void | desired_speed_z_output_callback (Fl_Widget *widget, void *data) |
| int | wx (int x) |
| int | wy (int y) |
| int | wh (int h) |
| int | ww (int w) |
| void | fltk_create_widgets () |
| int | main (int argc, char **argv) |
Variables | |
| Expert_Interface * | my_interface |
| const int | Default_Run_Simulation_Time = 20 |
| const int | Default_Auto_Repeat_Number = 20 |
| const int | Default_Steps_Before_Displaying = 20 |
| Pv_Scene * | my_scene = NULL |
| Pv_Mouse * | my_mouse = NULL |
| int | run_simulation_time |
| bool | pause_run_simulation |
| int | steps_before_displaying |
| int | auto_repeat_number |
| bool | display = true |
| Fl_Window * | window = NULL |
| Fl_Button * | play_button = NULL |
| Fl_Button * | step_button = NULL |
| Fl_Button * | restart_button = NULL |
| Fl_Counter * | display_ratio_counter = NULL |
| Fl_Counter * | speed_up_counter = NULL |
| Fl_Menu_Button * | camera_menu = NULL |
| Fl_Light_Button * | points_light_button = NULL |
| Fl_Light_Button * | path_light_button = NULL |
| Fl_Light_Button * | spline_light_button = NULL |
| Fl_Button * | load_trajectory_file_button = NULL |
| Fl_File_Chooser * | trajectory_file_chooser = NULL |
| Fl_Output * | trajectory_file_output = NULL |
| Fl_Value_Output * | position_x_output = NULL |
| Fl_Value_Output * | position_y_output = NULL |
| Fl_Value_Output * | position_z_output = NULL |
| Fl_Value_Output * | speed_x_output = NULL |
| Fl_Value_Output * | speed_y_output = NULL |
| Fl_Value_Output * | speed_z_output = NULL |
| Fl_Value_Input * | desired_speed_x_output = NULL |
| Fl_Value_Input * | desired_speed_y_output = NULL |
| Fl_Value_Input * | desired_speed_z_output = NULL |
| int | WIDGET_X = 10 |
| int | WIDGET_Y = 520 |
| int | WIDGET_HEIGHT = 40 |
|
||||||||||||
|
|
|
||||||||||||
|
00102 {
00103
00104 /*initial values of variables*/
00105 run_simulation_time=Default_Run_Simulation_Time;/*ms*/
00106 pause_run_simulation=true;
00107 steps_before_displaying=1;
00108 auto_repeat_number=Default_Auto_Repeat_Number;
00109
00110 /*SIMEX*/
00111 my_interface=new Expert_Interface();
00112
00113 /*SIMEX*/
00114 my_interface->define_data();
00115
00116 /*SIMEX*/
00117 my_interface->send_simulation_info();
00118
00119 }
|
|
|
00122 {
00123 }
|
|
|
00131 {
00132
00133 if(display==true){
00134
00135 Pv_Bicyclist *my_bicyclist=my_scene->my_bicyclist;
00136 position_x_output->value(my_bicyclist->get_position_x());
00137 position_y_output->value(my_bicyclist->get_position_y());
00138 position_z_output->value(my_bicyclist->get_position_z());
00139 speed_x_output->value(my_bicyclist->get_speed_x());
00140 speed_y_output->value(my_bicyclist->get_speed_y());
00141 speed_z_output->value(my_bicyclist->get_speed_z());
00142 desired_speed_x_output->value(my_bicyclist->get_desired_speed_x());
00143 desired_speed_y_output->value(my_bicyclist->get_desired_speed_y());
00144 desired_speed_z_output->value(my_bicyclist->get_desired_speed_z());
00145 }
00146
00147 }
|
|
|
00151 {
00152 static int auto_repeat=Default_Auto_Repeat_Number; /*to speed up*/
00153
00154 /*SIMEX*/
00155 my_interface->check_messages();
00156
00157
00158 /*SIMEX*/
00159 my_interface->notify_can_start(&pause_run_simulation,
00160 play_button,
00161 step_button);
00162
00163 /*SIMEX*/
00164 my_interface->notify_can_stop(&pause_run_simulation,
00165 play_button,
00166 step_button);
00167
00168 /*SIMEX*/
00169 my_interface->notify_can_step(my_scene,&display);
00170
00171
00172 /*SIMEX*/
00173 my_interface->notify_can_reset(restart_button_callback);
00174
00175
00176 /*SIMEX*/
00177 my_interface->notify_can_hide(&display,window);
00178
00179
00180 /*SIMEX*/
00181 my_interface->notify_can_show(&display,window,my_scene);
00182
00183
00184 if(pause_run_simulation==false){
00185
00186 my_scene->step();
00187
00188 update_interface_values();
00189
00190 steps_before_displaying--;
00191
00192 if(steps_before_displaying<=0){
00193
00194 if(display==true) my_scene->display();
00195
00196 steps_before_displaying=(int)display_ratio_counter->value();
00197
00198 }
00199 }
00200
00201 if(auto_repeat>0){
00202 auto_repeat--;
00203 run_simulation_func(value);
00204 }
00205 else{
00206 glutTimerFunc(run_simulation_time,run_simulation_func,0);
00207 auto_repeat=auto_repeat_number;
00208 }
00209
00210 }
|
|
||||||||||||||||||||
|
00214 {
00215 //my_scene->set_camera_mode(2);
00216 //my_mouse->press_release(button,state,x,y);
00217 }
|
|
||||||||||||
|
00221 {
00222 //my_mouse->active_motion(x,y);
00223 }
|
|
||||||||||||
|
00227 {
00228 //my_mouse->passive_motion(x,y);
00229 }
|
|
||||||||||||
|
00234 {
00235
00236 Pv_Gl::init();
00237 my_scene=new Pv_Scene(argc,argv);
00238 my_scene->init_OpenGL();
00239 my_mouse=new Pv_Mouse(my_scene,my_scene->get_camera());
00240 update_interface_values();
00241
00242 /*Execute one step of the bicyclist so that values are correct*/
00243 //_scene->step();
00244
00245 /*camera mode to centered*/
00246 my_scene->set_camera_mode(0);
00247
00248 spline_light_button_callback(NULL,NULL);
00249 path_light_button_callback(NULL,NULL);
00250 points_light_button_callback(NULL,NULL);
00251
00252 /*TODO: to remove*/
00253 my_scene->set_my_target_path("./trajectory_1.tra");
00254
00255 my_scene->step();
00256
00257 }
|
|
|
|
|
||||||||||||
|
|
|
||||||||||||
|
00280 {
00281
00282 if(pause_run_simulation==true){
00283 pause_run_simulation=false;
00284 play_button->label("Pause");
00285 step_button->hide();
00286 }
00287 else if(pause_run_simulation==false){
00288 pause_run_simulation=true;
00289 play_button->label("Play");
00290 step_button->show();
00291 }
00292
00293 }
|
|
||||||||||||
|
|
|
||||||||||||
|
00314 {
00315 steps_before_displaying=(int)display_ratio_counter->value();
00316 }
|
|
||||||||||||
|
00319 {
00320 auto_repeat_number=(int)speed_up_counter->value();
00321 }
|
|
||||||||||||
|
00324 {
00325 my_scene->set_camera_mode((int)camera_menu->value());
00326 if(display==true) my_scene->display();
00327 }
|
|
||||||||||||
|
00330 {
00331 my_scene->set_camera_mode((int)camera_menu->value());
00332 if(display==true) my_scene->display();
00333 }
|
|
||||||||||||
|
00336 {
00337 my_scene->set_camera_mode((int)camera_menu->value());
00338 if(display==true) my_scene->display();
00339 }
|
|
||||||||||||
|
00342 {
00343 my_scene->set_my_target_path_displayed((bool)points_light_button->value());
00344 if(display==true) my_scene->display();
00345 }
|
|
||||||||||||
|
00348 {
00349 my_scene->set_my_bicyclist_path_displayed((bool)path_light_button->value());
00350 if(display==true) my_scene->display();
00351 }
|
|
||||||||||||
|
00354 {
00355 my_scene->set_my_spline_displayed((bool)spline_light_button->value());
00356 if(display==true) my_scene->display();
00357 }
|
|
||||||||||||
|
00360 {
00361 /*SIMEX*/
00362 delete my_interface;
00363
00364 exit(0);
00365 }
|
|
||||||||||||
|
00371 {
00372 }
|
|
||||||||||||
|
00375 {
00376
00377 trajectory_file_output->value(trajectory_file_chooser->value());
00378 my_scene->set_my_target_path(trajectory_file_chooser->value());
00379 if(display==true) my_scene->display();
00380
00381 }
|
|
||||||||||||
|
00384 {
00385 if(trajectory_file_chooser==NULL){
00386 trajectory_file_chooser=new Fl_File_Chooser("./","*.tra",
00387 FL_SINGLE,
00388 "Trajectory Selection");
00389 trajectory_file_chooser->callback(trajectory_file_chooser_callback,NULL);
00390 }
00391 trajectory_file_chooser->show();
00392 }
|
|
||||||||||||
|
00395 {
00396 my_scene->my_bicyclist->set_desired_speed_x(desired_speed_x_output->value());
00397 }
|
|
||||||||||||
|
00400 {
00401 my_scene->my_bicyclist->set_desired_speed_y(desired_speed_y_output->value());
00402 }
|
|
||||||||||||
|
00405 {
00406 }
|
|
|
00419 {
00420 return((int)(WIDGET_X+x*(GN*WIDGET_HEIGHT+10)));
00421 }
|
|
|
00422 {
00423 return((int)(WIDGET_Y+y*(WIDGET_HEIGHT+10)));
00424 }
|
|
|
00425 {
00426 return((int)(WIDGET_HEIGHT*h));
00427 }
|
|
|
00428 {
00429 return((int)(WIDGET_HEIGHT*GN*w));
00430 }
|
|
|
00435 {
00436
00437 /*play button*/
00438 play_button=new Fl_Button(wx(0),wy(0),ww(2),wh(1),
00439 "Play");
00440 play_button->callback(play_button_callback,NULL);
00441
00442 /*step button*/
00443 step_button=new Fl_Button(wx(2),wy(0),ww(2),wh(1),
00444 "Step");
00445 step_button->callback(step_button_callback,NULL);
00446
00447 /*restart button*/
00448 restart_button=new Fl_Button(wx(4),wy(0),ww(2),wh(1),
00449 "Restart");
00450 restart_button->callback(restart_button_callback,NULL);
00451 /*display ratio counter*/
00452 display_ratio_counter=new Fl_Counter(wx(6),wy(0),ww(2),wh(1),
00453 "Display Ratio");
00454 display_ratio_counter->callback(display_ratio_counter_callback,NULL);
00455 display_ratio_counter->type(FL_SIMPLE_COUNTER);
00456 display_ratio_counter->range(1,100);
00457 display_ratio_counter->step(1);
00458 display_ratio_counter->value(Default_Steps_Before_Displaying);
00459
00460 /*fltk speed up counter*/
00461 speed_up_counter=new Fl_Counter(wx(8),wy(0),ww(2),wh(1),
00462 "Speed Up");
00463 speed_up_counter->callback(speed_up_counter_callback,NULL);
00464 speed_up_counter->type(FL_SIMPLE_COUNTER);
00465 speed_up_counter->range(1,100);
00466 speed_up_counter->step(1);
00467 speed_up_counter->value(Default_Auto_Repeat_Number);
00468
00469 /*camera menu*/
00470 camera_menu=new Fl_Menu_Button(wx(0),wy(1),ww(2),wh(1),
00471 "Camera");
00472 camera_menu->add("Linked",0,camera_menu_linked_callback,NULL,0);
00473 camera_menu->add("Centered",0,camera_menu_centered_callback,NULL,0);
00474 camera_menu->add("Free",0,camera_menu_free_callback,NULL,0);
00475 /*points light button*/
00476 points_light_button=new Fl_Light_Button(wx(0),wy(2),ww(2),wh(1),
00477 "Points");
00478 points_light_button->callback(points_light_button_callback,NULL);
00479 points_light_button->value(1);
00480 /*path light button*/
00481 path_light_button=new Fl_Light_Button(wx(2),wy(2),ww(2),wh(1),
00482 "Path");
00483 path_light_button->callback(path_light_button_callback,NULL);
00484 path_light_button->value(1);
00485 /*spline light button*/
00486 spline_light_button=new Fl_Light_Button(wx(4),wy(2),ww(2),wh(1),
00487 "Spline");
00488 spline_light_button->callback(spline_light_button_callback,NULL);
00489 spline_light_button->value(1);
00490
00491 /************
00492 *file loader
00493 ************/
00494 /*load trajectory file button*/
00495 load_trajectory_file_button=new Fl_Button(wx(0),wy(3),ww(3),wh(1),
00496 "Load Trajectory File");
00497 load_trajectory_file_button->callback(load_trajectory_file_callback,NULL);
00498 /*trajectory file output*/
00499 trajectory_file_output=new Fl_Output(wx(3),wy(3),ww(7),wh(1),"");
00500 trajectory_file_output->callback(trajectory_file_output_callback,NULL);
00501 /*******************
00502 *end of file loader
00503 *******************/
00504
00505 /*outputs*/
00506
00507 position_x_output=new Fl_Value_Output(wx(0),wy(4),ww(2),wh(1),"x");
00508 position_x_output->align(FL_ALIGN_RIGHT);
00509
00510 position_y_output=new Fl_Value_Output(wx(0),wy(5),ww(2),wh(1),"y");
00511 position_y_output->align(FL_ALIGN_RIGHT);
00512
00513 position_z_output=new Fl_Value_Output(wx(0),wy(6),ww(2),wh(1),"z");
00514 position_z_output->align(FL_ALIGN_RIGHT);
00515
00516 speed_x_output=new Fl_Value_Output(wx(3),wy(4),ww(2),wh(1),"dx");
00517 speed_x_output->align(FL_ALIGN_RIGHT);
00518
00519 speed_y_output=new Fl_Value_Output(wx(3),wy(5),ww(2),wh(1),"dy");
00520 speed_y_output->align(FL_ALIGN_RIGHT);
00521
00522 speed_z_output=new Fl_Value_Output(wx(3),wy(6),ww(2),wh(1),"dz");
00523 speed_z_output->align(FL_ALIGN_RIGHT);
00524
00525 desired_speed_x_output=new Fl_Value_Input(wx(6),wy(4),ww(2),wh(1),
00526 "d_dx");
00527 desired_speed_x_output->align(FL_ALIGN_RIGHT);
00528 desired_speed_x_output->callback(desired_speed_x_output_callback,NULL);
00529
00530 desired_speed_y_output=new Fl_Value_Input(wx(6),wy(5),ww(2),wh(1),
00531 "d_dy");
00532 desired_speed_y_output->align(FL_ALIGN_RIGHT);
00533 desired_speed_y_output->callback(desired_speed_y_output_callback,NULL);
00534
00535 desired_speed_z_output=new Fl_Value_Input(wx(6),wy(6),ww(2),wh(1),
00536 "d_dz");
00537 desired_speed_z_output->align(FL_ALIGN_RIGHT);
00538 desired_speed_z_output->callback(desired_speed_z_output_callback,NULL);
00539
00540 }
|
|
||||||||||||
|
00547 {
00548
00549 tsneak
00550
00551 /*init 1*/
00552 init1_func(argc,argv);
00553
00554 /*Create fltk window*/
00555 window = new Fl_Window(200,200,320,
00556 (int)(320./GN+10)/*(int)(820./GN+300)+50+50*/,
00557 "LR Bicyclist");
00558 //window->color(FL_BLACK);
00559 window->show(argc,argv);
00560 window->begin();
00561
00562 /*fltk widgets*/
00563 fltk_create_widgets();
00564
00565 /*OpenGL window*/
00566 glutInit(&argc,argv);
00567 glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGBA|GLUT_DEPTH/*|GLUT_ACCUM*/);
00568 glutInitWindowSize(300,(int)(300./GN));
00569 glutInitWindowPosition(10,10);
00570 glutCreateWindow("LR Bicyclist");
00571 glutDisplayFunc(display_func);
00572 glutReshapeFunc(reshape_func);
00573 glutMouseFunc(mouse_func);
00574 glutMotionFunc(motion_func);
00575 glutPassiveMotionFunc(passive_motion_func);
00576 glutTimerFunc(run_simulation_time,run_simulation_func,0);
00577
00578 /*init 2*/
00579 init2_func();
00580
00581 /*End of window*/
00582 window->end();
00583 window->callback(window_callback,NULL);
00584
00585 /*init 3*/
00586 init3_func(argc,argv);
00587
00588 /*initialize my scene*/
00589
00590
00591
00592
00593 /*Start the program*/
00594 Fl::run();
00595
00596 return 0;
00597
00598 csneak
00599 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1.2.18