示例#1
0
        void OnCompositionTargetRendering(object sender, EventArgs e)
        {
            if (ShowLinesVisual3D && lines==null)
            {
                lines = new LinesVisual3D { Color = Colors.Blue };
                view1.Children.Add(lines);
            }
            if (!ShowLinesVisual3D && lines!=null)
            {
                lines.IsRendering = false;
                view1.Children.Remove(lines);
                lines = null;
            }
            if (ShowPointsVisual3D && points == null)
            {
                points = new PointsVisual3D { Color = Colors.Red, Size=6 };
                view1.Children.Add(points);
            }
            if (!ShowPointsVisual3D && points != null)
            {
                points.IsRendering = false;
                view1.Children.Remove(points);
                points = null;
            }
            if (ShowScreenSpaceLines3D && screenSpaceLines == null)
            {
                screenSpaceLines = new ScreenSpaceLines3D { Color = Colors.Green };
                view1.Children.Add(screenSpaceLines);
            }
            if (!ShowScreenSpaceLines3D && screenSpaceLines != null)
            {
                view1.Children.Remove(screenSpaceLines);
                screenSpaceLines = null;
            }
            if (ShowWireLines && wireLines == null)
            {
                wireLines = new WireLines { Color = Colors.Pink };
                view1.Children.Add(wireLines);
            }
            if (!ShowWireLines && wireLines != null)
            {
                view1.Children.Remove(wireLines);
                wireLines = null;
            }

            if (Points==null || Points.Count != N || isAnimating)
            {
                Points = GeneratePoints(N, watch.ElapsedMilliseconds*0.001);
                RaisePropertyChanged("Points");
            }

            if (lines != null)
                lines.Points = Points;
            if (points != null)
                points.Points = Points;
            if (screenSpaceLines != null)
                screenSpaceLines.Points = Points;
            if (wireLines != null)
                wireLines.Lines = Points;
        }
        private void mnuViewShowRoadAxis_Unchecked(object sender, RoutedEventArgs e)
        {
            //RoadAxis.Visibility = Visibility.Hidden;
            if (line != null)
            {
                if (model.Children.Contains(line))
                {
                    model.Children.Remove(line);
                    line = null;
                }

                if (viewport.Children.Contains(planeModel))
                {
                    viewport.Children.Remove(planeModel);
                    planeModel = null;
                }

                if (model.Children.Contains(axes))
                {
                    model.Children.Remove(axes);
                    axes = null;
                }
            }
        }
        private void DrawRoadAxis()
        {
            Point3DCollection points = new Point3DCollection();

            points.Add(new Point3D(-planeWidth, FindYPoint(-planeWidth, -10), -10));
            points.Add(new Point3D(planeWidth, FindYPoint(planeWidth, -10), -10));

            line = new WireLines()
            {
                Lines = points,
                Color = Colors.Black,
                Thickness = 4.0,
            };

            line.Transform = new RotateTransform3D()
            {
                Rotation = new AxisAngleRotation3D(new Vector3D(0, 1, 0), Settings.Default.KinectAngle),
                CenterX = 0,
                CenterY = 0,
                CenterZ = -10
            };

            model.Children.Add(line);
        }
        private void mnuFileOpen_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog openFileDialog1 = new Microsoft.Win32.OpenFileDialog();
            openFileDialog1.Title = "Open Trajectory Data";
            openFileDialog1.DefaultExt = ".csv";
            openFileDialog1.Filter = "CSV files (*.csv)|*.txt|All files (*.*)|*.*";
            Nullable<bool> result = openFileDialog1.ShowDialog();

            if (result == true)
            {
                string openFileName = openFileDialog1.FileName;

                using (StreamReader sr = new StreamReader(openFileName))
                {
                    try
                    {

                        string line;
                        string[] row;
                        int i = 0;

                        while ((line = sr.ReadLine()) != null)
                        {
                            //Do not read the header
                            if (i > 0)
                            {
                                row = line.Split(',');
                                Globals.ds.trajectories.Rows.Add(row);
                            }

                            i++;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                    }
                }
            }
        }
示例#5
0
        private void OnCompositionTargetRendering(object sender, EventArgs e)
        {
            if (this.ShowLinesVisual3D && this.linesVisual == null)
            {
                this.linesVisual = new LinesVisual3D { Color = Colors.Blue };
                View1.Children.Add(this.linesVisual);
            }

            if (!this.ShowLinesVisual3D && this.linesVisual != null)
            {
                this.linesVisual.IsRendering = false;
                View1.Children.Remove(this.linesVisual);
                this.linesVisual = null;
            }

            if (this.ShowPointsVisual3D && this.pointsVisual == null)
            {
                this.pointsVisual = new PointsVisual3D { Color = Colors.Red, Size = 6 };
                View1.Children.Add(this.pointsVisual);
            }

            if (!this.ShowPointsVisual3D && this.pointsVisual != null)
            {
                this.pointsVisual.IsRendering = false;
                View1.Children.Remove(this.pointsVisual);
                this.pointsVisual = null;
            }

            if (this.ShowScreenSpaceLines3D && this.screenSpaceLines == null)
            {
                this.screenSpaceLines = new ScreenSpaceLines3D { Color = Colors.Green };
                View1.Children.Add(this.screenSpaceLines);
            }

            if (!this.ShowScreenSpaceLines3D && this.screenSpaceLines != null)
            {
                View1.Children.Remove(this.screenSpaceLines);
                this.screenSpaceLines = null;
            }

            if (this.ShowWireLines && this.wireLines == null)
            {
                this.wireLines = new WireLines { Color = Colors.Pink };
                View1.Children.Add(this.wireLines);
            }

            if (!this.ShowWireLines && this.wireLines != null)
            {
                View1.Children.Remove(this.wireLines);
                this.wireLines = null;
            }

            if (this.Points == null || this.Points.Count != this.NumberOfPoints)
            {
                this.Points = new Point3DCollection(GeneratePoints(this.NumberOfPoints, this.watch.ElapsedMilliseconds * 0.001));
            }

            if (this.linesVisual != null)
            {
                this.linesVisual.Points = this.Points;
            }

            if (this.pointsVisual != null)
            {
                this.pointsVisual.Points = this.Points;
            }

            if (this.screenSpaceLines != null)
            {
                this.screenSpaceLines.Points = this.Points;
            }

            if (this.wireLines != null)
            {
                this.wireLines.Lines = this.Points;
            }
        }