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_changed;
35 const TrackType &type;
41 std::vector<Track *> links;
46 Track &operator=(const Track &);
48 Track(Layout &, const TrackType &);
51 virtual Track *clone(Layout * = 0) const;
52 virtual const TrackType &get_type() const { return type; }
54 void set_block(Block *);
55 Block &get_block() const;
56 virtual void set_position(const Vector &);
57 virtual void set_rotation(float);
58 void set_slope(float);
60 float get_slope() const { return slope; }
61 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; }
72 bool is_path_changing() const { return path_changing; }
74 TrackPoint get_point(unsigned, unsigned, float) const;
75 TrackPoint get_point(unsigned, float) const;
77 virtual unsigned get_n_snap_nodes() const;
78 virtual Snap get_snap_node(unsigned) const;
79 virtual bool snap(Snap &, float, SnapType = SNAP_DEFAULT) const;
81 virtual SnapType get_default_snap_type_to(const Object &) const;
84 virtual unsigned get_n_link_slots() const;
85 virtual Track *get_link(unsigned) const;
86 const std::vector<Track *> &get_links() const { return links; }
87 virtual int get_link_slot(const Object &) const;
88 virtual bool link_to(Object &);
89 using Object::break_link;
90 virtual bool break_link(unsigned);
92 virtual bool collide_ray(const Vector &, const Vector &) const;
94 void save(std::list<Msp::DataFile::Statement> &) const;
96 void turnout_event(unsigned, unsigned);