3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #include "vehicletype.h"
15 VehicleType::VehicleType(unsigned n):
23 unsigned VehicleType::get_max_function() const
27 return (--functions.end())->first;
30 float VehicleType::get_front_axle_offset() const
32 float front = length/2;
34 front = axles.front().position;
37 const Bogie &bogie = bogies.front();
38 front = max(front, bogie.position+bogie.axles.front().position);
43 float VehicleType::get_back_axle_offset() const
45 float back = -length/2;
47 back = axles.back().position;
50 const Bogie &bogie = bogies.back();
51 back = min(back, bogie.position+bogie.axles.back().position);
57 VehicleType::Axle::Axle():
64 VehicleType::Bogie::Bogie():
70 VehicleType::Loader::Loader(VehicleType &vt):
71 DataFile::ObjectLoader<VehicleType>(vt)
73 add("axle", &Loader::axle);
74 add("bogie", &Loader::bogie);
75 add("function", &Loader::function);
76 add("height", &Loader::height);
77 add("length", &Loader::length);
78 add("locomotive", &VehicleType::locomotive);
79 add("object", &VehicleType::object);
80 add("name", &VehicleType::name);
81 add("width", &Loader::width);
84 void VehicleType::Loader::axle()
88 obj.axles.push_back(axl);
91 void VehicleType::Loader::bogie()
95 obj.bogies.push_back(bog);
98 void VehicleType::Loader::function(unsigned i, const string &f)
100 obj.functions[i] = f;
103 void VehicleType::Loader::height(float h)
108 void VehicleType::Loader::length(float l)
113 void VehicleType::Loader::width(float w)
119 VehicleType::Axle::Loader::Loader(Axle &a):
120 DataFile::ObjectLoader<Axle>(a)
122 add("position", &Loader::position);
123 add("powered", &Axle::powered);
124 add("wheel_diameter", &Loader::wheel_diameter);
127 void VehicleType::Axle::Loader::position(float p)
129 obj.position = p/1000;
132 void VehicleType::Axle::Loader::wheel_diameter(float d)
134 obj.wheel_dia = d/1000;
138 VehicleType::Bogie::Loader::Loader(Bogie &b):
139 DataFile::ObjectLoader<Bogie>(b)
141 add("axle", &Loader::axle);
142 add("object", &Bogie::object);
143 add("position", &Loader::position);
144 add("rotate_object", &Bogie::rotate_object);
147 void VehicleType::Bogie::Loader::axle()
151 obj.axles.push_back(axl);
154 void VehicleType::Bogie::Loader::position(float p)
156 obj.position = p/1000;
159 } // namespace Marklin