using System; using System.Collections.Generic; using System.Linq; using System.Text; using WW.Cad.Base; using WW.Cad.Drawing; using WW.Cad.Drawing.GDI; using WW.Cad.IO; using WW.Cad.Model; using WW.Math; using WW.Cad.Model.Entities; using WW.Actions; using WW.Cad.Model.Tables; using WW.Cad.Model.Objects; namespace TProduct.PumpGraph.Dxf { public partial class MultiSpeedBaseCuve : FeatChart { //绘制扬程曲线 protected void DrawQHCurve() { if (_allCurveQH == null || _allCurveQH.Count() == 0) return; var layer_curve = GetLayerByName("效率线"); var layer_curve_text = GetLayerByName("扬程功率线"); double borderOffsetFactor = 1.2;//调整背景遮罩的比例 1是文字的背景,越大背景遮罩效果越大 foreach (var curve in _allCurveQH) { if (!curve.IsDispCurve) continue; if (curve.CurveExpress == null) continue; var points = Eventech.Common.CurveExpressConver.ToPoints(curve.CurveExpress, 15); WW.Cad.Model.Entities.EntityColor colorDxf ; if (IsMonoColor) { colorDxf = _whiteColor; } else { colorDxf = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(curve.CurveColor); } var dxfSpline = DrawSingleCurveQH(colorDxf, points, layer_curve); if (dxfSpline == null) return; if (curve.IsDispName && !string.IsNullOrEmpty(curve.CurveName)) //&& !curve.CurveName.StartsWith("SIMUINDEX") && !curve.CurveName.StartsWith("COPYINDEX") && !curve.CurveName.StartsWith("MAX")) { if (curve.CurveName == "SIMUINDEX2") continue; var pt_posi = new Point3D(dxfSpline.FitPoints[0].X + _defatulCurveLabelHeight, dxfSpline.FitPoints[1].Y + _defatulCurveLabelHeight - 2, 0d); if (curve.LabelPosiName != null && !curve.LabelPosiName.IsZeroPt()) { pt_posi.X = MapRealToPictQ(curve.LabelPosiName.X); pt_posi.Y = MapRealToPictH(curve.LabelPosiName.Y); } pt_posi.X += _curveParasLabelSpaceX; pt_posi.Y += _curveParasLabelSpaceY; pt_posi.Y += _defatulCurveLabelHeight / 2;//大部分定位的是曲线上的位置,所以加上一个字高度 DxfMText textLabel = new DxfMText(BuildCadText_Trim0(curve.CurveName), pt_posi, _defatulCurveLabelHeight); textLabel.Color = colorDxf; if (_curveTextFont != null) textLabel.Style = _curveTextFont; if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Right) textLabel.AttachmentPoint = AttachmentPoint.MiddleRight; else if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Left) textLabel.AttachmentPoint = AttachmentPoint.MiddleLeft; else if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Top) textLabel.AttachmentPoint = AttachmentPoint.BottomCenter; textLabel.BackgroundFillFlags = BackgroundFillFlags.UseBackgroundFillColor | BackgroundFillFlags.UseDrawingWindowColor; textLabel.BackgroundFillInfo = new BackgroundFillInfo(); textLabel.BackgroundFillInfo.BorderOffsetFactor = borderOffsetFactor;//调整背景遮罩的比例 1是文字的背景,越大背景遮罩效果越大 if (_curveTextFont != null) textLabel.Style = this._curveTextFont; if (layer_curve_text != null) textLabel.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textLabel); } else if (curve.IsDispPara && !string.IsNullOrEmpty(curve.CurvePara)) { var pt_posi = new Point3D(dxfSpline.FitPoints[0].X + _defatulCurveLabelHeight, dxfSpline.FitPoints[1].Y + _defatulCurveLabelHeight - 2, 0d); if (curve.LabelPosiPara != null && curve.LabelPosiPara.IsZeroPt()) { pt_posi.X = MapRealToPictQ(curve.LabelPosiPara.X); pt_posi.Y = MapRealToPictH(curve.LabelPosiPara.Y); } pt_posi.X += _curveParasLabelSpaceX; pt_posi.Y += _curveParasLabelSpaceY; pt_posi.Y += _defatulCurveLabelHeight / 2;//大部分定位的是曲线上的位置,所以加上一个字高度 DxfMText textLabel = new DxfMText(BuildCadText_Trim0(curve.CurvePara), pt_posi, _defatulCurveLabelHeight); textLabel.Color = colorDxf; if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Right) textLabel.AttachmentPoint = AttachmentPoint.MiddleRight; else if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Left) textLabel.AttachmentPoint = AttachmentPoint.MiddleLeft; else if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Top) textLabel.AttachmentPoint = AttachmentPoint.BottomCenter; textLabel.BackgroundFillFlags = BackgroundFillFlags.UseBackgroundFillColor | BackgroundFillFlags.UseDrawingWindowColor; textLabel.BackgroundFillInfo = new BackgroundFillInfo(); textLabel.BackgroundFillInfo.BorderOffsetFactor = borderOffsetFactor;//调整背景遮罩的比例 1是文字的背景,越大背景遮罩效果越大 if (_curveTextFont != null) textLabel.Style = this._curveTextFont; if (layer_curve_text != null) textLabel.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textLabel); } } } protected DxfSpline DrawSingleCurveQH( WW.Cad.Model.Entities.EntityColor colorCurve, List curvePoints, WW.Cad.Model.Tables.DxfLayer layer = null) { if (curvePoints == null || curvePoints.Count() < 3) return null; DxfSpline dxfSpline = new DxfSpline(); dxfSpline.Degree = 3; dxfSpline.LineWeight = _defaultFeatCurveWidth; dxfSpline.Color = colorCurve; for (int i = 0; i < curvePoints.Count; i++) { Point3D pt3D = new Point3D(); pt3D.X = MapRealToPictQ(curvePoints[i].X); pt3D.Y = MapRealToPictH(curvePoints[i].Y); pt3D.Z = 0; dxfSpline.FitPoints.Add(pt3D); } if (dxfSpline.FitPoints.Count < 3) return null; if (layer != null) dxfSpline.Layer = layer; _dxfFileModel.Entities.Add(dxfSpline); // DxfLineType dashedLineType = new DxfLineType("Dashed", 0.5d, -0.3d); // DxfLineType dashedLineType = new DxfLineType("ByLayer", 1d, -0.3d); // _dxfFileModel.LineTypes.Add(dashedLineType); //_dxfFileModel.Colors.Add(colorCurve); return dxfSpline; } //绘制效率曲线 protected int _curveNumber4QE = 0; protected void DrawQECurve() { if (_allCurveQE == null || _allCurveQE.Count() == 0) return; var layer_curve = GetLayerByName("效率线"); var layer_curve_text = GetLayerByName("扬程功率线"); foreach (var curve in _allCurveQE) { if (!curve.IsDispCurve) continue; if (curve.CurveExpress == null) continue; var points = Eventech.Common.CurveExpressConver.ToPoints(curve.CurveExpress, 15); WW.Cad.Model.Entities.EntityColor colorDxf; if (IsMonoColor) { colorDxf = _whiteColor; } else { colorDxf = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(curve.CurveColor); } var dxfSpline = DrawSingleCurveQE(colorDxf, points, layer_curve); if (dxfSpline == null) return; _curveNumber4QE++; if (curve.IsDispPara && !string.IsNullOrEmpty(curve.CurvePara)) { var pt_posi = new Point3D(dxfSpline.FitPoints[0].X + _defatulCurveLabelHeight, dxfSpline.FitPoints[1].Y + _defatulCurveLabelHeight - 2, 0d); if (curve.LabelPosiPara != null) { pt_posi.X = MapRealToPictQ(curve.LabelPosiPara.X); pt_posi.Y = MapRealToPictE(curve.LabelPosiPara.Y); } DxfText textLabel = new DxfText(BuildCadText_Trim0(curve.CurvePara), pt_posi, _defatulCurveLabelHeight); textLabel.Color = colorDxf; if (_curveTextFont != null) textLabel.Style = this._curveTextFont; if (layer_curve_text != null) textLabel.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textLabel); } } } protected DxfSpline DrawSingleCurveQE(WW.Cad.Model.Entities.EntityColor colorCurve, List curvePoints, WW.Cad.Model.Tables.DxfLayer layer = null) { if (curvePoints == null || curvePoints.Count() < 3) return null; DxfSpline dxfSpline = new DxfSpline(); dxfSpline.Degree = 3; dxfSpline.LineWeight = _defaultFeatCurveWidth; dxfSpline.Color = colorCurve; // DxfLineType dashedLineType = new DxfLineType("Dashed", 0.5d, -0.3d); // DxfLineType dashedLineType = new DxfLineType("ByLayer", 1d, -0.3d); // _dxfFileModel.LineTypes.Add(dashedLineType); //_dxfFileModel.Colors.Add(colorCurve); for (int i = 0; i < curvePoints.Count; i++) { Point3D pt3D = new Point3D(); pt3D.X = MapRealToPictQ(curvePoints[i].X); pt3D.Y = MapRealToPictE(curvePoints[i].Y); pt3D.Z = 0; dxfSpline.FitPoints.Add(pt3D); } if (dxfSpline.FitPoints.Count < 3) return null; if (layer != null) dxfSpline.Layer = layer; _dxfFileModel.Entities.Add(dxfSpline); return dxfSpline; } //绘制功率曲线 protected int _curveNumber4QP = 0; protected void DrawQPCurve() { if (_allCurveQP == null || _allCurveQP.Count() == 0) return; var layer_curve = GetLayerByName("效率线"); var layer_curve_text = GetLayerByName("扬程功率线"); foreach (var curve in _allCurveQP) { if (!curve.IsDispCurve) continue; if (curve.CurveExpress == null) continue; var points = Eventech.Common.CurveExpressConver.ToPoints(curve.CurveExpress, 15); WW.Cad.Model.Entities.EntityColor colorDxf; if (IsMonoColor) { colorDxf = _whiteColor; } else { colorDxf = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(curve.CurveColor); } var dxfSpline = DrawSingleCurveQP(colorDxf, points, layer_curve); if (dxfSpline == null) return; _curveNumber4QP++; if (curve.IsDispPara && !string.IsNullOrEmpty(curve.CurvePara)) { var pt_posi = new Point3D(dxfSpline.FitPoints[0].X + _defatulCurveLabelHeight, dxfSpline.FitPoints[1].Y + _defatulCurveLabelHeight - 2, 0d); if (curve.LabelPosiPara != null) { pt_posi.X = MapRealToPictQ(curve.LabelPosiPara.X); pt_posi.Y = MapRealToPictP(curve.LabelPosiPara.Y); } //DxfText textLabel = new DxfText(curve.CurvePara, pt_posi, _defatulCurveLabelHeight); DxfMText textLabel = new DxfMText(BuildCadText_Trim0(curve.CurvePara), pt_posi, _defatulCurveLabelHeight); textLabel.Color = colorDxf; if (_curveTextFont != null) textLabel.Style = this._curveTextFont; if (layer_curve_text != null) textLabel.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textLabel); } } } protected DxfSpline DrawSingleCurveQP(WW.Cad.Model.Entities.EntityColor colorCurve, List curvePoints, WW.Cad.Model.Tables.DxfLayer layer = null) { if (curvePoints == null || curvePoints.Count() < 3) return null; DxfSpline dxfSpline = new DxfSpline(); dxfSpline.Degree = 3; dxfSpline.LineWeight = _defaultFeatCurveWidth; dxfSpline.Color = colorCurve; // DxfLineType dashedLineType = new DxfLineType("Dashed", 0.5d, -0.3d); // DxfLineType dashedLineType = new DxfLineType("ByLayer", 1d, -0.3d); // _dxfFileModel.LineTypes.Add(dashedLineType); //_dxfFileModel.Colors.Add(colorCurve); for (int i = 0; i < curvePoints.Count; i++) { Point3D pt3D = new Point3D(); pt3D.X = MapRealToPictQ(curvePoints[i].X); pt3D.Y = MapRealToPictP(curvePoints[i].Y); pt3D.Z = 0; dxfSpline.FitPoints.Add(pt3D); } if (dxfSpline.FitPoints.Count < 3) return null; if (layer != null) dxfSpline.Layer = layer; _dxfFileModel.Entities.Add(dxfSpline); return dxfSpline; } //绘制汽蚀曲线 protected int _curveNumber4NPSH = 0; protected void DrawQNPSHCurve() { if (_allCurveNPSH == null || _allCurveNPSH.Count() == 0) return; var layer_curve = GetLayerByName("效率线"); var layer_curve_text = GetLayerByName("扬程功率线"); foreach (var curve in _allCurveNPSH) { if (!curve.IsDispCurve) continue; if (curve.CurveExpress == null) continue; Eventech.Model.FeatPointList points = Eventech.Common.FitCurveHelper.GetFitPoints(curve.CurveExpress, 7); WW.Cad.Model.Entities.EntityColor colorDxf; if (IsMonoColor) { colorDxf = _whiteColor; } else { colorDxf = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(curve.CurveColor); } var dxfSpline = DrawSingleCurveQNPSH(colorDxf, points, layer_curve); if (dxfSpline == null) return; _curveNumber4NPSH++; if (curve.IsDispPara && !string.IsNullOrEmpty(curve.CurvePara)) { var pt_posi = new Point3D(dxfSpline.FitPoints[0].X + _defatulCurveLabelHeight*1.5, dxfSpline.FitPoints[0].Y + _defatulCurveLabelHeight , 0d); if (curve.LabelPosiPara != null) { pt_posi = new Point3D(curve.LabelPosiPara.X, curve.LabelPosiPara.Y , 0d); } if (curve.LabelPosiPara != null) { pt_posi.X = MapRealToPictQ(curve.LabelPosiPara.X); pt_posi.Y = MapRealToPictNPSH(curve.LabelPosiPara.Y); } pt_posi.X += _curveParasLabelSpaceX; pt_posi.Y += _curveParasLabelSpaceY; DxfMText textLabel = new DxfMText(BuildCadText_Trim0(curve.CurvePara), pt_posi, _defatulCurveLabelHeight); if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Right) textLabel.AttachmentPoint = AttachmentPoint.MiddleRight; else if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Left) textLabel.AttachmentPoint = AttachmentPoint.MiddleLeft; else if (curve.LabelPosiParaAligment == Eventech.Model.eTextAligment.Top) textLabel.AttachmentPoint = AttachmentPoint.BottomCenter; textLabel.Color = colorDxf; textLabel.BackgroundFillFlags = BackgroundFillFlags.UseBackgroundFillColor | BackgroundFillFlags.UseDrawingWindowColor; textLabel.BackgroundFillInfo = new BackgroundFillInfo(); textLabel.BackgroundFillInfo.BorderOffsetFactor = 1.2;//调整背景遮罩的比例 1是文字的背景,越大背景遮罩效果越大 if (_curveTextFont != null) textLabel.Style = this._curveTextFont; if (layer_curve_text != null) textLabel.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textLabel); } } } protected DxfSpline DrawSingleCurveQNPSH(WW.Cad.Model.Entities.EntityColor colorCurve, List curvePoints, WW.Cad.Model.Tables.DxfLayer layer = null) { DxfSpline dxfSpline = new DxfSpline(); dxfSpline.Degree = 3; dxfSpline.LineWeight = _defaultFeatCurveWidth; dxfSpline.Color = colorCurve; // DxfLineType dashedLineType = new DxfLineType("Dashed", 0.5d, -0.3d); // DxfLineType dashedLineType = new DxfLineType("ByLayer", 1d, -0.3d); // _dxfFileModel.LineTypes.Add(dashedLineType); //_dxfFileModel.Colors.Add(colorCurve); for (int i = 0; i < curvePoints.Count; i++) { Point3D pt3D = new Point3D(); pt3D.X = MapRealToPictQ(curvePoints[i].X); pt3D.Y = MapRealToPictNPSH(curvePoints[i].Y); pt3D.Z = 0; dxfSpline.FitPoints.Add(pt3D); } if (dxfSpline.FitPoints.Count < 3) return dxfSpline; if (layer != null) dxfSpline.Layer = layer; _dxfFileModel.Entities.Add(dxfSpline); return dxfSpline; } //绘制图表上的文字 protected void DrawDiagramInnerText() { if (_labelTextList == null) return; if (IsMonoColor) { _axisLabelColorH = _whiteColor; } var layer_curve_text = GetLayerByName("扬程功率线"); double gridHeight = (_diagramLeftTopPt.Y - _diagramLeftBottomPt.Y) / _coordinateParas.GridNumberY; foreach (var label in _labelTextList) { string title = label.Text; if (label.CurveTag == "H") { Point3D pt = new Point3D(); pt.X = MapRealToPictQ(label.X); pt.Y = MapRealToPictH(label.Y) + _defatulCurveLabelHeight; pt.Z = 0; DxfText textTitle = new DxfText(title, pt, _defatulCurveLabelHeight); textTitle.Thickness = 0.5d; if (_frameTextFont != null) textTitle.Style = _frameTextFont; textTitle.Color = this._axisLabelColorH; if (layer_curve_text != null) textTitle.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textTitle); } if (label.CurveTag == "E") { Point3D pt = new Point3D(); pt.X = MapRealToPictQ(label.X); pt.Y = MapRealToPictE(label.Y) + _defatulCurveLabelHeight; pt.Z = 0; DxfText textTitle = new DxfText(title, pt, _defatulCurveLabelHeight); textTitle.Thickness = 0.5d; if (_frameTextFont != null) textTitle.Style = _frameTextFont; textTitle.Color = this._axisLabelColorE; if (layer_curve_text != null) textTitle.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textTitle); } if (label.CurveTag == "P") { Point3D pt = new Point3D(); pt.X = MapRealToPictQ(label.X); pt.Y = MapRealToPictP(label.Y) + _defatulCurveLabelHeight; pt.Z = 0; DxfText textTitle = new DxfText(title, pt, _defatulCurveLabelHeight); textTitle.Thickness = 0.5d; if (_frameTextFont != null) textTitle.Style = _frameTextFont; textTitle.Color = this._axisLabelColorP; if (layer_curve_text != null) textTitle.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textTitle); } if (label.CurveTag == "NPSH") { Point3D pt = new Point3D(); pt.X = MapRealToPictQ(label.X); pt.Y = MapRealToPictNPSH(label.Y) + _defatulCurveLabelHeight; pt.Z = 0; DxfText textTitle = new DxfText(title, pt, _defatulCurveLabelHeight); textTitle.Thickness = 0.5d; if (_frameTextFont != null) textTitle.Style = _frameTextFont; textTitle.Color = this._axisLabelColorNPSH; if (layer_curve_text != null) textTitle.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textTitle); } } } } }