예제 #1
0
        public static PointsDistanceViewModel Create(PointProbeViewModel vm1, PointProbeViewModel vm2)
        {
            var p1  = new Point3D(vm1.X, vm1.Y, vm1.Z);
            var p2  = new Point3D(vm2.X, vm2.Y, vm2.Z);
            var t1  = vm1.GetChainTansform();
            var t2  = vm2.GetChainTansform();
            var pp2 = t1.Invert().Transform(t2.Transform(p2));
            var p12 = pp2 - p1;

            var pdvm = new PointsDistanceViewModel()
            {
                X = p12.X,
                Y = p12.Y,
                Z = p12.Z,
                //_vm1 = vm1,
                //_vm2 = vm2,
                Parent = vm1
            };

            var points = new Point3DCollection()
            {
                p1,
                p1 + new Vector3D(p12.X, 0.0, 0.0),
                p1 + new Vector3D(p12.X, 0.0, 0.0),
                p1 + new Vector3D(p12.X, p12.Y, 0.0),
                p1 + new Vector3D(p12.X, p12.Y, 0.0),
                pp2
            };

            var line = new LinesVisual3D()
            {
                Points    = points,
                Color     = Colors.Yellow,
                Thickness = 3
            };

            pdvm.Children.Add(line);
            pdvm._onIsSelectedChanged = (b) => line.Color = b ? Colors.Red : Colors.Yellow;
            pdvm.PropertyChanged     += (s, e) => pdvm.OnPropertyChanged(s, e);

            return(pdvm);
        }
예제 #2
0
        public static PointProbeViewModel Create(MachineElementViewModel parent, Point3D point, double radius = 5.0)
        {
            var t       = parent.GetChainTansform();
            var p       = t.Invert().Transform(point);
            var builder = new MeshBuilder();

            builder.AddSphere(p, radius);

            var vm = new PointProbeViewModel()
            {
                X            = p.X,
                Y            = p.Y,
                Z            = p.Z,
                Radius       = radius,
                Parent       = parent,
                MeshGeometry = builder.ToMesh(),
                Fill         = Brushes.Yellow
            };

            vm._onIsSelectedChanged = (b) => vm.Fill = b ? Brushes.Red : Brushes.Yellow;
            vm.PropertyChanged     += (s, e) => vm.OnPropertyChanged(s, e);

            return(vm);
        }