X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftrack.h;h=f065cb673e43a030115581d9e2380a1a54db2589;hb=6ba6af3637c299ab00828c49de9151429488cc17;hp=13a98bf51b268d4772dff9d1c7111df54fbea967;hpb=52cbe8d99669f843f8f75c51128e2748584dd03a;p=r2c2.git diff --git a/source/libmarklin/track.h b/source/libmarklin/track.h index 13a98bf..f065cb6 100644 --- a/source/libmarklin/track.h +++ b/source/libmarklin/track.h @@ -1,79 +1,96 @@ +/* $Id$ + +This file is part of the MSP Märklin suite +Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa +Distributed under the GPL +*/ + #ifndef LIBMARKLIN_TRACK_H_ #define LIBMARKLIN_TRACK_H_ #include #include +#include #include #include "geometry.h" namespace Marklin { +class Block; +class Layout; class TrackType; -class Track +class Track: public sigc::trackable { public: - class Loader: public Msp::DataFile::Loader + class Loader: public Msp::DataFile::BasicLoader { - private: - Track &track; - public: Loader(Track &); - Track &get_object() { return track; } private: void position(float, float, float); + void sensor_id(unsigned); + void turnout_id(unsigned); }; + sigc::signal signal_path_changed; + private: + Layout &layout; const TrackType &type; - Point pos; - float rot; - float slope; - bool flex; - unsigned turnout_id; - unsigned sensor_id; + Block *block; + Point pos; + float rot; + float slope; + bool flex; + unsigned turnout_id; + unsigned sensor_id; std::vector links; + unsigned active_path; + Track(const Track &); + Track &operator=(const Track &); public: - Track(const TrackType &); + Track(Layout &, const TrackType &); ~Track(); + Layout &get_layout() const { return layout; } const TrackType &get_type() const { return type; } - void set_position(const Point &); - const Point &get_position() const { return pos; } - void set_rotation(float); - float get_rotation() const { return rot; } - void set_slope(float); - float get_slope() const { return slope; } - void set_flex(bool); - bool get_flex() const { return flex; } - void set_turnout_id(unsigned); - unsigned get_turnout_id() const { return turnout_id; } - void set_sensor_id(unsigned); - unsigned get_sensor_id() const { return sensor_id; } - int get_endpoint_by_link(const Track &) const; - Point get_endpoint_position(unsigned) const; - float get_endpoint_direction(unsigned) const; - bool snap_to(Track &, bool); - bool snap(Point &, float &) const; - void break_link(Track &); - void break_links(); + + void set_block(Block *); + Block &get_block() const; + void set_position(const Point &); + void set_rotation(float); + void set_slope(float); + void set_flex(bool); + const Point &get_position() const { return pos; } + float get_rotation() const { return rot; } + float get_slope() const { return slope; } + bool get_flex() const { return flex; } + 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; } + void set_active_path(unsigned); + unsigned get_active_path() const { return active_path; } + + int get_endpoint_by_link(Track &) const; + Point get_endpoint_position(unsigned) const; + float get_endpoint_direction(unsigned) const; + bool snap_to(Track &, bool, float = 0); + bool snap(Point &, float &) const; + void break_link(Track &); + void break_links(); const std::vector &get_links() const { return links; } - Track *get_link(unsigned) const; - void check_slope(); - int traverse(unsigned, unsigned) const; - - /** - Creates a copy of the track. The new track will be almost identical, but - won't have any links to other tracks, nor a turnout or sensor id. - */ - Track *copy() const; -private: + Track *get_link(unsigned) const; + TrackPoint get_point(unsigned, unsigned, float) const; + TrackPoint get_point(unsigned, float) const; - // Direct copying not allowed due to links. See the copy() function. - Track(const Track &); - Track &operator=(const Track &); + void save(std::list &) const; +private: + void turnout_event(unsigned, bool); }; } // namespace Marklin