X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrack.h;h=ba59da0ad95b9badc3e55401c7b95a7bd764bf33;hb=08dea8dfcf923e9296bcd3910455540895d0439b;hp=b8a9a3d330bc6f472818f24a006266e111c9552b;hpb=b88d3630a0e3fdd763db018bbe5dbfe3180a95f2;p=r2c2.git diff --git a/source/libr2c2/track.h b/source/libr2c2/track.h index b8a9a3d..ba59da0 100644 --- a/source/libr2c2/track.h +++ b/source/libr2c2/track.h @@ -13,6 +13,7 @@ namespace R2C2 { class Block; class Layout; +class TrackAttachment; class Track: public Object, public sigc::trackable { @@ -22,13 +23,19 @@ public: public: Loader(Track &); private: + void path(unsigned); void position(float, float, float); void rotation(float); - void sensor_id(unsigned); - void turnout_id(unsigned); + void sensor_address(unsigned); + void slope(float); + void tilt(float); + void turnout_address(unsigned); }; + typedef std::list AttachmentList; + sigc::signal signal_link_changed; + sigc::signal signal_path_changing; sigc::signal signal_path_changed; private: @@ -36,11 +43,13 @@ private: Block *block; float slope; bool flex; + unsigned turnout_addr; unsigned turnout_id; - unsigned sensor_id; + unsigned sensor_addr; std::vector links; unsigned active_path; bool path_changing; + AttachmentList attachments; Track(const Track &); Track &operator=(const Track &); @@ -54,29 +63,26 @@ public: void set_block(Block *); Block &get_block() const; virtual void set_position(const Vector &); - virtual void set_rotation(float); - void set_slope(float); + virtual void set_rotation(const Angle &); + virtual void set_tilt(const Angle &); void set_flex(bool); - float get_slope() const { return slope; } bool get_flex() const { return flex; } +private: + void propagate_slope(); void check_slope(); - void set_turnout_id(unsigned); - void set_sensor_id(unsigned); - unsigned get_turnout_id() const { return turnout_id; } - unsigned get_sensor_id() const { return sensor_id; } +public: + void set_turnout_address(unsigned); + void set_sensor_address(unsigned); + unsigned get_turnout_address() const { return turnout_addr; } + unsigned get_sensor_address() const { return sensor_addr; } void set_active_path(unsigned); unsigned get_active_path() const { return active_path; } bool is_path_changing() const { return path_changing; } + float get_path_length(int = -1) const; - int get_endpoint_by_link(Track &) const; - bool snap_to(Track &, bool, float = 0); - void break_link(Track &); - void break_links(); - const std::vector &get_links() const { return links; } - Track *get_link(unsigned) const; - TrackPoint get_point(unsigned, unsigned, float) const; - TrackPoint get_point(unsigned, float) const; + OrientedPoint get_point(unsigned, unsigned, float) const; + OrientedPoint get_point(unsigned, float) const; virtual unsigned get_n_snap_nodes() const; virtual Snap get_snap_node(unsigned) const; @@ -85,11 +91,24 @@ private: virtual SnapType get_default_snap_type_to(const Object &) const; public: - virtual bool collide_ray(const Vector &, const Vector &) const; + virtual unsigned get_n_link_slots() const; + virtual Track *get_link(unsigned) const; + const std::vector &get_links() const { return links; } + virtual int get_link_slot(const Object &) const; + virtual bool link_to(Object &); + using Object::break_link; + virtual bool break_link(unsigned); + + void add_attachment(TrackAttachment &); + void remove_attachment(TrackAttachment &); + const AttachmentList &get_attachments() const { return attachments; } + AttachmentList get_attachments_ordered(unsigned) const; void save(std::list &) const; + void save_dynamic(std::list &) const; private: void turnout_event(unsigned, unsigned); + void turnout_failed(unsigned); }; } // namespace R2C2