Mercurial > hg > svapp
comparison framework/Document.h @ 100:22bf057ea151 1.2-stable
* merge from trunk (1.2 ended up being tracked from trunk, but we may want
this branch for fixes later)
author | Chris Cannam |
---|---|
date | Wed, 27 Feb 2008 10:32:45 +0000 |
parents | a798f5e6fc5e |
children |
comparison
equal
deleted
inserted
replaced
71:a8acc7841d70 | 100:22bf057ea151 |
---|---|
16 #ifndef _DOCUMENT_H_ | 16 #ifndef _DOCUMENT_H_ |
17 #define _DOCUMENT_H_ | 17 #define _DOCUMENT_H_ |
18 | 18 |
19 #include "layer/LayerFactory.h" | 19 #include "layer/LayerFactory.h" |
20 #include "plugin/transform/Transform.h" | 20 #include "plugin/transform/Transform.h" |
21 #include "plugin/transform/PluginTransformer.h"//!!! | |
22 #include "plugin/transform/ModelTransformer.h" | 21 #include "plugin/transform/ModelTransformer.h" |
23 #include "base/Command.h" | 22 #include "base/Command.h" |
24 | 23 |
25 #include <map> | 24 #include <map> |
26 #include <set> | 25 #include <set> |
112 /** | 111 /** |
113 * Create and return a suitable layer for the given transform, | 112 * Create and return a suitable layer for the given transform, |
114 * running the transform and associating the resulting model with | 113 * running the transform and associating the resulting model with |
115 * the new layer. | 114 * the new layer. |
116 */ | 115 */ |
117 Layer *createDerivedLayer(TransformId, | 116 Layer *createDerivedLayer(const Transform &, |
118 Model *inputModel, | 117 const ModelTransformer::Input &); |
119 const PluginTransformer::ExecutionContext &context, | |
120 QString configurationXml); | |
121 | 118 |
122 /** | 119 /** |
123 * Delete the given layer, and also its associated model if no | 120 * Delete the given layer, and also its associated model if no |
124 * longer used by any other layer. In general, this should be the | 121 * longer used by any other layer. In general, this should be the |
125 * only method used to delete layers -- doing so directly is a bit | 122 * only method used to delete layers -- doing so directly is a bit |
142 /** | 139 /** |
143 * Get the main model (the source for playback sample rate, etc). | 140 * Get the main model (the source for playback sample rate, etc). |
144 */ | 141 */ |
145 const WaveFileModel *getMainModel() const { return m_mainModel; } | 142 const WaveFileModel *getMainModel() const { return m_mainModel; } |
146 | 143 |
147 std::vector<Model *> getTransformerInputModels(); | 144 std::vector<Model *> getTransformInputModels(); |
145 | |
146 bool isKnownModel(const Model *) const; | |
148 | 147 |
149 /** | 148 /** |
150 * Add a derived model associated with the given transform, | 149 * Add a derived model associated with the given transform, |
151 * running the transform and returning the resulting model. | 150 * running the transform and returning the resulting model. |
152 */ | 151 */ |
153 Model *addDerivedModel(TransformId transform, | 152 Model *addDerivedModel(const Transform &transform, |
154 Model *inputModel, | 153 const ModelTransformer::Input &input, |
155 const PluginTransformer::ExecutionContext &context, | 154 QString &returnedMessage); |
156 QString configurationXml); | |
157 | 155 |
158 /** | 156 /** |
159 * Add a derived model associated with the given transform. This | 157 * Add a derived model associated with the given transform. This |
160 * is necessary to register any derived model that was not created | 158 * is necessary to register any derived model that was not created |
161 * by the document using createDerivedModel or createDerivedLayer. | 159 * by the document using createDerivedModel or createDerivedLayer. |
162 */ | 160 */ |
163 void addDerivedModel(TransformId, | 161 void addDerivedModel(const Transform &transform, |
164 Model *inputModel, | 162 const ModelTransformer::Input &input, |
165 const PluginTransformer::ExecutionContext &context, | 163 Model *outputModelToAdd); |
166 Model *outputModelToAdd, | |
167 QString configurationXml); | |
168 | 164 |
169 /** | 165 /** |
170 * Add an imported (non-derived, non-main) model. This is | 166 * Add an imported (non-derived, non-main) model. This is |
171 * necessary to register any imported model that is associated | 167 * necessary to register any imported model that is associated |
172 * with a layer. | 168 * with a layer. |
230 | 226 |
231 void modelAdded(Model *); | 227 void modelAdded(Model *); |
232 void mainModelChanged(WaveFileModel *); // emitted after modelAdded | 228 void mainModelChanged(WaveFileModel *); // emitted after modelAdded |
233 void modelAboutToBeDeleted(Model *); | 229 void modelAboutToBeDeleted(Model *); |
234 | 230 |
235 void modelGenerationFailed(QString transformName); | 231 void modelGenerationFailed(QString transformName, QString message); |
236 void modelRegenerationFailed(QString layerName, QString transformName); | 232 void modelGenerationWarning(QString transformName, QString message); |
233 void modelRegenerationFailed(QString layerName, QString transformName, | |
234 QString message); | |
235 void modelRegenerationWarning(QString layerName, QString transformName, | |
236 QString message); | |
237 void alignmentFailed(QString transformName, QString message); | |
237 | 238 |
238 protected: | 239 protected: |
239 void releaseModel(Model *model); | 240 void releaseModel(Model *model); |
240 | 241 |
241 /** | 242 /** |
265 // model is derived from another, then source will be non-NULL | 266 // model is derived from another, then source will be non-NULL |
266 // and the transform name will be set appropriately. If the | 267 // and the transform name will be set appropriately. If the |
267 // transform name is set but source is NULL, then there was a | 268 // transform name is set but source is NULL, then there was a |
268 // transform involved but the (target) model has been modified | 269 // transform involved but the (target) model has been modified |
269 // since being generated from it. | 270 // since being generated from it. |
271 | |
272 // This does not use ModelTransformer::Input, because it would | |
273 // be confusing to have Input objects hanging around with NULL | |
274 // models in them. | |
275 | |
270 const Model *source; | 276 const Model *source; |
271 TransformId transform; | 277 int channel; |
272 PluginTransformer::ExecutionContext context; | 278 Transform transform; |
273 QString configurationXml; | |
274 | 279 |
275 // Count of the number of layers using this model. | 280 // Count of the number of layers using this model. |
276 int refcount; | 281 int refcount; |
277 }; | 282 }; |
278 | 283 |
290 virtual QString getName() const { return m_name; } | 295 virtual QString getName() const { return m_name; } |
291 | 296 |
292 protected: | 297 protected: |
293 Document *m_d; | 298 Document *m_d; |
294 View *m_view; // I don't own this | 299 View *m_view; // I don't own this |
295 Layer *m_layer; // Document owns this, but I determine its lifespans | 300 Layer *m_layer; // Document owns this, but I determine its lifespan |
296 QString m_name; | 301 QString m_name; |
297 bool m_added; | 302 bool m_added; |
298 }; | 303 }; |
299 | 304 |
300 class RemoveLayerCommand : public Command | 305 class RemoveLayerCommand : public Command |
320 | 325 |
321 void addToLayerViewMap(Layer *, View *); | 326 void addToLayerViewMap(Layer *, View *); |
322 void removeFromLayerViewMap(Layer *, View *); | 327 void removeFromLayerViewMap(Layer *, View *); |
323 | 328 |
324 QString getUniqueLayerName(QString candidate); | 329 QString getUniqueLayerName(QString candidate); |
330 void writeBackwardCompatibleDerivation(QTextStream &, QString, Model *, | |
331 const ModelRecord &) const; | |
332 | |
333 static TransformId getAlignmentTransformName(); | |
325 | 334 |
326 /** | 335 /** |
327 * And these are the layers. We also control the lifespans of | 336 * And these are the layers. We also control the lifespans of |
328 * these (usually through the commands used to add and remove them). | 337 * these (usually through the commands used to add and remove them). |
329 */ | 338 */ |