diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 70ab332..f43fc8f 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 70ab332..f43fc8f 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FrmHDMAnalysis3.cs b/FrmHDMAnalysis3.cs index e3f526b..1c33707 100644 --- a/FrmHDMAnalysis3.cs +++ b/FrmHDMAnalysis3.cs @@ -6,11 +6,11 @@ using System.Text; using System.Windows.Forms; using DevComponents.DotNetBar; - using System.Collections; using GeoScene.Globe; using GeoScene.Data; using System.Windows.Forms.DataVisualization.Charting; +using System.Linq; namespace Cyberpipe { @@ -28,15 +28,20 @@ GSOGlobeControl globeControl1; object[,] sortIndex; GSOLayer layerTemp; - private FrmHDMAnalysis3() + private int curAxisXSize = 0; + + List zList = new List(); + + private FrmHDMAnalysis3() { - + } + public static FrmHDMAnalysis3 GetForm(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line, GSOGlobeControl _ctl) { if (allPipelineAnalysis == null) { - allPipelineAnalysis = new FrmHDMAnalysis3(arraylistP, arraylistF, _line,_ctl); + allPipelineAnalysis = new FrmHDMAnalysis3(arraylistP, arraylistF, _line, _ctl); } else { @@ -44,19 +49,28 @@ allPipelineAnalysis.listFeat = arraylistF; allPipelineAnalysis.line = _line; allPipelineAnalysis.globeControl1 = _ctl; - list = new ArrayList(); + list = new ArrayList(); } return allPipelineAnalysis; } - public FrmHDMAnalysis3(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line,GSOGlobeControl _ctl) + public FrmHDMAnalysis3(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line, GSOGlobeControl _ctl) { InitializeComponent(); listPoint = arraylistP; listFeat = arraylistF; line = _line; globeControl1 = _ctl; + + for (int i = 0; i < listPoint.Count; i++) + { + GSOPoint3d geoPoint = (GSOPoint3d)listPoint[i]; + + zList.Add(Convert.ToInt32(Math.Ceiling(geoPoint.Z))); + } + } + double A_x, A_y, B_x, B_y;//定义坐标点,用来就横断面的长度 /// /// 窗体初始化事件处理 @@ -76,8 +90,8 @@ void Frm_HDMAnalysis2_Shown(object sender, EventArgs e) { isShowFirst = true; - } + public void LoadChartEvent() { try @@ -90,19 +104,25 @@ chart1.Series["管线"].MarkerStyle = MarkerStyle.Circle; //点的类型 chart1.Series["管线"].MarkerBorderColor = Color.Black; //点的边框颜色 - chart1.ChartAreas[0].AxisX.Minimum = 0; //x轴的起始点大小 - chart1.ChartAreas[0].AxisY.Maximum = 0; //y轴的最大值 + ChartYDraw(zList.Min() - 1, zList.Max()); - chart1.ChartAreas[0].AxisX.Title = "距离 (米)"; + chart1.ChartAreas[0].AxisX.Title = "距离 (米)"; chart1.ChartAreas[0].AxisY.Title = "埋深 (米)"; - + + + chart1.ChartAreas[0].CursorX.IsUserEnabled = true; + chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; + chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = false; + chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;//启用X轴滚动条按钮 + + chart1.ChartAreas[0].AxisY2.Title = "高程 (米)"; double[] depths = new double[listFeat.Count]; for (int i = 0; i < listFeat.Count; i++) { GSOFeature f = listFeat[i] as GSOFeature; - double depth = f.GetFieldAsDouble("起始地面高程"); + double depth = f.GetFieldAsDouble("起始埋深"); depths[i] = depth; } double max_Depth = depths[0]; @@ -113,6 +133,7 @@ max_Depth = depths[i]; } } + chart1.ChartAreas[0].AxisY2.CustomLabels.Clear(); chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-5.4d, -5.6d, (max_Depth - 5.5).ToString("0.0")); chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-4.9d, -5.1d, (max_Depth - 5).ToString("0.0")); @@ -142,29 +163,30 @@ } catch (Exception ex) { - MessageBox.Show(ex.ToString()); + //LogError.PublishError(ex); } } - + /// /// 创建图表 /// /// /// - private void DrawCurveGraph(double a_x,double a_y) + private void DrawCurveGraph(double a_x, double a_y) { + // 遍历线,求距离 table = new DataTable(); //showTable.Columns.Clear(); list.Clear(); chart1.Series["管线"].Points.Clear(); - chart1.ChartAreas[0].AxisX.Maximum = Math.Round(line.GetSpaceLength(true, 6378137),2); + chart1.ChartAreas[0].AxisX.Maximum = Math.Round(line.GetSpaceLength(true, 6378137), 2); table.Columns.Add("编号", typeof(string)); table.Columns.Add("管线类型", typeof(string)); table.Columns.Add("管线编码", typeof(string)); table.Columns.Add("管径_毫米", typeof(string)); table.Columns.Add("材质", typeof(string)); - table.Columns.Add("管线埋深", typeof(string)); + table.Columns.Add("管线埋深", typeof(string)); sortIndex = new object[listPoint.Count, 2]; for (int i = 0; i <= listPoint.Count; i++) @@ -180,7 +202,7 @@ } } chart1.Series["管线"].Points.AddXY(maxNum + 2, 0); - chart1.Series["管线"].Points[i].MarkerBorderWidth = 0; //边框的宽度 + chart1.Series["管线"].Points[i].MarkerBorderWidth = 0;//边框的宽度 chart1.Series["管线"].Points[i].MarkerColor = Color.Transparent; chart1.Series["管线"].Points[i].MarkerSize = 0; continue; @@ -199,47 +221,56 @@ double x = Math.Abs(B_x - a_Point.X); double y = Math.Abs(B_y - a_Point.Y); - double dis = Math.Round(Math.Sqrt(x * x + y * y) , 2); + double Dis = 0.0; + Dis = Math.Round(Math.Sqrt(x * x + y * y), 2); list.Add(geoPoint.Z); - sortIndex[i, 0] = dis; + sortIndex[i, 0] = Dis; sortIndex[i, 1] = i; - chart1.Series["管线"].Points.AddXY(dis, geoPoint.Z);//绑定数据 + chart1.Series["管线"].Points.AddXY(Dis, geoPoint.Z);//绑定数据 - string pipeType = feature.Dataset == null ? "" : feature.Dataset.Caption; + + //录视频 + //double z = geoPoint.Z-458; + //chart1.Series["管线"].Points.AddXY(Dis, z); + + + string pipeType = feature.Dataset == null ? "" : feature.Dataset.Caption; string number = Convert.ToString(i + 1); - + string material = feature.GetFieldAsString("材质"); string diameter = feature.GetFieldAsString("管径_毫米"); string value = ""; try {//解决有的数字太小,转换不成功的问题 - value = Convert.ToDecimal(list[i].ToString()).ToString("f2"); + value = Convert.ToDecimal(list[i].ToString()).ToString("f2"); } catch (Exception e) { value = "0.00"; } - table.Rows.Add(new object[] { number, pipeType, feature.Name.ToString(), diameter, material,value});//list[i].ToString().Substring(0,list[i].ToString().IndexOf('.')+3) } + table.Rows.Add(new object[] { number, pipeType, feature.Name.ToString(), diameter, material, value });//list[i].ToString().Substring(0,list[i].ToString().IndexOf('.')+3) } //chart1.Series["管线"].Points[i].Label = number;//管线的标签 chart1.Series["管线"].Points[i].LegendText = number; if (feature.Geometry.Style.GetType() == typeof(GSOPipeLineStyle3D)) { GSOPipeLineStyle3D style = (GSOPipeLineStyle3D)feature.Geometry.Style; - chart1.Series["管线"].Points[i].MarkerBorderColor = style.LineColor; //点的填充色 + chart1.Series["管线"].Points[i].MarkerBorderColor = style.LineColor;//点的填充色 } else { chart1.Series["管线"].Points[i].MarkerBorderColor = Color.Black; } - chart1.Series["管线"].Points[i].MarkerBorderWidth = 3; //边框的宽度 + chart1.Series["管线"].Points[i].MarkerBorderWidth = 3;//边框的宽度 chart1.Series["管线"].Points[i].MarkerColor = Color.Transparent; - int scope = (int)chart1.ChartAreas[0].AxisX.Maximum > 100 ? (int)chart1.ChartAreas[0].AxisX.Maximum : 100; - chart1.Series["管线"].Points[i].MarkerSize = Convert.ToInt32(Math.Floor((feature.GetFieldAsDouble("管径_毫米") / 0.35 + chart1.Series["管线"].Points[i].MarkerBorderWidth)/scope));//点的大小 -// chart1.Series["管线"].Points[i].MarkerSize = Convert.ToInt32(Math.Floor((feature.GetFieldAsDouble("管径_毫米") / 0.35 + chart1.Series["管线"].Points[i].MarkerBorderWidth) / 100.0));//点的大小 - + curAxisXSize = (int)chart1.ChartAreas[0].AxisX.Maximum + 1; + + int markerSize = ComputeMarkerSize(feature.GetFieldAsDouble("管径_毫米")); + chart1.Series["管线"].Points[i].MarkerSize = markerSize;//点的大小 + // chart1.Series["管线"].Points[i].MarkerSize = Convert.ToInt32(Math.Floor((feature.GetFieldAsDouble("管径_毫米") / 0.35 + chart1.Series["管线"].Points[i].MarkerBorderWidth) / 100.0));//点的大小 + } string htmlCode = "" + "" + - "" + + "" + "
管线类型管线编码管径_毫米材质管线埋深
材质管线高程
" + "" + "" + - "" + + "" + "" + "
"; webBrowser1.DocumentText = htmlCode; + } + + private void ChartYDraw(double minY, double maxY) + { + chart1.ChartAreas[0].AxisY.Minimum = minY; + chart1.ChartAreas[0].AxisY.Maximum = maxY; + } + /// /// 图表的鼠标单击事件处理 /// @@ -286,7 +325,7 @@ /// private void chart1_MouseClick(object sender, MouseEventArgs e) { - HitTestResult result = chart1.HitTest(e.X, e.Y, true); + HitTestResult result = chart1.HitTest(e.X, e.Y, true); if (result.PointIndex >= 0) { DataPoint p = (DataPoint)result.Object; @@ -331,7 +370,7 @@ "color:#000099;}" + "" + "" + - "" + + "" + "
管线类型管线编码管径_毫米材质管线埋深
材质管线高程
" + row[1] + "" + row[2] + "" + row[3] + @@ -362,14 +401,7 @@ { HitTestResult result = chart1.HitTest(e.X, e.Y, true); //Cursor cr = this.Cursor; - if (result.PointIndex >= 0) - { - Cursor = Cursors.Hand; - } - else - { - Cursor = Cursors.Default; - } + Cursor = result.PointIndex >= 0 ? Cursors.Hand : Cursors.Default; } /// /// 导出CAD按钮事件处理 @@ -424,7 +456,7 @@ newLine.AddPart(points); newLine.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSOFeature newFeature = new GSOFeature(); - newFeature.Geometry = newLine; + newFeature.Geometry = newLine; globeControl1.Globe.MemoryLayer.AddFeature(newFeature); } @@ -448,7 +480,76 @@ f.Geometry = line; f.Geometry.LatLonCoord = false; f.Visible = false; - layerTemp.AddFeature(f); + layerTemp.AddFeature(f); + } + //局部放大 + private void chart1_SelectionRangeChanged(object sender, CursorEventArgs e) + { + if (chart1.Series[0].Points.Count == 0) + return; + double startPosition = 0.0; + double endPosition = 0.0; + double myInterval = 0.0; + startPosition = e.NewSelectionStart; + endPosition = e.NewSelectionEnd; + myInterval = Math.Abs(startPosition - endPosition); + if (myInterval.Equals(0.0)) + return; + + //X轴视图起点 + chart1.ChartAreas[0].AxisX.ScaleView.Position = Math.Min(startPosition, endPosition); + //X轴视图长度 + chart1.ChartAreas[0].AxisX.ScaleView.Size = myInterval; + //X轴间隔 + chart1.ChartAreas[0].AxisX.Interval = myInterval < 11.0 ? 1 : Math.Floor(myInterval / 10); + + curAxisXSize = (int)myInterval; + for (int i = 0; i < chart1.Series[0].Points.Count; i++) + { + DataPoint p = chart1.Series[0].Points[i]; + if (p == null) + { + continue; + } + string number = p.LegendText; + int indexInTableRows = 0; + bool isInt = int.TryParse(number, out indexInTableRows); + if (!isInt) continue; + DataRow row = table.Rows[indexInTableRows - 1]; + double diameter = Double.Parse(row[3].ToString()); + int markerSize = ComputeMarkerSize(diameter); + chart1.Series[0].Points[i].MarkerSize = markerSize;//点的大小 + } + + + + } + //恢复大小 + private void chart1_AxisScrollBarClicked(object sender, ScrollBarEventArgs e) + { + if (e.ButtonType == ScrollBarButtonType.ZoomReset) + { + chart1.ChartAreas[0].AxisX.Interval = 0; + } + curAxisXSize = (int)chart1.ChartAreas[0].AxisX.Maximum; + for (int i = 0; i < listPoint.Count; i++) + { + GSOFeature feature = listFeat[i] as GSOFeature; + if (feature == null) continue; + double diameter = feature.GetFieldAsDouble("管径_毫米"); + int markerSize = ComputeMarkerSize(diameter); + chart1.Series["管线"].Points[i].MarkerSize = markerSize;//点的大小 + } + } + + private int ComputeMarkerSize(double diameter) + { + int scope = curAxisXSize < 50 ? 50 : curAxisXSize; + int markerSize = + Convert.ToInt32( + Math.Floor(diameter / (0.35 * scope))); + markerSize = markerSize < 5 ? 5 : markerSize; + return markerSize; } } } \ No newline at end of file diff --git a/Cyberpipe.suo b/Cyberpipe.suo index 70ab332..f43fc8f 100644 --- a/Cyberpipe.suo +++ b/Cyberpipe.suo Binary files differ diff --git a/FrmHDMAnalysis3.cs b/FrmHDMAnalysis3.cs index e3f526b..1c33707 100644 --- a/FrmHDMAnalysis3.cs +++ b/FrmHDMAnalysis3.cs @@ -6,11 +6,11 @@ using System.Text; using System.Windows.Forms; using DevComponents.DotNetBar; - using System.Collections; using GeoScene.Globe; using GeoScene.Data; using System.Windows.Forms.DataVisualization.Charting; +using System.Linq; namespace Cyberpipe { @@ -28,15 +28,20 @@ GSOGlobeControl globeControl1; object[,] sortIndex; GSOLayer layerTemp; - private FrmHDMAnalysis3() + private int curAxisXSize = 0; + + List zList = new List(); + + private FrmHDMAnalysis3() { - + } + public static FrmHDMAnalysis3 GetForm(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line, GSOGlobeControl _ctl) { if (allPipelineAnalysis == null) { - allPipelineAnalysis = new FrmHDMAnalysis3(arraylistP, arraylistF, _line,_ctl); + allPipelineAnalysis = new FrmHDMAnalysis3(arraylistP, arraylistF, _line, _ctl); } else { @@ -44,19 +49,28 @@ allPipelineAnalysis.listFeat = arraylistF; allPipelineAnalysis.line = _line; allPipelineAnalysis.globeControl1 = _ctl; - list = new ArrayList(); + list = new ArrayList(); } return allPipelineAnalysis; } - public FrmHDMAnalysis3(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line,GSOGlobeControl _ctl) + public FrmHDMAnalysis3(ArrayList arraylistP, ArrayList arraylistF, GSOGeoPolyline3D _line, GSOGlobeControl _ctl) { InitializeComponent(); listPoint = arraylistP; listFeat = arraylistF; line = _line; globeControl1 = _ctl; + + for (int i = 0; i < listPoint.Count; i++) + { + GSOPoint3d geoPoint = (GSOPoint3d)listPoint[i]; + + zList.Add(Convert.ToInt32(Math.Ceiling(geoPoint.Z))); + } + } + double A_x, A_y, B_x, B_y;//定义坐标点,用来就横断面的长度 /// /// 窗体初始化事件处理 @@ -76,8 +90,8 @@ void Frm_HDMAnalysis2_Shown(object sender, EventArgs e) { isShowFirst = true; - } + public void LoadChartEvent() { try @@ -90,19 +104,25 @@ chart1.Series["管线"].MarkerStyle = MarkerStyle.Circle; //点的类型 chart1.Series["管线"].MarkerBorderColor = Color.Black; //点的边框颜色 - chart1.ChartAreas[0].AxisX.Minimum = 0; //x轴的起始点大小 - chart1.ChartAreas[0].AxisY.Maximum = 0; //y轴的最大值 + ChartYDraw(zList.Min() - 1, zList.Max()); - chart1.ChartAreas[0].AxisX.Title = "距离 (米)"; + chart1.ChartAreas[0].AxisX.Title = "距离 (米)"; chart1.ChartAreas[0].AxisY.Title = "埋深 (米)"; - + + + chart1.ChartAreas[0].CursorX.IsUserEnabled = true; + chart1.ChartAreas[0].CursorX.IsUserSelectionEnabled = true; + chart1.ChartAreas[0].AxisX.ScaleView.Zoomable = false; + chart1.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;//启用X轴滚动条按钮 + + chart1.ChartAreas[0].AxisY2.Title = "高程 (米)"; double[] depths = new double[listFeat.Count]; for (int i = 0; i < listFeat.Count; i++) { GSOFeature f = listFeat[i] as GSOFeature; - double depth = f.GetFieldAsDouble("起始地面高程"); + double depth = f.GetFieldAsDouble("起始埋深"); depths[i] = depth; } double max_Depth = depths[0]; @@ -113,6 +133,7 @@ max_Depth = depths[i]; } } + chart1.ChartAreas[0].AxisY2.CustomLabels.Clear(); chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-5.4d, -5.6d, (max_Depth - 5.5).ToString("0.0")); chart1.ChartAreas[0].AxisY2.CustomLabels.Add(-4.9d, -5.1d, (max_Depth - 5).ToString("0.0")); @@ -142,29 +163,30 @@ } catch (Exception ex) { - MessageBox.Show(ex.ToString()); + //LogError.PublishError(ex); } } - + /// /// 创建图表 /// /// /// - private void DrawCurveGraph(double a_x,double a_y) + private void DrawCurveGraph(double a_x, double a_y) { + // 遍历线,求距离 table = new DataTable(); //showTable.Columns.Clear(); list.Clear(); chart1.Series["管线"].Points.Clear(); - chart1.ChartAreas[0].AxisX.Maximum = Math.Round(line.GetSpaceLength(true, 6378137),2); + chart1.ChartAreas[0].AxisX.Maximum = Math.Round(line.GetSpaceLength(true, 6378137), 2); table.Columns.Add("编号", typeof(string)); table.Columns.Add("管线类型", typeof(string)); table.Columns.Add("管线编码", typeof(string)); table.Columns.Add("管径_毫米", typeof(string)); table.Columns.Add("材质", typeof(string)); - table.Columns.Add("管线埋深", typeof(string)); + table.Columns.Add("管线埋深", typeof(string)); sortIndex = new object[listPoint.Count, 2]; for (int i = 0; i <= listPoint.Count; i++) @@ -180,7 +202,7 @@ } } chart1.Series["管线"].Points.AddXY(maxNum + 2, 0); - chart1.Series["管线"].Points[i].MarkerBorderWidth = 0; //边框的宽度 + chart1.Series["管线"].Points[i].MarkerBorderWidth = 0;//边框的宽度 chart1.Series["管线"].Points[i].MarkerColor = Color.Transparent; chart1.Series["管线"].Points[i].MarkerSize = 0; continue; @@ -199,47 +221,56 @@ double x = Math.Abs(B_x - a_Point.X); double y = Math.Abs(B_y - a_Point.Y); - double dis = Math.Round(Math.Sqrt(x * x + y * y) , 2); + double Dis = 0.0; + Dis = Math.Round(Math.Sqrt(x * x + y * y), 2); list.Add(geoPoint.Z); - sortIndex[i, 0] = dis; + sortIndex[i, 0] = Dis; sortIndex[i, 1] = i; - chart1.Series["管线"].Points.AddXY(dis, geoPoint.Z);//绑定数据 + chart1.Series["管线"].Points.AddXY(Dis, geoPoint.Z);//绑定数据 - string pipeType = feature.Dataset == null ? "" : feature.Dataset.Caption; + + //录视频 + //double z = geoPoint.Z-458; + //chart1.Series["管线"].Points.AddXY(Dis, z); + + + string pipeType = feature.Dataset == null ? "" : feature.Dataset.Caption; string number = Convert.ToString(i + 1); - + string material = feature.GetFieldAsString("材质"); string diameter = feature.GetFieldAsString("管径_毫米"); string value = ""; try {//解决有的数字太小,转换不成功的问题 - value = Convert.ToDecimal(list[i].ToString()).ToString("f2"); + value = Convert.ToDecimal(list[i].ToString()).ToString("f2"); } catch (Exception e) { value = "0.00"; } - table.Rows.Add(new object[] { number, pipeType, feature.Name.ToString(), diameter, material,value});//list[i].ToString().Substring(0,list[i].ToString().IndexOf('.')+3) } + table.Rows.Add(new object[] { number, pipeType, feature.Name.ToString(), diameter, material, value });//list[i].ToString().Substring(0,list[i].ToString().IndexOf('.')+3) } //chart1.Series["管线"].Points[i].Label = number;//管线的标签 chart1.Series["管线"].Points[i].LegendText = number; if (feature.Geometry.Style.GetType() == typeof(GSOPipeLineStyle3D)) { GSOPipeLineStyle3D style = (GSOPipeLineStyle3D)feature.Geometry.Style; - chart1.Series["管线"].Points[i].MarkerBorderColor = style.LineColor; //点的填充色 + chart1.Series["管线"].Points[i].MarkerBorderColor = style.LineColor;//点的填充色 } else { chart1.Series["管线"].Points[i].MarkerBorderColor = Color.Black; } - chart1.Series["管线"].Points[i].MarkerBorderWidth = 3; //边框的宽度 + chart1.Series["管线"].Points[i].MarkerBorderWidth = 3;//边框的宽度 chart1.Series["管线"].Points[i].MarkerColor = Color.Transparent; - int scope = (int)chart1.ChartAreas[0].AxisX.Maximum > 100 ? (int)chart1.ChartAreas[0].AxisX.Maximum : 100; - chart1.Series["管线"].Points[i].MarkerSize = Convert.ToInt32(Math.Floor((feature.GetFieldAsDouble("管径_毫米") / 0.35 + chart1.Series["管线"].Points[i].MarkerBorderWidth)/scope));//点的大小 -// chart1.Series["管线"].Points[i].MarkerSize = Convert.ToInt32(Math.Floor((feature.GetFieldAsDouble("管径_毫米") / 0.35 + chart1.Series["管线"].Points[i].MarkerBorderWidth) / 100.0));//点的大小 - + curAxisXSize = (int)chart1.ChartAreas[0].AxisX.Maximum + 1; + + int markerSize = ComputeMarkerSize(feature.GetFieldAsDouble("管径_毫米")); + chart1.Series["管线"].Points[i].MarkerSize = markerSize;//点的大小 + // chart1.Series["管线"].Points[i].MarkerSize = Convert.ToInt32(Math.Floor((feature.GetFieldAsDouble("管径_毫米") / 0.35 + chart1.Series["管线"].Points[i].MarkerBorderWidth) / 100.0));//点的大小 + } string htmlCode = "" + "" + - "" + + "" + "
管线类型管线编码管径_毫米材质管线埋深
材质管线高程
" + "" + "" + - "" + + "" + "" + "
"; webBrowser1.DocumentText = htmlCode; + } + + private void ChartYDraw(double minY, double maxY) + { + chart1.ChartAreas[0].AxisY.Minimum = minY; + chart1.ChartAreas[0].AxisY.Maximum = maxY; + } + /// /// 图表的鼠标单击事件处理 /// @@ -286,7 +325,7 @@ /// private void chart1_MouseClick(object sender, MouseEventArgs e) { - HitTestResult result = chart1.HitTest(e.X, e.Y, true); + HitTestResult result = chart1.HitTest(e.X, e.Y, true); if (result.PointIndex >= 0) { DataPoint p = (DataPoint)result.Object; @@ -331,7 +370,7 @@ "color:#000099;}" + "" + "" + - "" + + "" + "
管线类型管线编码管径_毫米材质管线埋深
材质管线高程
" + row[1] + "" + row[2] + "" + row[3] + @@ -362,14 +401,7 @@ { HitTestResult result = chart1.HitTest(e.X, e.Y, true); //Cursor cr = this.Cursor; - if (result.PointIndex >= 0) - { - Cursor = Cursors.Hand; - } - else - { - Cursor = Cursors.Default; - } + Cursor = result.PointIndex >= 0 ? Cursors.Hand : Cursors.Default; } /// /// 导出CAD按钮事件处理 @@ -424,7 +456,7 @@ newLine.AddPart(points); newLine.AltitudeMode = EnumAltitudeMode.RelativeToGround; GSOFeature newFeature = new GSOFeature(); - newFeature.Geometry = newLine; + newFeature.Geometry = newLine; globeControl1.Globe.MemoryLayer.AddFeature(newFeature); } @@ -448,7 +480,76 @@ f.Geometry = line; f.Geometry.LatLonCoord = false; f.Visible = false; - layerTemp.AddFeature(f); + layerTemp.AddFeature(f); + } + //局部放大 + private void chart1_SelectionRangeChanged(object sender, CursorEventArgs e) + { + if (chart1.Series[0].Points.Count == 0) + return; + double startPosition = 0.0; + double endPosition = 0.0; + double myInterval = 0.0; + startPosition = e.NewSelectionStart; + endPosition = e.NewSelectionEnd; + myInterval = Math.Abs(startPosition - endPosition); + if (myInterval.Equals(0.0)) + return; + + //X轴视图起点 + chart1.ChartAreas[0].AxisX.ScaleView.Position = Math.Min(startPosition, endPosition); + //X轴视图长度 + chart1.ChartAreas[0].AxisX.ScaleView.Size = myInterval; + //X轴间隔 + chart1.ChartAreas[0].AxisX.Interval = myInterval < 11.0 ? 1 : Math.Floor(myInterval / 10); + + curAxisXSize = (int)myInterval; + for (int i = 0; i < chart1.Series[0].Points.Count; i++) + { + DataPoint p = chart1.Series[0].Points[i]; + if (p == null) + { + continue; + } + string number = p.LegendText; + int indexInTableRows = 0; + bool isInt = int.TryParse(number, out indexInTableRows); + if (!isInt) continue; + DataRow row = table.Rows[indexInTableRows - 1]; + double diameter = Double.Parse(row[3].ToString()); + int markerSize = ComputeMarkerSize(diameter); + chart1.Series[0].Points[i].MarkerSize = markerSize;//点的大小 + } + + + + } + //恢复大小 + private void chart1_AxisScrollBarClicked(object sender, ScrollBarEventArgs e) + { + if (e.ButtonType == ScrollBarButtonType.ZoomReset) + { + chart1.ChartAreas[0].AxisX.Interval = 0; + } + curAxisXSize = (int)chart1.ChartAreas[0].AxisX.Maximum; + for (int i = 0; i < listPoint.Count; i++) + { + GSOFeature feature = listFeat[i] as GSOFeature; + if (feature == null) continue; + double diameter = feature.GetFieldAsDouble("管径_毫米"); + int markerSize = ComputeMarkerSize(diameter); + chart1.Series["管线"].Points[i].MarkerSize = markerSize;//点的大小 + } + } + + private int ComputeMarkerSize(double diameter) + { + int scope = curAxisXSize < 50 ? 50 : curAxisXSize; + int markerSize = + Convert.ToInt32( + Math.Floor(diameter / (0.35 * scope))); + markerSize = markerSize < 5 ? 5 : markerSize; + return markerSize; } } } \ No newline at end of file diff --git a/FrmHDMAnalysis3.designer.cs b/FrmHDMAnalysis3.designer.cs index cf42ffa..3c13ebb 100644 --- a/FrmHDMAnalysis3.designer.cs +++ b/FrmHDMAnalysis3.designer.cs @@ -102,6 +102,8 @@ this.chart1.Size = new System.Drawing.Size(614, 328); this.chart1.TabIndex = 0; this.chart1.Text = "chart1"; + this.chart1.SelectionRangeChanged += new System.EventHandler(this.chart1_SelectionRangeChanged); + this.chart1.AxisScrollBarClicked += new System.EventHandler(this.chart1_AxisScrollBarClicked); this.chart1.MouseClick += new System.Windows.Forms.MouseEventHandler(this.chart1_MouseClick); this.chart1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.chart1_MouseMove); //