]> git.tdb.fi Git - r2c2.git/commitdiff
Perform check_slope automatically with certain operations
authorMikko Rasa <tdb@tdb.fi>
Mon, 13 May 2013 20:58:10 +0000 (23:58 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 13 May 2013 20:58:10 +0000 (23:58 +0300)
source/designer/manipulator.cpp
source/libr2c2/layout.cpp
source/libr2c2/layout.h
source/libr2c2/track.cpp
source/libr2c2/track.h

index 5bf02e9760ab2765cc01e0842c111b760b89b429..9dbf1cbb8900c7c240caba8f6a9ebe48212a5ad8 100644 (file)
@@ -116,9 +116,6 @@ void Manipulator::flatten()
                        track->set_slope(0);
        }
 
-       for(set<Track *>::iterator i=neighbors.begin(); i!=neighbors.end(); ++i)
-               (*i)->check_slope();
-
        update_objects();
 }
 
@@ -204,9 +201,6 @@ void Manipulator::even_slope(bool smooth)
                cur_z += dz;
        }
 
-       for(set<Track *>::iterator i=neighbors.begin(); i!=neighbors.end(); ++i)
-               (*i)->check_slope();
-
        update_objects();
 }
 
@@ -307,9 +301,6 @@ void Manipulator::cancel()
                i->object->set_rotation(i->rot);
        }
 
-       for(set<Track *>::iterator i=neighbors.begin(); i!=neighbors.end(); ++i)
-               (*i)->check_slope();
-
        for(vector<Track *>::iterator i=extend_tracks.begin(); i!=extend_tracks.end(); ++i)
                delete *i;
        extend_tracks.clear();
@@ -440,9 +431,6 @@ void Manipulator::axis_motion(unsigned axis, float value, float)
 
                for(vector<MObject>::iterator i=objects.begin(); i!=objects.end(); ++i)
                        i->object->set_position(Vector(center.x+i->pos.x, center.y+i->pos.y, center.z+i->pos.z+dz));
-
-               for(set<Track *>::iterator i=neighbors.begin(); i!=neighbors.end(); ++i)
-                       (*i)->check_slope();
        }
        else if(mode==EXTEND)
        {
index a2c97b7cbdfaaa887992e8d23392c607355d5a2e..45b18e322fa6e8db5a065fb616e002b869b206a8 100644 (file)
@@ -405,12 +405,6 @@ Layout::Loader::Loader(Layout &l):
        add("train", static_cast<void (Loader::*)(unsigned, unsigned, const std::string &)>(&Loader::train));
 }
 
-void Layout::Loader::finish()
-{
-       for(set<Track *>::iterator i=obj.tracks.begin(); i!=obj.tracks.end(); ++i)
-               (*i)->check_slope();
-}
-
 void Layout::Loader::route()
 {
        Route *rte = new Route(obj);
index c32795594bd253b43d03299e0dfe2e30f3b74d81..5573673f0f7a4c2987d6355388e2e3c4df7c94d0 100644 (file)
@@ -31,7 +31,6 @@ public:
        public:
                Loader(Layout &);
        private:
-               virtual void finish();
                void route();
                void route(const std::string &);
                void signal(ArticleNumber);
index 7b9a4a2d70b30febaf96ebf917cb284153ba44ac..6a6cbd97ee36f51d5ea3adf9031b9d984ea49007 100644 (file)
@@ -69,6 +69,9 @@ Block &Track::get_block() const
 void Track::set_position(const Vector &p)
 {
        position = p;
+       for(vector<Track *>::const_iterator i=links.begin(); i!=links.end(); ++i)
+               if(*i)
+                       (*i)->check_slope();
 }
 
 void Track::set_rotation(float r)
@@ -299,6 +302,7 @@ bool Track::link_to(Object &other)
                                break_link(i);
                                links[i] = otrack;
                                otrack->links[j] = this;
+                               check_slope();
                                layout.create_blocks(*this);
 
                                signal_link_changed.emit(i, otrack);
index 7ad7dd141907d18d48ad382fb7d3b300e56f3eeb..13409d5e753a75b0b9345f6d072a621e75dc56e5 100644 (file)
@@ -59,8 +59,10 @@ public:
        void set_flex(bool);
        float get_slope() const { return slope; }
        bool get_flex() const { return flex; }
+private:
        void check_slope();
 
+public:
        void set_turnout_id(unsigned);
        void set_sensor_id(unsigned);
        unsigned get_turnout_id() const { return turnout_id; }