3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBMARKLIN_TRACK_H_
9 #define LIBMARKLIN_TRACK_H_
13 #include <msp/datafile/loader.h>
23 class Loader: public Msp::DataFile::BasicLoader<Track>
28 void position(float, float, float);
32 const TrackType &type;
39 std::vector<Track *> links;
41 // Direct copying not allowed due to links. See the copy() function.
43 Track &operator=(const Track &);
45 Track(const TrackType &);
48 const TrackType &get_type() const { return type; }
50 void set_position(const Point &);
51 void set_rotation(float);
52 void set_slope(float);
54 const Point &get_position() const { return pos; }
55 float get_rotation() const { return rot; }
56 float get_slope() const { return slope; }
57 bool get_flex() const { return flex; }
60 void set_turnout_id(unsigned);
61 void set_sensor_id(unsigned);
62 unsigned get_turnout_id() const { return turnout_id; }
63 unsigned get_sensor_id() const { return sensor_id; }
65 int get_endpoint_by_link(const Track &) const;
66 Point get_endpoint_position(unsigned) const;
67 float get_endpoint_direction(unsigned) const;
68 bool snap_to(Track &, bool);
69 bool snap(Point &, float &) const;
70 void break_link(Track &);
72 const std::vector<Track *> &get_links() const { return links; }
73 Track *get_link(unsigned) const;
74 int traverse(unsigned, unsigned) const;
75 Point get_point(unsigned, unsigned, float) const;
78 Creates a copy of the track. The new track will be almost identical, but
79 won't have any links to other tracks, nor a turnout or sensor id.
83 void save(std::list<Msp::DataFile::Statement> &) const;
86 } // namespace Marklin