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"
16 class TrackAttachment;
18 class Track: public Object, public sigc::trackable
21 class Loader: public Msp::DataFile::ObjectLoader<Track>
26 void position(float, float, float);
28 void sensor_id(unsigned);
31 void turnout_id(unsigned);
34 typedef std::list<TrackAttachment *> AttachmentList;
36 sigc::signal<void, unsigned, Track *> signal_link_changed;
37 sigc::signal<void, unsigned> signal_path_changing;
38 sigc::signal<void, unsigned> signal_path_changed;
41 const TrackType &type;
47 std::vector<Track *> links;
50 AttachmentList attachments;
53 Track &operator=(const Track &);
55 Track(Layout &, const TrackType &);
58 virtual Track *clone(Layout * = 0) const;
59 virtual const TrackType &get_type() const { return type; }
61 void set_block(Block *);
62 Block &get_block() const;
63 virtual void set_position(const Vector &);
64 virtual void set_rotation(const Angle &);
65 virtual void set_tilt(const Angle &);
67 bool get_flex() const { return flex; }
69 void propagate_slope();
73 void set_turnout_id(unsigned);
74 void set_sensor_id(unsigned);
75 unsigned get_turnout_id() const { return turnout_id; }
76 unsigned get_sensor_id() const { return sensor_id; }
77 void set_active_path(unsigned);
78 unsigned get_active_path() const { return active_path; }
79 bool is_path_changing() const { return path_changing; }
80 float get_path_length(int = -1) const;
82 OrientedPoint get_point(unsigned, unsigned, float) const;
83 OrientedPoint get_point(unsigned, float) const;
85 virtual unsigned get_n_snap_nodes() const;
86 virtual Snap get_snap_node(unsigned) const;
87 virtual bool snap(Snap &, float, SnapType = SNAP_DEFAULT) const;
89 virtual SnapType get_default_snap_type_to(const Object &) const;
92 virtual unsigned get_n_link_slots() const;
93 virtual Track *get_link(unsigned) const;
94 const std::vector<Track *> &get_links() const { return links; }
95 virtual int get_link_slot(const Object &) const;
96 virtual bool link_to(Object &);
97 using Object::break_link;
98 virtual bool break_link(unsigned);
100 void add_attachment(TrackAttachment &);
101 void remove_attachment(TrackAttachment &);
102 const AttachmentList &get_attachments() const { return attachments; }
103 AttachmentList get_attachments_ordered(unsigned) const;
105 void save(std::list<Msp::DataFile::Statement> &) const;
107 void turnout_event(unsigned, unsigned);