]> git.tdb.fi Git - r2c2.git/blobdiff - source/engineer/engineer.cpp
Style fixes, including:
[r2c2.git] / source / engineer / engineer.cpp
index d5f8495171daecd082a2e43d75670c0952335b49..3ac7c7682a605cc06942c23cfee7607db157259c 100644 (file)
@@ -113,7 +113,7 @@ Train *Engineer::add_train(unsigned addr)
                TrainPanel *tpanel=new TrainPanel(*this, ui_res, *train);
                root->add(*tpanel);
                int y=main_panel->get_geometry().y;
-               for(TrainPanelSeq::iterator i=train_panels.begin(); i!=train_panels.end(); ++i)
+               for(list<TrainPanel *>::iterator i=train_panels.begin(); i!=train_panels.end(); ++i)
                        y-=(*i)->get_geometry().h;
                tpanel->set_position(0, y-tpanel->get_geometry().h);
                train_panels.push_back(tpanel);
@@ -213,8 +213,8 @@ void Engineer::tick()
 
        glDisable(GL_LIGHTING);
        glColor4f(1, 1, 1, 1);
-       const Track3DSeq &ltracks=layout_3d.get_tracks();
-       for(Track3DSeq::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
+       const list<Track3D *> &ltracks=layout_3d.get_tracks();
+       for(list<Track3D *>::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i)
        {
                Track &track=(*i)->get_track();
                if(track.get_turnout_id())
@@ -286,7 +286,7 @@ void Engineer::button_press(int x, int y, unsigned btn, unsigned)
        {
                if(btn==1 && placing_block)
                {
-                       set_block_color(*placing_block, Color(1, 1, 1));
+                       set_block_color(*placing_block, GL::Color(1, 1, 1));
 
                        placing_train->place(placing_block, placing_entry);
                        placing_train=0;
@@ -335,10 +335,10 @@ void Engineer::pointer_motion(int x, int y)
                        if(&block!=placing_block)
                        {
                                if(placing_block)
-                                       set_block_color(*placing_block, Color(1, 1, 1));
+                                       set_block_color(*placing_block, GL::Color(1, 1, 1));
                                placing_block=&block;
                                placing_entry=0;
-                               set_block_color(*placing_block, Color(0.5, 1, 0.7));
+                               set_block_color(*placing_block, GL::Color(0.5, 1, 0.7));
                        }
                }
                else if(track && track->get_track().get_turnout_id())
@@ -350,7 +350,7 @@ void Engineer::pointer_motion(int x, int y)
 
 void Engineer::view_all()
 {
-       const Track3DSeq &tracks=layout_3d.get_tracks();
+       const list<Track3D *> &tracks=layout_3d.get_tracks();
 
        cam_rot=0;
        float best_height=-1;
@@ -362,9 +362,9 @@ void Engineer::view_all()
                float max_x=0;
                float min_y=0;
                float max_y=0;
-               for(Track3DSeq::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
+               for(list<Track3D *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
                {
-                       Point minp,maxp;
+                       Point minp, maxp;
                        (*i)->get_bounds(angle, minp, maxp);
                        min_x=min(min_x, minp.x);
                        max_x=max(max_x, maxp.x);
@@ -392,11 +392,11 @@ void Engineer::view_all()
        cam_pos.z=max(best_height*1.05/0.82843, 0.15);
 }
 
-void Engineer::set_block_color(const Block &block, const Color &color)
+void Engineer::set_block_color(const Block &block, const GL::Color &color)
 {
        const set<Track *> &tracks=block.get_tracks();
        for(set<Track *>::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
-               layout_3d.get_track(*i)->set_color(color);
+               layout_3d.get_track(**i).set_color(color);
 }
 
 void Engineer::sensor_event(bool state, Sensor *sensor)
@@ -407,11 +407,11 @@ void Engineer::sensor_event(bool state, Sensor *sensor)
                {
                        Block &block=trfc_mgr->get_block_by_track((*i)->get_track());
                        if(state)
-                               (*i)->set_color(Color(1, 0.5, 0.3));
+                               (*i)->set_color(GL::Color(1, 0.5, 0.3));
                        else if(block.get_train())
-                               set_block_color(block, Color(1, 1, 0.3));
+                               set_block_color(block, GL::Color(1, 1, 0.3));
                        else
-                               (*i)->set_color(Color(1, 1, 1));
+                               (*i)->set_color(GL::Color(1, 1, 1));
                }
 }
 
@@ -425,26 +425,25 @@ void Engineer::block_reserved(const Block &block, const Train *train)
        }
 
        if(train)
-               set_block_color(block, Color(1, 1, 0.3));
+               set_block_color(block, GL::Color(1, 1, 0.3));
        else
-               set_block_color(block, Color(1, 1, 1));
+               set_block_color(block, GL::Color(1, 1, 1));
 }
 
 void Engineer::project_3d()
 {
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
-       //glFrustum(-0.055228, 0.055228, -0.041421, 0.041421, 0.1, 10);
-       glFrustum(-0.069036, 0.041421, -0.041421, 0.041421, 0.1, 10);
+       float offset=200.0/screen_w*0.055228;
+       glFrustum(-0.055228-offset, 0.055228-offset, -0.041421, 0.041421, 0.1, 10);
        glMatrixMode(GL_MODELVIEW);
 }
 
 Track3D *Engineer::pick_track(int x, int y)
 {
-       float xx=((float)(x-(int)screen_w*5/8)/screen_h)*0.82843;
-       //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-100)/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();
        glLoadIdentity();