]> git.tdb.fi Git - r2c2.git/commitdiff
Fix some bad behavior in tools
authorMikko Rasa <tdb@tdb.fi>
Wed, 2 Apr 2014 19:57:22 +0000 (22:57 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 2 Apr 2014 20:03:34 +0000 (23:03 +0300)
source/designer/extendtool.cpp
source/designer/slopetool.cpp

index 021f184a8fb89a4393a9b8dfa6525691ad0da426..163729e297509db776b64366f5d358796f60c466 100644 (file)
@@ -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<TrackIter>::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<TrackIter>::const_iterator i=unlinked_endpoints.begin(); i!=unlinked_endpoints.end(); ++i)
+                       if(extend_tracks.front()->link_to(**i))
+                               break;
+       }
 }
 
 vector<Track *> ExtendTool::create_straight(const Vector &start, const Angle &dir, float length, float limit)
index 58a50e1507cf7efad982cf0b0aaaedb08929fe8f..d4a6ffb770f7b5fecd38b2b5c6e14544efa63e94 100644 (file)
@@ -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<TrackIter>::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)