10 BeamGate::BeamGate(Layout &l):
24 BeamGate *BeamGate::clone(Layout *to_layout) const
26 BeamGate *gate = new BeamGate(to_layout ? *to_layout : layout);
27 gate->set_position(position);
28 gate->set_rotation(rotation);
32 const BeamGateType &BeamGate::get_type() const
34 return BeamGateType::instance();
37 void BeamGate::set_position(const Vector &p)
44 void BeamGate::set_rotation(const Angle &r)
51 void BeamGate::update_attachment()
53 attach_to_closest(100*layout.get_catalogue().get_gauge());
57 TrackPoint tp = track->get_point(track.entry(), offset);
63 Block *BeamGate::get_block() const
66 return &track->get_block();
71 void BeamGate::save(list<DataFile::Statement> &st) const
73 st.push_back((DataFile::Statement("position"), position.x, position.y, position.z));
74 st.push_back((DataFile::Statement("rotation"), rotation.radians()));
76 st.push_back((DataFile::Statement("address"), address));
80 BeamGate::Loader::Loader(BeamGate &g):
81 DataFile::ObjectLoader<BeamGate>(g)
83 add("address", &Loader::address);
84 add("position", &Loader::position);
85 add("rotation", &Loader::rotation);
88 void BeamGate::Loader::address(unsigned a)
93 void BeamGate::Loader::position(float x, float y, float z)
95 obj.set_position(Vector(x, y, z));
98 void BeamGate::Loader::rotation(float r)
100 obj.set_rotation(Angle::from_radians(r));