X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdesigner%2Fdesigner.cpp;h=c9c045af2e253d9091d89cefa964b17618b12a58;hb=7abd932fe2f61d2762dd7677801dd7a1ebf9b420;hp=b0971c25271be9d65390ff08ca5841614e7c84b6;hpb=651698847d5293cfb15b6fb23a394701388c0151;p=r2c2.git diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index b0971c2..c9c045a 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -27,6 +27,7 @@ Distributed under the GPL #include #include "libmarklin/route.h" #include "libmarklin/tracktype.h" +#include "3d/path.h" #include "designer.h" #include "input.h" #include "manipulator.h" @@ -201,6 +202,7 @@ void Designer::set_sensor_id() void Designer::edit_route(Route &r) { cur_route = &r; + show_route(r); } void Designer::add_selection_to_route() @@ -218,6 +220,8 @@ void Designer::add_selection_to_route() { IO::print("%s\n", e.what()); } + + show_route(*cur_route); } Point Designer::map_pointer_coords(int x, int y) @@ -428,27 +432,12 @@ void Designer::render() { pipeline->render_all(); layout_3d->get_endpoint_scene().render(); + if(cur_route) + layout_3d->get_path_scene().render(); GL::enable(GL_CULL_FACE); GL::disable(GL::DEPTH_TEST); overlay->render(0); GL::enable(GL::DEPTH_TEST); - /*if(cur_route) - { - glColor4f(0.5, 0.8, 1.0, 1.0); - const set &rtracks = cur_route->get_tracks(); - const map &turnouts = cur_route->get_turnouts(); - for(set::const_iterator i=rtracks.begin(); i!=rtracks.end(); ++i) - { - unsigned path = 0; - if(unsigned tid=(*i)->get_turnout_id()) - { - map::const_iterator j = turnouts.find(tid); - if(j!=turnouts.end()) - path = j->second; - } - layout_3d->get_track(**i).render_path(path); - } - }*/ manipulator.render(); if(mode==MEASURE) @@ -592,3 +581,30 @@ string Designer::tooltip(int x, int y) return string(); } + +void Designer::show_route(const Route &route) +{ + const set <racks = layout->get_tracks(); + const set &rtracks = route.get_tracks(); + for(set::iterator i=ltracks.begin(); i!=ltracks.end(); ++i) + { + Track3D &t3d = layout_3d->get_track(**i); + if(rtracks.count(*i)) + { + t3d.get_path().set_color(GL::Color(0.5, 0.8, 1.0)); + if((*i)->get_type().is_turnout()) + { + unsigned tid = (*i)->get_turnout_id(); + int path = (tid ? route.get_turnout(tid) : -1); + if(path>=0) + t3d.get_path().set_path(path); + else + t3d.get_path().set_mask((*i)->get_type().get_paths()); + } + else + t3d.get_path().set_path(0); + } + else + t3d.get_path().set_mask(0); + } +}