comparison 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
comparison
equal deleted inserted replaced
46:5364a9d338a2 47:bac8b14ab355
45 } 45 }
46 46
47 void 47 void
48 TransformFactory::populateTransforms() 48 TransformFactory::populateTransforms()
49 { 49 {
50 //!!!
51 std::vector<QString> fexplugs = 50 std::vector<QString> fexplugs =
52 FeatureExtractionPluginFactory::getAllPluginIdentifiers(); 51 FeatureExtractionPluginFactory::getAllPluginIdentifiers();
52
53 std::map<QString, QString> makers;
53 54
54 for (size_t i = 0; i < fexplugs.size(); ++i) { 55 for (size_t i = 0; i < fexplugs.size(); ++i) {
55 56
56 QString pluginId = fexplugs[i]; 57 QString pluginId = fexplugs[i];
57 58
60 61
61 if (!factory) { 62 if (!factory) {
62 std::cerr << "WARNING: TransformFactory::populateTransforms: No feature extraction plugin factory for instance " << pluginId.toLocal8Bit().data() << std::endl; 63 std::cerr << "WARNING: TransformFactory::populateTransforms: No feature extraction plugin factory for instance " << pluginId.toLocal8Bit().data() << std::endl;
63 continue; 64 continue;
64 } 65 }
65
66 //!!! well, really we want to be able to query this without having to instantiate
67 66
68 FeatureExtractionPlugin *plugin = 67 FeatureExtractionPlugin *plugin =
69 factory->instantiatePlugin(pluginId, 48000); 68 factory->instantiatePlugin(pluginId, 48000);
70 69
71 if (!plugin) { 70 if (!plugin) {
91 .arg(pluginDescription) 90 .arg(pluginDescription)
92 .arg(outputs[j].description.c_str()); 91 .arg(outputs[j].description.c_str());
93 } 92 }
94 93
95 m_transforms[transformName] = userDescription; 94 m_transforms[transformName] = userDescription;
96 } 95
97 } 96 makers[transformName] = plugin->getMaker().c_str();
97 }
98 }
99
100 // disambiguate plugins with similar descriptions
101
102 std::map<QString, int> descriptions;
103
104 for (TransformMap::iterator i = m_transforms.begin(); i != m_transforms.end();
105 ++i) {
106
107 QString name = i->first, description = i->second;
108
109 ++descriptions[description];
110 ++descriptions[QString("%1 [%2]").arg(description).arg(makers[name])];
111 }
112
113 std::map<QString, int> counts;
114 TransformMap newMap;
115
116 for (TransformMap::iterator i = m_transforms.begin(); i != m_transforms.end();
117 ++i) {
118
119 QString name = i->first, description = i->second;
120
121 if (descriptions[description] > 1) {
122 description = QString("%1 [%2]").arg(description).arg(makers[name]);
123 if (descriptions[description] > 1) {
124 description = QString("%1 <%2>")
125 .arg(description).arg(++counts[description]);
126 }
127 }
128
129 newMap[name] = description;
130 }
131
132 m_transforms = newMap;
98 } 133 }
99 134
100 QString 135 QString
101 TransformFactory::getTransformDescription(TransformName name) 136 TransformFactory::getTransformDescription(TransformName name)
102 { 137 {