Exemple #1
0
        public void UpdateView()
        {
            if (Visibility != Visibility.Visible)
            {
                return;
            }

            foreach (var streamable in Items)
            {
                if (streamable.Name == null || streamable.Name == "")
                {
                    continue;
                }

                var foundOne = false;

                //Check if datastream is already in the tree
                foreach (var item in DatastreamTree.Items)
                {
                    if ((TreeViewItem)item == null || ((TreeViewItem)item).DataContext == streamable)
                    {
                        foundOne = true;
                        break;
                    }
                }

                if (foundOne)
                {
                    continue;
                }

                var elements = Visualizer.Visualizer.GetModels(streamable.Data);

                var adds = Visualizer.Visualizer.GetTreeItems(streamable, elements);

                if (adds == null)
                {
                    continue;
                }

                DatastreamTree.Items.Add(adds);

                if (elements == null)
                {
                    continue;
                }
                if (elements == null)
                {
                    continue;
                }

                foreach (var m in elements)
                {
                    var model = m;

                    if (model.Parent != null)
                    {
                        if (model is MeshGeometryModel3D)
                        {
                            model = new MeshGeometryModel3D()
                            {
                                Geometry  = ((MeshGeometryModel3D)m).Geometry,
                                Material  = ((MeshGeometryModel3D)m).Material,
                                Transform = ((MeshGeometryModel3D)m).Transform,
                            };
                        }
                        else if (model is PointGeometryModel3D)
                        {
                            model = new PointGeometryModel3D()
                            {
                                Geometry  = ((PointGeometryModel3D)m).Geometry,
                                Transform = ((PointGeometryModel3D)m).Transform,
                                Color     = ((PointGeometryModel3D)m).Color
                            };
                        }
                        else if (model is LineGeometryModel3D)
                        {
                            model = new LineGeometryModel3D()
                            {
                                Geometry  = ((LineGeometryModel3D)m).Geometry,
                                Transform = ((LineGeometryModel3D)m).Transform,
                                Color     = ((LineGeometryModel3D)m).Color
                            };
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (Viewport.RenderHost.RenderTechnique != null)
                    {
                        model.Attach(Viewport.RenderHost);
                    }

                    Viewport.Items.Add(model);
                }
            }

            ViewportHelper.ZoomExtents(Viewport);
        }
Exemple #2
0
        private void ViewModel()
        {
            Application.Current.Dispatcher.Invoke(delegate
            {
                InitViewport();

                var vis = Visualizer.Visualizer.GetModels(_streamableObject.Data);

                if (vis == null)
                {
                    return;
                }

                foreach (var m in vis)
                {
                    var model = m;

                    if (model.Parent != null)
                    {
                        if (model is MeshGeometryModel3D)
                        {
                            model = new MeshGeometryModel3D()
                            {
                                Geometry  = ((MeshGeometryModel3D)m).Geometry,
                                Material  = ((MeshGeometryModel3D)m).Material,
                                Transform = ((MeshGeometryModel3D)m).Transform
                            };
                        }
                        else if (model is PointGeometryModel3D)
                        {
                            model = new PointGeometryModel3D()
                            {
                                Geometry  = ((PointGeometryModel3D)m).Geometry,
                                Transform = ((PointGeometryModel3D)m).Transform,
                                Color     = ((PointGeometryModel3D)m).Color
                            };
                        }
                        else if (model is LineGeometryModel3D)
                        {
                            model = new LineGeometryModel3D()
                            {
                                Geometry  = ((LineGeometryModel3D)m).Geometry,
                                Transform = ((LineGeometryModel3D)m).Transform,
                                Color     = ((LineGeometryModel3D)m).Color
                            };
                        }
                        else
                        {
                            continue;
                        }
                    }

                    if (Viewport.RenderHost.RenderTechnique != null)
                    {
                        model.Attach(Viewport.RenderHost);
                    }

                    Viewport.Items.Add(model);
                }

                ViewportHelper.ZoomExtents(Viewport);

                Viewport.Visibility         = Visibility.Visible;
                LoadingAnimation.Visibility = Visibility.Hidden;
            });
        }