Example #1
0
        private void ListBoxItem1_1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            var dsgDlg = new BpDesignDialog(bpView);

            dsgDlg.ShowDialog();
            bpView = dsgDlg.view;
        }
Example #2
0
        private void LoadParams(object sender, RoutedEventArgs e)
        {
            try
            {
                var openInfo = new OpenFileDialog();
                openInfo.Filter = "JSON文件(*.json)|*.json";

                if (openInfo.ShowDialog() == true)
                {
                    using (var fs = new FileStream(openInfo.FileName, FileMode.Open, FileAccess.Read))
                    {
                        using (var rs = new StreamReader(fs))
                        {
                            DataContext = view = JsonConvert.DeserializeObject <BpDesignView>(rs.ReadToEnd());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShowError(ex);
            }
        }
Example #3
0
        public BpDesignDialog(BpDesignView designView)
        {
            InitializeComponent();

            DataContext = view = designView;
        }
Example #4
0
        /// <summary>
        /// 根据参数绘制边坡。
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public static AcDb.Entity[] MakeBianpo(BpDesignView param)
        {
            var result = new List <AcDb.Entity>();
            var db     = AcAp.Application.DocumentManager.MdiActiveDocument.Database;

            // 边坡顶点。
            var vertexes = new List <Point2d>();

            // 线路顶部。
            vertexes.Add(new Point2d(-param.Lujiankuan * 0.5, 0));
            vertexes.Add(new Point2d(param.Lujiankuan * 0.5, 0));

            // 路肩宽标注。
            result.Add(new AcDb.AlignedDimension(
                           new Point3d(-param.Lujiankuan * 0.5, 1, 0),
                           new Point3d(param.Lujiankuan * 0.5, 1, 0),
                           new Point3d(0, 1.5, 0), null, AcDb.ObjectId.Null));

            // 路肩高程标记。
            var lujianTriangle = EntityHelper.CreatePolygon(new[]
            {
                -param.Lujiankuan * 0.5, 0,
                -param.Lujiankuan * 0.5 + 0.2, 0.4,
                -param.Lujiankuan * 0.5 - 0.2, 0.4,
            });

            result.Add(lujianTriangle);
            result.Add(lujianTriangle.GetTransformedCopy(
                           AcGe.Matrix3d.Displacement(Vector3d.XAxis * param.Lujiankuan)));

            // 路肩高程文字。
            var lujianHeight = new AcDb.DBText();

            lujianHeight.SetDatabaseDefaults(db); // 重要!
            lujianHeight.TextString     = param.Lujiangaocheng.ToString("0.##");
            lujianHeight.HorizontalMode = AcDb.TextHorizontalMode.TextCenter;
            lujianHeight.AlignmentPoint = new Point3d(-param.Lujiankuan * 0.5, 0.5, 0);
            lujianHeight.AdjustAlignment(db); // 重要!
            result.Add(lujianHeight);
            result.Add(lujianHeight.GetTransformedCopy(
                           AcGe.Matrix3d.Displacement(Vector3d.XAxis * param.Lujiankuan)));

            // 一级边坡。
            var yijipogao = param.HasErjibianpo ? param.Yijipogao :
                            (param.Lujiangaocheng - param.Churukougaocheng);

            vertexes.Insert(0, vertexes.First() +
                            new Vector2d(-yijipogao * param.Yijipolv, -yijipogao));
            vertexes.Add(vertexes.Last() +
                         new Vector2d(yijipogao * param.Yijipolv, -yijipogao));

            // 一级边坡坡率。
            var yjbppl = new AcDb.DBText();

            yjbppl.SetDatabaseDefaults(db); // 重要!
            yjbppl.TextString     = "1:" + param.Yijipolv.ToString("0.##");
            yjbppl.HorizontalMode = AcDb.TextHorizontalMode.TextCenter;
            var yjbppl1 = yjbppl.Clone() as AcDb.DBText; // 右侧对称。

            yjbppl.AlignmentPoint = new Point3d(
                -(param.Lujiankuan + yijipogao * param.Yijipolv) * 0.5,
                -yijipogao * 0.5 + 0.1, 0);
            yjbppl.Rotation = Math.Atan2(1, param.Yijipolv);
            yjbppl.AdjustAlignment(db); // 重要!
            result.Add(yjbppl);
            yjbppl1.AlignmentPoint = new Point3d(
                (param.Lujiankuan + yijipogao * param.Yijipolv) * 0.5,
                -yijipogao * 0.5 + 0.1, 0);
            yjbppl1.Rotation = -Math.Atan2(1, param.Yijipolv);
            yjbppl1.AdjustAlignment(db); // 重要!
            result.Add(yjbppl1);

            // 一级边坡宽度标注。
            result.Add(new AcDb.AlignedDimension(
                           new Point3d(-param.Lujiankuan * 0.5, 1, 0),
                           new Point3d(-param.Lujiankuan * 0.5 - yijipogao * param.Yijipolv, 1, 0),
                           new Point3d(0, 1.5, 0), null, AcDb.ObjectId.Null));
            result.Add(new AcDb.AlignedDimension(
                           new Point3d(param.Lujiankuan * 0.5, 1, 0),
                           new Point3d(param.Lujiankuan * 0.5 + yijipogao * param.Yijipolv, 1, 0),
                           new Point3d(0, 1.5, 0), null, AcDb.ObjectId.Null));

            // 二级边坡。
            if (param.HasErjibianpo)
            {
                // 1米加宽平台。
                vertexes.Insert(0, vertexes.First() + new Vector2d(-1, 0));
                vertexes.Add(vertexes.Last() + new Vector2d(1, 0));
                // 标注。
                result.Add(new AcDb.AlignedDimension(
                               new Point3d(vertexes[0].X, vertexes[0].Y, 0),
                               new Point3d(vertexes[1].X, vertexes[1].Y, 0),
                               new Point3d(0, 1.5, 0), null, AcDb.ObjectId.Null));
                result.Add(new AcDb.AlignedDimension(
                               new Point3d(vertexes[vertexes.Count - 1].X, vertexes[vertexes.Count - 1].Y, 0),
                               new Point3d(vertexes[vertexes.Count - 2].X, vertexes[vertexes.Count - 2].Y, 0),
                               new Point3d(0, 1.5, 0), null, AcDb.ObjectId.Null));

                // 二级边坡。
                var erjipogao = param.HasSanjibianpo ? param.Erjipogao :
                                (param.Lujiangaocheng - param.Churukougaocheng - yijipogao);
                vertexes.Insert(0, vertexes.First() +
                                new Vector2d(-erjipogao * param.Erjipolv, -erjipogao));
                vertexes.Add(vertexes.Last() +
                             new Vector2d(erjipogao * param.Erjipolv, -erjipogao));

                // 二级边坡坡率。
                var ejbppl = new AcDb.DBText();
                ejbppl.SetDatabaseDefaults(db); // 重要!
                ejbppl.TextString     = "1:" + param.Erjipolv.ToString("0.##");
                ejbppl.HorizontalMode = AcDb.TextHorizontalMode.TextCenter;
                var ejbppl1 = ejbppl.Clone() as AcDb.DBText; // 右侧对称。
                ejbppl.AlignmentPoint = new Point3d(
                    -param.Lujiankuan * 0.5 - yijipogao * param.Yijipolv
                    - 1 - erjipogao * param.Erjipolv * 0.5,
                    -yijipogao - erjipogao * 0.5 + 0.1, 0);
                ejbppl.Rotation = Math.Atan2(1, param.Erjipolv);
                ejbppl.AdjustAlignment(db); // 重要!
                result.Add(ejbppl);
                ejbppl1.AlignmentPoint = new Point3d(
                    param.Lujiankuan * 0.5 + yijipogao * param.Yijipolv
                    + 1 + erjipogao * param.Erjipolv * 0.5,
                    -yijipogao - erjipogao * 0.5 + 0.1, 0);
                ejbppl1.Rotation = -Math.Atan2(1, param.Erjipolv);
                ejbppl1.AdjustAlignment(db); // 重要!
                result.Add(ejbppl1);

                // 二级边坡宽度标注。
                result.Add(new AcDb.AlignedDimension(
                               new Point3d(-param.Lujiankuan * 0.5 - yijipogao * param.Yijipolv - 1, 1, 0),
                               new Point3d(-param.Lujiankuan * 0.5 - yijipogao * param.Yijipolv - 1
                                           - erjipogao * param.Erjipolv, 1, 0),
                               new Point3d(0, 1.5, 0), null, AcDb.ObjectId.Null));
                result.Add(new AcDb.AlignedDimension(
                               new Point3d(param.Lujiankuan * 0.5 + yijipogao * param.Yijipolv + 1, 1, 0),
                               new Point3d(param.Lujiankuan * 0.5 + yijipogao * param.Yijipolv + 1
                                           + erjipogao * param.Erjipolv, 1, 0),
                               new Point3d(0, 1.5, 0), null, AcDb.ObjectId.Null));
            }

            // TODO 三级边坡。

            result.Add(EntityHelper.CreatePolygon(
                           vertexes.SelectMany(p2d => p2d.ToArray()).ToArray(),
                           closed: false));

            return(result.ToArray());
        }