Example #1
0
        /// <summary>
        /// 查询钻孔编号列表,输出为Borehole类形式
        /// </summary>
        /// <param name="_projectName">项目名称</param>
        /// <returns></returns>
        public static List <Borehole> ReadZkListAsClass(string _projectName)
        {
            // 创建连接到设置信息数据库
            string sql = "Data Source=" + Program.ReadProgramPath() + "\\" + _projectName + ".gsygeo";

            using (SQLiteConnection conn = new SQLiteConnection(sql))
            {
                // 打开连接
                conn.Open();

                // 新建要返回的类列表
                List <Borehole> zklist = new List <Borehole>();

                // 循环读取钻孔数据
                sql = "select * from zkBasicInfo order by name";
                SQLiteDataReader reader = new SQLiteCommand(sql, conn).ExecuteReader();
                while (reader.Read())
                {
                    Borehole zk = new Borehole(reader["name"].ToString(), Convert.ToDouble(reader["altitude"]));
                    zk.X = Convert.ToDouble(reader["xAxis"]);
                    zk.Y = Convert.ToDouble(reader["yAxis"]);
                    zk.InitialWaterLevel = Convert.ToDouble(reader["initialWaterLevel"]);
                    zk.StableWaterLevel  = Convert.ToDouble(reader["stableWaterLevel"]);
                    zk.Layers            = BoreholeDataBase.ReadZkLayer(_projectName, reader["name"].ToString());
                    zk.Samples           = BoreholeDataBase.ReadZkSample(_projectName, reader["name"].ToString());
                    zk.NTests            = BoreholeDataBase.ReadZkNTest(_projectName, reader["name"].ToString());

                    zklist.Add(zk);
                }

                // 返回
                return(zklist);
            }
        }
Example #2
0
        // TreeView选择节点变化时激活不同的内容控件
        private void ProjectTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e)
        {
            // 读取选中节点
            TreeViewItem selectedItem = (TreeViewItem)e.NewValue;

            // 根据选中状况清空窗口中的控件
            if (selectedItem == null)
            {
                this.ContectGrid.Children.Clear();
                return;
            }

            if (selectedItem.Header.ToString() != "基本信息" && selectedItem.Parent != null)
            {
                this.ContectGrid.Children.Clear();
            }

            // 选中一级节点时
            // 选中"基本信息"
            if (selectedItem.Header.ToString() == "基本信息")
            {
                ProjectBasicInfo prjb = new ProjectBasicInfo();
                this.ContectGrid.Children.Add(prjb);
            }

            // 选中二级、三级节点时
            if (selectedItem.Parent != null)
            {
                // 读取父节点
                TreeViewItem parentItem = (TreeViewItem)selectedItem.Parent;

                // 选中"钻孔"子节点
                if (parentItem.Header.ToString() == "钻孔")
                {
                    // 读取当前所选钻孔名称
                    string prj    = Program.currentProject;
                    string zkName = selectedItem.Header.ToString();

                    // 实例化一个Borehole类,并将当前所选钻孔的数据库信息赋值给此实例
                    Borehole bh = new Borehole(zkName, BoreholeDataBase.ReadAltitude(prj, zkName));
                    bh.X = BoreholeDataBase.ReadXAxis(prj, zkName);
                    bh.Y = BoreholeDataBase.ReadYAxis(prj, zkName);
                    bh.InitialWaterLevel = BoreholeDataBase.ReadInitialWaterLevel(prj, zkName);
                    bh.StableWaterLevel  = BoreholeDataBase.ReadStableWaterLevel(prj, zkName);
                    bh.Layers            = BoreholeDataBase.ReadZkLayer(prj, zkName);
                    bh.Samples           = BoreholeDataBase.ReadZkSample(prj, zkName);
                    bh.NTests            = BoreholeDataBase.ReadZkNTest(prj, zkName);

                    // 实例化BoreholeControl用户控件,并赋值
                    BoreholeControl bhc = new BoreholeControl(bh);
                    this.ContectGrid.Children.Add(bhc);
                }

                // 选取"原位测试"-"静力触探"子节点
                if (parentItem.Header.ToString() == "静力触探")
                {
                    // 读取当前所选触探孔名称
                    string prj    = Program.currentProject;
                    string jkName = selectedItem.Header.ToString();

                    // 实例化一个CPT类,并将当前所选触探孔的数据库信息赋值给此实例
                    CPT cpt = new CPT(jkName, CPTDataBase.ReadAltitude(prj, jkName));
                    cpt.X      = CPTDataBase.ReadXAxis(prj, jkName);
                    cpt.Y      = CPTDataBase.ReadYAxis(prj, jkName);
                    cpt.Layers = CPTDataBase.ReadJkLayer(prj, jkName);
                    cpt.PsList = CPTDataBase.ReadJkPs(prj, jkName);

                    // 实例化CPTControl用户控件,并赋值
                    CPTControl cptc = new CPTControl(cpt);
                    this.ContectGrid.Children.Add(cptc);
                }

                // 选取"室内试验"-"土工常规"子节点
                if (selectedItem.Header.ToString() == "土工常规")
                {
                    // 实例化一个RoutineSoilTest类列表,并读取数据库信息赋值给此实例
                    List <RoutineSoilTest> rsts = RoutineSoilTestDataBase.ReadAllData(Program.currentProject);

                    // 实例化RoutineSoilTestControl用户控件,并赋值
                    RoutineSoilTestControl rstc = new RoutineSoilTestControl(rsts);
                    this.ContectGrid.Children.Add(rstc);
                }

                // 选取"室内试验"-"颗粒分析"子节点
                if (selectedItem.Header.ToString() == "颗粒分析")
                {
                    // 实例化一个RoutineSoilTest类列表,并读取数据库信息赋值给此实例
                    List <GrainAnalysisTest> gats = GrainAnalysisTestDataBase.ReadAllData(Program.currentProject);

                    // 实例化RoutineSoilTestControl用户控件,并赋值
                    GrainAnalysisTestControl gatc = new GrainAnalysisTestControl(gats);
                    this.ContectGrid.Children.Add(gatc);
                }
            }
        }
