]> git.tdb.fi Git - r2c2.git/commitdiff
Add a shortcut for getting the gauge of a TrackType
authorMikko Rasa <tdb@tdb.fi>
Sat, 3 May 2014 11:03:33 +0000 (14:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 3 May 2014 11:03:33 +0000 (14:03 +0300)
source/3d/path.cpp
source/designer/extendtool.cpp
source/designer/movetool.cpp
source/designer/svgexporter.cpp
source/libr2c2/track.cpp
source/libr2c2/trackattachment.cpp
source/libr2c2/tracktype.cpp
source/libr2c2/tracktype.h

index 8c36a3088f249f65305e9c13c5ea4e0a7f1d1e7f..1b4dba54fe03ee75674d3d4b649ea211a8692552 100644 (file)
@@ -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)
index 9b6ec9ab606474bd5c1facfdd9d2b623fb86d80c..aac7672514a76ab7fc443042acea6752e600f5d2 100644 (file)
@@ -62,7 +62,7 @@ void ExtendTool::connect()
        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;
+               limit = (*i)->get_type().get_gauge()/10;
                
                for(vector<TrackIter>::const_iterator j=i; ++j!=unlinked_endpoints.end(); )
                {
index 57f6216507e63c55a3d2157eaf519d6877b3f6ef..e0338273435d7069a772debb9f536ddecc9f3721 100644 (file)
@@ -68,5 +68,5 @@ MoveTool::Boundary::Boundary(MObject *o, unsigned i):
        limit(-1)
 {
        if(Track *track = dynamic_cast<Track *>(object->object))
-               limit = track->get_type().get_appearance().get_gauge();
+               limit = track->get_type().get_gauge();
 }
index f7248ef6dfffb5988e85f880c399a4574101ff68..d099b731b70f4361ef416d1b4e3abe218951221a 100644 (file)
@@ -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; j<n_endpoints; ++j)
                {
index 680e6ea8746cbe63ba7a2c797c8a952da6a625a4..7b6bef1de2d7e914846f67ec1b8c5f8b4eadfd64 100644 (file)
@@ -320,7 +320,7 @@ bool Track::link_to(Object &other)
        if(!otrack)
                return false;
 
-       float limit = type.get_appearance().get_gauge();
+       float limit = type.get_gauge();
        if(!flex && !otrack->get_flex())
                limit /= 10;
        limit *= limit;
index b67ba5fbbb6274ac7c69f6e9d7710ad01930ce56..024166820dc8adcac64e2a2be16e710b19ed681b 100644 (file)
@@ -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);
index 59b8f9ca275b4fe508b94fe77c32ec220ab83472..3c6876b0cc8b5bd72a7e0f476f45b6d631f2aa6a 100644 (file)
@@ -1,5 +1,6 @@
 #include <cmath>
 #include <msp/geometry/union.h>
+#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);
index 56d164f1b652a308a58a7ec1b0cf7505d6491631..9d167d18c7c91822ebd25b1dd047fc8a6233309e 100644 (file)
@@ -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;