X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Flibr2c2%2Ftrack.h;h=4dbfa2db87eabd56c12616f759adebdef1f4ca2c;hb=66c2c7ca5a4bd369293959bc211b040834343381;hp=95f902303a58f8a08d1118f0afd9c95782516702;hpb=1ff06c5bc46a677fa389ef86c6b26664368f1653;p=r2c2.git diff --git a/source/libr2c2/track.h b/source/libr2c2/track.h index 95f9023..4dbfa2d 100644 --- a/source/libr2c2/track.h +++ b/source/libr2c2/track.h @@ -1,17 +1,10 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #ifndef LIBR2C2_TRACK_H_ #define LIBR2C2_TRACK_H_ #include #include #include -#include +#include #include "geometry.h" namespace R2C2 { @@ -23,7 +16,7 @@ class TrackType; class Track: public sigc::trackable { public: - class Loader: public Msp::DataFile::BasicLoader + class Loader: public Msp::DataFile::ObjectLoader { public: Loader(Track &); @@ -33,13 +26,14 @@ public: void turnout_id(unsigned); }; + sigc::signal signal_link_changed; sigc::signal signal_path_changed; private: Layout &layout; const TrackType &type; Block *block; - Point pos; + Vector pos; float rot; float slope; bool flex; @@ -47,6 +41,7 @@ private: unsigned sensor_id; std::vector links; unsigned active_path; + bool path_changing; Track(const Track &); Track &operator=(const Track &); @@ -59,11 +54,11 @@ public: void set_block(Block *); Block &get_block() const; - void set_position(const Point &); + void set_position(const Vector &); void set_rotation(float); void set_slope(float); void set_flex(bool); - const Point &get_position() const { return pos; } + const Vector &get_position() const { return pos; } float get_rotation() const { return rot; } float get_slope() const { return slope; } bool get_flex() const { return flex; } @@ -75,22 +70,26 @@ public: unsigned get_sensor_id() const { return sensor_id; } void set_active_path(unsigned); unsigned get_active_path() const { return active_path; } + bool is_path_changing() const { return path_changing; } int get_endpoint_by_link(Track &) const; - Point get_endpoint_position(unsigned) const; + Vector get_endpoint_position(unsigned) const; float get_endpoint_direction(unsigned) const; bool snap_to(Track &, bool, float = 0); - bool snap(Point &, float &) const; + bool snap(Vector &, float &) const; 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; + TrackPoint get_nearest_point(const Vector &) const; + + bool collide_ray(const Vector &, const Vector &); void save(std::list &) const; private: - void turnout_event(unsigned, bool); + void turnout_event(unsigned, unsigned); }; } // namespace R2C2