diff transform/TransformFactory.cpp @ 47:bac8b14ab355

* Add menu for re-adding existing layers * Fix layer tree window so that it at least approximates correct * Add bundled operations in command history, for use with things like multiple consecutive changes to a parameter value * Disambiguate plugins that happen to have identical descriptions * Add spectral centroid plugin (could use some parameters!) * Some other fixes
author Chris Cannam
date Fri, 17 Mar 2006 17:38:28 +0000
parents 742e6882e187
children 39ae3dee27b9
line wrap: on
line diff
--- a/transform/TransformFactory.cpp	Thu Mar 16 18:46:00 2006 +0000
+++ b/transform/TransformFactory.cpp	Fri Mar 17 17:38:28 2006 +0000
@@ -47,10 +47,11 @@
 void
 TransformFactory::populateTransforms()
 {
-    //!!!
     std::vector<QString> fexplugs =
 	FeatureExtractionPluginFactory::getAllPluginIdentifiers();
 
+    std::map<QString, QString> makers;
+
     for (size_t i = 0; i < fexplugs.size(); ++i) {
 
 	QString pluginId = fexplugs[i];
@@ -63,8 +64,6 @@
 	    continue;
 	}
 
-	//!!! well, really we want to be able to query this without having to instantiate
-
 	FeatureExtractionPlugin *plugin = 
 	    factory->instantiatePlugin(pluginId, 48000);
 
@@ -93,8 +92,44 @@
 	    }
 
 	    m_transforms[transformName] = userDescription;
+	    
+	    makers[transformName] = plugin->getMaker().c_str();
 	}
     }
+
+    // disambiguate plugins with similar descriptions
+
+    std::map<QString, int> descriptions;
+
+    for (TransformMap::iterator i = m_transforms.begin(); i != m_transforms.end();
+	 ++i) {
+
+	QString name = i->first, description = i->second;
+
+	++descriptions[description];
+	++descriptions[QString("%1 [%2]").arg(description).arg(makers[name])];
+    }
+
+    std::map<QString, int> counts;
+    TransformMap newMap;
+
+    for (TransformMap::iterator i = m_transforms.begin(); i != m_transforms.end();
+	 ++i) {
+
+	QString name = i->first, description = i->second;
+
+	if (descriptions[description] > 1) {
+	    description = QString("%1 [%2]").arg(description).arg(makers[name]);
+	    if (descriptions[description] > 1) {
+		description = QString("%1 <%2>")
+		    .arg(description).arg(++counts[description]);
+	    }
+	}
+
+	newMap[name] = description;
+    }	    
+	    
+    m_transforms = newMap;
 }
 
 QString