]> git.tdb.fi Git - r2c2.git/blobdiff - source/designer/extendtool.cpp
Rework article numbers
[r2c2.git] / source / designer / extendtool.cpp
index aac7672514a76ab7fc443042acea6752e600f5d2..8698fd52e6aabc048b348d49b796a06c236fb3e2 100644 (file)
@@ -26,19 +26,18 @@ ExtendTool::ExtendTool(Designer &d, Input::Keyboard &k, Input::Mouse &m, const s
                set_done(false);
        }
 
-       const Catalogue::ObjectMap &object_types = designer.get_catalogue().get_all();
-       for(Catalogue::ObjectMap::const_iterator i=object_types.begin(); i!=object_types.end(); ++i)
-               if(const TrackType *tt = dynamic_cast<const TrackType *>(i->second))
-               {
-                       const vector<TrackPart> &parts = tt->get_parts();
-                       if(parts.size()!=1)
-                               continue;
-                       if(parts.front().is_curved() || parts.front().is_dead_end())
-                               continue;
+       list<TrackType *> track_types = designer.get_catalogue().get_list<TrackType>();
+       for(list<TrackType *>::iterator i=track_types.begin(); i!=track_types.end(); ++i)
+       {
+               const vector<TrackPart> &parts = (*i)->get_parts();
+               if(parts.size()!=1)
+                       continue;
+               if(parts.front().is_curved() || parts.front().is_dead_end())
+                       continue;
 
-                       types_by_length[parts.front().get_length()] = tt;
-                       max_preference = max(max_preference, tt->get_autofit_preference());
-               }
+               types_by_length[parts.front().get_length()] = *i;
+               max_preference = max(max_preference, (*i)->get_autofit_preference());
+       }
 }
 
 ExtendTool::~ExtendTool()
@@ -144,20 +143,20 @@ void ExtendTool::pointer_motion()
                                delete *i;
                        extend_tracks = trks;
 
-                       map<ArticleNumber, unsigned> counts;
+                       map<const TrackType *, unsigned> counts;
                        length = 0;
                        for(vector<Track *>::iterator i=extend_tracks.begin(); i!=extend_tracks.end(); ++i)
                        {
                                length += (*i)->get_type().get_total_length();
-                               ++counts[(*i)->get_type().get_article_number()];
+                               ++counts[&(*i)->get_type()];
                        }
 
                        string detail;
-                       for(map<ArticleNumber, unsigned>::const_iterator i=counts.begin(); i!=counts.end(); ++i)
+                       for(map<const TrackType *, unsigned>::const_iterator i=counts.begin(); i!=counts.end(); ++i)
                        {
                                if(!detail.empty())
                                        detail += ", ";
-                               detail += format("%dx %s", i->second, i->first);
+                               detail += format("%dx %s", i->second, i->first->get_article_number());
                        }
 
                        signal_status.emit(format("Extend: %.0fmm (%s)", length*1000, detail));