Mercurial > hg > svapp
comparison 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 |
comparison
equal
deleted
inserted
replaced
328:28c17ce7a6e9 | 337:1e3af7f4fa86 |
---|---|
27 | 27 |
28 class Model; | 28 class Model; |
29 class Layer; | 29 class Layer; |
30 class View; | 30 class View; |
31 class WaveFileModel; | 31 class WaveFileModel; |
32 | |
33 class AdditionalModelConverter; | |
32 | 34 |
33 /** | 35 /** |
34 * A Sonic Visualiser document consists of a set of data models, and | 36 * A Sonic Visualiser document consists of a set of data models, and |
35 * also the visualisation layers used to display them. Changes to the | 37 * also the visualisation layers used to display them. Changes to the |
36 * layers and their layout need to be stored and managed in much the | 38 * layers and their layout need to be stored and managed in much the |
119 | 121 |
120 /** | 122 /** |
121 * Create and return suitable layers for the given transforms, | 123 * Create and return suitable layers for the given transforms, |
122 * which must be identical apart from the output (i.e. must use | 124 * which must be identical apart from the output (i.e. must use |
123 * the same plugin and configuration). The layers are returned in | 125 * the same plugin and configuration). The layers are returned in |
124 * the same order as the transformed are supplied. | 126 * the same order as the transforms are supplied. |
125 */ | 127 */ |
126 std::vector<Layer *> createDerivedLayers(const Transforms &, | 128 std::vector<Layer *> createDerivedLayers(const Transforms &, |
127 const ModelTransformer::Input &); | 129 const ModelTransformer::Input &); |
130 | |
131 class LayerCreationHandler { | |
132 public: | |
133 virtual ~LayerCreationHandler() { } | |
134 | |
135 /** | |
136 * The primary layers are those corresponding 1-1 to the input | |
137 * models, listed in the same order as the input models. The | |
138 * additional layers vector contains any layers (from all | |
139 * models) that were returned separately at the end of | |
140 * processing. | |
141 */ | |
142 virtual void layersCreated(std::vector<Layer *> primary, | |
143 std::vector<Layer *> additional) = 0; | |
144 }; | |
145 | |
146 /** | |
147 * Create suitable layers for the given transforms, which must be | |
148 * identical apart from the output (i.e. must use the same plugin | |
149 * and configuration). This method returns after initialising the | |
150 * transformer process, and the layers are returned through a | |
151 * subsequent call to the provided handler (which must be non-null). | |
152 */ | |
153 void createDerivedLayersAsync(const Transforms &, | |
154 const ModelTransformer::Input &, | |
155 LayerCreationHandler *handler); | |
128 | 156 |
129 /** | 157 /** |
130 * Delete the given layer, and also its associated model if no | 158 * Delete the given layer, and also its associated model if no |
131 * longer used by any other layer. In general, this should be the | 159 * longer used by any other layer. In general, this should be the |
132 * only method used to delete layers -- doing so directly is a bit | 160 * only method used to delete layers -- doing so directly is a bit |
166 /** | 194 /** |
167 * Add derived models associated with the given set of related | 195 * Add derived models associated with the given set of related |
168 * transforms, running the transforms and returning the resulting | 196 * transforms, running the transforms and returning the resulting |
169 * models. | 197 * models. |
170 */ | 198 */ |
199 friend class AdditionalModelConverter; | |
171 std::vector<Model *> addDerivedModels(const Transforms &transforms, | 200 std::vector<Model *> addDerivedModels(const Transforms &transforms, |
172 const ModelTransformer::Input &input, | 201 const ModelTransformer::Input &input, |
173 QString &returnedMessage); | 202 QString &returnedMessage, |
203 AdditionalModelConverter *); | |
174 | 204 |
175 /** | 205 /** |
176 * Add a derived model associated with the given transform. This | 206 * Add a derived model associated with the given transform. This |
177 * is necessary to register any derived model that was not created | 207 * is necessary to register any derived model that was not created |
178 * by the document using createDerivedModel or createDerivedLayer. | 208 * by the document using createDerivedModel or createDerivedLayer. |
179 */ | 209 */ |
180 void addDerivedModel(const Transform &transform, | 210 void addAlreadyDerivedModel(const Transform &transform, |
181 const ModelTransformer::Input &input, | 211 const ModelTransformer::Input &input, |
182 Model *outputModelToAdd); | 212 Model *outputModelToAdd); |
183 | 213 |
184 /** | 214 /** |
185 * Add an imported (non-derived, non-main) model. This is | 215 * Add an imported (non-derived, non-main) model. This is |
186 * necessary to register any imported model that is associated | 216 * necessary to register any imported model that is associated |
187 * with a layer. | 217 * with a layer. |
207 * be set using setModel before this method is called. | 237 * be set using setModel before this method is called. |
208 */ | 238 */ |
209 void addLayerToView(View *, Layer *); | 239 void addLayerToView(View *, Layer *); |
210 | 240 |
211 /** | 241 /** |
212 * Remove the given layer from the given view. | 242 * Remove the given layer from the given view. Ownership of the |
243 * layer is transferred to a command object on the undo stack, and | |
244 * the layer will be deleted when the undo stack is pruned. | |
213 */ | 245 */ |
214 void removeLayerFromView(View *, Layer *); | 246 void removeLayerFromView(View *, Layer *); |
215 | 247 |
216 /** | 248 /** |
217 * Return true if alignment is supported (i.e. if the necessary | 249 * Return true if alignment is supported (i.e. if the necessary |
296 // models in them. | 328 // models in them. |
297 | 329 |
298 const Model *source; | 330 const Model *source; |
299 int channel; | 331 int channel; |
300 Transform transform; | 332 Transform transform; |
333 bool additional; | |
301 | 334 |
302 // Count of the number of layers using this model. | 335 // Count of the number of layers using this model. |
303 int refcount; | 336 int refcount; |
304 }; | 337 }; |
305 | 338 |
306 typedef std::map<Model *, ModelRecord> ModelMap; | 339 typedef std::map<Model *, ModelRecord> ModelMap; |
307 ModelMap m_models; | 340 ModelMap m_models; |
341 | |
342 /** | |
343 * Add an extra derived model (returned at the end of processing a | |
344 * transform). | |
345 */ | |
346 void addAdditionalModel(Model *); | |
308 | 347 |
309 class AddLayerCommand : public Command | 348 class AddLayerCommand : public Command |
310 { | 349 { |
311 public: | 350 public: |
312 AddLayerCommand(Document *d, View *view, Layer *layer); | 351 AddLayerCommand(Document *d, View *view, Layer *layer); |
355 static TransformId getAlignmentTransformName(); | 394 static TransformId getAlignmentTransformName(); |
356 | 395 |
357 void toXml(QTextStream &, QString, QString, bool asTemplate) const; | 396 void toXml(QTextStream &, QString, QString, bool asTemplate) const; |
358 void writePlaceholderMainModel(QTextStream &, QString) const; | 397 void writePlaceholderMainModel(QTextStream &, QString) const; |
359 | 398 |
399 std::vector<Layer *> createLayersForDerivedModels(std::vector<Model *>, | |
400 QStringList names); | |
401 | |
360 /** | 402 /** |
361 * And these are the layers. We also control the lifespans of | 403 * And these are the layers. We also control the lifespans of |
362 * these (usually through the commands used to add and remove them). | 404 * these (usually through the commands used to add and remove them). |
363 */ | 405 */ |
364 typedef std::set<Layer *> LayerSet; | 406 typedef std::set<Layer *> LayerSet; |