X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftrack.h;h=eaf8de217c8c267bf7e2d831da8002aab4a5c878;hb=2bb6ce8ada216c0b2caa48f4639d03f2c581098e;hp=21c505fb9ae12c180ed955e632aab989d0684b03;hpb=c47f3fad07af11210c9cbd65d87964794189065e;p=r2c2.git diff --git a/source/libmarklin/track.h b/source/libmarklin/track.h index 21c505f..eaf8de2 100644 --- a/source/libmarklin/track.h +++ b/source/libmarklin/track.h @@ -1,7 +1,7 @@ /* $Id$ This file is part of the MSP Märklin suite -Copyright © 2006-2009 Mikkosoft Productions, Mikko Rasa +Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa Distributed under the GPL */ @@ -10,14 +10,17 @@ Distributed under the GPL #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::BasicLoader @@ -26,10 +29,14 @@ public: Loader(Track &); private: void position(float, float, float); + void sensor_id(unsigned); + void turnout_id(unsigned); }; private: + Layout &layout; const TrackType &type; + Block *block; Point pos; float rot; float slope; @@ -37,16 +44,19 @@ private: unsigned turnout_id; unsigned sensor_id; std::vector links; + unsigned active_path; - // Direct copying not allowed due to links. See the copy() function. 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_block(Block *); + Block &get_block() const; void set_position(const Point &); void set_rotation(float); void set_slope(float); @@ -61,8 +71,10 @@ public: 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(const Track &) const; + int get_endpoint_by_link(Track &) const; Point get_endpoint_position(unsigned) const; float get_endpoint_direction(unsigned) const; bool snap_to(Track &, bool); @@ -71,16 +83,12 @@ public: void break_links(); const std::vector &get_links() const { return links; } Track *get_link(unsigned) const; - unsigned traverse(unsigned, unsigned) const; - Point get_point(unsigned, unsigned, float) 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; + TrackPoint get_point(unsigned, unsigned, float) const; + TrackPoint get_point(unsigned, float) const; void save(std::list &) const; +private: + void turnout_event(unsigned, bool); }; } // namespace Marklin