From: Mikko Rasa Date: Wed, 5 Jun 2013 10:53:12 +0000 (+0300) Subject: Reduce interface clutter in Layout by storing Objects in a uniform way X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e214fd389b9819eac0379cfb78e0f446e267b839;p=r2c2.git Reduce interface clutter in Layout by storing Objects in a uniform way --- diff --git a/source/3d/layout.cpp b/source/3d/layout.cpp index d243374..2927e44 100644 --- a/source/3d/layout.cpp +++ b/source/3d/layout.cpp @@ -16,19 +16,12 @@ Layout3D::Layout3D(Layout &l): sun.set_position(0, -0.259, 0.966, 0); lighting.attach(0, sun); - 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_vehicle_added.connect(sigc::mem_fun(this, &Layout3D::vehicle_added)); - layout.signal_vehicle_removed.connect(sigc::mem_fun(this, &Layout3D::vehicle_removed)); - layout.signal_signal_added.connect(sigc::mem_fun(this, &Layout3D::signal_added)); - layout.signal_signal_removed.connect(sigc::mem_fun(this, &Layout3D::signal_removed)); - - const set <racks = layout.get_tracks(); - for(set::iterator i=ltracks.begin(); i!=ltracks.end(); ++i) - track_added(**i); - const set &lsignals = layout.get_signals(); - for(set::iterator i=lsignals.begin(); i!=lsignals.end(); ++i) - signal_added(**i); + layout.signal_object_added.connect(sigc::mem_fun(this, &Layout3D::object_added)); + layout.signal_object_removed.connect(sigc::mem_fun(this, &Layout3D::object_removed)); + + const set &lobjs = layout.get_all(); + for(set::iterator i=lobjs.begin(); i!=lobjs.end(); ++i) + object_added(**i); } Layout3D::~Layout3D() @@ -97,40 +90,36 @@ Signal3D &Layout3D::get_signal(Signal &s) const return *get_item(signals, &s); } -void Layout3D::track_added(Track &t) -{ - new Track3D(*this, t); -} - -void Layout3D::track_removed(Track &t) -{ - TrackMap::iterator i = tracks.find(&t); - if(i!=tracks.end()) - delete i->second; -} - -void Layout3D::vehicle_added(Vehicle &v) -{ - new Vehicle3D(*this, v); -} - -void Layout3D::vehicle_removed(Vehicle &v) -{ - VehicleMap::iterator i = vehicles.find(&v); - if(i!=vehicles.end()) - delete i->second; -} - -void Layout3D::signal_added(Signal &s) -{ - new Signal3D(*this, s); -} - -void Layout3D::signal_removed(Signal &s) -{ - SignalMap::iterator i = signals.find(&s); - if(i!=signals.end()) - delete i->second; +void Layout3D::object_added(Object &o) +{ + if(Track *t = dynamic_cast(&o)) + new Track3D(*this, *t); + else if(Signal *s = dynamic_cast(&o)) + new Signal3D(*this, *s); + else if(Vehicle *v = dynamic_cast(&o)) + new Vehicle3D(*this, *v); +} + +void Layout3D::object_removed(Object &o) +{ + if(Track *t = dynamic_cast(&o)) + { + TrackMap::iterator i = tracks.find(t); + if(i!=tracks.end()) + delete i->second; + } + else if(Signal *s = dynamic_cast(&o)) + { + SignalMap::iterator i = signals.find(s); + if(i!=signals.end()) + delete i->second; + } + else if(Vehicle *v = dynamic_cast(&o)) + { + VehicleMap::iterator i = vehicles.find(v); + if(i!=vehicles.end()) + delete i->second; + } } } // namespace R2C2 diff --git a/source/3d/layout.h b/source/3d/layout.h index 1e189bd..8456fa8 100644 --- a/source/3d/layout.h +++ b/source/3d/layout.h @@ -61,12 +61,8 @@ public: const Msp::GL::Lighting &get_lighting() const { return lighting; } private: - void track_added(Track &); - void track_removed(Track &); - void vehicle_added(Vehicle &); - void vehicle_removed(Vehicle &); - void signal_added(Signal &); - void signal_removed(Signal &); + void object_added(Object &); + void object_removed(Object &); }; } // namespace R2C2 diff --git a/source/3d/view.cpp b/source/3d/view.cpp index 6b5115d..e058be7 100644 --- a/source/3d/view.cpp +++ b/source/3d/view.cpp @@ -28,7 +28,7 @@ View3D::View3D(Layout3D &l, unsigned w, unsigned h): void View3D::view_all(bool tight) { - const set &tracks = layout.get_layout().get_tracks(); + const set &tracks = layout.get_layout().get_all(); Geometry::BoundingBox bbox; for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) bbox = bbox|(*i)->get_bounding_box(); diff --git a/source/designer/designer.cpp b/source/designer/designer.cpp index 6d4d49d..d640073 100644 --- a/source/designer/designer.cpp +++ b/source/designer/designer.cpp @@ -68,8 +68,8 @@ Designer::Designer(int argc, char **argv): layout = new Layout(catalogue); layout_3d = new Layout3D(*layout); - layout->signal_track_added.connect(sigc::mem_fun(this, &Designer::track_added)); - layout->signal_track_removed.connect(sigc::mem_fun(this, &Designer::track_removed)); + layout->signal_object_added.connect(sigc::mem_fun(this, &Designer::object_added)); + layout->signal_object_removed.connect(sigc::mem_fun(this, &Designer::object_removed)); if(argc>1) { @@ -412,7 +412,7 @@ void Designer::key_press(unsigned key) else if(key==Msp::Input::KEY_F && shift) { const set &tracks = selection.get_objects(); - const set <racks = layout->get_tracks(); + const set <racks = layout->get_all(); for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) { (*i)->set_flex(!(*i)->get_flex()); @@ -513,16 +513,20 @@ void Designer::render() glColor3f(1.0, 1.0, 1.0); } -void Designer::track_added(Track &trk) +void Designer::object_added(Object &obj) { - new_tracks.push_back(&trk); + if(Track *trk = dynamic_cast(&obj)) + new_tracks.push_back(trk); } -void Designer::track_removed(Track &trk) +void Designer::object_removed(Object &obj) { - list::iterator i = find(new_tracks.begin(), new_tracks.end(), &trk); - if(i!=new_tracks.end()) - new_tracks.erase(i); + if(Track *trk = dynamic_cast(&obj)) + { + list::iterator i = find(new_tracks.begin(), new_tracks.end(), trk); + if(i!=new_tracks.end()) + new_tracks.erase(i); + } } Object *Designer::pick_object(const Vector &pointer) @@ -531,7 +535,7 @@ Object *Designer::pick_object(const Vector &pointer) const GL::Vector3 &cpos = view.get_camera().get_position(); GL::Vector4 cray = view.get_camera().unproject(GL::Vector4(pointer.x, pointer.y, 0, 0)); - return view.get_layout().get_layout().pick_object(Ray(cpos, Vector(cray))); + return view.get_layout().get_layout().pick(Ray(cpos, Vector(cray))); } void Designer::update_track_icon(Track3D &track) @@ -651,7 +655,7 @@ string Designer::tooltip(int x, int y) void Designer::clear_paths() { - const set <racks = layout->get_tracks(); + const set <racks = layout->get_all(); for(set::iterator i=ltracks.begin(); i!=ltracks.end(); ++i) { Track3D &t3d = layout_3d->get_track(**i); diff --git a/source/designer/designer.h b/source/designer/designer.h index 8348f60..fd70358 100644 --- a/source/designer/designer.h +++ b/source/designer/designer.h @@ -113,8 +113,8 @@ private: void axis_motion(unsigned, float, float); void apply_camera(); void render(); - void track_added(R2C2::Track &); - void track_removed(R2C2::Track &); + void object_added(R2C2::Object &); + void object_removed(R2C2::Object &); R2C2::Object *pick_object(const R2C2::Vector &); void update_track_icon(R2C2::Track3D &); void selection_changed(); diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index 2ee9676..ba27cae 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -322,7 +322,7 @@ void Manipulator::button_press(unsigned btn) j->object->break_link(**i); } - const set <racks = designer.get_layout().get_tracks(); + const set <racks = designer.get_layout().get_all(); for(set::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i) { bool ok = true; @@ -366,7 +366,7 @@ void Manipulator::axis_motion(unsigned axis, float value, float) i->object->set_rotation(i->rot); } - const set <racks = designer.get_layout().get_tracks(); + const set <racks = designer.get_layout().get_all(); float limit = max(designer.get_layout().get_catalogue().get_gauge(), designer.get_camera_controller().get_view_scale()/100.0f); MObject *snapped = 0; diff --git a/source/designer/measure.cpp b/source/designer/measure.cpp index c7fead1..f0d64e2 100644 --- a/source/designer/measure.cpp +++ b/source/designer/measure.cpp @@ -120,7 +120,7 @@ void Measure::update_mesh() void Measure::snap_to_tracks(Snap &sn) { - const set <racks = designer.get_layout().get_tracks(); + const set <racks = designer.get_layout().get_all(); for(set::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i) if((*i)->snap(sn, 0.01, SNAP_NODE)) return; diff --git a/source/designer/svgexporter.cpp b/source/designer/svgexporter.cpp index ca95f90..9f42ab4 100644 --- a/source/designer/svgexporter.cpp +++ b/source/designer/svgexporter.cpp @@ -36,7 +36,7 @@ void SvgExporter::save(const string &fn) Vector minp; Vector maxp; - const set &tracks = layout.get_tracks(); + const set &tracks = layout.get_all(); for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) { xmlpp::Element *elem = root->add_child("g"); diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index b7b114b..b3c1f5f 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -388,7 +388,7 @@ Track *Engineer::pick_track(const Vector &p) const GL::Vector3 &start = camera.get_position(); GL::Vector4 ray = camera.unproject(GL::Vector4(p.x, p.y, 0, 0)); - return layout.pick_track(Ray(start, Vector(ray))); + return layout.pick(Ray(start, Vector(ray))); } void Engineer::process_new_train(Train &train) diff --git a/source/libr2c2/blockallocator.cpp b/source/libr2c2/blockallocator.cpp index acb59ae..f73697a 100644 --- a/source/libr2c2/blockallocator.cpp +++ b/source/libr2c2/blockallocator.cpp @@ -26,7 +26,7 @@ BlockAllocator::BlockAllocator(Train &t): layout.signal_block_reserved.connect(sigc::mem_fun(this, &BlockAllocator::block_reserved)); layout.signal_sensor_state_changed.connect(sigc::mem_fun(this, &BlockAllocator::sensor_state_changed)); - const set &tracks = layout.get_tracks(); + const set &tracks = layout.get_all(); for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) if((*i)->get_turnout_id()) (*i)->signal_path_changed.connect(sigc::hide(sigc::bind(sigc::mem_fun(this, &BlockAllocator::turnout_path_changed), sigc::ref(**i)))); diff --git a/source/libr2c2/layout.cpp b/source/libr2c2/layout.cpp index 1654295..6db66a6 100644 --- a/source/libr2c2/layout.cpp +++ b/source/libr2c2/layout.cpp @@ -16,6 +16,7 @@ #include "trackcircuit.h" #include "tracktype.h" #include "train.h" +#include "vehicle.h" #include "vehicletype.h" #include "zone.h" @@ -51,10 +52,8 @@ Layout::~Layout() delete *routes.begin(); while(!zones.empty()) delete *zones.begin(); - while(!signals.empty()) - delete *signals.begin(); - while(!tracks.empty()) - delete *tracks.begin(); + objects.del(); + objects.del(); while(!blocks.empty()) delete *blocks.begin(); } @@ -66,78 +65,93 @@ Driver &Layout::get_driver() const return *driver; } -void Layout::add_track(Track &t) +void Layout::add(Object &o) { - if(tracks.insert(&t).second) + if(objects.insert(o)) + signal_object_added.emit(o); +} + +void Layout::add(Track &t) +{ + if(objects.insert(t)) { + // Blocks must be recreated first create_blocks(); - signal_track_added.emit(t); + signal_object_added.emit(t); } } -Track *Layout::pick_track(const Ray &ray) +template<> +const set &Layout::get_all() const { - return pick(tracks, ray); + return objects.get(); } -void Layout::remove_track(Track &t) +template<> +const set &Layout::get_all() const { - if(tracks.erase(&t)) - { - create_blocks(t); - signal_track_removed.emit(t); - } + return objects.get(); } -unsigned Layout::allocate_turnout_id() +template<> +const set &Layout::get_all() const { - set used_ids; - for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) - if((*i)->get_turnout_id()) - used_ids.insert((*i)->get_turnout_id()); - - unsigned result = next_turnout_id; - while(used_ids.count(result)) - ++result; - next_turnout_id = result+1; - - return result; + return objects.get(); } -void Layout::add_signal(Signal &s) +template<> +const set &Layout::get_all() const { - if(signals.insert(&s).second) - signal_signal_added.emit(s); + return objects.get(); } -Signal *Layout::pick_signal(const Ray &ray) +template +T *Layout::pick(const Ray &ray) { - return pick(signals, ray); + const set &objs = objects.get(); + for(set::const_iterator i=objs.begin(); i!=objs.end(); ++i) + if(T *t = dynamic_cast(*i)) + if(t->collide_ray(ray)) + return t; + + return 0; } -void Layout::remove_signal(Signal &s) +template Object *Layout::pick(const Ray &); +template Track *Layout::pick(const Ray &); +template Signal *Layout::pick(const Ray &); +template Vehicle *Layout::pick(const Ray &); + +void Layout::remove(Object &o) { - if(signals.erase(&s)) - signal_signal_removed.emit(s); + if(objects.erase(o)) + signal_object_removed.emit(o); } -Object *Layout::pick_object(const Ray &ray) +void Layout::remove(Track &t) { - if(Object *obj = pick_track(ray)) - return obj; - else if((obj = pick_signal(ray))) - return obj; - return 0; + if(objects.erase(t)) + { + // Blocks must be recreated first + create_blocks(t); + signal_object_removed.emit(t); + } } -template -T *Layout::pick(const set &objs, const Ray &ray) +unsigned Layout::allocate_turnout_id() { - for(typename set::const_iterator i=objs.begin(); i!=objs.end(); ++i) - if((*i)->collide_ray(ray)) - return *i; + set used_ids; + const set &tracks = objects.get(); + for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) + if((*i)->get_turnout_id()) + used_ids.insert((*i)->get_turnout_id()); - return 0; + unsigned result = next_turnout_id; + while(used_ids.count(result)) + ++result; + next_turnout_id = result+1; + + return result; } void Layout::add_block(Block &b) @@ -164,6 +178,7 @@ void Layout::create_blocks() used_tracks.insert(btracks.begin(), btracks.end()); } + const set &tracks = objects.get(); for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) if(used_tracks.count(*i)==0) { @@ -277,18 +292,6 @@ void Layout::remove_train(Train &t) signal_train_removed.emit(t); } -void Layout::add_vehicle(Vehicle &v) -{ - if(vehicles.insert(&v).second) - signal_vehicle_added.emit(v); -} - -void Layout::remove_vehicle(Vehicle &v) -{ - if(vehicles.erase(&v)) - signal_vehicle_removed.emit(v); -} - void Layout::add_sensor(Sensor &s) { if(sensors.insert(&s).second) @@ -316,6 +319,7 @@ void Layout::tick() for(set::iterator i=sensors.begin(); i!=sensors.end(); ++i) (*i)->tick(dt); + const set &signals = objects.get(); for(set::iterator i=signals.begin(); i!=signals.end(); ++i) (*i)->tick(dt); for(map::iterator i=trains.begin(); i!=trains.end(); ++i) @@ -338,6 +342,7 @@ void Layout::save(const string &fn) const if(!base.empty()) writer.write((DataFile::Statement("base"), base)); + const set &tracks = objects.get(); for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) { DataFile::Statement st("track"); @@ -346,6 +351,7 @@ void Layout::save(const string &fn) const writer.write(st); } + const set &signals = objects.get(); for(set::const_iterator i=signals.begin(); i!=signals.end(); ++i) { DataFile::Statement st("signal"); @@ -377,6 +383,7 @@ void Layout::save_dynamic(const string &fn) const IO::BufferedFile out(fn, IO::M_WRITE); DataFile::Writer writer(out); + const set &tracks = objects.get(); for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) if(unsigned tid = (*i)->get_turnout_id()) writer.write((DataFile::Statement("turnout"), tid, (*i)->get_active_path())); @@ -406,6 +413,59 @@ void Layout::sensor_state_changed(Sensor &sensor, Sensor::State state) } +template +Layout::Storage::~Storage() +{ + while(!base.empty()) + delete *base.begin(); +} + +template +bool Layout::Storage::insert(B &b) +{ + bool result = base.insert(&b).second; + if(result) + caches.clear(); + return result; +} + +template +bool Layout::Storage::erase(B &b) +{ + bool result = base.erase(&b); + if(result) + caches.clear(); + return result; +} + +template +template +const set &Layout::Storage::get() const +{ + for(list::const_iterator i=caches.begin(); i!=caches.end(); ++i) + if(i->check_type >()) + return i->value >(); + + caches.push_back(set()); + set &result = caches.back().value >(); + for(typename set::const_iterator i=base.begin(); i!=base.end(); ++i) + if(T *t = dynamic_cast(*i)) + result.insert(t); + + return result; +} + +template +template +void Layout::Storage::del() +{ + set ts = get(); + for(typename set::iterator i=ts.begin(); i!=ts.end(); ++i) + if(base.count(*i)) + delete *i; +} + + Layout::Loader::Loader(Layout &l): DataFile::ObjectLoader(l), new_tracks(false) @@ -453,7 +513,8 @@ void Layout::Loader::track(ArticleNumber art_nr) Track *trk = new Track(obj, obj.catalogue.get_track(art_nr)); load_sub(*trk); new_tracks = true; - for(set::iterator i=obj.tracks.begin(); i!=obj.tracks.end(); ++i) + const set &tracks = obj.objects.get(); + for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) if(*i!=trk) trk->link_to(**i); } diff --git a/source/libr2c2/layout.h b/source/libr2c2/layout.h index de5588c..f9a2ba1 100644 --- a/source/libr2c2/layout.h +++ b/source/libr2c2/layout.h @@ -44,21 +44,41 @@ public: void zone(); }; +private: + template + class Storage + { + private: + std::set base; + mutable std::list caches; + + public: + ~Storage(); + + bool insert(B &); + bool erase(B &); + + const std::set &get() const { return base; } + + template + const std::set &get() const; + + template + void del(); + }; + +public: typedef std::set ZoneSet; typedef std::vector ZoneArray; - sigc::signal signal_track_added; - sigc::signal signal_track_removed; - sigc::signal signal_signal_added; - sigc::signal signal_signal_removed; + sigc::signal signal_object_added; + sigc::signal signal_object_removed; sigc::signal signal_route_added; sigc::signal signal_route_removed; sigc::signal signal_zone_added; sigc::signal signal_zone_removed; sigc::signal signal_train_added; sigc::signal signal_train_removed; - sigc::signal signal_vehicle_added; - sigc::signal signal_vehicle_removed; sigc::signal signal_block_reserved; sigc::signal signal_sensor_state_changed; sigc::signal signal_emergency; @@ -67,14 +87,12 @@ private: Catalogue &catalogue; Driver *driver; std::string base; - std::set tracks; - std::set signals; + Storage objects; std::set routes; ZoneSet zones; std::set blocks; std::set sensors; std::map trains; - std::set vehicles; Msp::Time::TimeStamp last_tick; unsigned next_turnout_id; @@ -87,24 +105,20 @@ public: Driver &get_driver() const; const std::string &get_base() const { return base; } - void add_track(Track &); - const std::set &get_tracks() const { return tracks; } - Track *pick_track(const Ray &); - void remove_track(Track &); - unsigned allocate_turnout_id(); - - void add_signal(Signal &); - const std::set &get_signals() const { return signals; } - Signal *pick_signal(const Ray &); - void remove_signal(Signal &); + void add(Object &); + void add(Track &); - Object *pick_object(const Ray &); + template + const std::set &get_all() const; -private: template - static T *pick(const std::set &, const Ray &); + T *pick(const Ray &); + + void remove(Object &); + void remove(Track &); + + unsigned allocate_turnout_id(); -public: void add_block(Block &); Block &get_block(unsigned) const; const std::set &get_blocks() const { return blocks; } @@ -129,9 +143,6 @@ public: const std::map &get_trains() const { return trains; } void remove_train(Train &); - void add_vehicle(Vehicle &); - void remove_vehicle(Vehicle &); - void add_sensor(Sensor &); void remove_sensor(Sensor &); diff --git a/source/libr2c2/route.cpp b/source/libr2c2/route.cpp index 80c6108..685ad66 100644 --- a/source/libr2c2/route.cpp +++ b/source/libr2c2/route.cpp @@ -147,7 +147,7 @@ Route::Route(Layout &l): temporary(false) { layout.add_route(*this); - layout.signal_track_removed.connect(sigc::mem_fun(this, &Route::track_removed)); + layout.signal_object_removed.connect(sigc::mem_fun(this, &Route::object_removed)); } Route::~Route() @@ -402,9 +402,10 @@ RouteValidityMask Route::check_validity(Track &trk) const return static_cast(result); } -void Route::track_removed(Track &t) +void Route::object_removed(Object &o) { - tracks.erase(&t); + if(Track *t = dynamic_cast(&o)) + tracks.erase(t); } Route *Route::find(const TrackIter &from, Track &to) @@ -437,7 +438,7 @@ Route::Loader::Loader(Route &r): void Route::Loader::finish() { - const set <racks = obj.layout.get_tracks(); + const set <racks = obj.layout.get_all(); for(set::const_iterator i=ltracks.begin(); i!=ltracks.end(); ++i) { unsigned tid = (*i)->get_turnout_id(); diff --git a/source/libr2c2/route.h b/source/libr2c2/route.h index e5164ce..0dd16f4 100644 --- a/source/libr2c2/route.h +++ b/source/libr2c2/route.h @@ -10,6 +10,7 @@ namespace R2C2 { class Layout; +class Object; class Track; class TrackIter; class Zone; @@ -81,7 +82,7 @@ public: void save(std::list &) const; private: RouteValidityMask check_validity(Track &) const; - void track_removed(Track &); + void object_removed(Object &); public: static Route *find(const TrackIter &, Track &); diff --git a/source/libr2c2/signal.cpp b/source/libr2c2/signal.cpp index a858e0d..38e1124 100644 --- a/source/libr2c2/signal.cpp +++ b/source/libr2c2/signal.cpp @@ -24,14 +24,14 @@ Signal::Signal(Layout &l, const SignalType &t): check_allocated_blocks(false), passing(false) { - layout.add_signal(*this); + layout.add(*this); layout.signal_block_reserved.connect(sigc::mem_fun(this, &Signal::block_reserved)); } Signal::~Signal() { - layout.remove_signal(*this); + layout.remove(*this); } Signal *Signal::clone(Layout *to_layout) const @@ -59,7 +59,7 @@ void Signal::set_position(const Vector &p) void Signal::update_location() { - const set &tracks = layout.get_tracks(); + const set &tracks = layout.get_all(); float limit = layout.get_catalogue().get_gauge()*2; float dist = -1; for(set::const_iterator i=tracks.begin(); i!=tracks.end(); ++i) diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index c2b190f..51c73c2 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -26,7 +26,7 @@ Track::Track(Layout &l, const TrackType &t): if(type.is_turnout()) turnout_id = layout.allocate_turnout_id(); - layout.add_track(*this); + layout.add(*this); if(layout.has_driver()) layout.get_driver().signal_turnout.connect(sigc::mem_fun(this, &Track::turnout_event)); @@ -37,7 +37,7 @@ Track::Track(Layout &l, const TrackType &t): Track::~Track() { break_links(); - layout.remove_track(*this); + layout.remove(*this); } Track *Track::clone(Layout *to_layout) const diff --git a/source/libr2c2/vehicle.cpp b/source/libr2c2/vehicle.cpp index 1c4a5b0..457cb33 100644 --- a/source/libr2c2/vehicle.cpp +++ b/source/libr2c2/vehicle.cpp @@ -25,7 +25,7 @@ Vehicle::Vehicle(Layout &l, const VehicleType &t): bogies.assign(type.get_bogies().begin(), type.get_bogies().end()); rods.assign(type.get_rods().begin(), type.get_rods().end()); - layout.add_vehicle(*this); + layout.add(*this); } Vehicle::~Vehicle() @@ -34,7 +34,7 @@ Vehicle::~Vehicle() detach_back(); if(prev) detach_front(); - layout.remove_vehicle(*this); + layout.remove(*this); } Vehicle *Vehicle::clone(Layout *to_layout) const diff --git a/source/libr2c2/vehicle.h b/source/libr2c2/vehicle.h index d259201..e7427b1 100644 --- a/source/libr2c2/vehicle.h +++ b/source/libr2c2/vehicle.h @@ -124,8 +124,6 @@ public: virtual unsigned get_n_link_slots() const; virtual Vehicle *get_link(unsigned) const; virtual int get_link_slot(const Object &) const; - - virtual bool collide_ray(const Vector &, const Vector &) const { return false; } }; } // namespace R2C2