Mercurial > hg > svapp
diff framework/Document.h @ 337:1e3af7f4fa86 tony_integration
Merge from branch tonioni
author | Chris Cannam |
---|---|
date | Tue, 11 Mar 2014 17:34:53 +0000 |
parents | 0c37405cf579 |
children | dd07d48d7d4f |
line wrap: on
line diff
--- a/framework/Document.h Tue Jan 28 15:02:15 2014 +0000 +++ b/framework/Document.h Tue Mar 11 17:34:53 2014 +0000 @@ -30,6 +30,8 @@ class View; class WaveFileModel; +class AdditionalModelConverter; + /** * A Sonic Visualiser document consists of a set of data models, and * also the visualisation layers used to display them. Changes to the @@ -121,11 +123,37 @@ * Create and return suitable layers for the given transforms, * which must be identical apart from the output (i.e. must use * the same plugin and configuration). The layers are returned in - * the same order as the transformed are supplied. + * the same order as the transforms are supplied. */ std::vector<Layer *> createDerivedLayers(const Transforms &, const ModelTransformer::Input &); + class LayerCreationHandler { + public: + virtual ~LayerCreationHandler() { } + + /** + * The primary layers are those corresponding 1-1 to the input + * models, listed in the same order as the input models. The + * additional layers vector contains any layers (from all + * models) that were returned separately at the end of + * processing. + */ + virtual void layersCreated(std::vector<Layer *> primary, + std::vector<Layer *> additional) = 0; + }; + + /** + * Create suitable layers for the given transforms, which must be + * identical apart from the output (i.e. must use the same plugin + * and configuration). This method returns after initialising the + * transformer process, and the layers are returned through a + * subsequent call to the provided handler (which must be non-null). + */ + void createDerivedLayersAsync(const Transforms &, + const ModelTransformer::Input &, + LayerCreationHandler *handler); + /** * Delete the given layer, and also its associated model if no * longer used by any other layer. In general, this should be the @@ -168,18 +196,20 @@ * transforms, running the transforms and returning the resulting * models. */ + friend class AdditionalModelConverter; std::vector<Model *> addDerivedModels(const Transforms &transforms, const ModelTransformer::Input &input, - QString &returnedMessage); + QString &returnedMessage, + AdditionalModelConverter *); /** * Add a derived model associated with the given transform. This * is necessary to register any derived model that was not created * by the document using createDerivedModel or createDerivedLayer. */ - void addDerivedModel(const Transform &transform, - const ModelTransformer::Input &input, - Model *outputModelToAdd); + void addAlreadyDerivedModel(const Transform &transform, + const ModelTransformer::Input &input, + Model *outputModelToAdd); /** * Add an imported (non-derived, non-main) model. This is @@ -209,7 +239,9 @@ void addLayerToView(View *, Layer *); /** - * Remove the given layer from the given view. + * Remove the given layer from the given view. Ownership of the + * layer is transferred to a command object on the undo stack, and + * the layer will be deleted when the undo stack is pruned. */ void removeLayerFromView(View *, Layer *); @@ -298,6 +330,7 @@ const Model *source; int channel; Transform transform; + bool additional; // Count of the number of layers using this model. int refcount; @@ -306,6 +339,12 @@ typedef std::map<Model *, ModelRecord> ModelMap; ModelMap m_models; + /** + * Add an extra derived model (returned at the end of processing a + * transform). + */ + void addAdditionalModel(Model *); + class AddLayerCommand : public Command { public: @@ -357,6 +396,9 @@ void toXml(QTextStream &, QString, QString, bool asTemplate) const; void writePlaceholderMainModel(QTextStream &, QString) const; + std::vector<Layer *> createLayersForDerivedModels(std::vector<Model *>, + QStringList names); + /** * And these are the layers. We also control the lifespans of * these (usually through the commands used to add and remove them).