Mercurial > hg > svapp
comparison framework/Document.h @ 350:aebee52e86b3
Merge from branch tony_integration
author | Chris Cannam |
---|---|
date | Wed, 14 May 2014 09:54:46 +0100 |
parents | dd07d48d7d4f |
children | f5c914661f6f |
comparison
equal
deleted
inserted
replaced
330:46b24009ce7a | 350:aebee52e86b3 |
---|---|
17 #define _DOCUMENT_H_ | 17 #define _DOCUMENT_H_ |
18 | 18 |
19 #include "layer/LayerFactory.h" | 19 #include "layer/LayerFactory.h" |
20 #include "transform/Transform.h" | 20 #include "transform/Transform.h" |
21 #include "transform/ModelTransformer.h" | 21 #include "transform/ModelTransformer.h" |
22 #include "transform/FeatureExtractionModelTransformer.h" | |
22 #include "base/Command.h" | 23 #include "base/Command.h" |
23 | 24 |
24 #include <map> | 25 #include <map> |
25 #include <set> | 26 #include <set> |
26 | 27 |
27 class Model; | 28 class Model; |
28 class Layer; | 29 class Layer; |
29 class View; | 30 class View; |
30 class WaveFileModel; | 31 class WaveFileModel; |
32 | |
33 class AdditionalModelConverter; | |
31 | 34 |
32 /** | 35 /** |
33 * 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 |
34 * also the visualisation layers used to display them. Changes to the | 37 * also the visualisation layers used to display them. Changes to the |
35 * 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 |
115 */ | 118 */ |
116 Layer *createDerivedLayer(const Transform &, | 119 Layer *createDerivedLayer(const Transform &, |
117 const ModelTransformer::Input &); | 120 const ModelTransformer::Input &); |
118 | 121 |
119 /** | 122 /** |
123 * Create and return suitable layers for the given transforms, | |
124 * which must be identical apart from the output (i.e. must use | |
125 * the same plugin and configuration). The layers are returned in | |
126 * the same order as the transforms are supplied. | |
127 */ | |
128 std::vector<Layer *> createDerivedLayers(const Transforms &, | |
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); | |
156 | |
157 /** | |
120 * Delete the given layer, and also its associated model if no | 158 * Delete the given layer, and also its associated model if no |
121 * 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 |
122 * 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 |
123 * of a social gaffe. | 161 * of a social gaffe. |
124 */ | 162 */ |
152 Model *addDerivedModel(const Transform &transform, | 190 Model *addDerivedModel(const Transform &transform, |
153 const ModelTransformer::Input &input, | 191 const ModelTransformer::Input &input, |
154 QString &returnedMessage); | 192 QString &returnedMessage); |
155 | 193 |
156 /** | 194 /** |
195 * Add derived models associated with the given set of related | |
196 * transforms, running the transforms and returning the resulting | |
197 * models. | |
198 */ | |
199 friend class AdditionalModelConverter; | |
200 std::vector<Model *> addDerivedModels(const Transforms &transforms, | |
201 const ModelTransformer::Input &input, | |
202 QString &returnedMessage, | |
203 AdditionalModelConverter *); | |
204 | |
205 /** | |
157 * Add a derived model associated with the given transform. This | 206 * Add a derived model associated with the given transform. This |
158 * is necessary to register any derived model that was not created | 207 * is necessary to register any derived model that was not created |
159 * by the document using createDerivedModel or createDerivedLayer. | 208 * by the document using createDerivedModel or createDerivedLayer. |
160 */ | 209 */ |
161 void addDerivedModel(const Transform &transform, | 210 void addAlreadyDerivedModel(const Transform &transform, |
162 const ModelTransformer::Input &input, | 211 const ModelTransformer::Input &input, |
163 Model *outputModelToAdd); | 212 Model *outputModelToAdd); |
164 | 213 |
165 /** | 214 /** |
166 * Add an imported (non-derived, non-main) model. This is | 215 * Add an imported (non-derived, non-main) model. This is |
167 * necessary to register any imported model that is associated | 216 * necessary to register any imported model that is associated |
168 * with a layer. | 217 * with a layer. |
188 * be set using setModel before this method is called. | 237 * be set using setModel before this method is called. |
189 */ | 238 */ |
190 void addLayerToView(View *, Layer *); | 239 void addLayerToView(View *, Layer *); |
191 | 240 |
192 /** | 241 /** |
193 * 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. | |
194 */ | 245 */ |
195 void removeLayerFromView(View *, Layer *); | 246 void removeLayerFromView(View *, Layer *); |
196 | 247 |
197 /** | 248 /** |
198 * Return true if alignment is supported (i.e. if the necessary | 249 * Return true if alignment is supported (i.e. if the necessary |
277 // models in them. | 328 // models in them. |
278 | 329 |
279 const Model *source; | 330 const Model *source; |
280 int channel; | 331 int channel; |
281 Transform transform; | 332 Transform transform; |
333 bool additional; | |
282 | 334 |
283 // Count of the number of layers using this model. | 335 // Count of the number of layers using this model. |
284 int refcount; | 336 int refcount; |
285 }; | 337 }; |
286 | 338 |
287 typedef std::map<Model *, ModelRecord> ModelMap; | 339 typedef std::map<Model *, ModelRecord> ModelMap; |
288 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 *); | |
289 | 347 |
290 class AddLayerCommand : public Command | 348 class AddLayerCommand : public Command |
291 { | 349 { |
292 public: | 350 public: |
293 AddLayerCommand(Document *d, View *view, Layer *layer); | 351 AddLayerCommand(Document *d, View *view, Layer *layer); |
317 | 375 |
318 protected: | 376 protected: |
319 Document *m_d; | 377 Document *m_d; |
320 View *m_view; // I don't own this | 378 View *m_view; // I don't own this |
321 Layer *m_layer; // Document owns this, but I determine its lifespan | 379 Layer *m_layer; // Document owns this, but I determine its lifespan |
380 bool m_wasDormant; | |
322 QString m_name; | 381 QString m_name; |
323 bool m_added; | 382 bool m_added; |
324 }; | 383 }; |
325 | 384 |
326 typedef std::map<Layer *, std::set<View *> > LayerViewMap; | 385 typedef std::map<Layer *, std::set<View *> > LayerViewMap; |
336 static TransformId getAlignmentTransformName(); | 395 static TransformId getAlignmentTransformName(); |
337 | 396 |
338 void toXml(QTextStream &, QString, QString, bool asTemplate) const; | 397 void toXml(QTextStream &, QString, QString, bool asTemplate) const; |
339 void writePlaceholderMainModel(QTextStream &, QString) const; | 398 void writePlaceholderMainModel(QTextStream &, QString) const; |
340 | 399 |
400 std::vector<Layer *> createLayersForDerivedModels(std::vector<Model *>, | |
401 QStringList names); | |
402 | |
341 /** | 403 /** |
342 * And these are the layers. We also control the lifespans of | 404 * And these are the layers. We also control the lifespans of |
343 * these (usually through the commands used to add and remove them). | 405 * these (usually through the commands used to add and remove them). |
344 */ | 406 */ |
345 typedef std::set<Layer *> LayerSet; | 407 typedef std::set<Layer *> LayerSet; |