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 OrientedPoint p = track.point();
58 position = p.position;
59 rotation = p.rotation;
64 Block *BeamGate::get_block() const
67 return &track->get_block();
72 void BeamGate::save(list<DataFile::Statement> &st) const
74 st.push_back((DataFile::Statement("position"), position.x, position.y, position.z));
75 st.push_back((DataFile::Statement("rotation"), rotation.radians()));
77 st.push_back((DataFile::Statement("address"), address));
81 BeamGate::Loader::Loader(BeamGate &g):
82 DataFile::ObjectLoader<BeamGate>(g)
84 add("address", &Loader::address);
85 add("position", &Loader::position);
86 add("rotation", &Loader::rotation);
89 void BeamGate::Loader::address(unsigned a)
94 void BeamGate::Loader::position(float x, float y, float z)
96 obj.set_position(Vector(x, y, z));
99 void BeamGate::Loader::rotation(float r)
101 obj.set_rotation(Angle::from_radians(r));