1 #ifndef LIBR2C2_TRACK_H_
2 #define LIBR2C2_TRACK_H_
6 #include <sigc++/trackable.h>
7 #include <msp/datafile/objectloader.h>
10 #include "tracktype.h"
17 class Track: public Object, public sigc::trackable
20 class Loader: public Msp::DataFile::ObjectLoader<Track>
25 void position(float, float, float);
27 void sensor_id(unsigned);
28 void turnout_id(unsigned);
31 sigc::signal<void, unsigned, Track *> signal_link_changed;
32 sigc::signal<void, unsigned> signal_path_changing;
33 sigc::signal<void, unsigned> signal_path_changed;
36 const TrackType &type;
42 std::vector<Track *> links;
47 Track &operator=(const Track &);
49 Track(Layout &, const TrackType &);
52 virtual Track *clone(Layout * = 0) const;
53 virtual const TrackType &get_type() const { return type; }
55 void set_block(Block *);
56 Block &get_block() const;
57 virtual void set_position(const Vector &);
58 virtual void set_rotation(const Angle &);
59 void set_slope(float);
61 float get_slope() const { return slope; }
62 bool get_flex() const { return flex; }
67 void set_turnout_id(unsigned);
68 void set_sensor_id(unsigned);
69 unsigned get_turnout_id() const { return turnout_id; }
70 unsigned get_sensor_id() const { return sensor_id; }
71 void set_active_path(unsigned);
72 unsigned get_active_path() const { return active_path; }
73 bool is_path_changing() const { return path_changing; }
75 TrackPoint get_point(unsigned, unsigned, float) const;
76 TrackPoint get_point(unsigned, float) const;
78 virtual unsigned get_n_snap_nodes() const;
79 virtual Snap get_snap_node(unsigned) const;
80 virtual bool snap(Snap &, float, SnapType = SNAP_DEFAULT) const;
82 virtual SnapType get_default_snap_type_to(const Object &) const;
85 virtual unsigned get_n_link_slots() const;
86 virtual Track *get_link(unsigned) const;
87 const std::vector<Track *> &get_links() const { return links; }
88 virtual int get_link_slot(const Object &) const;
89 virtual bool link_to(Object &);
90 using Object::break_link;
91 virtual bool break_link(unsigned);
93 void save(std::list<Msp::DataFile::Statement> &) const;
95 void turnout_event(unsigned, unsigned);