X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Ftrack.cpp;h=05f9f2f717c1044b47446b73aeab0ac01f68b73b;hb=97443d96ff3ce51388d2edd1e0dca8f2cd231346;hp=fc365862301c9acfa0734ccd3b510b7a5c6cbe77;hpb=c12e074c6b9b5136e72931fb47a562e40e0a24f9;p=r2c2.git diff --git a/source/libmarklin/track.cpp b/source/libmarklin/track.cpp index fc36586..05f9f2f 100644 --- a/source/libmarklin/track.cpp +++ b/source/libmarklin/track.cpp @@ -130,8 +130,10 @@ void Track::set_active_path(unsigned p) throw InvalidParameterValue("Invalid path"); layout.get_driver().set_turnout(turnout_id, p&1); - if(type.get_n_paths()>2) + if(type.is_double_address()) layout.get_driver().set_turnout(turnout_id+1, p&2); + else if(type.get_n_paths()>2) + active_path = (active_path&1) | (p&2); } int Track::get_endpoint_by_link(const Track &other) const @@ -293,6 +295,11 @@ unsigned Track::traverse(unsigned i, unsigned path) const throw Exception("Track endpoint did not have a counterpart"); } +unsigned Track::traverse(unsigned i) const +{ + return traverse(i, active_path); +} + TrackPoint Track::get_point(unsigned epi, unsigned path, float d) const { TrackPoint p = type.get_point(epi, path, d); @@ -300,6 +307,7 @@ TrackPoint Track::get_point(unsigned epi, unsigned path, float d) const float s = sin(rot); p.pos = Point(pos.x+c*p.pos.x-s*p.pos.y, pos.y+s*p.pos.x+c*p.pos.y, 0); + p.dir += rot; if(type.get_endpoints().size()==2) { float len = type.get_path_length(path); @@ -319,6 +327,11 @@ TrackPoint Track::get_point(unsigned epi, unsigned path, float d) const return p; } +TrackPoint Track::get_point(unsigned epi, float d) const +{ + return get_point(epi, active_path, d); +} + void Track::save(list &st) const { st.push_back((DataFile::Statement("position"), pos.x, pos.y, pos.z));