3 This file is part of R²C²
4 Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBR2C2_TRACK_H_
9 #define LIBR2C2_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);
36 sigc::signal<void, unsigned> signal_path_changed;
40 const TrackType &type;
48 std::vector<Track *> links;
52 Track &operator=(const Track &);
54 Track(Layout &, const TrackType &);
57 Layout &get_layout() const { return layout; }
58 const TrackType &get_type() const { return type; }
60 void set_block(Block *);
61 Block &get_block() const;
62 void set_position(const Point &);
63 void set_rotation(float);
64 void set_slope(float);
66 const Point &get_position() const { return pos; }
67 float get_rotation() const { return rot; }
68 float get_slope() const { return slope; }
69 bool get_flex() const { return flex; }
72 void set_turnout_id(unsigned);
73 void set_sensor_id(unsigned);
74 unsigned get_turnout_id() const { return turnout_id; }
75 unsigned get_sensor_id() const { return sensor_id; }
76 void set_active_path(unsigned);
77 unsigned get_active_path() const { return active_path; }
79 int get_endpoint_by_link(Track &) const;
80 Point get_endpoint_position(unsigned) const;
81 float get_endpoint_direction(unsigned) const;
82 bool snap_to(Track &, bool, float = 0);
83 bool snap(Point &, float &) const;
84 void break_link(Track &);
86 const std::vector<Track *> &get_links() const { return links; }
87 Track *get_link(unsigned) const;
88 TrackPoint get_point(unsigned, unsigned, float) const;
89 TrackPoint get_point(unsigned, float) const;
91 void save(std::list<Msp::DataFile::Statement> &) const;
93 void turnout_event(unsigned, bool);