X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibmarklin%2Fcatalogue.cpp;h=fca6045fc38da36c5613758fd205f95c1a5f791a;hb=cc0ee0a5e71590960bc8cb7baee7a10ef09ce3f0;hp=bb724bc823868bc8beb12b8ec968258ae80ad324;hpb=48dff17ed3144d944965e7cb534e1f8fb92bd620;p=r2c2.git diff --git a/source/libmarklin/catalogue.cpp b/source/libmarklin/catalogue.cpp index bb724bc..fca6045 100644 --- a/source/libmarklin/catalogue.cpp +++ b/source/libmarklin/catalogue.cpp @@ -8,8 +8,8 @@ Distributed under the GPL #include #include #include "catalogue.h" -#include "locotype.h" #include "tracktype.h" +#include "vehicletype.h" using namespace std; using namespace Msp; @@ -26,7 +26,7 @@ Catalogue::~Catalogue() { for(map::iterator i=tracks.begin(); i!=tracks.end(); ++i) delete i->second; - for(map::iterator i=locos.begin(); i!=locos.end(); ++i) + for(map::iterator i=vehicles.begin(); i!=vehicles.end(); ++i) delete i->second; } @@ -39,15 +39,6 @@ void Catalogue::add_track(TrackType &track) signal_track_added.emit(track); } -void Catalogue::add_locomotive(LocoType &loco) -{ - if(locos.count(loco.get_article_number())) - throw Exception("Duplicate track type"); - - locos[loco.get_article_number()] = &loco; - signal_loco_added.emit(loco); -} - const TrackType &Catalogue::get_track(unsigned art_nr) const { map::const_iterator i=tracks.find(art_nr); @@ -57,11 +48,20 @@ const TrackType &Catalogue::get_track(unsigned art_nr) const return *i->second; } -const LocoType &Catalogue::get_locomotive(unsigned art_nr) const +void Catalogue::add_vehicle(VehicleType &veh) { - map::const_iterator i=locos.find(art_nr); - if(i==locos.end()) - throw KeyError("Unknown locomotive type"); + if(vehicles.count(veh.get_article_number())) + throw Exception("Duplicate vehicle type"); + + vehicles[veh.get_article_number()] = &veh; + signal_vehicle_added.emit(veh); +} + +const VehicleType &Catalogue::get_vehicle(unsigned art_nr) const +{ + map::const_iterator i = vehicles.find(art_nr); + if(i==vehicles.end()) + throw KeyError("Unknown vehicle type"); return *i->second; } @@ -73,10 +73,10 @@ Catalogue::Loader::Loader(Catalogue &c): add("ballast_profile", &Loader::ballast_profile); add("gauge", &Loader::gauge); add("layout", &Loader::layout); - add("locomotive", &Loader::locomotive); add("rail_profile", &Loader::rail_profile); add("scale", &Loader::scale); add("track", &Loader::track); + add("vehicle", &Loader::vehicle); } void Catalogue::Loader::ballast_profile() @@ -87,6 +87,9 @@ void Catalogue::Loader::ballast_profile() void Catalogue::Loader::gauge(float g) { obj.gauge = g/1000; + obj.path_profile = Profile(); + obj.path_profile.append_point(Point(0.1*obj.gauge, 0)); + obj.path_profile.append_point(Point(-0.1*obj.gauge, 0)); } void Catalogue::Loader::layout() @@ -94,14 +97,6 @@ void Catalogue::Loader::layout() load_sub(obj.layout); } -void Catalogue::Loader::locomotive(unsigned art_nr) -{ - RefPtr loco = new LocoType(art_nr); - load_sub(*loco); - obj.add_locomotive(*loco); - loco.release(); -} - void Catalogue::Loader::rail_profile() { load_sub(obj.rail_profile); @@ -120,4 +115,12 @@ void Catalogue::Loader::track(unsigned art_nr) trk.release(); } +void Catalogue::Loader::vehicle(unsigned art_nr) +{ + RefPtr veh = new VehicleType(art_nr); + load_sub(*veh); + obj.add_vehicle(*veh); + veh.release(); +} + } // namespace Marklin