public static void Remove_Redundant_Point(LJJSPoint startPoint, List <LJJSPoint> list) { /** * Comparison<LJJSPoint> Sort_Dele = (a, b) => * { * * if (a.YValue > b.YValue) * { * return 1; * } * else if (a.YValue == b.YValue) * { * return 0; * } * else * { * return -1; * } * };**/ List <LJJSPoint> redund_list = MsehAndMsevContainer.same_YValue_PointsList(list); //redund_list.Sort(Sort_Dele); AddLineHatchManager.my_list_LJJSPOint_sort(redund_list); for (int ss = 0; ss < redund_list.Count - 1; ss++) { if (redund_list[ss].YValue == redund_list[ss + 1].YValue) { list.Remove(redund_list[ss]); } } //list.Sort(Sort_Dele); AddLineHatchManager.my_list_LJJSPOint_sort(list); }
public static void wrong_Point_exterminate(LJJSPoint startPoint, List <LJJSPoint> list) { List <LJJSPoint> Remove_wrong_point_list = new List <LJJSPoint>(); for (int ss = 0; ss < list.Count; ss++) { if (list[ss].YValue > 0 || list[ss].XValue < startPoint.XValue || list[ss].XValue >= startPoint.XValue + 50) { //MessageBox.Show(string.Format("error,坐标:({0},{1})", drawptcol[ss].XValue.ToString(), drawptcol[ss].YValue.ToString())); //GAY if (list[ss].YValue > 0) { Remove_wrong_point_list.Add(list[ss]); continue; } if (list[ss].XValue < startPoint.XValue || list[ss].XValue >= startPoint.XValue + 50) { list[ss].XValue = startPoint.XValue; } } } //GAY foreach (LJJSPoint sss in Remove_wrong_point_list) { list.Remove(sss); } AddLineHatchManager.Remove_Redundant_Point(startPoint, list); //去除具有同yvalue的点 }
private void AddContinuousLineToFigure(JDStruc jdstruc, Hashtable drawht, int index, List <Hashtable> drawhtList) { //fff Color curr_color = AddLineHatchManager.get_Color_By_CurveItemShowName(this.lineItemStruct); if (null == m_KDCList || m_KDCList.Count == 0) { return; } ArrayList al;//完成排序的绘图点; ArrayList al1 = null; if (m_KDCList[0].KStyle == KDCStyle.DuiShu) //对数项; { drawht = HashUtil.MoveHashTableZeroValue(drawht); //去掉数据中的0值; al = HashUtil.GetHastablePaiXuList(drawht); //完成排序的绘图点; if (al.Count < 2) { return; } AddDuiShuContinuousToFigure(m_KDCList[0], al, jdstruc, drawht, curr_color);//添加对数类型折线 return; } else//普通项 { al = HashUtil.GetHastablePaiXuList(drawht);//完成排序的绘图点; 将所有y值即depth由小到大排序 /** * if (drawhtList != null) * { * al1 = HashUtil.GetHastablePaiXuList(drawhtList[1]); * }**/ if (al.Count < 2) { return; } if (lineItemStruct.LiSubClass.Equals("msev") == false && lineItemStruct.LiSubClass.Equals("mseh") == false && lineItemStruct.LiSubClass.Equals("wxcs2") == false && lineItemStruct.LiSubClass.Equals("jgl") == false) { //不是填充垂向功和切向功 或者 填充物性指数交汇和进给量的情况 this.AddNormalContinuousToFigure(al, jdstruc, drawht, curr_color, index); //画边缘线 } //填充物性指数交汇和进给量 #region if (lineItemStruct.LiSubClass.Equals("wxcs2")) { if (DrawPointContainer.list[index].WXCSJiaoHuiList == null) { this.AddNormalContinuousToFigure(al, jdstruc, drawht, curr_color, index); //Blue } if (null != DrawPointContainer.list[index].WXCSJiaoHuiList && null != DrawPointContainer.list[index].JinGeiLiangList) { //Gai Color wxcs_jiaohui_color = AddLineHatchManager.get_Color_By_CurveItemShowName("物性指数交汇"); Color jgl_color = AddLineHatchManager.get_Color_By_CurveItemShowName("进给量"); AddLineHatchManager.Gei_Qu_Xian_De_Jiao_Dian_Nei_Bu_Tu_Se_Quicker(wxcs_jiaohui_color, jgl_color, DrawPointContainer.list[index].WXCSJiaoHuiList, DrawPointContainer.list[index].JinGeiLiangList, lineItemStruct, index); } } if (lineItemStruct.LiSubClass.Equals("jgl")) { if (DrawPointContainer.list[index].JinGeiLiangList == null) { this.AddNormalContinuousToFigure(al, jdstruc, drawht, curr_color, index); // Green } if (null != DrawPointContainer.list[index].WXCSJiaoHuiList && null != DrawPointContainer.list[index].JinGeiLiangList) { //Gai Color wxcs_jiaohui_color = AddLineHatchManager.get_Color_By_CurveItemShowName("物性指数交汇"); Color jgl_color = AddLineHatchManager.get_Color_By_CurveItemShowName("进给量"); AddLineHatchManager.Gei_Qu_Xian_De_Jiao_Dian_Nei_Bu_Tu_Se_Quicker(wxcs_jiaohui_color, jgl_color, DrawPointContainer.list[index].WXCSJiaoHuiList, DrawPointContainer.list[index].JinGeiLiangList, lineItemStruct, index); } } #endregion //填充垂向功和切向功 #region if (lineItemStruct.LiSubClass.Equals("msev")) { if (DrawPointContainer.list[index].msevList == null) { this.AddNormalContinuousToFigure(al, jdstruc, drawht, curr_color, index); } if (null != DrawPointContainer.list[index].msevList && null != DrawPointContainer.list[index].msehList) { //Gai Color msev_color = AddLineHatchManager.get_Color_By_CurveItemShowName("垂向功"); Color mseh_color = AddLineHatchManager.get_Color_By_CurveItemShowName("切向功"); AddLineHatchManager.Gei_Qu_Xian_De_Jiao_Dian_Nei_Bu_Tu_Se_Quicker(mseh_color, msev_color, DrawPointContainer.list[index].msehList, DrawPointContainer.list[index].msevList, lineItemStruct, index); } } if (lineItemStruct.LiSubClass.Equals("mseh")) { if (DrawPointContainer.list[index].msehList == null) { this.AddNormalContinuousToFigure(al, jdstruc, drawht, curr_color, index); } if (null != DrawPointContainer.list[index].msevList && null != DrawPointContainer.list[index].msehList) { //Gai Color mseh_color = AddLineHatchManager.get_Color_By_CurveItemShowName("切向功"); Color msev_color = AddLineHatchManager.get_Color_By_CurveItemShowName("垂向功"); AddLineHatchManager.Gei_Qu_Xian_De_Jiao_Dian_Nei_Bu_Tu_Se_Quicker(mseh_color, msev_color, DrawPointContainer.list[index].msehList, DrawPointContainer.list[index].msevList, lineItemStruct, index); } } #endregion //TO BE DONE string sb = lineItemStruct.LiSubClass; if (lineItemStruct.LiSubClass == "wxcs") //物性指数涂色 { if (this.lrptstartName.Equals("wxcs")) { if (DrawPointContainer.list[index].wxcsList == null) { DrawPointContainer.list[index].wxcsList = new List <LJJSPoint>(); } //suizuan AddLineHatchManager.Gei_Qu_Xian_Tu_Se(al, jdstruc, drawht, DrawPointContainer.list[index].wxcsList, this.lrptstart); //在此给画好的曲线填充颜色 //1118 wxcs this.AddNormalContinuousToFigure(al, jdstruc, drawht, Color.Black, index); //填充颜色后,边缘线消失,需要再画一次 /** * if (drawhtList != null) * { * this.AddNormalContinuousToFigure(al, jdstruc, drawhtList[1], Color.Blue, index,null); * }**/ } else { MessageBox.Show("不知道线道起点坐标,无法显示涂色"); } } } }
public static void Gei_Qu_Xian_De_Jiao_Dian_Nei_Bu_Tu_Se(List <LJJSPoint> line1, List <LJJSPoint> line2, LineItemStruct lineItemStruct, int index) //给曲线交点内部涂色 { if (lineItemStruct.LiSubClass.Equals("wxcs2") || lineItemStruct.LiSubClass.Equals("jgl")) { //物性指数交汇和进给量的数据有问题,其中一个在y值相同时有两个x值,另外一个比另一个多4个点 需要进行处理 if (line1.Count != line2.Count) { List <LJJSPoint> list = MsehAndMsevContainer.findLostPoints(line1, line2);//寻找多出的点 if (DrawPointContainer.list[index].JinGeiLiangList != null) { bool res1 = MsehAndMsevContainer.check_Multi_Same_YValue(line1); bool res2 = MsehAndMsevContainer.check_Multi_Same_YValue(line2); //若为true,则代表具有此list中有两个点的y值相同,x值不同,需要去掉 List <LJJSPoint> same_Y_list; if (res1 == true) { same_Y_list = MsehAndMsevContainer.same_YValue_PointsList(line1); if (same_Y_list.Count > 0) { for (int i = 0; i < same_Y_list.Count - 1; i++) { line1.Remove(same_Y_list[i]); } } } if (res2 == true) { same_Y_list = MsehAndMsevContainer.same_YValue_PointsList(line2); if (same_Y_list.Count > 0) { for (int i = 0; i < same_Y_list.Count - 1; i++) { line2.Remove(same_Y_list[i]); } } } int jingeiliang1 = line1.Count; int wxcs1 = line2.Count; foreach (LJJSPoint point in list) { line2.Remove(point); //去掉多出的点 } bool rrr = MsehAndMsevContainer.checkSameYValue_orNot(line1, line2); //检测两个list中所有的点的y值能不能对应上 if (rrr == false) //对应不上,则直接返回 { MessageBox.Show("两个曲线上的点的个数不同,错误"); MessageBox.Show(line1.Count.ToString()); MessageBox.Show(line2.Count.ToString()); return; } } //StringBuilder sb = new StringBuilder(); /**if (list != null) * { * foreach (LJJSPoint item in list) * { * sb.Append(string.Format("多出的点坐标:({0},{1})", item.XValue.ToString(), item.YValue.ToString())); * sb.Append("\r\n"); * } * } * MessageBox.Show(sb.ToString());**/ } } for (int i = 0; i < line1.Count; i++) { if (double.IsNaN(line1[i].XValue) == true || double.IsInfinity(line1[i].XValue) == true) { MessageBox.Show(string.Format("值是NaN,第{0}个", i)); } if (double.IsNaN(line2[i].XValue) == true || double.IsInfinity(line2[i].XValue) == true) { MessageBox.Show(string.Format("值是NaN,第{0}个", i)); } if (line1[i].YValue != line2[i].YValue) { MessageBox.Show("两个曲线上的点的YValue不同,错误"); return; } } //MessageBox.Show("正确,可以涂色"); vdDocument activeDOcu = DrawCommonData.activeDocument; //对两条线,每次在每条线上分别取两个点,y值可以对应上(即可以连成两条平行直线) for (int i = 0; i < line1.Count - 1; i++) { LJJSPoint line1_x1y1 = line1[i]; LJJSPoint line1_x2y2 = line1[i + 1]; LJJSPoint line2_x1y1 = line2[i]; LJJSPoint line2_x2y2 = line2[i + 1]; List <LJJSPoint> list; if (line1_x1y1.YValue == line1_x2y2.YValue && line2_x1y1.YValue == line2_x2y2.YValue) { continue; } //line1 is this.drawptcol, line2 is this.randomPointList if (line2_x2y2.XValue < line1_x2y2.XValue) { if (line2_x1y1.XValue < line1_x1y1.XValue) { list = new List <LJJSPoint>() { line2_x2y2, line1_x2y2, line1_x1y1, line2_x1y1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 double xAvg = (line1_x1y1.XValue + line1_x2y2.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Original", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); } else { LJJSPoint jiaodian = GetJiaoDIan.getjiaoDian(line1_x1y1, line1_x2y2, line2_x1y1, line2_x2y2); //两个三角形涂色 //第一个三角形 list = new List <LJJSPoint>() { jiaodian, line2_x1y1, line1_x1y1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 double xAvg = (jiaodian.XValue + line2_x1y1.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Red", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); //第二个三角形 list = new List <LJJSPoint>() { line2_x2y2, line1_x2y2, jiaodian }; colorIndex = Color.Red.ToArgb(); //颜色的argb值 xAvg = (jiaodian.XValue + line1_x2y2.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Original", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); } } else { if (line2_x1y1.XValue > line1_x1y1.XValue) { list = new List <LJJSPoint>() { line1_x2y2, line2_x2y2, line2_x1y1, line1_x1y1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 double xAvg = (line2_x1y1.XValue + line2_x2y2.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Red", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); } else { LJJSPoint jiaodian = GetJiaoDIan.getjiaoDian(line1_x1y1, line1_x2y2, line2_x1y1, line2_x2y2); //两个三角形涂色 //第一个三角形 list = new List <LJJSPoint>() { jiaodian, line1_x1y1, line2_x1y1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 double xAvg = (jiaodian.XValue + line1_x1y1.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Original", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); //第二个三角形 list = new List <LJJSPoint>() { line1_x2y2, line2_x2y2, jiaodian }; colorIndex = Color.Red.ToArgb(); //颜色的argb值 xAvg = (jiaodian.XValue + line2_x2y2.XValue) / 2; if (double.IsNaN(xAvg) == true || double.IsInfinity(xAvg) == true) { MessageBox.Show("xAvg是NaN"); } AddLineHatchManager.selectColorByXValue_WithoutTransition("Red", out colorSelect, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(activeDOcu, list, colorIndex, colorIndex); } } } }
public static void Gei_Qu_Xian_Tu_Se(ArrayList al, JDStruc jdstruc, Hashtable drawht, List <LJJSPoint> line, LJJSPoint lrptstart) //给曲线部分涂色, lrptstart 是线道原点的坐标 { // vdDocument activeDOcu = DrawCommonData.activeDocument; for (int i = 0; i < line.Count - 1; i++) { double y1_value = (double)line[i].YValue; double x1_value = (double)line[i].XValue; double y2_value = (double)line[i + 1].YValue; double x2_value = (double)line[i + 1].XValue; /**double y1_value = (double)al[i]; * double x1_value = (double)drawht[y1_value]; * * double y2_value = (double)al[i+1]; * double x2_value = (double)drawht[y2_value]; * if (this.drawptcol.Count == 1) * { * y1_value += this.drawptcol[0].YValue; * x1_value += this.drawptcol[0].XValue; * y2_value += this.drawptcol[0].YValue; * x2_value += this.drawptcol[0].XValue; * } * else * { * MessageBox.Show("error,this.drawptcol.Count is " + this.drawptcol.Count.ToString()); * return; * }**/ //y2的值一定大于y1 //TO BE DONE /** 涂左边 * LJJSPoint Oy1 = new LJJSPoint(lrptstart.XValue,y1_value); * LJJSPoint x1y1 = new LJJSPoint(x1_value,y1_value); * * LJJSPoint Oy2 = new LJJSPoint(lrptstart.XValue,y2_value); * LJJSPoint x2y2 = new LJJSPoint(x2_value,y2_value); * // **/ /** 涂右边 * LJJSPoint Oy1 = new LJJSPoint(x1_value, y1_value); * LJJSPoint x1y1 = new LJJSPoint(lrptstart.XValue + 50, y1_value); * * LJJSPoint Oy2 = new LJJSPoint(x2_value, y2_value); * LJJSPoint x2y2 = new LJJSPoint(lrptstart.XValue + 50, y2_value); **/ LJJSPoint Oy1 = new LJJSPoint(lrptstart.XValue, y1_value); LJJSPoint x1y1 = new LJJSPoint(lrptstart.XValue + 50, y1_value); LJJSPoint Oy2 = new LJJSPoint(lrptstart.XValue, y2_value); LJJSPoint x2y2 = new LJJSPoint(lrptstart.XValue + 50, y2_value); List <LJJSPoint> hatchPtLst = new List <LJJSPoint>() { Oy2, x2y2, x1y1, Oy1 }; CurveColorEnum colorSelect; int colorIndex = Color.Red.ToArgb(); //颜色的argb值 // AddLineHatchManager.selectColorByXValue(lrptstart,line, (x1_value + x2_value) / 2, ref colorIndex); //选择颜色 try { AddLineHatchManager.selectColorByXValue(lrptstart, line, x1_value, ref colorIndex); //选择颜色 AreaHatch.AddStandardAreaHatch(DrawCommonData.activeDocument, hatchPtLst, colorIndex, colorIndex); } catch { return; } } }
public static void selectColorByXValue(LJJSPoint lrptstart, List <LJJSPoint> xValuesList, double xValue, ref int colorIndex) { //double MaxX = AddLineHatchManager.findMaxX(xValuesList); //double MinX = AddLineHatchManager.findMinX(xValuesList); #region /** * double MaxX = lrptstart.XValue+50; * double MinX = lrptstart.XValue; * double length = MaxX-MinX; * * * Color sourceColor = Color.Blue; * Color destColor = Color.Red; * * int redSpace = destColor.R - sourceColor.R; * int greenSpace = destColor.G - sourceColor.G; * int blueSpace = destColor.B - sourceColor.B; * * * double proportion = (xValue-lrptstart.XValue) / length; * * int r = int.Parse(Math.Round(sourceColor.R + proportion * redSpace).ToString()); * int g = int.Parse(Math.Round(sourceColor.G + proportion * greenSpace).ToString()); * int b = int.Parse(Math.Round(sourceColor.B + proportion * blueSpace).ToString()); * * * * * colorIndex = Color.FromArgb(r, g, b).ToArgb(); **/ #endregion #region double MaxX = lrptstart.XValue + 50; double MinX = lrptstart.XValue; double length = MaxX - MinX; double step = (MaxX - MinX) / 3; double ZoneOne = MinX + step; double ZoneTwo = MinX + 2 * step; CurveColorEnum curvecolor = CurveColorEnum.BlackToRed; if (xValue >= MinX && xValue < ZoneOne) //白 -》 黄 { curvecolor = CurveColorEnum.WhiteToYellow; AddLineHatchManager.selectLittleColorByXValue(xValue, ref curvecolor, MinX, ZoneOne, ref colorIndex); } else if (xValue >= ZoneOne && xValue < ZoneTwo) //黄 -》 红 { curvecolor = CurveColorEnum.YellowToRed; AddLineHatchManager.selectLittleColorByXValue(xValue, ref curvecolor, ZoneOne, ZoneTwo, ref colorIndex); } else if (xValue >= ZoneTwo && xValue <= MaxX) //红 -》黑 { curvecolor = CurveColorEnum.RedToBlack; AddLineHatchManager.selectLittleColorByXValue(xValue, ref curvecolor, ZoneTwo, MaxX, ref colorIndex); } else { // curvecolor = CurveColorEnum.RedToBlack; //return; // AddLineHatchManager.selectLittleColorByXValue(xValue, ref curvecolor, ZoneTwo, MaxX, ref colorIndex,true); throw new Exception("???wxcs hatch"); //return; } #endregion }