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 MultiSpeed8 { #region 等效线 //更新等效线(不要放在UpdateChart中,注意对外部使用) public void SetEqualParaCurveE(List allEqualParaCurveE) { if (allEqualParaCurveE == null) return; this._equalParaCurveE = new Eventech.Model.CombineCurveList(); foreach (var curve in allEqualParaCurveE) { _equalParaCurveE.Add(new Eventech.Model.CombineCurve(curve)); } } public void SetEqualParaCurveE(Eventech.Model.CombineCurveList allEqualParaCurveE) { if (allEqualParaCurveE == null) return; this._equalParaCurveE = new Eventech.Model.CombineCurveList(); foreach (var curve in allEqualParaCurveE) { _equalParaCurveE.Add(new Eventech.Model.CombineCurve(curve)); } } //绘制等效线 public void DrawEqualParaCurveE(Eventech.Model.CombineCurveList allEqualParaCurveE) { if (allEqualParaCurveE == null) return; var dxf_curve_color = _equalParaCurveColor; if (IsMonoColor) { dxf_curve_color = _whiteColor; } var layer_curve = GetLayerByName("效率线"); //var layer_curve_text = GetLayerByName("扬程功率线"); //var layer_curve_blod = GetLayerByName("扬程功率线"); foreach (var equalCurve in allEqualParaCurveE) { DxfSpline equalParaSpline = new DxfSpline(); equalParaSpline.Degree = 3; equalParaSpline.Color = dxf_curve_color; equalParaSpline.LineWeight = _equalParaCurveWidth; if (dxf_curve_color != null) equalParaSpline.Color = dxf_curve_color; if (layer_curve != null) equalParaSpline.Layer = layer_curve; int i = 0; for (i = 0; i < equalCurve.PointInfo.Count; i++) { //ControlCoordinates coor = mainDiagram.DiagramToPoint(equalCurve.PointInfo[i].X, // equalCurve.PointInfo[i].Y); //screenPoints.Add(coor.Point); Point3D imgPoint = new Point3D(); imgPoint.X = MapRealToPictQ(equalCurve.PointInfo[i].X); imgPoint.Y = MapRealToPictH(equalCurve.PointInfo[i].Y); imgPoint.Z = 0; equalParaSpline.FitPoints.Add(imgPoint); } //去掉重曲线复点 //Point[] pointArray = screenPoints.Distinct().ToArray(); // 绘制 if (equalParaSpline.FitPoints.Count() > 2) { //penCurve.DashStyle = System.Drawing.Drawing2D.DashStyle.DashDotDot; if (equalCurve.IsClosed) {//封闭 equalParaSpline.Closed = true; _dxfFileModel.Entities.Add(equalParaSpline); //System.Drawing.Drawing2D.FillMode aFillMode = System.Drawing.Drawing2D.FillMode.Alternate; //_graphics.DrawClosedCurve(penCurve, imgPoints.ToArray(), equalCurve.DispTension, aFillMode); } else {//开放曲线 _dxfFileModel.Entities.Add(equalParaSpline); //_graphics.DrawCurve(penCurve, imgPoints.ToArray(), equalCurve.DispTension); //Bezier曲线绘制 //List bezierCurves = null; //bezierCurves = Eventech.Common.BezierCurveHelper.CreateOpenCurves(equalCurve.PointInfo.ToArray()); //foreach (var c in bezierCurves) //{ // ControlCoordinates coor0 = mainDiagram.DiagramToPoint(c.Point0.X, c.Point0.Y); // ControlCoordinates coor1 = mainDiagram.DiagramToPoint(c.Point1.X, c.Point1.Y); // ControlCoordinates coor2 = mainDiagram.DiagramToPoint(c.Point2.X, c.Point2.Y); // ControlCoordinates coor3 = mainDiagram.DiagramToPoint(c.Point3.X, c.Point3.Y); // g.DrawBezier(penCurve, coor0.Point, coor1.Point, coor3.Point, coor3.Point); //} } } else if (equalParaSpline.FitPoints.Count() == 2) {//直线 DxfLine line = new DxfLine(equalParaSpline.FitPoints[0], equalParaSpline.FitPoints[1]); if (dxf_curve_color != null) line.Color = dxf_curve_color; if (layer_curve != null) line.Layer = layer_curve; _dxfFileModel.Entities.Add(line); // _graphics.DrawLine(penCurve, imgPoints[0], imgPoints[1]); } else if (equalParaSpline.FitPoints.Count() == 1) {//点 //DxfPoint pt_title = new DxfPoint(equalParaSpline.FitPoints[0]); //pt_title.Color = color; //_dxfFileModel.Entities.Add(pt_title); DxfCircle cr = new DxfCircle(equalParaSpline.FitPoints[0], _equalCurveParaLabelHeight * 0.2); if (dxf_curve_color != null) cr.Color = dxf_curve_color; if (layer_curve != null) cr.Layer = layer_curve; _dxfFileModel.Entities.Add(cr); //RectangleF rc = new RectangleF(imgPoints[0].X - 2, imgPoints[0].Y - 2, 4, 4); //using (Brush b = new SolidBrush(curveColor)) // _graphics.FillEllipse(b, rc); } } } //显示效率值 public void DrawEqualParaCurvePara(Eventech.Model.CombineCurveList allEqualParaCurveE) { if (allEqualParaCurveE == null) return; //是否显示 if (!isDispEqualParaTextE) return; if (IsMonoColor) { _equalParaCurveColor = _whiteColor; } Point3D textPosi = new Point3D(); var layer_curve_text = GetLayerByName("扬程功率线"); // if (_annoAnchorPointList == null) {//自己定义位置 foreach (var equalCurve in allEqualParaCurveE) { //位置影射 //ControlCoordinates coor = mainDiagram.DiagramToPoint(equalCurve.PointInfo[0].X, // equalCurve.PointInfo[0].Y); if (equalCurve.PointInfo[0].Y > equalCurve.PointInfo[equalCurve.PointInfo.Count - 1].Y) { textPosi.X = MapRealToPictQ(equalCurve.PointInfo[0].X) - _equalCurveParaLabelHeight * 0.1 + _equalCurveParaLabelHeight_Offset_X; textPosi.Y = MapRealToPictH(equalCurve.PointInfo[0].Y) + _equalCurveParaLabelHeight * 0.2 + _equalCurveParaLabelHeight_Offset_Y; textPosi.Z = 0d; } else { textPosi.X = MapRealToPictQ(equalCurve.PointInfo[equalCurve.PointInfo.Count - 1].X) - _equalCurveParaLabelHeight * 0.1 + _equalCurveParaLabelHeight_Offset_X; textPosi.Y = MapRealToPictH(equalCurve.PointInfo[equalCurve.PointInfo.Count - 1].Y) + _equalCurveParaLabelHeight * 0.2 + _equalCurveParaLabelHeight_Offset_Y; textPosi.Z = 0d; } //绘制文字 //DxfText textEqualCurve = new DxfText(equalCurve.CurvePara.ToString() + "%", textPosi, 2d); //textEqualCurve.Thickness = 0.4d; //textEqualCurve.Height = _equalCurveParaLabelHeight; //textEqualCurve.Color = _equalParaCurveColor; //if (_curveTextFont != null) // textEqualCurve.Style = _curveTextFont; //_dxfFileModel.Entities.Add(textEqualCurve); textPosi.Y = textPosi.Y + 5; DxfMText textEqualCurve = new DxfMText(BuildCadText(Trim0(equalCurve.CurvePara) + "%"), textPosi, 2d); textEqualCurve.Height = _equalCurveParaLabelHeight; textEqualCurve.Color = _equalParaCurveColor; textEqualCurve.AttachmentPoint = AttachmentPoint.BottomCenter; //BackgroundFillFlags与BackgroundFillInfo属性设置背景遮罩 textEqualCurve.BackgroundFillFlags = BackgroundFillFlags.UseBackgroundFillColor | BackgroundFillFlags.UseDrawingWindowColor; textEqualCurve.BackgroundFillInfo = new BackgroundFillInfo(); textEqualCurve.BackgroundFillInfo.BorderOffsetFactor = 1.2;//调整背景遮罩的比例 1是文字的背景,越大背景遮罩效果越大 if (_curveTextFont != null) textEqualCurve.Style = _curveTextFont; if (layer_curve_text != null) textEqualCurve.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textEqualCurve); //_graphics.DrawString(equalCurve.CurvePara.ToString(), fontText, brushText, // textPosi.X, textPosi.Y - 15); } } else {//读取数据库中设置的文字位置 if (theCurveLabelHelper == null) theCurveLabelHelper = new ChartCurveLabelHelper(); //else // theCurveLabelHelper.ClearLabel();//清空 string equalParaCurveText = null; double textLength = 0; //double textWidth = 0; for (int k = 0; k < _annoAnchorPointList.Count; k++) { equalParaCurveText = _annoAnchorPointList[k].Text.Substring(0, _annoAnchorPointList[k].Text.Length - 1); textPosi.X = MapRealToPictQ(_annoAnchorPointList[k].X) - _equalCurveParaLabelHeight * 0.1; textPosi.Y = MapRealToPictH(_annoAnchorPointList[k].Y) + _equalCurveParaLabelHeight * 0.2; textPosi.Z = 0d; textLength = equalParaCurveText.Length; textPosi.Y = textPosi.Y + 2; //右 //if (_annoAnchorPointList[k].TextAligment == (int)Eventech.Model.eTextAligment.Right) //{ DxfMText textEqualCurve = new DxfMText(BuildCadText_Trim0(equalParaCurveText) + "%", textPosi, 2d); textEqualCurve.Height = _equalCurveParaLabelHeight; textEqualCurve.Color = _equalParaCurveColor; if (_curveTextFont != null) textEqualCurve.Style = _curveTextFont; if (layer_curve_text != null) textEqualCurve.Layer = layer_curve_text; _dxfFileModel.Entities.Add(textEqualCurve); //} ////下 //if (_annoAnchorPointList[k].TextAligment == (int)Eventech.Model.eTextAligment.Bottom) //{ // DxfText textEqualCurve = new DxfText(equalParaCurveText + "%", textPosi, 2d); // textEqualCurve.Thickness = 0.4d; // textEqualCurve.Height = _equalCurveParaLabelHeight; // textEqualCurve.Color = _equalParaCurveColor; // _dxfFileModel.Entities.Add(textEqualCurve); //} ////左 //if (_annoAnchorPointList[k].TextAligment == (int)Eventech.Model.eTextAligment.Left) //{ // DxfText textEqualCurve = new DxfText(equalParaCurveText + "%", textPosi, 2d); // textEqualCurve.Thickness = 0.4d; // textEqualCurve.Height = _defatulCurveLabelHeight; // textEqualCurve.Color = _equalParaCurveColor; // _dxfFileModel.Entities.Add(textEqualCurve); //} ////上 //if (_annoAnchorPointList[k].TextAligment == (int)Eventech.Model.eTextAligment.Top) //{ // DxfText textEqualCurve = new DxfText(equalParaCurveText + "%", textPosi, 2d); // textEqualCurve.Thickness = 0.4d; // textEqualCurve.Height = _defatulCurveLabelHeight; // textEqualCurve.Color = _equalParaCurveColor; // _dxfFileModel.Entities.Add(textEqualCurve); //} } } } #endregion //工作点 private void DrawWorkPoint() { if (!_isDrawDesignPoint) return; var layer_curve = GetLayerByName("效率线"); var textColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(10); if (this._isMonoColor) { textColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(TProduct.PumpGraph.Dxf.AutoCadHelper.WhiteColorIndex); } if (this._designPointStdUnit != null) { Point2D centerPt = new Point2D(); centerPt.X = MapRealToPictQ(this._designPointStdUnit.X); centerPt.Y = MapRealToPictH(this._designPointStdUnit.Y); //插入块 //var block = _dxfFileModel.Blocks.Where(x => x.Name == "性能曲线_BMS_工况点_V0").FirstOrDefault(); //if (block != null) //{ // var insert = new DxfInsert(block); // insert.ScaleFactor = new Vector3D(3.2, 3.2, 3.2); // insert.InsertionPoint = new WW.Math.Point3D(centerPt.X, centerPt.Y, 0); // _dxfFileModel.Entities.Add(insert); // _dxfFileModel.ResetHandles(); //} var dxfLineDash = _dxfFileModel.LineTypes.Where(x => x.Name == "DASHED2").FirstOrDefault();//虚线 //延长线 DxfLine lineQ = new DxfLine(new Point2D(centerPt.X, centerPt.Y), new Point2D(centerPt.X, 0)); lineQ.LineWeight = 30; lineQ.Color = textColor; lineQ.Layer = layer_curve; if (dxfLineDash != null) lineQ.LineType = dxfLineDash; _dxfFileModel.Entities.Add(lineQ); DxfLine lineH = new DxfLine(new Point2D(centerPt.X, centerPt.Y), new Point2D(0, centerPt.Y)); lineH.LineWeight = 30; lineH.Layer = layer_curve; if (dxfLineDash != null) lineH.LineType = dxfLineDash; lineH.Color = textColor; _dxfFileModel.Entities.Add(lineH); if (this.OtherDesignPoints != null) { foreach (var pt in this.OtherDesignPoints) { DrawCrossPointLine(pt ); } } } //工作点的小圆点 if (_workPointReal != null && _workPointReal.Q > 0.1) { float ra = 2; Point2D centerPtQH = new Point2D(); centerPtQH.X = MapRealToPictQ(this._workPointReal.Q); centerPtQH.Y = MapRealToPictH(this._workPointReal.H); DxfCircle circleQH = new DxfCircle(new Point2D(centerPtQH.X, centerPtQH.Y), ra); circleQH.LineWeight = 30; circleQH.Color = textColor; circleQH.Layer = layer_curve; _dxfFileModel.Entities.Add(circleQH); if (_curveNumber4QE > 0) { Point2D centerPtQE = new Point2D(); centerPtQE.X = MapRealToPictQ(this._workPointReal.Q); centerPtQE.Y = MapRealToPictE(this._workPointReal.E); DxfCircle circleQE = new DxfCircle(new Point2D(centerPtQE.X, centerPtQE.Y), ra); circleQE.LineWeight = 30; circleQE.Color = textColor; circleQE.Layer = layer_curve; _dxfFileModel.Entities.Add(circleQE); } //由于点和曲线有时分开, 暂时不显示工作点(功率) //Point2D centerPtQP = new Point2D(); //centerPtQP.X = MapRealToPictQ(this._workPointReal.Q); //centerPtQP.Y = MapRealToPictP(this._workPointReal.P); //DxfCircle circleQP = new DxfCircle(new Point2D(centerPtQP.X, centerPtQP.Y), ra); //circleQP.LineWeight = 30; //circleQP.Color = textColor; //circleQP.Layer = layer_curve; //_dxfFileModel.Entities.Add(circleQP); if (_curveNumber4NPSH > 0) { if (this._workPointReal.NPSH > 0) { Point2D centerPtQNPSH = new Point2D(); centerPtQNPSH.X = MapRealToPictQ(this._workPointReal.Q); centerPtQNPSH.Y = MapRealToPictNPSH(this._workPointReal.NPSH); DxfCircle circleQNPSH = new DxfCircle(new Point2D(centerPtQNPSH.X, centerPtQNPSH.Y), ra); circleQNPSH.LineWeight = 30; circleQNPSH.Color = textColor; circleQNPSH.Layer = layer_curve; _dxfFileModel.Entities.Add(circleQNPSH); } } #region 工作点文字 //double y_rated = -207; //DxfText axisLabel_q = GetRatedFrameDxfText(_workPointReal.Q, y_rated, "Q"); //DxfText axisLabel_h = GetRatedFrameDxfText(_workPointReal.H, y_rated, "H"); //if (this._workPointN > 10) //{ // DxfText axisLabel_n = GetRatedFrameDxfText(_workPointN, y_rated, "N"); //} //DxfText axisLabel_p = GetRatedFrameDxfText(_workPointReal.P, y_rated, "P"); //DxfText axisLabel_e = GetRatedFrameDxfText(_workPointReal.E, y_rated, "E"); //if (_workPointReal.NPSH > 0.01) //{ // DxfText axisLabel_npsh = GetRatedFrameDxfText(_workPointReal.NPSH, y_rated, "NPSH"); //} #endregion } } // 点(倒三角形式) protected void DrawCrossPointLine(Eventech.Model.FeatPoint pt) { Point2D centerPt = new Point2D(); centerPt.X = MapRealToPictQ(pt.X); centerPt.Y = MapRealToPictH(pt.Y); DxfLine lineH = new DxfLine(new Point2D(centerPt.X, centerPt.Y), new Point2D(centerPt.X - 25, centerPt.Y)); lineH.LineWeight = 35; lineH.Color = _designPointColor; _dxfFileModel.Entities.Add(lineH); DxfLine lineV = new DxfLine(new Point2D(centerPt.X, centerPt.Y), new Point2D(centerPt.X, centerPt.Y - 16)); lineV.LineWeight = 35; lineV.Color = _designPointColor; _dxfFileModel.Entities.Add(lineV); DxfLine lineX1 = new DxfLine(new Point2D(centerPt.X, centerPt.Y - 16), new Point2D(centerPt.X - 25, centerPt.Y)); lineX1.LineWeight = 35; lineX1.Color = _designPointColor; _dxfFileModel.Entities.Add(lineX1); DxfLine lineX2 = new DxfLine(new Point2D(centerPt.X, centerPt.Y - 11.26), new Point2D(centerPt.X - 17.45, centerPt.Y)); lineX2.LineWeight = 35; lineX2.Color = _designPointColor; _dxfFileModel.Entities.Add(lineX2); DxfLine lineX3 = new DxfLine(new Point2D(centerPt.X, centerPt.Y - 6.52), new Point2D(centerPt.X - 10.1, centerPt.Y)); lineX3.LineWeight = 35; lineX3.Color = _designPointColor; _dxfFileModel.Entities.Add(lineX3); } } }