From: Mikko Rasa Date: Mon, 13 May 2013 20:58:10 +0000 (+0300) Subject: Perform check_slope automatically with certain operations X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=8b7d4054b05002d82338775ac9b4ee764a8560e4;p=r2c2.git Perform check_slope automatically with certain operations --- diff --git a/source/designer/manipulator.cpp b/source/designer/manipulator.cpp index 5bf02e9..9dbf1cb 100644 --- a/source/designer/manipulator.cpp +++ b/source/designer/manipulator.cpp @@ -116,9 +116,6 @@ void Manipulator::flatten() track->set_slope(0); } - for(set::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::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::iterator i=neighbors.begin(); i!=neighbors.end(); ++i) - (*i)->check_slope(); - for(vector::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::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::iterator i=neighbors.begin(); i!=neighbors.end(); ++i) - (*i)->check_slope(); } else if(mode==EXTEND) { diff --git a/source/libr2c2/layout.cpp b/source/libr2c2/layout.cpp index a2c97b7..45b18e3 100644 --- a/source/libr2c2/layout.cpp +++ b/source/libr2c2/layout.cpp @@ -405,12 +405,6 @@ Layout::Loader::Loader(Layout &l): add("train", static_cast(&Loader::train)); } -void Layout::Loader::finish() -{ - for(set::iterator i=obj.tracks.begin(); i!=obj.tracks.end(); ++i) - (*i)->check_slope(); -} - void Layout::Loader::route() { Route *rte = new Route(obj); diff --git a/source/libr2c2/layout.h b/source/libr2c2/layout.h index c327955..5573673 100644 --- a/source/libr2c2/layout.h +++ b/source/libr2c2/layout.h @@ -31,7 +31,6 @@ public: public: Loader(Layout &); private: - virtual void finish(); void route(); void route(const std::string &); void signal(ArticleNumber); diff --git a/source/libr2c2/track.cpp b/source/libr2c2/track.cpp index 7b9a4a2..6a6cbd9 100644 --- a/source/libr2c2/track.cpp +++ b/source/libr2c2/track.cpp @@ -69,6 +69,9 @@ Block &Track::get_block() const void Track::set_position(const Vector &p) { position = p; + for(vector::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); diff --git a/source/libr2c2/track.h b/source/libr2c2/track.h index 7ad7dd1..13409d5 100644 --- a/source/libr2c2/track.h +++ b/source/libr2c2/track.h @@ -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; }