예제 #1
0
        private void CreateAnnotations(List <Annotation_PointToPoint> list)
        {
            foreach (Annotation_PointToPoint a in list)
            {
                double length = (a.pt2 - a.pt1).magnitude();

                string label = new Inches(length).GetStringWithoutUnits();

                double extra = length - label.Length * a.size - 1;
                if (extra < 0)
                {
                    extra = 0;
                }

                Point3D p1 = new Point3D(a.pt1.x, a.pt1.y, a.pt1.z);
                Point3D p2 = new Point3D(a.pt2.x, a.pt2.y, a.pt2.z);

                Vector3D over = p2 - p1;
                over.Normalize();

                Vector3D up = new Vector3D(a.dir.x, a.dir.y, a.dir.z);

                ScreenSpaceLines3D ss = new ScreenSpaceLines3D();
                ss.Color     = Colors.Black;
                ss.Thickness = LineThickness;
                ss.Points.Add(p1 + up / 2);
                ss.Points.Add(p1 + up * (a.dist + a.size));
                ss.Points.Add(p2 + up / 2);
                ss.Points.Add(p2 + up * (a.dist + a.size));
                if (extra > 0)
                {
                    ss.Points.Add(p1 + up * (a.dist + a.size / 2));
                    ss.Points.Add(p1 + up * (a.dist + a.size / 2) + over * (extra / 2));
                    ss.Points.Add(p2 + up * (a.dist + a.size / 2));
                    ss.Points.Add(p2 + up * (a.dist + a.size / 2) - over * (extra / 2));
                }
                vp.Children.Add(ss);

                ModelVisual3D mv3d = wpfmisc.CreateTextLabel3D(label, Brushes.Black, true, a.size,
                                                               p1 + over * length / 2 + up * (a.dist + a.size / 2),
                                                               over, up);

                vp.Children.Add(mv3d);
            }
        }