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>
23 class Track: public sigc::trackable
26 class Loader: public Msp::DataFile::BasicLoader<Track>
31 void position(float, float, float);
32 void sensor_id(unsigned);
33 void turnout_id(unsigned);
38 const TrackType &type;
46 std::vector<Track *> links;
50 Track &operator=(const Track &);
52 Track(Layout &, const TrackType &);
55 Layout &get_layout() const { return layout; }
56 const TrackType &get_type() const { return type; }
58 void set_block(Block *);
59 Block &get_block() const;
60 void set_position(const Point &);
61 void set_rotation(float);
62 void set_slope(float);
64 const Point &get_position() const { return pos; }
65 float get_rotation() const { return rot; }
66 float get_slope() const { return slope; }
67 bool get_flex() const { return flex; }
70 void set_turnout_id(unsigned);
71 void set_sensor_id(unsigned);
72 unsigned get_turnout_id() const { return turnout_id; }
73 unsigned get_sensor_id() const { return sensor_id; }
74 void set_active_path(unsigned);
75 unsigned get_active_path() const { return active_path; }
77 int get_endpoint_by_link(Track &) const;
78 Point get_endpoint_position(unsigned) const;
79 float get_endpoint_direction(unsigned) const;
80 bool snap_to(Track &, bool);
81 bool snap(Point &, float &) const;
82 void break_link(Track &);
84 const std::vector<Track *> &get_links() const { return links; }
85 Track *get_link(unsigned) const;
86 TrackPoint get_point(unsigned, unsigned, float) const;
87 TrackPoint get_point(unsigned, float) const;
89 void save(std::list<Msp::DataFile::Statement> &) const;
91 void turnout_event(unsigned, bool);
94 } // namespace Marklin