private void AddPerYYWZHatch(string yYWZ, double gWJS, double T2jzz, double jdTop) { double gwjsZuoBiaoY = ZuoBiaoOper.GetJSZongZBValue(ptStart.YValue, gWJS, jdTop, FrameDesign.ValueCoordinate); string subsql = this.hcgzItemDesignStruc.ClosedArea_Field_YYWZ + @"='" + yYWZ + @"'"; if (null != kdcItem) { double sfsStartX = kdcItem.KMin; double sfsEndX = T2jzz; double kdsStartX = T2jzz; double kdsEndX = kdcItem.KMax; List <LJJSPoint> sfslst = GetClosedAreaDRS(sfsStartX, sfsEndX, kdcItem, subsql, gwjsZuoBiaoY); double xt2 = DuiShuOper.XGetDSZuoBiaoValue(ptStart.XValue, 1, kdcItem.KParm, T2jzz, kdcItem.KMin); double ytmp = endy; List <LJJSPoint> kdslst = GetClosedAreaDRS(kdsStartX, kdsEndX, kdcItem, subsql, gwjsZuoBiaoY); kdslst.Add(new LJJSPoint(xt2, gwjsZuoBiaoY)); double ytmpkd = starty; sfslst.Add(new LJJSPoint(xt2, (ytmp + ytmpkd) * 0.5 * HCGZLTXiShu + gwjsZuoBiaoY)); sfslst.Add(new LJJSPoint(xt2, gwjsZuoBiaoY)); kdslst.Add(new LJJSPoint(xt2, (ytmp + ytmpkd) * 0.5 * HCGZLTXiShu + gwjsZuoBiaoY)); AreaHatch.AddStandardAreaHatch(DrawCommonData.activeDocument, sfslst, this.hcgzItemDesignStruc.SFLTColor, this.hcgzItemDesignStruc.SFLTColor); AreaHatch.AddStandardAreaHatch(DrawCommonData.activeDocument, kdslst, hcgzItemDesignStruc.KDLTColor, hcgzItemDesignStruc.KDLTColor); } }
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; } } }