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>
27 void position(float, float, float);
29 void sensor_address(unsigned);
32 void turnout_address(unsigned);
35 typedef std::list<TrackAttachment *> AttachmentList;
37 sigc::signal<void, unsigned, Track *> signal_link_changed;
38 sigc::signal<void, unsigned> signal_path_changing;
39 sigc::signal<void, unsigned> signal_path_changed;
42 const TrackType &type;
46 unsigned turnout_addr;
49 std::vector<Track *> links;
52 AttachmentList attachments;
55 Track &operator=(const Track &);
57 Track(Layout &, const TrackType &);
60 virtual Track *clone(Layout * = 0) const;
61 virtual const TrackType &get_type() const { return type; }
63 void set_block(Block *);
64 Block &get_block() const;
65 virtual void set_position(const Vector &);
66 virtual void set_rotation(const Angle &);
67 virtual void set_tilt(const Angle &);
69 bool get_flex() const { return flex; }
71 void propagate_slope();
75 void set_turnout_address(unsigned);
76 void set_sensor_address(unsigned);
77 unsigned get_turnout_address() const { return turnout_addr; }
78 unsigned get_sensor_address() const { return sensor_addr; }
79 void set_active_path(unsigned);
80 unsigned get_active_path() const { return active_path; }
81 bool is_path_changing() const { return path_changing; }
82 float get_path_length(int = -1) const;
84 OrientedPoint get_point(unsigned, unsigned, float) const;
85 OrientedPoint get_point(unsigned, float) const;
87 virtual unsigned get_n_snap_nodes() const;
88 virtual Snap get_snap_node(unsigned) const;
89 virtual bool snap(Snap &, float, SnapType = SNAP_DEFAULT) const;
91 virtual SnapType get_default_snap_type_to(const Object &) const;
94 virtual unsigned get_n_link_slots() const;
95 virtual Track *get_link(unsigned) const;
96 const std::vector<Track *> &get_links() const { return links; }
97 virtual int get_link_slot(const Object &) const;
98 virtual bool link_to(Object &);
99 using Object::break_link;
100 virtual bool break_link(unsigned);
102 void add_attachment(TrackAttachment &);
103 void remove_attachment(TrackAttachment &);
104 const AttachmentList &get_attachments() const { return attachments; }
105 AttachmentList get_attachments_ordered(unsigned) const;
107 void save(std::list<Msp::DataFile::Statement> &) const;
108 void save_dynamic(std::list<Msp::DataFile::Statement> &) const;
110 void turnout_event(unsigned, unsigned);
111 void turnout_failed(unsigned);