X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Fengineer%2Fengineer.cpp;h=f0999d91cd9ffaddd1736f0c6fd6493e36077084;hb=5116fff210cdc3f0fbdae13046cc60450aad5e8f;hp=8c1738eb0603d4e152a20afe7344d5f4e1ba814d;hpb=91385545a7d76784a17af421b0def49775be0d4c;p=r2c2.git diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index 8c1738e..f0999d9 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -19,8 +19,10 @@ #include "libr2c2/driver.h" #include "libr2c2/trackcircuit.h" #include "libr2c2/tracktype.h" +#include "3d/allocation.h" #include "3d/path.h" #include "3d/track.h" +#include "3d/trackcircuit.h" #include "3d/vehicle.h" #include "engineer.h" #include "mainwindow.h" @@ -70,12 +72,16 @@ Engineer::Engineer(int argc, char **argv): DataFile::load(layout, options.layout_fn); layout.signal_train_added.connect(sigc::mem_fun(this, &Engineer::train_added)); - layout.signal_block_reserved.connect(sigc::hide<1>(sigc::mem_fun(this, &Engineer::reset_block_color))); layout.signal_emergency.connect(sigc::mem_fun(this, &Engineer::set_status)); const set &blocks = layout.get_all(); for(set::const_iterator i=blocks.begin(); i!=blocks.end(); ++i) - if(Sensor *sensor = (*i)->get_sensor()) - sensor->signal_state_changed.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &Engineer::reset_block_color), sigc::ref(**i)))); + if(TrackCircuit *tc = (*i)->get_sensor()) + new TrackCircuit3D(layout_3d, *tc); + + const set &tracks = layout.get_all(); + for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) + if((*i)->get_type().is_turnout()) + new Path3D(layout_3d.get(**i)); if(FS::exists(options.state_fn)) DataFile::load(layout, options.state_fn); @@ -208,12 +214,8 @@ void Engineer::tick() delete picking_path; picking_path = new Path3D(layout_3d.get(*track)); - if(picking_entry>=0) - picking_path->set_mask(picking_track->get_type().get_endpoint(picking_entry).paths); - else - picking_path->set_mask(picking_track->get_type().get_paths()); picking_path->set_color(GL::Color(0)); - picking_path->set_layer(1); + picking_path->set_layer(2); } } } @@ -250,7 +252,6 @@ void Engineer::button_press(unsigned btn) else if(btn==3 && picking_entry>=0) { picking_entry = (picking_entry+1)%picking_track->get_type().get_endpoints().size(); - picking_path->set_mask(picking_track->get_type().get_endpoint(picking_entry).paths); } } else @@ -350,37 +351,6 @@ void Engineer::view_all() camera.set_depth_clip(pos.z*0.5, pos.z*1.5); } -void Engineer::set_block_color(const Block &block, const GL::Color &color) -{ - const set &tracks = block.get_tracks(); - for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) - layout_3d.get(**i).get_path().set_color(color); -} - -void Engineer::reset_block_color(const Block &block) -{ - bool active = false; - if(Sensor *sensor = block.get_sensor()) - active = sensor->get_state()>Sensor::INACTIVE; - - if(block.get_train()) - { - GL::Color color; - map::iterator i = train_colors.find(block.get_train()); - if(i!=train_colors.end()) - color = i->second; - - if(active) - set_block_color(block, color*0.6); - else - set_block_color(block, color*0.5+0.5); - } - else if(active) - set_block_color(block, GL::Color(0.6)); - else - set_block_color(block, GL::Color(1)); -} - Object *Engineer::pick_object(const Vector &p) { const GL::Vector3 &start = camera.get_position(); @@ -430,6 +400,9 @@ void Engineer::train_added(Train &train) } } train_colors[&train] = best_color; + + Allocation3D *alloc = new Allocation3D(layout_3d, train); + alloc->set_color(best_color); } void Engineer::sighandler(int sig)