Example #3
0
        /// <summary>
        /// 方法,绘制单个钻孔柱状图
        /// </summary>
        /// <param name="_drawIndex">柱状图编号,从0开始,用于绘制多个柱状图时计算其摆放位置</param>
        /// <param name="_projectName">工程名称</param>
        /// <param name="_companyName">公司名称</param>
        /// <param name="_zk">钻孔数据</param>
        /// <param name="_scaleList">比例尺列表</param>
        /// <param name="_style1">钻孔柱状图的文字样式</param>
        /// <param name="_style2">剖面图钻孔的文字样式</param>
        public void DrawZk(int _drawIndex, string _projectName, string[] _company, Borehole _zk, List <double> _scaleList, DxfTextStyle _style1, DxfTextStyle _style2)
        {
            // 当钻孔内没有分层时退出
            if (_zk.Layers.Count == 0)
            {
                return;
            }

            // 计算图形横向偏移量,用于绘制多个柱状图时的空间摆放距离
            double xDis = _drawIndex * 195;

            // 绘制钻孔柱状图框架
            AddRectangle(0 + xDis, 0, 195 + xDis, 280);
            AddRectangle(10 + xDis, 20, 185 + xDis, 261);
            Model.Entities[Model.Entities.Count - 1].LineWeight = 30;

            double[,] pointKJ = new double[25, 4]
            {
                { 10, 254, 185, 254 }, { 10, 247, 57, 247 }, { 63, 247, 185, 247 }, { 10, 240, 185, 240 }, { 10, 220, 185, 220 },
                { 131.5, 233, 185, 233 }, { 132.5, 225, 150.5, 225 }, { 152.5, 225, 170.5, 225 }, { 172.5, 225, 184, 225 },
                { 30, 261, 30, 240 }, { 57, 254, 57, 240 }, { 63, 254, 63, 240 }, { 90, 261, 90, 240 }, { 110, 261, 110, 240 },
                { 137, 254, 137, 240 }, { 157, 254, 157, 240 }, { 22, 240, 22, 20 }, { 30, 240, 30, 20 }, { 42, 240, 42, 20 },
                { 52, 240, 52, 20 }, { 62, 240, 62, 20 }, { 77, 240, 77, 20 }, { 131.5, 240, 131.5, 20 },
                { 151.5, 240, 151.5, 20 }, { 171.5, 240, 171.5, 20 }
            };
            for (int i = 0; i < 25; i++)
            {
                AddLine(pointKJ[i, 0] + xDis, pointKJ[i, 1], pointKJ[i, 2] + xDis, pointKJ[i, 3]);
            }

            string[] textKJ = new string[31]
            {
                "工程名称", "钻孔编号", "孔口高程", "勘察单位", "钻孔深度", "钻孔日期", "初见水位", "稳定水位", "地\n质\n年\n代", "及\n成\n因", "层\n \n序",
                "层\n底\n标\n高\n(m)", "层\n底\n深\n度\n(m)", "分\n层\n厚\n度\n(m)", "岩  土  描  述", "标贯/动探", "取 样", "注水试验", "击 数", "深 度(m)",
                "编 号", "深 度(m)", "渗透系数\n(cm/s)", "深度(m)", "钻 孔 柱 状 图", "制图:", "校核:", "审查:", "核定:", "X:", "Y:"
            };
            double[,] ptextKJ = new double[31, 3]
            {
                { 20, 257.5, 20 }, { 20, 250.5, 20 }, { 20, 243.5, 20 }, { 100, 257.5, 20 }, { 100, 250.5, 20 }, { 100, 243.5, 20 }, { 147, 250.5, 20 }, { 147, 243.5, 20 },
                { 13, 230, 6 }, { 19, 230, 6 }, { 26, 230, 8 }, { 36, 230, 12 }, { 47, 230, 10 }, { 57, 230, 10 }, { 104.25, 230, 54.5 }, { 141.5, 236.5, 20 },
                { 161.5, 236.5, 20 }, { 178.25, 236.5, 13.5 }, { 141.5, 229, 20 }, { 141.5, 222.5, 20 }, { 161.5, 229, 20 }, { 161.5, 222.5, 20 }, { 178.25, 229, 13.5 },
                { 178.25, 222.5, 13.5 }, { 97.5, 270, 31 }, { 32, 13, 10 }, { 70, 13, 10 }, { 106, 13, 10 }, { 144, 13, 10 }, { 65.5, 252, 5 }, { 65.5, 245, 5 }
            };
            for (int i = 0; i < textKJ.Length; i++)
            {
                DxfMText t = AddMText(textKJ[i], ptextKJ[i, 0] + xDis, ptextKJ[i, 1], ptextKJ[i, 2], 2.5, _style1);
                if (i == 11 || i == 12 || i == 13 || i == 22)
                {
                    t.LineSpacingFactor = 0.8;
                }
            }

            // 绘制表头信息
            AddMText(_projectName, 60 + xDis, 257.5, 60, 2.5, _style1);
            AddMText(_zk.Name, 43.5 + xDis, 250.5, 27, 2.5, _style1);
            AddMText(_zk.Altitude.ToString("0.00") + "      m", 43.5 + xDis, 243.5, 27, 2.5, _style1);
            AddMText(_company[0], 147.5 + xDis, 257.5, 75, 2.5, _style1);
            AddMText(_zk.Layers[_zk.Layers.Count - 1].Depth.ToString("0.00") + "   m", 123.5 + xDis, 250.5, 27, 2.5, _style1);

            // 计算比例尺
            double scale;

            if (_zk.Layers[_zk.Layers.Count - 1].Depth <= 20)
            {
                scale = 100;
            }
            else if (_zk.Layers[_zk.Layers.Count - 1].Depth <= 40)
            {
                scale = 200;
            }
            else if (_zk.Layers[_zk.Layers.Count - 1].Depth <= 100)
            {
                scale = 500;
            }
            else
            {
                scale = 1000;
            }
            AddMText("柱\n状\n图\n1:" + scale, 69.5 + xDis, 230, 12, 2.5, _style1);

            // 绘制分层
            for (int i = 0; i < _zk.Layers.Count; i++)
            {
                // 分层线及深度标签
                double drawY = 220 - _zk.Layers[i].Depth / scale * 1000;

                AddLine(10 + xDis, drawY, 131.5 + xDis, drawY);
                AddMText(_zk.Layers[i].Number, 26 + xDis, drawY + 3, 8, 2.5, _style1);
                AddMText((_zk.Altitude - _zk.Layers[i].Depth).ToString("0.00"), 36 + xDis, drawY + 3, 8, 2.5, _style1);
                AddMText(_zk.Layers[i].Depth.ToString("0.00"), 47 + xDis, drawY + 3, 8, 2.5, _style1);
                if (i > 0)
                {
                    AddMText((_zk.Layers[i].Depth - _zk.Layers[i - 1].Depth).ToString("0.00"), 57 + xDis, drawY + 3, 8, 2.5, _style1);
                }
                else
                {
                    AddMText(_zk.Layers[i].Depth.ToString("0.00"), 57 + xDis, drawY + 3, 8, 2.5, _style1);
                }

                // 地质填充
                double hatchY1 = drawY;
                double hatchY2;
                if (i > 0)
                {
                    hatchY2 = 220 - _zk.Layers[i - 1].Depth / scale * 1000;
                }
                else
                {
                    hatchY2 = 220;
                }

                try
                {
                    string s = _zk.Layers[i].Name;
                    if (s.Contains("黏"))
                    {
                        s = s.Replace("黏", "粘");
                    }
                    AddRecHatch(HatchTrans(s), 62 + xDis, hatchY1, 77 + xDis, hatchY2);
                }
                catch
                {
                    AddRecHatch("SOLID", 62 + xDis, hatchY1, 77 + xDis, hatchY2);
                }

                // 岩土描述
                double presY = hatchY2 - 0.7;

                DxfMText t = AddMText(_zk.Layers[i].Name + ":" + _zk.Layers[i].Description, 78 + xDis, presY, 54.5, 1.5, _style1);
                t.AttachmentPoint = AttachmentPoint.TopLeft;
            }

            // 绘制标贯/动探
            for (int i = 0; i < _zk.NTests.Count; i++)
            {
                double drawY = 220 - _zk.NTests[i].Depth / scale * 1000;

                AddLine(131.5 + xDis, drawY, 151.5 + xDis, drawY);
                AddMText(_zk.NTests[i].Value.ToString("0"), 141.5 + xDis, drawY + 2, 20, 2.5, _style1);
                AddMText(_zk.NTests[i].Depth.ToString("0.00"), 141.5 + xDis, drawY - 2, 20, 2.5, _style1);
            }

            // 绘制取样
            for (int i = 0; i < _zk.Samples.Count; i++)
            {
                double drawY = 220 - _zk.Samples[i].Depth * 1000 / scale;

                AddLine(151.5 + xDis, drawY, 171.5 + xDis, drawY);
                AddMText(_zk.Samples[i].Name, 161.5 + xDis, drawY + 2, 20, 2.5, _style1);
                AddMText(_zk.Samples[i].Depth.ToString("0.00"), 161.5 + xDis, drawY - 2, 20, 2.5, _style1);
            }

            // 绘制人员信息
            AddMText(_company[2], 44 + xDis, 13, 10, 2.5, _style1);
            AddMText(_company[4], 82 + xDis, 13, 10, 2.5, _style1);
            AddMText(_company[5], 118 + xDis, 13, 10, 2.5, _style1);
            AddMText(_company[6], 156 + xDis, 13, 10, 2.5, _style1);

            // 绘制剖面图钻孔
            double distanceY = 280;

            for (int i = 0; i < _scaleList.Count; i++)
            {
                // 计算绘图起始位置
                distanceY = distanceY + 40 + _zk.Layers[_zk.Layers.Count - 1].Depth * 1000 / _scaleList[i];

                // 绘制钻孔编号、孔口高程、钻孔轴线
                AddLine(124 + xDis, distanceY + 10, 136 + xDis, distanceY + 10);
                AddMText(_zk.Name, 130 + xDis, distanceY + 13.5, 12, 4, _style2);
                AddMText(_zk.Altitude.ToString("0.00"), 130 + xDis, distanceY + 7, 12, 4, _style2);
                DxfPolyline2D l = AddLine(130 + xDis, distanceY, 130 + xDis, distanceY - _zk.Layers[_zk.Layers.Count - 1].Depth * 1000 / _scaleList[i]);
                l.LineWeight = 50;

                // 绘制分层
                for (int j = 0; j < _zk.Layers.Count; j++)
                {
                    double layerY    = distanceY - _zk.Layers[j].Depth * 1000 / _scaleList[i];
                    double layerYold = distanceY;
                    if (j > 0)
                    {
                        layerYold = distanceY - _zk.Layers[j - 1].Depth * 1000 / _scaleList[i];
                    }

                    if (j < _zk.Layers.Count - 1)
                    {
                        AddLine(120 + xDis, layerY, 130 + xDis, layerY);
                    }
                    DxfMText text = AddMText(_zk.Layers[j].Depth.ToString("0.00") + "(" + (_zk.Altitude - _zk.Layers[j].Depth).ToString("0.00") + ")", 132 + xDis, layerY, 25, 3, _style2);
                    text.AttachmentPoint = AttachmentPoint.MiddleLeft;

                    try
                    {
                        string s = _zk.Layers[j].Name;
                        if (s.Contains("黏"))
                        {
                            s = s.Replace("黏", "粘");
                        }
                        AddRecHatch(HatchTrans(s), 120 + xDis, layerY, 130 + xDis, layerYold);
                    }
                    catch
                    {
                        AddRecHatch("SOLID", 120 + xDis, layerY, 130 + xDis, layerYold);
                    }
                }

                // 绘制取样
                for (int j = 0; j < _zk.Samples.Count; j++)
                {
                    double sampleY = distanceY - _zk.Samples[j].Depth * 1000 / _scaleList[i];

                    if (_zk.Samples[j].IsDisturbed)
                    {
                        AddCircle(127.5 + xDis, sampleY, 1, false);
                    }
                    else
                    {
                        AddCircle(127.5 + xDis, sampleY, 1, true);
                    }
                }

                // 绘制标贯/动探
                for (int j = 0; j < _zk.NTests.Count; j++)
                {
                    double bgY = distanceY - _zk.NTests[j].Depth * 1000 / _scaleList[i];

                    DxfMText text = AddMText(_zk.NTests[j].Type.ToString() + "=" + _zk.NTests[j].Value, 120.5 + xDis, bgY, 6, 2.5, _style2);
                    text.AttachmentPoint = AttachmentPoint.MiddleLeft;
                }

                // 绘制比例尺标记
                double scY = distanceY - _zk.Layers[_zk.Layers.Count - 1].Depth * 1000 / _scaleList[i] / 2;

                DxfMText t = AddMText("1:" + _scaleList[i], 20 + xDis, scY, 80, 20, _style2);
                t.AttachmentPoint = AttachmentPoint.MiddleLeft;
            }
        }
