public void ShouldSyncItsContainerWithModelParents()
        {
            var model_a = new Model ("a");
            var model_b = new Model ("b");
            var model_container = new Model("container");
            var models = new ModelCollection(model_container);
            models.AddRange(new [] {model_a, model_b});

            Assert.That(models.Container, Is.EqualTo(model_container));
            Assert.That(models.All(m => m.Parent == model_container));

            models.Clear();

            Assert.That(model_a.Parent, Is.Null);
            Assert.That(model_b.Parent, Is.Null);

            models.Add(model_a);

            Assert.That(model_a.Parent, Is.EqualTo(model_container));

            models.Insert(0, model_b);

            Assert.That(model_b.Parent, Is.EqualTo(model_container));

            models.Remove(model_a);

            Assert.That(model_a.Parent, Is.Null);
        }
        /// <summary>
        /// Disposes of the model
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    if (ModelCollection != null)
                    {
                        foreach (var model in modelCollection)
                        {
                            ((CustomPhongMaterial)((CustomGM3D)model).Material).Dispose();
                            ((CustomGM3D)model).Detach();
                            ((CustomGM3D)model).Dispose();
                            model.Dispose();
                        }

                        foreach (var model in ModelCollection)
                        {
                            ((CustomPhongMaterial)((CustomGM3D)model).Material).Dispose();
                            ((CustomGM3D)model).Detach();
                            ((CustomGM3D)model).Dispose();
                            model.Dispose();
                        }

                        modelCollection.Clear();
                        ModelCollection.Clear();
                    }

                    if (diffuse != null)
                    {
                        diffuse.Dispose();
                    }

                    if (normal != null)
                    {
                        normal.Dispose();
                    }

                    if (specular != null)
                    {
                        specular.Dispose();
                    }

                    if (mData != null)
                    {
                        mData.Clear();
                        mData = null;
                    }
                }
                disposed = true;

                base.Dispose(disposing);
            }
        }
 private void UpdateModelCollect(int nCamID)
 {
     ModelCollection.Clear();
     foreach (var it in Vision.VisionDataHelper.GetTemplateListForSpecCamera(nCamID, ModelFileHelper.GetWorkDictoryProfileList(new string[] { "shm" })))
     {
         ModelCollection.Add(new ModelItem()
         {
             StrName = it.Replace(string.Format("Cam{0}_", nCamID), ""), StrFullName = it
         });
     }
 }
Example #4
0
 public void DropAll()
 {
     foreach (IModel m in _models.Values)
     {
         m.Delete();
     }
     _models.Clear();
     // TODO: do we want to clear cameras or not?
     //_views.Clear();
     Engine.Atmosphere.Unload();
     Engine.Atmosphere.SkyBox_Enable(false, false);
     Engine.Gl.DestroyAllMeshes();
     Engine.TV3DEngine.Clear(false);
     Engine.TV3DEngine.RenderToScreen();
 }
        private void UpdateModelCollect(int nCamID)
        {
            ModelCollection.Clear();
            AllModelCollection.Clear();
            var FileList = ModelFileHelper.GetWorkDictoryProfileList(new string[] { "shm" });

            foreach (var it in FileList)
            {
                AllModelCollection.Add(new ModelItem()
                {
                    StrName = it, StrFullName = it
                });
            }
            foreach (var it in Vision.VisionDataHelper.GetTemplateListForSpecCamera(nCamID, FileList))
            {
                ModelCollection.Add(new ModelItem()
                {
                    StrName = it.Replace(string.Format("Cam{0}_", nCamID), ""), StrFullName = it
                });
            }
            RaisePropertyChanged("ModelCollection");
            RaisePropertyChanged("AllModelCollection");
        }