tx
2025-04-09 fa7510e1ed63df0366787fa4ed1b3db6426d2b46
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
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 ZlpFeatChart1 : ZlpFeatChart
    {
        public ZlpFeatChart1()
        {
 
        }
 
        public virtual bool InitialTemplate()
        {
            return false;
        }
 
        public override bool CreateDxf(string strFilePath)
        {
            try
            {
                if (string.IsNullOrEmpty(_strTemplateFile) || !System.IO.File.Exists(_strTemplateFile))
                {
                    return false;
                }
 
 
                _dxfFileModel = DwgReader.Read(_strTemplateFile);
 
                InitialChartColorAndFont();
 
                //默认字体
                _axisTextFont = new DxfTextStyle("arial", "arial.ttf");
                _dxfFileModel.TextStyles.Add(_axisTextFont);
                _frameTextFont = _dxfFileModel.GetTextStyleWithName("FS");//文件自带字体 
 
                InitialDiagramSize();
 
                DrawAxisQ_First();//画X轴
 
                DrawAxisH();//画Y轴
 
                DrawDesignPointLine();
 
                if (CurveInfoQH != null && CurveInfoQH.Count > 0)
                {
                    foreach (var curve in CurveInfoQH)
                    {
                        if (_annoAnchorPointList == null)
                        {
                            DrawSingleCurveH( curve.PointInfo, curve.CurvePara.ToString() + "°", false);
                        }
                        else
                        {
                            DrawSingleCurveH( curve.PointInfo, null, false);
                        }
                    }
                }
 
                if (EqualParaCurveE != null && EqualParaCurveE.Count > 0)
                {
                    foreach (var curve in EqualParaCurveE)
                    {
                        if (_annoAnchorPointList == null)
                        {
                            DrawSingleCurveE( curve.PointInfo, curve.CurvePara.ToString() + "%", curve.IsClosed);
                        }
                        else
                        {
                            DrawSingleCurveE( curve.PointInfo, null, curve.IsClosed);
                        }
                    }
                }
 
                if (_annoAnchorPointList != null  )
                {
                    for (int k = 0; k < _annoAnchorPointList.Count; k++)
                    {
                        var curveLabel = _annoAnchorPointList[k];
                        WW.Cad.Model.Entities.EntityColor colorCurve;
                        if (curveLabel.CurveTag == "QH")
                            colorCurve = _axisLabelColorQ;
                         else
                             colorCurve = _axisLabelColorE ;
 
                        Point3D pt3D = new Point3D();
                        pt3D.X = MapRealToPictQ(_coordinateParas.AxisCalcQ.Calc(curveLabel.X))+2;
                        pt3D.Y = MapRealToPictH(_coordinateParas.AxisCalcH.Calc(curveLabel.Y))+7;
                        pt3D.Z = 0;
 
 
                        DxfText textLabel = new DxfText(curveLabel.Text, pt3D, 2d);
                        textLabel.Thickness = 0.4d;
                        textLabel.Height = 6;
                        textLabel.Color = colorCurve;
                        //textLabel.Style = _defaultTextFont;
                        _dxfFileModel.Entities.Add(textLabel);
 
                    }
                }
 
 
                DrawDesignPointLine();
 
                //额定点 和 额定参数文字
                //DrawRatedParas();
 
 
 
                //标题栏
                DrawFrameTtileText();
 
 
 
                //if (_equipmentCurveParas != null)
                //{
                //    WW.Cad.Model.Entities.EntityColor colorDxf = GetEntityColor(System.Drawing.Color.Beige);
 
                //    DrawSingleCurveQH(colorDxf, _equipmentCurveParas.CurveInfo, null);
                //}
 
 
                ////添加尺寸
                //DxfDimension.Aligned dimension = new DxfDimension.Aligned(_dxfFileModel.DefaultDimensionStyle);
                //dimension.DimensionLineLocation = new Point3D(7, 2, 0);
                //// Touches bottom side of the circle.
                //dimension.ExtensionLine1StartPoint = new Point3D(3, 0, 0);
                //// Touches top side of the circle.
                //dimension.ExtensionLine2StartPoint = new Point3D(3, 4, 0);
                //_dxfFileModel.Entities.Add(dimension);
 
 
 
                //保存文件
                SaveFile(strFilePath);
 
 
            }
            catch  //(Exception ex)
            {
 
                return false;
            }
 
 
            return true;
        }
 
 
        public override bool InitialTemplate(string CorpDataFolder, Eventech.Model.eLocalizationType location, string attachInfo)
        {
            _currentLangugage = location;
            var file = GetTemplateFilePath(CorpDataFolder, location);
            if (string.IsNullOrEmpty(file))
                return false;
            this._strTemplateFile = file;
            return true;
        }
 
        public static string GetTemplateFilePath(string CorpDataFolder, Eventech.Model.eLocalizationType location)
        {
            string strTemplateFolder = null;
            if (location != Eventech.Model.eLocalizationType.zhCN)
            {
                strTemplateFolder = System.IO.Path.Combine(CorpDataFolder, "template", "ZLP_Style1_EN.dwg");
                if (System.IO.File.Exists(strTemplateFolder))
                {
                    return strTemplateFolder;
                }
                strTemplateFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "template", "ZLP_Style1_EN.dwg");
                if (System.IO.File.Exists(strTemplateFolder))
                {
                    return strTemplateFolder;
                }
            }
 
            strTemplateFolder = System.IO.Path.Combine(CorpDataFolder, "template", "ZLP_Style1_CN.dwg");
            if (System.IO.File.Exists(strTemplateFolder))
            {
                return strTemplateFolder;
            }
            strTemplateFolder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "template", "ZLP_Style1_CN.dwg");
            if (System.IO.File.Exists(strTemplateFolder))
            {
                return strTemplateFolder;
            }
 
            return strTemplateFolder;
        }
 
 
 
 
  
    }
}