From: Mikko Rasa Date: Wed, 2 Apr 2014 19:57:22 +0000 (+0300) Subject: Fix some bad behavior in tools X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=c494ead3347f37500a527c5111ef2dfbde34a09a;p=r2c2.git Fix some bad behavior in tools --- diff --git a/source/designer/extendtool.cpp b/source/designer/extendtool.cpp index 021f184..163729e 100644 --- a/source/designer/extendtool.cpp +++ b/source/designer/extendtool.cpp @@ -22,8 +22,8 @@ ExtendTool::ExtendTool(Designer &d, Input::Keyboard &k, Input::Mouse &m, const s if(unlinked_endpoints.empty()) { - done = true; set_status("No free endpoints"); + set_done(false); } const Catalogue::ObjectMap &object_types = designer.get_catalogue().get_all(); @@ -93,6 +93,7 @@ void ExtendTool::connect() if(!ok) { set_status("No aligned endpoints found"); + set_done(false); return; } @@ -101,6 +102,7 @@ void ExtendTool::connect() if(extend_tracks.empty()) { set_status("No connection possible"); + set_done(false); return; } @@ -162,9 +164,12 @@ void ExtendTool::pointer_motion() void ExtendTool::finish() { - for(vector::const_iterator i=unlinked_endpoints.begin(); i!=unlinked_endpoints.end(); ++i) - if(extend_tracks.front()->link_to(**i)) - break; + if(!extend_tracks.empty()) + { + for(vector::const_iterator i=unlinked_endpoints.begin(); i!=unlinked_endpoints.end(); ++i) + if(extend_tracks.front()->link_to(**i)) + break; + } } vector ExtendTool::create_straight(const Vector &start, const Angle &dir, float length, float limit) diff --git a/source/designer/slopetool.cpp b/source/designer/slopetool.cpp index 58a50e1..d4a6ffb 100644 --- a/source/designer/slopetool.cpp +++ b/source/designer/slopetool.cpp @@ -38,6 +38,9 @@ SlopeTool::SlopeTool(Designer &d, Input::Keyboard &k, Input::Mouse &m, const set void SlopeTool::even_slope(bool smooth) { + if(done) + return; + float start_z = tracks.front()->get_snap_node(tracks.front().entry()).position.z; float end_z = tracks.back()->get_snap_node(tracks.back().reverse().entry()).position.z; @@ -70,10 +73,15 @@ void SlopeTool::even_slope(bool smooth) set_slope(*i, cur_z, tilt); cur_z += (*i)->get_type().get_path_length(0)*(end_z-start_z)/length; } + + set_done(true); } void SlopeTool::flatten() { + if(done) + return; + float z = 0; for(list::iterator i=tracks.begin(); i!=tracks.end(); ++i) { @@ -89,6 +97,8 @@ void SlopeTool::flatten() (*i)->set_position(Vector(p.x, p.y, z)); (*i)->set_tilt(Angle::zero()); } + + set_done(true); } void SlopeTool::set_slope(const TrackIter &track, float z, const Angle &tilt)