scale 1 87;
-gauge 16.5;
vehicle \39230
{
const Vector &rail_min = rail_profile.get_min_coords();
const Vector &rail_max = rail_profile.get_max_coords();
- float gauge = catalogue.get_gauge();
+ float gauge = appearance.get_gauge();
float width = max(max(-ballast_min.x, ballast_max.x)*2, gauge+(rail_max.x-rail_min.x)*2)+0.004;
float height = ballast_max.y-ballast_min.y+rail_max.y-rail_min.y+0.01;
void Path3D::set_layer(float l)
{
- z_offs = l*layout.get_layout().get_catalogue().get_gauge()*0.01;
+ z_offs = l*track.get_track().get_type().get_appearance().get_gauge()*0.01;
}
void Path3D::path_changed(unsigned p)
own_data(false)
{
const TrackAppearance &appearance = tt.get_appearance();
- const Catalogue &cat = catalogue.get_catalogue();
const vector<TrackPart> &parts = tt.get_parts();
const Profile &ballast_profile = appearance.get_ballast_profile();
const Vector &tie_max = tie_profile.get_max_coords();
float tie_h = tie_max.y-tie_min.y;
- float gauge = cat.get_gauge();
+ float gauge = appearance.get_gauge();
string obj_name = tt.get_object();
if(!obj_name.empty())
const GL::Vector3 &pos = camera.get_position();
const GL::Vector3 &look = camera.get_look_direction();
float dist = get_distance();
- float low = view.get_layout().get_layout().get_catalogue().get_gauge()*5;
+ // XXX This should probably depend on the layout contents in some way
+ float low = 0.1;
if(dist+delta<low)
delta = low-dist;
camera.set_position(pos-look*delta);
void ExtendTool::connect()
{
- float limit = designer.get_layout().get_catalogue().get_gauge()/10;
+ float limit;
Track *start_track = 0;
Track *end_track = 0;
for(vector<TrackIter>::const_iterator i=unlinked_endpoints.begin(); i!=unlinked_endpoints.end(); ++i)
{
start_sn = (*i)->get_snap_node(i->entry());
+ limit = (*i)->get_type().get_appearance().get_gauge()/10;
for(vector<TrackIter>::const_iterator j=i; ++j!=unlinked_endpoints.end(); )
{
i->object->set_rotation(i->original_rotation);
}
- float limit = max(designer.get_layout().get_catalogue().get_gauge(),
- designer.get_camera_controller().get_view_scale()/100.0f);
+ float limit = designer.get_camera_controller().get_view_scale()/100.0f;
MObject *snapped = 0;
for(list<Boundary>::iterator i=boundaries.begin(); (!snapped && i!=boundaries.end()); ++i)
{
for(set<Object *>::const_iterator j=snap_targets.begin(); (!snapped && j!=snap_targets.end()); ++j)
- if((*i)->snap_to(**j, limit))
+ if((*i)->snap_to(**j, (i->limit>0 ? max(i->limit, limit) : limit)))
snapped = i->object;
}
MoveTool::Boundary::Boundary(MObject *o, unsigned i):
object(o),
- index(i)
-{ }
+ index(i),
+ limit(-1)
+{
+ if(Track *track = dynamic_cast<Track *>(object->object))
+ limit = track->get_type().get_appearance().get_gauge();
+}
{
MObject *object;
unsigned index;
+ float limit;
Boundary(MObject *, unsigned);
using namespace R2C2;
SvgExporter::SvgExporter(const Layout &l):
- layout(l),
- gauge(0)
+ layout(l)
{ }
void SvgExporter::save(const string &fn)
{
- gauge = layout.get_catalogue().get_gauge();
-
xmlpp::Document *doc = new xmlpp::Document;
root = doc->create_root_node("svg", "http://www.w3.org/2000/svg");
style->set_attribute("type", "text/css");
styles.push_back(".rail { fill: none; stroke: #000000; }");
styles.push_back(".border { fill: none; stroke: #808080; }");
- styles.push_back(format(".artnr { text-anchor: middle; font-family: sans; font-size: %.3f; }", gauge*750));
+ styles.push_back(".artnr { text-anchor: middle; font-family: sans; }");
defs = root->add_child("defs");
{
save_track(**i);
+ float gauge = (*i)->get_type().get_appearance().get_gauge();
unsigned n_endpoints = (*i)->get_type().get_endpoints().size();
for(unsigned j=0; j<n_endpoints; ++j)
{
minp = maxp = pos;
else
{
- minp.x = min(minp.x, pos.x);
- minp.y = min(minp.y, pos.y);
- maxp.x = max(maxp.x, pos.x);
- maxp.y = max(maxp.y, pos.y);
+ minp.x = min(minp.x, pos.x-gauge*3);
+ minp.y = min(minp.y, pos.y-gauge*3);
+ maxp.x = max(maxp.x, pos.x+gauge*3);
+ maxp.y = max(maxp.y, pos.y+gauge*3);
}
}
}
style->set_child_text(join(styles.begin(), styles.end(), "\n"));
root->set_attribute("viewBox", format("%.3f %.3f %.3f %.3f",
- minp.x*1000-gauge*3, -maxp.y*1000-gauge*3, (maxp.x-minp.x)*1000+gauge*6, (maxp.y-minp.y)*1000+gauge*6));
+ minp.x*1000, -maxp.y*1000, (maxp.x-minp.x)*1000, (maxp.y-minp.y)*1000));
doc->write_to_file_formatted(fn);
}
string SvgExporter::create_appearance(const TrackAppearance &appearance)
{
- string key = format("a%p", &appearance);
+ float gauge = appearance.get_gauge();
+ string key = format("a%.0f", gauge*1000);
if(!appearances_created.count(&appearance))
{
styles.push_back(format(".%s .rail { stroke-width: %.3f }", key, rail_width*1000));
styles.push_back(format(".%s .border { stroke-width: %.3f }", key, rail_width*500));
+ styles.push_back(format(".%s .artnr { font-size: %.3f }", key, gauge*750));
appearances_created.insert(&appearance);
}
group->set_attribute("id", key);
group->set_attribute("class", appearance_key);
+ float gauge = appearance.get_gauge();
float rail_width = appearance.get_rail_profile().get_width();
const vector<TrackType::Endpoint> &endpoints = type.get_endpoints();
{
private:
const R2C2::Layout &layout;
- float gauge;
xmlpp::Element *root;
xmlpp::Element *defs;
std::set<const R2C2::TrackType *> tracks_created;
void BeamGate::update_attachment()
{
- attach_to_closest(100*TrackAttachment::layout.get_catalogue().get_gauge());
+ attach_to_closest(100);
if(track)
{
Catalogue::Catalogue():
scale(1),
- gauge(1.524),
layout(*this)
{ }
Catalogue::Loader::Loader(Catalogue &c):
DataFile::ObjectLoader<Catalogue>(c)
{
- add("gauge", &Loader::gauge);
add("layout", &Loader::layout);
add("scale", &Loader::scale);
add("signal", &Loader::signal);
add("vehicle", &Loader::vehicle);
}
-void Catalogue::Loader::gauge(float g)
-{
- obj.gauge = g/1000;
-}
-
void Catalogue::Loader::layout()
{
load_sub(obj.layout);
public:
Loader(Catalogue &);
private:
- void gauge(float);
void layout();
void scale(float, float);
void signal(ArticleNumber);
private:
float scale;
- float gauge;
TrackAppearance appearance;
ObjectMap objects;
Layout layout;
~Catalogue();
float get_scale() const { return scale; }
- float get_gauge() const { return gauge; }
void add(ObjectType &);
const ObjectType &get(const ArticleNumber &) const;
void Signal::update_attachment()
{
- attach_to_closest(layout.get_catalogue().get_gauge()*2);
+ attach_to_closest(2);
if(track)
block = track.block_iter();
if(!otrack)
return false;
- float limit = layout.get_catalogue().get_gauge();
+ float limit = type.get_appearance().get_gauge();
if(!flex && !otrack->get_flex())
limit /= 10;
limit *= limit;
namespace R2C2 {
TrackAppearance::TrackAppearance():
+ gauge(1.524),
tie_length(0),
tie_spacing(1)
{ }
ObjectLoader<TrackAppearance>(a)
{
add("ballast_profile", &Loader::ballast_profile);
+ add("gauge", &Loader::gauge);
add("rail_profile", &Loader::rail_profile);
add("technique", &TrackAppearance::technique);
add("tie_length", &Loader::tie_length);
load_sub(obj.ballast_profile);
}
+void TrackAppearance::Loader::gauge(float g)
+{
+ obj.gauge = g/1000;
+}
+
void TrackAppearance::Loader::rail_profile()
{
load_sub(obj.rail_profile);
private:
void ballast_profile();
+ void gauge(float);
void rail_profile();
void tie_length(float);
void tie_profile();
};
private:
+ float gauge;
Profile rail_profile;
Profile ballast_profile;
Profile tie_profile;
public:
TrackAppearance();
+ float get_gauge() const { return gauge; }
float get_rail_elevation() const;
const Profile &get_rail_profile() const { return rail_profile; }
const Profile &get_ballast_profile() const { return ballast_profile; }
Snap sn;
sn.position = position;
sn.rotation = rotation;
- if((*i)->snap(sn, limit, SNAP_SEGMENT))
+ float gauge = (*i)->get_type().get_appearance().get_gauge();
+ if((*i)->snap(sn, gauge*limit, SNAP_SEGMENT))
{
float d = distance(position, sn.position);
if(d<dist || dist<0)
scale 1 87;
-gauge 16.5;
track_appearance
{
+ gauge 16.5;
rail_profile
{
point 1.5 0.0;
scale 1 87;
-gauge 16.5;
vehicle \46274
{