X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fdesigner.cpp;h=3ca630f2431cfccbc12b475b91e357fd0b9edc65;hb=bc955b09faf8365a72d07bb5ee1253c9b958c897;hp=9edf816afcdef1ec7a557b42a9617c586777f3a4;hpb=52cbe8d99669f843f8f75c51128e2748584dd03a;p=r2c2.git diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index 9edf816..3ca630f 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -63,15 +63,15 @@ Designer::Designer(int argc, char **argv): if(argc>1) { layout->load(argv[1]); - const Track3DSeq <racks=layout_3d->get_tracks(); - for(Track3DSeq::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i) + const list <racks=layout_3d->get_tracks(); + for(list::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i) { if((*i)->get_track().get_sensor_id()) - (*i)->set_color(Color(1, 1, 0.5)); + (*i)->set_color(GL::Color(1, 1, 0.5)); else if((*i)->get_track().get_turnout_id()) - (*i)->set_color(Color(0.5, 1, 1)); + (*i)->set_color(GL::Color(0.5, 1, 1)); else if((*i)->get_track().get_flex()) - (*i)->set_color(Color(1, 0.5, 1)); + (*i)->set_color(GL::Color(1, 0.5, 1)); } } @@ -83,6 +83,17 @@ Designer::Designer(int argc, char **argv): measure->signal_done.connect(sigc::mem_fun(this, &Designer::measure_done)); } +Designer::~Designer() +{ + delete manipulator; + delete selection; + delete layout; + delete layout_3d; + delete cat_layout; + delete cat_layout_3d; + delete measure; +} + int Designer::main() { setenv("__GL_SYNC_TO_VBLANK", "1", 0); @@ -132,8 +143,8 @@ void Designer::map_pointer_coords(int x, int y, float &gx, float &gy) float uy=sin_yaw*-sin_pitch*0.41421; float uz=cos_pitch*0.41421; - float xf=(float)x*2/screen_w-1; - float yf=1-(float)y*2/screen_h; + float xf=static_cast(x)*2/screen_w-1; + float yf=1-static_cast(y)*2/screen_h; float vx=cos_yaw*cos_pitch + xf*rx + yf*ux; float vy=sin_yaw*cos_pitch + xf*ry + yf*uy; @@ -148,7 +159,7 @@ void Designer::tick() SDL_Event event; while(SDL_PollEvent(&event)) { - float gx,gy; + float gx, gy; switch(event.type) { case SDL_MOUSEBUTTONDOWN: @@ -256,17 +267,6 @@ void Designer::tick() SDL_GL_SwapBuffers(); } -Designer::~Designer() -{ - delete manipulator; - delete selection; - delete layout; - delete layout_3d; - delete cat_layout; - delete cat_layout_3d; - delete measure; -} - /*** private ***/ void Designer::key_press(unsigned key, unsigned mod, wchar_t ch) @@ -358,11 +358,11 @@ void Designer::key_press(unsigned key, unsigned mod, wchar_t ch) if(*j!=*i) (*i)->snap_to(**j, true); - Track3D *t3d=layout_3d->get_track(*i); + Track3D &t3d=layout_3d->get_track(**i); if((*i)->get_flex()) - t3d->set_color(Color(1, 0.5, 1)); + t3d.set_color(GL::Color(1, 0.5, 1)); else - t3d->set_color(Color(1, 1, 1)); + t3d.set_color(GL::Color(1, 1, 1)); } } else if(key==SDLK_f) @@ -536,18 +536,6 @@ void Designer::render() measure->render(); } - /*glBegin(GL_LINES); - glColor4f(1, 0, 0, 1); - glVertex3f(0, 0, 0); - glVertex3f(0.5, 0, 0); - glColor4f(0, 1, 0, 1); - glVertex3f(0, 0, 0); - glVertex3f(0, 0.5, 0); - glColor4f(0, 0, 1, 1); - glVertex3f(0, 0, 0); - glVertex3f(0, 0, 0.5); - glEnd();*/ - glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, screen_w, 0, screen_h, 0, 1); @@ -582,9 +570,9 @@ Track3D *Designer::pick_track(int x, int y) if(mode==CATALOGUE) l=cat_layout_3d; - float xx=((float)(x-(int)screen_w/2)/screen_h)*0.82843; - float yy=((float)y/screen_h-0.5)*0.82843; - float size=(float)4/screen_h*0.82843; + float xx=(static_cast(x-static_cast(screen_w)/2)/screen_h)*0.82843; + float yy=(static_cast(y)/screen_h-0.5)*0.82843; + float size=4.0/screen_h*0.82843; project_3d(); apply_camera(); @@ -621,9 +609,9 @@ void Designer::measure_done() void Designer::move_tooltip(int x, int y) { - int w=(int)(font->get_string_width(tooltip)*20); - tooltip_x=max(min((int)screen_w-w, x), 0); - tooltip_y=max(min((int)screen_h-20, y), 0); + int w=static_cast(font->get_string_width(tooltip)*20); + tooltip_x=max(min(static_cast(screen_w)-w, x), 0); + tooltip_y=max(min(static_cast(screen_h)-20, y), 0); } void Designer::save_accept() @@ -639,11 +627,11 @@ void Designer::turnout_id_accept() unsigned id=lexical_cast(input->get_text()); track->set_turnout_id(id); - Track3D *t3d=layout_3d->get_track(track); + Track3D &t3d=layout_3d->get_track(*track); if(id) - t3d->set_color(Color(0.5, 1, 1)); + t3d.set_color(GL::Color(0.5, 1, 1)); else - t3d->set_color(Color(1, 1, 1)); + t3d.set_color(GL::Color(1, 1, 1)); input_dismiss(); } @@ -654,11 +642,11 @@ void Designer::sensor_id_accept() unsigned id=lexical_cast(input->get_text()); track->set_sensor_id(id); - Track3D *t3d=layout_3d->get_track(track); + Track3D &t3d=layout_3d->get_track(*track); if(id) - t3d->set_color(Color(1, 1, 0.5)); + t3d.set_color(GL::Color(1, 1, 0.5)); else - t3d->set_color(Color(1, 1, 1)); + t3d.set_color(GL::Color(1, 1, 1)); input_dismiss(); }