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::Loader
30 Track &get_object() { return track; }
32 void position(float, float, float);
36 const TrackType &type;
43 std::vector<Track *> links;
46 Track(const TrackType &);
49 const TrackType &get_type() const { return type; }
50 void set_position(const Point &);
51 const Point &get_position() const { return pos; }
52 void set_rotation(float);
53 float get_rotation() const { return rot; }
54 void set_slope(float);
55 float get_slope() const { return slope; }
57 bool get_flex() const { return flex; }
58 void set_turnout_id(unsigned);
59 unsigned get_turnout_id() const { return turnout_id; }
60 void set_sensor_id(unsigned);
61 unsigned get_sensor_id() const { return sensor_id; }
62 int get_endpoint_by_link(const Track &) const;
63 Point get_endpoint_position(unsigned) const;
64 float get_endpoint_direction(unsigned) const;
65 bool snap_to(Track &, bool);
66 bool snap(Point &, float &) const;
67 void break_link(Track &);
69 const std::vector<Track *> &get_links() const { return links; }
70 Track *get_link(unsigned) const;
72 int traverse(unsigned, unsigned) const;
73 Point get_point(unsigned, unsigned, float) const;
76 Creates a copy of the track. The new track will be almost identical, but
77 won't have any links to other tracks, nor a turnout or sensor id.
82 // Direct copying not allowed due to links. See the copy() function.
84 Track &operator=(const Track &);
87 } // namespace Marklin