14 Layout3D::Layout3D(Layout &l):
16 catalogue(layout.get_catalogue())
18 // South, 15° from zenith
19 sun.set_position(0, -0.259, 0.966, 0);
20 sun.set_diffuse(GL::Color(0.9));
21 lighting.set_ambient(GL::Color(0.4));
22 lighting.attach(0, sun);
24 layout.signal_object_added.connect(sigc::mem_fun(this, &Layout3D::object_added));
25 layout.signal_object_removed.connect(sigc::mem_fun(this, &Layout3D::object_removed));
27 const set<Object *> &lobjs = layout.get_all<Object>();
28 for(set<Object *>::iterator i=lobjs.begin(); i!=lobjs.end(); ++i)
34 while(!utilities.empty())
35 delete *utilities.begin();
36 while(!objects.empty())
37 delete objects.begin()->second;
40 void Layout3D::add(Object3D &o)
42 insert_unique(objects, &o.get_object(), &o);
45 Object3D &Layout3D::get_3d(Object &o) const
47 return *get_item(objects, &o);
50 void Layout3D::remove(Object3D &o)
52 objects.erase(&o.get_object());
55 void Layout3D::add(Utility3D &u)
60 void Layout3D::remove(Utility3D &u)
65 void Layout3D::object_added(Object &o)
67 if(Track *t = dynamic_cast<Track *>(&o))
68 new Track3D(*this, *t);
69 else if(Signal *s = dynamic_cast<Signal *>(&o))
70 new Signal3D(*this, *s);
71 else if(Vehicle *v = dynamic_cast<Vehicle *>(&o))
72 new Vehicle3D(*this, *v);
73 else if(BeamGate *g = dynamic_cast<BeamGate *>(&o))
74 new BeamGate3D(*this, *g);
75 else if(Terrain *r = dynamic_cast<Terrain *>(&o))
76 new Terrain3D(*this, *r);
79 void Layout3D::object_removed(Object &o)
81 ObjectMap::iterator i = objects.find(&o);