hytos / DTI_PID / SPPIDConverter / Model / SPPID_Document.cs @ 5dfb8a24
이력 | 보기 | 이력해설 | 다운로드 (8.15 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using Converter.BaseModel; |
7 |
using Converter.SPPID.Util; |
8 |
|
9 |
namespace Converter.SPPID.Model |
10 |
{ |
11 |
public class SPPID_Document : Document |
12 |
{ |
13 |
public SPPID_Document(string xmlPath) : base(xmlPath) |
14 |
{ |
15 |
|
16 |
} |
17 |
|
18 |
private double testX = 0.855; |
19 |
private double testY = 0.55; |
20 |
|
21 |
public List<SymbolMapping> SymbolMappings; |
22 |
public List<LineMapping> LineMappings; |
23 |
public List<LineNumberMapping> LineNumberMappings; |
24 |
public List<AssociationMapping> AssociationMappings; |
25 |
public ETCSetting ETCSetting; |
26 |
|
27 |
private List<Group> GROUPS { get; set; } |
28 |
|
29 |
public string DrawingName { get; set; } |
30 |
public string DrawingNumber { get; set; } |
31 |
public string Unit { get; set; } |
32 |
public string Template { get; set; } |
33 |
|
34 |
public void SetSPPIDInfo() |
35 |
{ |
36 |
foreach (var item in SYMBOLS) |
37 |
{ |
38 |
if (item.SPPID == null) |
39 |
item.SPPID = new SPPIDSymbolInfo(); |
40 |
double x = double.NaN; |
41 |
double y = double.NaN; |
42 |
SPPIDUtil.ConvertPointBystring(item.LOCATION, ref x, ref y); |
43 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
44 |
item.SPPID.LOCATION_X = x; |
45 |
item.SPPID.LOCATION_Y = y; |
46 |
} |
47 |
|
48 |
foreach (var item in LINES) |
49 |
{ |
50 |
if (item.SPPID == null) |
51 |
item.SPPID = new SPPIDLineInfo(); |
52 |
double x = double.NaN; |
53 |
double y = double.NaN; |
54 |
|
55 |
SPPIDUtil.ConvertPointBystring(item.STARTPOINT, ref x, ref y); |
56 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
57 |
item.SPPID.START_X = x; |
58 |
item.SPPID.START_Y = y; |
59 |
|
60 |
SPPIDUtil.ConvertPointBystring(item.ENDPOINT, ref x, ref y); |
61 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
62 |
item.SPPID.END_X = x; |
63 |
item.SPPID.END_Y = y; |
64 |
} |
65 |
} |
66 |
|
67 |
public bool SetSPPIDMapping() |
68 |
{ |
69 |
foreach (var item in SYMBOLS) |
70 |
{ |
71 |
SymbolMapping mapping = SymbolMappings.Find(x => x.UID == item.DBUID); |
72 |
item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
73 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
74 |
return false; |
75 |
} |
76 |
|
77 |
foreach (var item in LINES) |
78 |
{ |
79 |
LineMapping mapping = LineMappings.Find(x => x.UID == item.TYPEUID); |
80 |
item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
81 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
82 |
return false; |
83 |
} |
84 |
|
85 |
return true; |
86 |
} |
87 |
|
88 |
//#region Grouping Source |
89 |
//private void SetGrouping() |
90 |
//{ |
91 |
// try |
92 |
// { |
93 |
// // Line 기준으로 묶음 |
94 |
// foreach (Line item in LINES) |
95 |
// if (!item.SPPID.IsGroup) |
96 |
// SetGroupingByItem(item); |
97 |
// // End |
98 |
|
99 |
// // Symbol 기준으로 묶음 |
100 |
// foreach (Symbol item in SYMBOLS) |
101 |
// if (!item.SPPID.IsGroup) |
102 |
// SetGroupingByItem(item); |
103 |
// // End |
104 |
// } |
105 |
// catch (Exception ex) |
106 |
// { |
107 |
|
108 |
// } |
109 |
//} |
110 |
|
111 |
//private void SetGroupingByItem(object item) |
112 |
//{ |
113 |
// try |
114 |
// { |
115 |
// Group group = new Group(); |
116 |
// group.Items.Add(item); |
117 |
// bool forward = true; |
118 |
// SetGroupingByConnectedItem(item, group.Items, ref forward); |
119 |
|
120 |
// GROUPS.Add(group); |
121 |
// } |
122 |
// catch (Exception ex) |
123 |
// { |
124 |
|
125 |
// } |
126 |
//} |
127 |
|
128 |
//private void SetGroupingByConnectedItem(object item, List<object> list, ref bool IsForward) |
129 |
//{ |
130 |
// try |
131 |
// { |
132 |
// if (typeof(Line) == item.GetType()) |
133 |
// { |
134 |
// Line line = item as Line; |
135 |
// line.SPPID.IsGroup = true; |
136 |
// SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, line.CONNECTORS); |
137 |
// } |
138 |
// else if (typeof(Symbol) == item.GetType()) |
139 |
// { |
140 |
// Symbol symbol = item as Symbol; |
141 |
// symbol.SPPID.IsGroup = true; |
142 |
// // Symbol의 경우 BaseSymbol Connector가 2개 이하때 진행 / 나머지는 Grouping 종료 |
143 |
// if (symbol.CONNECTORS.Count <= 2) |
144 |
// { |
145 |
// SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, symbol.CONNECTORS); |
146 |
// } |
147 |
// } |
148 |
// IsForward = false; |
149 |
// } |
150 |
// catch (Exception ex) |
151 |
// { |
152 |
|
153 |
// } |
154 |
//} |
155 |
|
156 |
//private int GetChildConnectorCount(Symbol symbol) |
157 |
//{ |
158 |
// int count = 0; |
159 |
// foreach (var childSymbol in symbol.ChildSymbols) |
160 |
// { |
161 |
// GetChildConnectorCountLoop(childSymbol, ref count); |
162 |
// } |
163 |
|
164 |
// return count; |
165 |
//} |
166 |
|
167 |
//private void GetChildConnectorCountLoop(ChildSymbol childSymbol, ref int count) |
168 |
//{ |
169 |
// count = count + childSymbol.Connectors.Count; |
170 |
|
171 |
// foreach (var child in childSymbol.ChildSymbols) |
172 |
// { |
173 |
// GetChildConnectorCountLoop(child, ref count); |
174 |
// } |
175 |
//} |
176 |
|
177 |
//private void SetGroupingByConnectedItem_ConnectorsLogic(object item, List<object> list, ref bool IsForward, List<Connector> connectors) |
178 |
//{ |
179 |
// foreach (Connector connector in connectors) |
180 |
// { |
181 |
// object connItem = SPPIDUtil.FindObjectByUID(this, connector.CONNECTEDITEM); |
182 |
// if (connItem != null) |
183 |
// { |
184 |
// bool result = false; |
185 |
// if (typeof(Line) == connItem.GetType()) |
186 |
// { |
187 |
// Line connLine = connItem as Line; |
188 |
// // 연결되는 Item이 전부 Line일 경우 Branch, Line Type을 확인 |
189 |
// if (item.GetType() == connLine.GetType() && |
190 |
// (SPPIDUtil.IsBranchLine(((Line)item).UID, connLine) || item.SPPIDMAPPINGNAME != connLine.SPPIDMAPPINGNAME)) |
191 |
// continue; |
192 |
|
193 |
// result = true; |
194 |
// } |
195 |
// else if (typeof(Symbol) == connItem.GetType()) |
196 |
// { |
197 |
// Symbol connSymbol = connItem as Symbol; |
198 |
// // 연결되는 Symbol의 Connector가 부가 심볼일 경우는 result = false |
199 |
// foreach (Connector symbolConnector in connSymbol.CONNECTORS) |
200 |
// { |
201 |
// if (symbolConnector.CONNECTEDITEM == item.UID) |
202 |
// { |
203 |
// if (symbolConnector.INDEX == 0) |
204 |
// result = true; |
205 |
// else |
206 |
// result = false; |
207 |
// break; |
208 |
// } |
209 |
// } |
210 |
// } |
211 |
|
212 |
// if (!connItem.GROUPING && result) |
213 |
// { |
214 |
// if (IsForward) |
215 |
// list.Add(connItem); |
216 |
// else |
217 |
// list.Insert(0, connItem); |
218 |
// SetGroupingByConnectedItem(connItem, list, ref IsForward); |
219 |
// } |
220 |
// } |
221 |
// } |
222 |
//} |
223 |
|
224 |
//private bool IsChildConnector(Symbol symol, Connector connector) |
225 |
//{ |
226 |
// bool result = false; |
227 |
|
228 |
|
229 |
|
230 |
|
231 |
// return result; |
232 |
//} |
233 |
//#endregion |
234 |
} |
235 |
} |