X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2F3d%2Flayout.cpp;h=70c55096cfa91eed259b6be9ebd99ef701dfd88c;hb=9ddcd066e37e4c72685817c042c30897786ece05;hp=1a557153fda308ce56a18066e281ca2e3e1b8830;hpb=651698847d5293cfb15b6fb23a394701388c0151;p=r2c2.git diff --git a/source/3d/layout.cpp b/source/3d/layout.cpp index 1a55715..70c5509 100644 --- a/source/3d/layout.cpp +++ b/source/3d/layout.cpp @@ -14,6 +14,8 @@ Distributed under the GPL #include #include #include "layout.h" +#include "track.h" +#include "vehicle.h" using namespace std; using namespace Msp; @@ -26,7 +28,7 @@ Layout3D::Layout3D(Layout &l): { layout.signal_track_added.connect(sigc::mem_fun(this, &Layout3D::track_added)); layout.signal_track_removed.connect(sigc::mem_fun(this, &Layout3D::track_removed)); - layout.signal_train_added.connect(sigc::mem_fun(this, &Layout3D::train_added)); + layout.signal_vehicle_added.connect(sigc::mem_fun(this, &Layout3D::vehicle_added)); const set <racks = layout.get_tracks(); for(set::iterator i=ltracks.begin(); i!=ltracks.end(); ++i) @@ -37,8 +39,8 @@ Layout3D::~Layout3D() { while(!tracks.empty()) delete tracks.front(); - while(!trains.empty()) - delete trains.front(); + while(!vehicles.empty()) + delete vehicles.front(); } void Layout3D::add_track(Track3D &t) @@ -89,7 +91,7 @@ Track3D *Layout3D::pick_track(float x, float y, float size) const Track3D *track = 0; unsigned track_depth = numeric_limits::max(); for(vector::iterator i=select_buf.begin(); i!=select_buf.end(); ++i) - if(i->min_depthmin_depthnames.empty()) { track = reinterpret_cast(i->names.back()); track_depth = i->min_depth; @@ -98,25 +100,25 @@ Track3D *Layout3D::pick_track(float x, float y, float size) const return track; } -void Layout3D::add_train(Train3D &t) +void Layout3D::add_vehicle(Vehicle3D &v) { - trains.push_back(&t); + vehicles.push_back(&v); } -void Layout3D::remove_train(Train3D &t) +void Layout3D::remove_vehicle(Vehicle3D &v) { - list::iterator i = find(trains.begin(), trains.end(), &t); - if(i!=trains.end()) - trains.erase(i); + list::iterator i = find(vehicles.begin(), vehicles.end(), &v); + if(i!=vehicles.end()) + vehicles.erase(i); } -Train3D &Layout3D::get_train(const Train &t) const +Vehicle3D &Layout3D::get_vehicle(const Vehicle &v) const { - for(list::const_iterator i=trains.begin(); i!=trains.end(); ++i) - if(&(*i)->get_train()==&t) + for(list::const_iterator i=vehicles.begin(); i!=vehicles.end(); ++i) + if(&(*i)->get_vehicle()==&v) return **i; - throw KeyError("Unknown train"); + throw KeyError("Unknown vehicle"); } void Layout3D::track_added(Track &t) @@ -134,9 +136,9 @@ void Layout3D::track_removed(Track &t) } } -void Layout3D::train_added(Train &t) +void Layout3D::vehicle_added(Vehicle &v) { - new Train3D(*this, t); + new Vehicle3D(*this, v); } } // namespace Marklin