Example #4
0
        /// <summary>
        /// 带参数的构造函数,选取某钻孔时调用
        /// </summary>
        /// <param name="_selectedZk">所选钻孔</param>
        public BoreholeControl(Borehole _selectedZk)
        {
            InitializeComponent();

            // 设置当前为旧钻孔,设置删除按钮可用性
            this.DeleteZkButton.IsEnabled = true;
            isNewZk   = false;
            oldZkName = _selectedZk.Name;

            // 初始化DataTable
            InitialLayerListDataTable();
            InitialSampleListDataTable();
            InitialNTestListDataTable();

            // 定义各输入框的工具提示
            DefineToolTip();

            // 设置绑定
            this.LayerListDataGrid.DataContext  = dtLayer;
            this.SampleListDataGrid.DataContext = dtSample;
            this.NTestListDataGrid.DataContext  = dtNTest;

            // 赋值基本信息
            this.ZKNameTextBox.Text            = _selectedZk.Name;
            this.ZKAltitudeTextBox.Text        = _selectedZk.Altitude.ToString();
            this.AxisXTextBox.Text             = _selectedZk.X.ToString() != "-0.19880205" ? _selectedZk.X.ToString() : null;
            this.AxisYTextBox.Text             = _selectedZk.Y.ToString() != "-0.19880205" ? _selectedZk.Y.ToString() : null;
            this.InitialWaterLevelTextBox.Text = _selectedZk.InitialWaterLevel.ToString() != "-0.19880205" ? _selectedZk.InitialWaterLevel.ToString() : null;
            this.StableWaterLevelTextBox.Text  = _selectedZk.StableWaterLevel.ToString() != "-0.19880205" ? _selectedZk.StableWaterLevel.ToString() : null;

            // 赋值分层列表
            for (int i = 0; i < _selectedZk.Layers.Count; i++)
            {
                string number      = _selectedZk.Layers[i].Number;
                string name        = _selectedZk.Layers[i].Name;
                string geo         = _selectedZk.Layers[i].Geo;
                string description = _selectedZk.Layers[i].Description;
                double depth       = _selectedZk.Layers[i].Depth;
                AddRowToLayerListDataTable(number, name, geo, depth, description);
            }

            // 赋值取样列表
            for (int i = 0; i < _selectedZk.Samples.Count; i++)
            {
                string name        = _selectedZk.Samples[i].Name;
                double depth       = _selectedZk.Samples[i].Depth;
                bool   isDisturbed = _selectedZk.Samples[i].IsDisturbed;
                AddRowToSampleListDataTable(name, depth, isDisturbed);
            }

            // 赋值标贯/动探列表
            for (int i = 0; i < _selectedZk.NTests.Count; i++)
            {
                string        name  = _selectedZk.NTests[i].Name;
                double        depth = _selectedZk.NTests[i].Depth;
                double        value = _selectedZk.NTests[i].Value;
                ZkNTest.ntype type  = _selectedZk.NTests[i].Type;
                AddRowToNTestListDataTable(name, depth, value, type);
            }

            // 更新状态标签
            this.IsChangedTextBlock.Text = "";

            // 绘图
            DrawZk();
        }