1 #include "libr2c2/block.h"
2 #include "allocation.h"
11 Allocation3D::Allocation3D(Layout3D &l, Train &t):
15 layout.get_layout().signal_block_reserved.connect(sigc::mem_fun(this, &Allocation3D::block_reserved));
16 train.signal_advanced.connect(sigc::mem_fun(this, &Allocation3D::train_advanced));
19 void Allocation3D::set_color(const GL::Color &c)
22 for(PathMap::const_iterator i=paths.begin(); i!=paths.end(); ++i)
24 GL::Color block_color = get_color_for_block(*i->first);
25 for(PathList::const_iterator j=i->second.begin(); j!=i->second.end(); ++j)
26 (*j)->set_color(block_color);
30 GL::Color Allocation3D::get_color_for_block(const Block &block) const
32 float intensity = 0.25+train.get_block_allocator().is_block_current(block)*0.75;
33 return color*intensity;
36 void Allocation3D::block_reserved(Block &block, Train *t)
40 if(paths.count(&block))
43 PathList &bpaths = paths[&block];
44 GL::Color block_color = get_color_for_block(block);
45 const Block::TrackSet &tracks = block.get_tracks();
46 for(Block::TrackSet::const_iterator i=tracks.begin(); i!=tracks.end(); ++i)
48 Path3D *path = new Path3D(layout.get_3d(**i));
49 bpaths.push_back(path);
51 path->set_color(block_color);
52 path->set_automatic();
57 PathMap::iterator i = paths.find(&block);
61 for(PathList::iterator j=i->second.begin(); j!=i->second.end(); ++j)
67 void Allocation3D::train_advanced(Block &block)
69 PathMap::iterator i = paths.find(&block);
73 for(PathList::iterator j=i->second.begin(); j!=i->second.end(); ++j)
74 (*j)->set_color(color);