tx
2025-04-22 e0b138b3e057de6f57021e6c8963868f5c5acc5a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
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 LxpFeatChart10
    {
        //绘制区域
        public void DrawRegion()
        {
            #region 最优区域(标注)
            DxfDimensionStyle alternativedimenstionStyle = null;
            if (this._isDispRegionPrefer && this._regionPointParas != null)
            {
                if (alternativedimenstionStyle == null)
                {
                    WW.Cad.Model.Color deminColor = WW.Cad.Model.Color.CreateFromColorIndex(100); //CreateFromRgb(0, 255, 0);
                    var frameTextFont = _dxfFileModel.GetTextStyleWithName("PC_TEXTSTYLE");//文件自带字体 
 
                    alternativedimenstionStyle = new DxfDimensionStyle(_dxfFileModel);
                    alternativedimenstionStyle.Name = "Architectural";//GB_LINEAR 文字在线上面 "Architectural" 文字在中间
                    //alternativedimenstionStyle.LinearUnitFormat = LinearUnitFormat.Engineering;
                    alternativedimenstionStyle.ArrowSize = 7.5d;
                    alternativedimenstionStyle.TextHeight = 15;
                    //alternativedimenstionStyle.FixedExtensionLineLength = 5;
                    alternativedimenstionStyle.ExtensionLineColor = deminColor;
                    alternativedimenstionStyle.ExtensionLineExtension = 2;
                    alternativedimenstionStyle.DimensionLineColor = deminColor;
                    alternativedimenstionStyle.TextColor = deminColor;
                    if (frameTextFont != null)
                        alternativedimenstionStyle.TextStyle = frameTextFont;
                    //alternativedimenstionStyle.TickSize = 10;
                    _dxfFileModel.DimensionStyles.Add(alternativedimenstionStyle);
 
                }
 
                DxfDimension.Linear dimension = new DxfDimension.Linear(alternativedimenstionStyle);
                //  dimension.HasTextRotation = false;
                //  dimension.TextRotation = 0;
                // Touches bottom side of the circle.
                dimension.ExtensionLine1StartPoint = new Point3D(MapRealToPictQ(this._regionPointParas.PerferRegionMin.Q), MapRealToPictH(this._regionPointParas.PerferRegionMin.H), 0);
                // Touches top side of the circle.
                dimension.ExtensionLine2StartPoint = new Point3D(MapRealToPictQ(this._regionPointParas.PerferRegionMax.Q), MapRealToPictH(this._regionPointParas.PerferRegionMax.H), 0);
                //dimension.Color = GetEntityColor(System.Drawing.Color.Beige);
                //dimension.DxfColor = GetEntityColor(System.Drawing.Color.Beige);
                dimension.DimensionLineLocation = new Point3D((dimension.ExtensionLine1StartPoint.X + dimension.ExtensionLine2StartPoint.X) * 0.5, 880, 0);
                //  dimension.UseTextMiddlePoint = true;
                //dimension.HorizontalDirection = 0;
 
                dimension.Text = " 优先工作区 ";//
                _dxfFileModel.Entities.Add(dimension);
 
                //DxfVPort activeViewport = DxfVPort.CreateActiveVPort();
                //activeViewport.Center = new Point2D(3, 2);
                //activeViewport.Height = 15;
                //_dxfFileModel.VPorts.Add(activeViewport);
            }
            #endregion
 
            #region 运行区域(标注)
            if (_isDispRegionAllow && this._regionPointParas != null)
            {
                if (alternativedimenstionStyle == null)
                {
                    WW.Cad.Model.Color deminColor = WW.Cad.Model.Color.CreateFromColorIndex(100);
 
                    if (this._isMonoColor)
                        deminColor = WW.Cad.Model.Color.CreateFromColorIndex(7);
 
                    alternativedimenstionStyle = new DxfDimensionStyle(_dxfFileModel);
                    alternativedimenstionStyle.Name = "Architectural";
                    //alternativedimenstionStyle.LinearUnitFormat = LinearUnitFormat.Engineering;
                    alternativedimenstionStyle.ArrowSize = 7.5d;
                    alternativedimenstionStyle.TextHeight = 10;
                    //alternativedimenstionStyle.FixedExtensionLineLength = 5;
                    alternativedimenstionStyle.ExtensionLineColor = deminColor;
                    alternativedimenstionStyle.ExtensionLineExtension = 7;
                    alternativedimenstionStyle.DimensionLineColor = deminColor;
                    alternativedimenstionStyle.TextColor = deminColor;
                    //alternativedimenstionStyle.TickSize = 10;
                    _dxfFileModel.DimensionStyles.Add(alternativedimenstionStyle);
 
                }
 
 
                DxfDimension.Linear dimension = new DxfDimension.Linear(alternativedimenstionStyle);
                //  dimension.HasTextRotation = false;
                //  dimension.TextRotation = 0;
                // Touches bottom side of the circle.
                dimension.ExtensionLine1StartPoint = new Point3D(MapRealToPictQ(this._regionPointParas.AllowRegionMin.Q), MapRealToPictH(this._regionPointParas.AllowRegionMin.H), 0);
                // Touches top side of the circle.
                dimension.ExtensionLine2StartPoint = new Point3D(MapRealToPictQ(this._regionPointParas.AllowRegionMax.Q), MapRealToPictH(this._regionPointParas.AllowRegionMax.H), 0);
                //dimension.Color = GetEntityColor(System.Drawing.Color.Beige);
                //dimension.DxfColor = GetEntityColor(System.Drawing.Color.Beige);
                dimension.DimensionLineLocation = new Point3D((dimension.ExtensionLine1StartPoint.X + dimension.ExtensionLine2StartPoint.X) * 0.5, 910, 0);
                //  dimension.UseTextMiddlePoint = true;
                //dimension.HorizontalDirection = 0;
                dimension.Text = " 允许工作区 "; 
                _dxfFileModel.Entities.Add(dimension);
 
                //DxfVPort activeViewport = DxfVPort.CreateActiveVPort();
                //activeViewport.Center = new Point2D(3, 2);
                //activeViewport.Height = 15;
                //_dxfFileModel.VPorts.Add(activeViewport);
            }
            #endregion
 
            #region 最小流量线
            if (_isDispRegionAllow && this._regionPointParas != null)
            {
                var regionAllowQ_pict = MapRealToPictQ(this._regionPointParas.AllowRegionMin.Q);
 
 
                var curveColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(110);
                //
                var dxfLineDash = _dxfFileModel.LineTypes.Where(x => x.Name == "DASHED2").FirstOrDefault();//虚线
                //延长线
                DxfLine lineQ = new DxfLine(new Point2D(regionAllowQ_pict, this._diagramLeftTopPt_QH.Y), new Point2D(regionAllowQ_pict, -8));
                lineQ.LineWeight = 40;
                lineQ.Color = curveColor;
                if (dxfLineDash != null)
                    lineQ.LineType = dxfLineDash;
                _dxfFileModel.Entities.Add(lineQ);
 
                //文字
                var textFont = _dxfFileModel.GetTextStyleWithName("PC_TEXTSTYLE4");//文件自带字体 
                if (textFont == null)
                    textFont = _dxfFileModel.GetTextStyleWithName("Standard");//文件自带字体 
 
                Point3D pt_q_min = new Point3D();
                pt_q_min.X = regionAllowQ_pict;
                pt_q_min.Y = -30;
                pt_q_min.Z = 0d;
                DxfMText text_q_min = new DxfMText("Qmin", pt_q_min, 11);//\P表示回车
                text_q_min.AttachmentPoint = AttachmentPoint.TopCenter;
                text_q_min.Color = curveColor;
                text_q_min.Style = textFont;
                _dxfFileModel.Entities.Add(text_q_min);
            }
            #endregion
 
        }
 
        #region 工作点
        private void DrawWorkPoint()
        {
            if (!_isDrawDesignPoint)
                return;
            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();//虚线
 
                var curveColor = TProduct.PumpGraph.Dxf.AutoCadHelper.GetColor(10);
 
                //延长线
                DxfLine lineQ = new DxfLine(new Point2D(centerPt.X, centerPt.Y), new Point2D(centerPt.X, 0));
                lineQ.LineWeight = 30;
                lineQ.Color = curveColor;
                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;
                if (dxfLineDash != null)
                    lineH.LineType = dxfLineDash;
                lineH.Color = curveColor;
                _dxfFileModel.Entities.Add(lineH);
 
            }
 
 
 
 
 
 
            //if (_workPointReal != null && _workPointReal.Q > 0.1)
            //{
            //    #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
            //}
        }
        #endregion
 
        #region  额定参数
        private void DrawRatedParas()
        {
            if (_ratedParas == null)
                return;
 
 
            //
            DrawRatedPointLine();
 
 
            #region 额定点文字
            double y_rated = -183;
 
            DxfText axisLabel_q = GetRatedFrameDxfText(_ratedParas.Q, y_rated, "Q");
            DxfText axisLabel_h = GetRatedFrameDxfText(_ratedParas.H, y_rated, "H");
 
            if (this._ratedN > 10)
            {
                DxfText axisLabel_n = GetRatedFrameDxfText(_ratedN, y_rated, "N");
            }
 
 
            DxfText axisLabel_p = GetRatedFrameDxfText(_ratedParas.P, y_rated, "P");
            DxfText axisLabel_e = GetRatedFrameDxfText(_ratedParas.E, y_rated, "E");
 
            if (_ratedParas.NPSHr > 0.01)
            {
                DxfText axisLabel_npsh = GetRatedFrameDxfText(_ratedParas.NPSHr, y_rated, "NPSH");
            }
 
            #endregion
        }
 
 
        #endregion
    }
}