1 #ifndef LIBMARKLIN_TRACK_H_
2 #define LIBMARKLIN_TRACK_H_
6 #include <msp/datafile/loader.h>
16 class Loader: public Msp::DataFile::Loader
23 Track &get_object() { return track; }
25 void position(float, float, float);
29 const TrackType &type;
36 std::vector<Track *> links;
39 Track(const TrackType &);
42 const TrackType &get_type() const { return type; }
43 void set_position(const Point &);
44 const Point &get_position() const { return pos; }
45 void set_rotation(float);
46 float get_rotation() const { return rot; }
47 void set_slope(float);
48 float get_slope() const { return slope; }
50 bool get_flex() const { return flex; }
51 void set_turnout_id(unsigned);
52 unsigned get_turnout_id() const { return turnout_id; }
53 void set_sensor_id(unsigned);
54 unsigned get_sensor_id() const { return sensor_id; }
55 int get_endpoint_by_link(const Track &) const;
56 Point get_endpoint_position(unsigned) const;
57 float get_endpoint_direction(unsigned) const;
58 bool snap_to(Track &, bool);
59 bool snap(Point &, float &) const;
60 void break_link(Track &);
62 const std::vector<Track *> &get_links() const { return links; }
63 Track *get_link(unsigned) const;
65 int traverse(unsigned, unsigned) const;
68 Creates a copy of the track. The new track will be almost identical, but
69 won't have any links to other tracks, nor a turnout or sensor id.
74 // Direct copying not allowed due to links. See the copy() function.
76 Track &operator=(const Track &);
79 } // namespace Marklin