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 Layout &get_layout() const { return layout; }
54 const TrackType &get_type() const { return type; }
56 void set_position(const Point &);
57 void set_rotation(float);
58 void set_slope(float);
60 const Point &get_position() const { return pos; }
61 float get_rotation() const { return rot; }
62 float get_slope() const { return slope; }
63 bool get_flex() const { return flex; }
66 void set_turnout_id(unsigned);
67 void set_sensor_id(unsigned);
68 unsigned get_turnout_id() const { return turnout_id; }
69 unsigned get_sensor_id() const { return sensor_id; }
70 void set_active_path(unsigned);
71 unsigned get_active_path() const { return active_path; }
73 int get_endpoint_by_link(const Track &) const;
74 Point get_endpoint_position(unsigned) const;
75 float get_endpoint_direction(unsigned) const;
76 bool snap_to(Track &, bool);
77 bool snap(Point &, float &) const;
78 void break_link(Track &);
80 const std::vector<Track *> &get_links() const { return links; }
81 Track *get_link(unsigned) const;
82 unsigned traverse(unsigned, unsigned) const;
83 TrackPoint get_point(unsigned, unsigned, float) const;
84 TrackPoint get_point(unsigned, float) const;
86 void save(std::list<Msp::DataFile::Statement> &) const;
88 void turnout_event(unsigned, bool);
91 } // namespace Marklin