3 This file is part of the MSP Märklin suite
4 Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBMARKLIN_TRACK_H_
9 #define LIBMARKLIN_TRACK_H_
13 #include <sigc++/trackable.h>
14 #include <msp/datafile/loader.h>
22 class Track: public sigc::trackable
25 class Loader: public Msp::DataFile::BasicLoader<Track>
30 void position(float, float, float);
31 void sensor_id(unsigned);
32 void turnout_id(unsigned);
37 const TrackType &type;
44 std::vector<Track *> links;
48 Track &operator=(const Track &);
50 Track(Layout &, const TrackType &);
53 const TrackType &get_type() const { return type; }
55 void set_position(const Point &);
56 void set_rotation(float);
57 void set_slope(float);
59 const Point &get_position() const { return pos; }
60 float get_rotation() const { return rot; }
61 float get_slope() const { return slope; }
62 bool get_flex() const { return flex; }
65 void set_turnout_id(unsigned);
66 void set_sensor_id(unsigned);
67 unsigned get_turnout_id() const { return turnout_id; }
68 unsigned get_sensor_id() const { return sensor_id; }
69 void set_active_path(unsigned);
70 unsigned get_active_path() const { return active_path; }
72 int get_endpoint_by_link(const Track &) const;
73 Point get_endpoint_position(unsigned) const;
74 float get_endpoint_direction(unsigned) const;
75 bool snap_to(Track &, bool);
76 bool snap(Point &, float &) const;
77 void break_link(Track &);
79 const std::vector<Track *> &get_links() const { return links; }
80 Track *get_link(unsigned) const;
81 unsigned traverse(unsigned, unsigned) const;
82 Point get_point(unsigned, unsigned, float) const;
84 void save(std::list<Msp::DataFile::Statement> &) const;
86 void turnout_event(unsigned, bool);
89 } // namespace Marklin