]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/manipulator.cpp
Add target type to all lexical_casts
[r2c2.git] / source / designer / manipulator.cpp
index 359fbbb5e0b8d05feb884ac4ada0fb3707ebaceb..c103314564a69daead55d65c255382681819b3e1 100644 (file)
@@ -1,13 +1,6 @@
-/* $Id$
-
-This file is part of R²C²
-Copyright © 2006-2010  Mikkosoft Productions, Mikko Rasa
-Distributed under the GPL
-*/
-
 #include <algorithm>
 #include <cmath>
-#include <msp/strings/formatter.h>
+#include <msp/strings/format.h>
 #include "libr2c2/tracktype.h"
 #include "designer.h"
 #include "manipulator.h"
@@ -484,11 +477,23 @@ void Manipulator::pointer_motion(int x, int y)
                                        delete *i;
                                extend_tracks = trks;
 
+                               map<ArticleNumber, unsigned> counts;
                                length = 0;
                                for(vector<Track *>::iterator i=extend_tracks.begin(); i!=extend_tracks.end(); ++i)
+                               {
                                        length += (*i)->get_type().get_total_length();
-
-                               signal_status.emit(format("Extend: %.0fmm", length*1000));
+                                       ++counts[(*i)->get_type().get_article_number()];
+                               }
+
+                               string detail;
+                               for(map<ArticleNumber, unsigned>::const_iterator i=counts.begin(); i!=counts.end(); ++i)
+                               {
+                                       if(!detail.empty())
+                                               detail += ", ";
+                                       detail += format("%dx %s", i->second, i->first);
+                               }
+
+                               signal_status.emit(format("Extend: %.0fmm (%s)", length*1000, detail));
                        }
                }
        }
@@ -641,11 +646,7 @@ vector<Track *> Manipulator::create_straight(const R2C2::Vector &start, float di
                float s = sin(dir);
                for(vector<float>::iterator i=lengths.begin(); i!=lengths.end(); ++i)
                {
-                       map<float, const TrackType *>::iterator j = types_by_length.find(*i);
-                       if(j==types_by_length.end())
-                               throw LogicError("Internal error");
-
-                       Track *track = new Track(designer.get_layout(), *j->second);
+                       Track *track = new Track(designer.get_layout(), *get_item(types_by_length, *i));
                        track->set_position(pos);
                        track->set_rotation(dir);