X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftracktype.h;h=b540e291bd4bf75bef03440ef9530c91321e61a1;hb=b860a56bd9bc8894311c02d7673f379beff3220b;hp=d38f1b21b86d4f4fdac0f4e6f84d21804189c807;hpb=1ff06c5bc46a677fa389ef86c6b26664368f1653;p=r2c2.git diff --git a/source/libr2c2/tracktype.h b/source/libr2c2/tracktype.h index d38f1b2..b540e29 100644 --- a/source/libr2c2/tracktype.h +++ b/source/libr2c2/tracktype.h @@ -1,67 +1,80 @@ -/* $Id$ - -This file is part of R²C² -Copyright © 2006-2010 Mikkosoft Productions, Mikko Rasa -Distributed under the GPL -*/ - #ifndef LIBR2C2_TRACKTYPE_H_ #define LIBR2C2_TRACKTYPE_H_ -#include +#include #include "articlenumber.h" #include "geometry.h" +#include "objecttype.h" #include "trackpart.h" namespace R2C2 { -class TrackType +class TrackAppearance; + +class TrackType: public ObjectType { public: struct Endpoint { - Point pos; - float dir; // Direction outwards from the endpoint + Vector pos; + Angle dir; // Direction outwards from the endpoint unsigned paths; - Endpoint(float, float, float, unsigned); + Endpoint(float, float, const Angle &, unsigned); + + bool has_path(unsigned p) const { return paths&(1< + class Loader: public Msp::DataFile::DerivedObjectLoader { public: - Loader(TrackType &); + typedef Msp::DataFile::Collection Collection; + + private: + Collection &coll; + bool state_bits_set; + + public: + Loader(TrackType &, Collection &); + + virtual Collection &get_collection() const { return coll; } private: virtual void finish(); + void appearance(const std::string &); void part(); void position(float, float, float); + void state_bits(unsigned); }; private: - ArticleNumber art_nr; - std::string description; + const TrackAppearance *appearance; std::vector parts; std::vector endpoints; - bool double_address; + unsigned state_bits; unsigned autofit_preference; + std::string object; public: - TrackType(const ArticleNumber &); + TrackType(); - const ArticleNumber &get_article_number() const { return art_nr; } - const std::string &get_description() const { return description; } + const TrackAppearance &get_appearance() const; + float get_gauge() const; float get_total_length() const; float get_path_length(int) const; unsigned get_paths() const; unsigned get_n_paths() const; + unsigned coerce_path(unsigned, unsigned) const; + unsigned get_state_bits() const { return state_bits; } bool is_turnout() const; bool is_dead_end() const; - bool is_double_address() const { return double_address; } unsigned get_autofit_preference() const { return autofit_preference; } + const std::string &get_object() const { return object; } const std::vector &get_parts() const { return parts; } const std::vector &get_endpoints() const { return endpoints; } const Endpoint &get_endpoint(unsigned) const; - TrackPoint get_point(unsigned, unsigned, float) const; + OrientedPoint get_point(unsigned, unsigned, float) const; + OrientedPoint get_nearest_point(const Vector &) const; private: void collect_endpoints();