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<Track3D *> <racks=layout_3d->get_tracks();
+ for(list<Track3D *>::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));
}
}
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);
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<float>(x)*2/screen_w-1;
+ float yf=1-static_cast<float>(y)*2/screen_h;
float vx=cos_yaw*cos_pitch + xf*rx + yf*ux;
float vy=sin_yaw*cos_pitch + xf*ry + yf*uy;
SDL_Event event;
while(SDL_PollEvent(&event))
{
- float gx,gy;
+ float gx, gy;
switch(event.type)
{
case SDL_MOUSEBUTTONDOWN:
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)
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)
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);
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<float>(x-static_cast<int>(screen_w)/2)/screen_h)*0.82843;
+ float yy=(static_cast<float>(y)/screen_h-0.5)*0.82843;
+ float size=4.0/screen_h*0.82843;
project_3d();
apply_camera();
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<int>(font->get_string_width(tooltip)*20);
+ tooltip_x=max(min(static_cast<int>(screen_w)-w, x), 0);
+ tooltip_y=max(min(static_cast<int>(screen_h)-20, y), 0);
}
void Designer::save_accept()
unsigned id=lexical_cast<unsigned>(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();
}
unsigned id=lexical_cast<unsigned>(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();
}