comparison main/MainWindow.cpp @ 224:b5a2428f647b

* Merge from transforms branch -- switch over to using Transform object properly
author Chris Cannam
date Fri, 07 Dec 2007 16:47:31 +0000
parents a3011df6ddad
children d7ded015af32
comparison
equal deleted inserted replaced
222:a3011df6ddad 224:b5a2428f647b
909 LayerFactory::PeakFrequencySpectrogram, 909 LayerFactory::PeakFrequencySpectrogram,
910 LayerFactory::Spectrum 910 LayerFactory::Spectrum
911 }; 911 };
912 912
913 std::vector<Model *> models; 913 std::vector<Model *> models;
914 if (m_document) models = m_document->getTransformerInputModels(); //!!! not well named for this! 914 if (m_document) models = m_document->getTransformInputModels();
915 bool plural = (models.size() > 1); 915 bool plural = (models.size() > 1);
916 if (models.empty()) { 916 if (models.empty()) {
917 models.push_back(getMainModel()); // probably 0 917 models.push_back(getMainModel()); // probably 0
918 } 918 }
919 919
1182 m_transformsMenu = menuBar()->addMenu(tr("&Transform")); 1182 m_transformsMenu = menuBar()->addMenu(tr("&Transform"));
1183 m_transformsMenu->setTearOffEnabled(true); 1183 m_transformsMenu->setTearOffEnabled(true);
1184 } 1184 }
1185 1185
1186 TransformList transforms = 1186 TransformList transforms =
1187 TransformFactory::getInstance()->getAllTransforms(); 1187 TransformFactory::getInstance()->getAllTransformDescriptions();
1188 1188
1189 vector<QString> types = 1189 vector<QString> types =
1190 TransformFactory::getInstance()->getAllTransformTypes(); 1190 TransformFactory::getInstance()->getAllTransformTypes();
1191 1191
1192 map<QString, map<QString, SubdividingMenu *> > categoryMenus; 1192 map<QString, map<QString, SubdividingMenu *> > categoryMenus;
2732 Model *model = 0; 2732 Model *model = 0;
2733 2733
2734 if (suggestedModel) { 2734 if (suggestedModel) {
2735 2735
2736 // check its validity 2736 // check its validity
2737 std::vector<Model *> inputModels = m_document->getTransformerInputModels(); 2737 std::vector<Model *> inputModels = m_document->getTransformInputModels();
2738 for (size_t j = 0; j < inputModels.size(); ++j) { 2738 for (size_t j = 0; j < inputModels.size(); ++j) {
2739 if (inputModels[j] == suggestedModel) { 2739 if (inputModels[j] == suggestedModel) {
2740 model = suggestedModel; 2740 model = suggestedModel;
2741 break; 2741 break;
2742 } 2742 }
2853 } 2853 }
2854 2854
2855 return; 2855 return;
2856 } 2856 }
2857 2857
2858 TransformId transform = i->second; 2858 //!!! want to do something like this, but it's not supported in
2859 ModelTransformerFactory *factory = ModelTransformerFactory::getInstance(); 2859 //ModelTransformerFactory yet
2860 2860 /*
2861 QString configurationXml;
2862
2863 int channel = -1; 2861 int channel = -1;
2864 // pick up the default channel from any existing layers on the same pane 2862 // pick up the default channel from any existing layers on the same pane
2865 for (int j = 0; j < pane->getLayerCount(); ++j) { 2863 for (int j = 0; j < pane->getLayerCount(); ++j) {
2866 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j)); 2864 int c = LayerFactory::getInstance()->getChannel(pane->getLayer(j));
2867 if (c != -1) { 2865 if (c != -1) {
2868 channel = c; 2866 channel = c;
2869 break; 2867 break;
2870 } 2868 }
2871 } 2869 }
2870 */
2872 2871
2873 // We always ask for configuration, even if the plugin isn't 2872 // We always ask for configuration, even if the plugin isn't
2874 // supposed to be configurable, because we need to let the user 2873 // supposed to be configurable, because we need to let the user
2875 // change the execution context (block size etc). 2874 // change the execution context (block size etc).
2876 2875
2877 PluginTransformer::ExecutionContext context(channel); 2876 QString transformId = i->second;
2877 Transform transform = TransformFactory::getInstance()->
2878 getDefaultTransformFor(transformId);
2878 2879
2879 std::vector<Model *> candidateInputModels = 2880 std::vector<Model *> candidateInputModels =
2880 m_document->getTransformerInputModels(); 2881 m_document->getTransformInputModels();
2881 2882
2882 Model *defaultInputModel = 0; 2883 Model *defaultInputModel = 0;
2883 for (int j = 0; j < pane->getLayerCount(); ++j) { 2884 for (int j = 0; j < pane->getLayerCount(); ++j) {
2884 Layer *layer = pane->getLayer(j); 2885 Layer *layer = pane->getLayer(j);
2885 if (!layer) continue; 2886 if (!layer) continue;
2898 size_t endFrame = 0; 2899 size_t endFrame = 0;
2899 m_viewManager->getSelection().getExtents(startFrame, endFrame); 2900 m_viewManager->getSelection().getExtents(startFrame, endFrame);
2900 if (endFrame > startFrame) duration = endFrame - startFrame; 2901 if (endFrame > startFrame) duration = endFrame - startFrame;
2901 else startFrame = 0; 2902 else startFrame = 0;
2902 2903
2903 Model *inputModel = factory->getConfigurationForTransformer 2904 ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
2905 getConfigurationForTransform
2904 (transform, 2906 (transform,
2905 candidateInputModels, 2907 candidateInputModels,
2906 defaultInputModel, 2908 defaultInputModel,
2907 context,
2908 configurationXml,
2909 m_playSource, 2909 m_playSource,
2910 startFrame, 2910 startFrame,
2911 duration); 2911 duration);
2912 2912
2913 if (!inputModel) return; 2913 if (!input.getModel()) return;
2914 2914
2915 // std::cerr << "MainWindow::addLayer: Input model is " << inputModel << " \"" << inputModel->objectName().toStdString() << "\"" << std::endl; 2915 // std::cerr << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName().toStdString() << "\"" << std::endl;
2916 2916
2917 Layer *newLayer = m_document->createDerivedLayer(transform, 2917 Layer *newLayer = m_document->createDerivedLayer(transform, input);
2918 inputModel,
2919 context,
2920 configurationXml);
2921 2918
2922 if (newLayer) { 2919 if (newLayer) {
2923 m_document->addLayerToView(pane, newLayer); 2920 m_document->addLayerToView(pane, newLayer);
2924 m_document->setChannel(newLayer, context.channel); 2921 m_document->setChannel(newLayer, input.getChannel());
2925 m_recentTransforms.add(transform); 2922 m_recentTransforms.add(transformId);
2926 m_paneStack->setCurrentLayer(pane, newLayer); 2923 m_paneStack->setCurrentLayer(pane, newLayer);
2927 } 2924 }
2928 2925
2929 updateMenuStates(); 2926 updateMenuStates();
2930 } 2927 }