From: Mikko Rasa Date: Sat, 3 May 2014 11:03:33 +0000 (+0300) Subject: Add a shortcut for getting the gauge of a TrackType X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=2875ea548e0567ad2ce1b8f9bda58e6452813204;p=r2c2.git Add a shortcut for getting the gauge of a TrackType --- diff --git a/source/3d/path.cpp b/source/3d/path.cpp index 8c36a30..1b4dba5 100644 --- a/source/3d/path.cpp +++ b/source/3d/path.cpp @@ -59,7 +59,7 @@ void Path3D::set_color(const GL::Color &c) void Path3D::set_layer(float l) { - z_offs = l*track.get_track().get_type().get_appearance().get_gauge()*0.01; + z_offs = l*track.get_track().get_type().get_gauge()*0.01; } void Path3D::path_changed(unsigned p) diff --git a/source/designer/extendtool.cpp b/source/designer/extendtool.cpp index 9b6ec9a..aac7672 100644 --- a/source/designer/extendtool.cpp +++ b/source/designer/extendtool.cpp @@ -62,7 +62,7 @@ void ExtendTool::connect() for(vector::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; + limit = (*i)->get_type().get_gauge()/10; for(vector::const_iterator j=i; ++j!=unlinked_endpoints.end(); ) { diff --git a/source/designer/movetool.cpp b/source/designer/movetool.cpp index 57f6216..e033827 100644 --- a/source/designer/movetool.cpp +++ b/source/designer/movetool.cpp @@ -68,5 +68,5 @@ MoveTool::Boundary::Boundary(MObject *o, unsigned i): limit(-1) { if(Track *track = dynamic_cast(object->object)) - limit = track->get_type().get_appearance().get_gauge(); + limit = track->get_type().get_gauge(); } diff --git a/source/designer/svgexporter.cpp b/source/designer/svgexporter.cpp index f7248ef..d099b73 100644 --- a/source/designer/svgexporter.cpp +++ b/source/designer/svgexporter.cpp @@ -34,7 +34,7 @@ void SvgExporter::save(const string &fn) { save_track(**i); - float gauge = (*i)->get_type().get_appearance().get_gauge(); + float gauge = (*i)->get_type().get_gauge(); unsigned n_endpoints = (*i)->get_type().get_endpoints().size(); for(unsigned j=0; jget_flex()) limit /= 10; limit *= limit; diff --git a/source/libr2c2/trackattachment.cpp b/source/libr2c2/trackattachment.cpp index b67ba5f..0241668 100644 --- a/source/libr2c2/trackattachment.cpp +++ b/source/libr2c2/trackattachment.cpp @@ -50,7 +50,7 @@ void TrackAttachment::attach_to_closest(float limit) Snap sn; sn.position = position; sn.rotation = rotation; - float gauge = (*i)->get_type().get_appearance().get_gauge(); + float gauge = (*i)->get_type().get_gauge(); if((*i)->snap(sn, gauge*limit, SNAP_SEGMENT)) { float d = distance(position, sn.position); diff --git a/source/libr2c2/tracktype.cpp b/source/libr2c2/tracktype.cpp index 59b8f9c..3c6876b 100644 --- a/source/libr2c2/tracktype.cpp +++ b/source/libr2c2/tracktype.cpp @@ -1,5 +1,6 @@ #include #include +#include "trackappearance.h" #include "tracktype.h" using namespace std; @@ -14,6 +15,11 @@ TrackType::TrackType(const ArticleNumber &an, const TrackAppearance &ta): autofit_preference(1) { } +float TrackType::get_gauge() const +{ + return appearance.get_gauge(); +} + float TrackType::get_total_length() const { return get_path_length(-1); diff --git a/source/libr2c2/tracktype.h b/source/libr2c2/tracktype.h index 56d164f..9d167d1 100644 --- a/source/libr2c2/tracktype.h +++ b/source/libr2c2/tracktype.h @@ -52,6 +52,7 @@ public: TrackType(const ArticleNumber &, const TrackAppearance &); const TrackAppearance &get_appearance() const { return appearance; } + float get_gauge() const; float get_total_length() const; float get_path_length(int) const; unsigned get_paths() const;