diff layer/LayerFactory.h @ 1471:f2525e6cbdf1 by-id

More layer updates
author Chris Cannam
date Mon, 01 Jul 2019 14:17:13 +0100
parents 9e846af73f3e
children b43ff1abdc02
line wrap: on
line diff
--- a/layer/LayerFactory.h	Fri Jun 28 17:37:22 2019 +0100
+++ b/layer/LayerFactory.h	Mon Jul 01 14:17:13 2019 +0100
@@ -19,8 +19,9 @@
 #include <QString>
 #include <set>
 
+#include "data/model/Model.h"
+
 class Layer;
-class Model;
 class Clipboard;
 
 class LayerFactory
@@ -56,7 +57,7 @@
     virtual ~LayerFactory();
 
     typedef std::set<LayerType> LayerTypeSet;
-    LayerTypeSet getValidLayerTypes(Model *model);
+    LayerTypeSet getValidLayerTypes(ModelId modelId);
 
     /**
      * Return the set of layer types that an end user should be
@@ -86,8 +87,8 @@
 
     bool isLayerSliceable(const Layer *);
 
-    void setModel(Layer *layer, Model *model);
-    Model *createEmptyModel(LayerType type, Model *baseModel);
+    void setModel(Layer *layer, ModelId model);
+    std::shared_ptr<Model> createEmptyModel(LayerType type, ModelId baseModel);
 
     int getChannel(Layer *layer);
     void setChannel(Layer *layer, int channel);
@@ -100,12 +101,12 @@
 
 protected:
     template <typename LayerClass, typename ModelClass>
-    bool trySetModel(Layer *layerBase, Model *modelBase) {
+    bool trySetModel(Layer *layerBase, ModelId modelId) {
         LayerClass *layer = dynamic_cast<LayerClass *>(layerBase);
         if (!layer) return false;
-        ModelClass *model = dynamic_cast<ModelClass *>(modelBase);
+        auto model = ModelById::getAs<ModelClass>(modelId);
         if (!model) return false;
-        layer->setModel(model);
+        layer->setModel(modelId);
         return true;
     }