개정판 4b4dbca9
dev issue #000 : child Symbol Modeling
Change-Id: I26536f33fec33160b1efaf92f4fc5b45ccd48f9b
DTI_PID/BaseModel/Project_DB.cs | ||
---|---|---|
221 | 221 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
222 | 222 |
{ |
223 | 223 |
cmd.CommandText = string.Format(@" |
224 |
SELECT s.UID, s.Name, st.Type, sp.SPPID_SYMBOL_PATH FROM {1} as st, {0} as s |
|
224 |
SELECT sp.UID, s.Name, st.Type, sp.SPPID_SYMBOL_PATH FROM {1} as st, {0} as s
|
|
225 | 225 |
LEFT OUTER JOIN {2} as sp |
226 | 226 |
ON s.UID = SP.UID |
227 | 227 |
WHERE s.SymbolType_UID = st.UID |
... | ... | |
244 | 244 |
return dt; |
245 | 245 |
} |
246 | 246 |
|
247 |
public static DataTable SelectProjectChildSymbol() |
|
248 |
{ |
|
249 |
DataTable result = new DataTable(); |
|
250 |
result.Columns.Add("UID"); |
|
251 |
result.Columns.Add("Name"); |
|
252 |
result.Columns.Add("Type"); |
|
253 |
result.Columns.Add("SPPID_SYMBOL_PATH"); |
|
254 |
|
|
255 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
256 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
257 |
using (DataTable dt = new DataTable()) |
|
258 |
{ |
|
259 |
try |
|
260 |
{ |
|
261 |
connection.Open(); |
|
262 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
263 |
{ |
|
264 |
cmd.CommandText = string.Format(@" |
|
265 |
SELECT AdditionalSymbol FROM Symbol"); |
|
266 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
267 |
dt.Load(dr); |
|
268 |
List<string> childList = new List<string>(); |
|
269 |
foreach (DataRow row in dt.Rows) |
|
270 |
{ |
|
271 |
if (!string.IsNullOrEmpty((string)row["AdditionalSymbol"])) |
|
272 |
{ |
|
273 |
string[] array = row["AdditionalSymbol"].ToString().Split(new char[] { '/' }); |
|
274 |
foreach (var childString in array) |
|
275 |
{ |
|
276 |
childList.Add(childString.Split(new char[] { ',' })[2]); |
|
277 |
} |
|
278 |
} |
|
279 |
|
|
280 |
} |
|
281 |
|
|
282 |
dt.Clear(); |
|
283 |
cmd.Reset(); |
|
284 |
cmd.CommandText = string.Format(@" |
|
285 |
SELECT * FROM {0}", SPPID_SYMBOL_MAPPING_TABLE); |
|
286 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
287 |
dt.Load(dr); |
|
288 |
|
|
289 |
childList = childList.Distinct().ToList(); |
|
290 |
foreach (var child in childList) |
|
291 |
{ |
|
292 |
string mappingPath = string.Empty; |
|
293 |
DataRow[] rows = dt.Select(string.Format("UID = '{0}'", child)); |
|
294 |
if (rows.Length == 1) |
|
295 |
mappingPath = !DBNull.Value.Equals(rows[0]["SPPID_SYMBOL_PATH"]) ? (string)rows[0]["SPPID_SYMBOL_PATH"] : null; |
|
296 |
|
|
297 |
DataRow newRow = result.NewRow(); |
|
298 |
newRow["UID"] = child; |
|
299 |
newRow["Name"] = child; |
|
300 |
newRow["Type"] = "Child Symbol"; |
|
301 |
newRow["SPPID_SYMBOL_PATH"] = mappingPath; |
|
302 |
result.Rows.Add(newRow); |
|
303 |
} |
|
304 |
} |
|
305 |
connection.Close(); |
|
306 |
} |
|
307 |
catch (Exception ex) |
|
308 |
{ |
|
309 |
|
|
310 |
} |
|
311 |
finally |
|
312 |
{ |
|
313 |
connection.Dispose(); |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
return result; |
|
318 |
} |
|
319 |
|
|
247 | 320 |
public static DataTable SelectProjectLine() |
248 | 321 |
{ |
249 | 322 |
DataTable dt = new DataTable(); |
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
309 | 309 |
_LMSymbol.Commit(); |
310 | 310 |
symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
311 | 311 |
|
312 |
//foreach (var item in symbol.ChildSymbols)
|
|
313 |
// CreateChildSymbol(item, _LMSymbol, x, y);
|
|
312 |
foreach (var item in symbol.ChildSymbols) |
|
313 |
CreateChildSymbol(item, _LMSymbol);
|
|
314 | 314 |
} |
315 | 315 |
|
316 | 316 |
ReleaseCOMObjects(_LMSymbol); |
317 | 317 |
} |
318 | 318 |
|
319 |
private void CreateChildSymbol(ChildSymbol childSymbol, LMSymbol parentSymbol, double x, double y)
|
|
319 |
private void CreateChildSymbol(ChildSymbol childSymbol, LMSymbol parentSymbol) |
|
320 | 320 |
{ |
321 |
LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(childSymbol.SPPID.MAPPINGNAME, x, y, TargetItem: parentSymbol); |
|
322 |
foreach (var item in childSymbol.ChildSymbols) |
|
323 |
CreateChildSymbol(item, _LMSymbol, x, y); |
|
321 |
Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[parentSymbol.get_GraphicOID().ToString()]; |
|
322 |
double x1 = 0; |
|
323 |
double x2 = 0; |
|
324 |
double y1 = 0; |
|
325 |
double y2 = 0; |
|
326 |
symbol2d.Range(out x1, out y1, out x2, out y2); |
|
327 |
|
|
328 |
LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(childSymbol.SPPID.MAPPINGNAME, (x1 + x2) / 2, (y1 + y2) / 2, TargetItem: parentSymbol); |
|
329 |
if (_LMSymbol != null) |
|
330 |
{ |
|
331 |
childSymbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
|
332 |
foreach (var item in childSymbol.ChildSymbols) |
|
333 |
CreateChildSymbol(item, _LMSymbol); |
|
334 |
} |
|
335 |
|
|
324 | 336 |
|
325 | 337 |
ReleaseCOMObjects(_LMSymbol); |
326 | 338 |
} |
DTI_PID/SPPIDConverter/ConverterForm.cs | ||
---|---|---|
35 | 35 |
|
36 | 36 |
|
37 | 37 |
private DataTable _ID2SymbolDT = new DataTable(); |
38 |
private DataTable _ID2ChildSymbolDT = new DataTable(); |
|
38 | 39 |
private DataTable _ID2LineDT = new DataTable(); |
39 | 40 |
private DataTable _ID2AttributeDT = new DataTable(); |
40 | 41 |
private DataTable _ID2LinePropertyDT = new DataTable(); |
... | ... | |
42 | 43 |
|
43 | 44 |
|
44 | 45 |
private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
46 |
private List<ChildSymbolMapping> childSymbolMappings = new List<ChildSymbolMapping>(); |
|
45 | 47 |
private List<LineMapping> lineMappings = new List<LineMapping>(); |
46 | 48 |
private List<LineNumberMapping> lineNumberMappings = new List<LineNumberMapping>(); |
47 | 49 |
private List<AttributeMapping> attributeMappings = new List<AttributeMapping>(); |
... | ... | |
321 | 323 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
322 | 324 |
}); |
323 | 325 |
} |
326 |
|
|
327 |
MergeID2ChildSymbol(); |
|
328 |
} |
|
329 |
} |
|
330 |
|
|
331 |
private void MergeID2ChildSymbol() |
|
332 |
{ |
|
333 |
using (DataTable childSymbolDT = Project_DB.SelectProjectChildSymbol()) |
|
334 |
{ |
|
335 |
childSymbolMappings.Clear(); |
|
336 |
_ID2ChildSymbolDT = childSymbolDT; |
|
337 |
_ID2ChildSymbolDT.Columns.Add("Clear"); |
|
338 |
_ID2ChildSymbolDT.Columns["Clear"].Caption = ""; |
|
339 |
foreach (DataRow row in childSymbolDT.Rows) |
|
340 |
{ |
|
341 |
childSymbolMappings.Add(new ChildSymbolMapping() |
|
342 |
{ |
|
343 |
UID = row["UID"] == null ? "" : row["UID"].ToString(), |
|
344 |
SYMBOLNAME = row["Name"] == null ? "" : row["Name"].ToString(), |
|
345 |
SPPIDSYMBOLNAME = row["SPPID_SYMBOL_PATH"] == null ? "" : row["SPPID_SYMBOL_PATH"].ToString(), |
|
346 |
}); |
|
347 |
} |
|
348 |
|
|
349 |
_ID2SymbolDT.Merge(_ID2ChildSymbolDT); |
|
324 | 350 |
} |
325 | 351 |
} |
326 | 352 |
|
... | ... | |
523 | 549 |
//SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\zIsocynates-325_Page75.xml"); |
524 | 550 |
SPPID_Document document = new SPPID_Document(@"Z:\HanKyouHo\temp\Isocynates\Temp\Isocynates-325_Page49.xml"); |
525 | 551 |
document.SymbolMappings = symbolMappings; |
552 |
document.ChildSymbolMappings = childSymbolMappings; |
|
526 | 553 |
document.LineMappings = lineMappings; |
527 | 554 |
document.LineNumberMappings = lineNumberMappings; |
528 | 555 |
document.AttributeMappings = attributeMappings; |
DTI_PID/SPPIDConverter/Form/MappingForm.Designer.cs | ||
---|---|---|
327 | 327 |
this.gridViewSymbol.Name = "gridViewSymbol"; |
328 | 328 |
this.gridViewSymbol.OptionsBehavior.ReadOnly = true; |
329 | 329 |
this.gridViewSymbol.OptionsCustomization.AllowGroup = false; |
330 |
this.gridViewSymbol.OptionsView.ShowAutoFilterRow = true; |
|
330 | 331 |
this.gridViewSymbol.OptionsView.ShowGroupPanel = false; |
331 | 332 |
this.gridViewSymbol.ShowingEditor += new System.ComponentModel.CancelEventHandler(this.gridView_ShowingEditor); |
332 | 333 |
// |
DTI_PID/SPPIDConverter/Form/MappingForm.cs | ||
---|---|---|
65 | 65 |
this.lineDT = lineDT; |
66 | 66 |
this.linePropertyDT = linePropertyDT; |
67 | 67 |
this.associationDT = associationDT; |
68 |
|
|
68 | 69 |
InitID2GridView(); |
69 | 70 |
InitSPPIDSymbolTree(); |
70 | 71 |
InitETCSetting(); |
DTI_PID/SPPIDConverter/Model/ChildSymbolMapping.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
|
|
7 |
namespace Converter.SPPID.Model |
|
8 |
{ |
|
9 |
public class ChildSymbolMapping |
|
10 |
{ |
|
11 |
private string _UID; |
|
12 |
private string _SYMBOLNAME; |
|
13 |
private string _SPPIDSYMBOLNAME; |
|
14 |
|
|
15 |
public string UID { get => _UID; set => _UID = value; } |
|
16 |
public string SYMBOLNAME { get => _SYMBOLNAME; set => _SYMBOLNAME = value; } |
|
17 |
public string SPPIDSYMBOLNAME { get => _SPPIDSYMBOLNAME; set => _SPPIDSYMBOLNAME = value; } |
|
18 |
} |
|
19 |
} |
DTI_PID/SPPIDConverter/Model/SPPID_Document.cs | ||
---|---|---|
20 | 20 |
private double testY = 0.55; |
21 | 21 |
|
22 | 22 |
public List<SymbolMapping> SymbolMappings; |
23 |
public List<ChildSymbolMapping> ChildSymbolMappings; |
|
23 | 24 |
public List<LineMapping> LineMappings; |
24 | 25 |
public List<LineNumberMapping> LineNumberMappings; |
25 | 26 |
public List<AttributeMapping> AttributeMappings; |
... | ... | |
32 | 33 |
public string Unit { get; set; } |
33 | 34 |
public string Template { get; set; } |
34 | 35 |
|
36 |
|
|
35 | 37 |
public void SetSPPIDInfo() |
36 | 38 |
{ |
37 | 39 |
foreach (var item in SYMBOLS) |
... | ... | |
44 | 46 |
SPPIDUtil.ConvertSPPIDPoint(ref x, ref y, SIZE_WIDTH, SIZE_HEIGHT, testX, testY); |
45 | 47 |
item.SPPID.ORIGINAL_X = x; |
46 | 48 |
item.SPPID.ORIGINAL_Y = y; |
49 |
|
|
50 |
foreach (var childSymbol in item.ChildSymbols) |
|
51 |
{ |
|
52 |
if (childSymbol.SPPID == null) |
|
53 |
childSymbol.SPPID = new SPPIDSymbolInfo(); |
|
54 |
SetChildSymbolSPPIDInfo(childSymbol); |
|
55 |
} |
|
47 | 56 |
} |
48 | 57 |
|
49 | 58 |
foreach (var item in LINES) |
... | ... | |
124 | 133 |
item.SPPID.ORIGINAL_Y = y; |
125 | 134 |
} |
126 | 135 |
} |
127 |
|
|
136 |
|
|
137 |
private void SetChildSymbolSPPIDInfo(ChildSymbol item) |
|
138 |
{ |
|
139 |
foreach (var childSymbol in item.ChildSymbols) |
|
140 |
{ |
|
141 |
if (childSymbol.SPPID == null) |
|
142 |
childSymbol.SPPID = new SPPIDSymbolInfo(); |
|
143 |
SetChildSymbolSPPIDInfo(childSymbol); |
|
144 |
} |
|
145 |
} |
|
146 |
|
|
128 | 147 |
public bool SetSPPIDMapping() |
129 | 148 |
{ |
130 | 149 |
foreach (var item in SYMBOLS) |
... | ... | |
133 | 152 |
item.SPPID.MAPPINGNAME = mapping != null ? mapping.SPPIDSYMBOLNAME : null; |
134 | 153 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
135 | 154 |
return false; |
155 |
|
|
156 |
foreach (var childSymbol in item.ChildSymbols) |
|
157 |
{ |
|
158 |
ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME); |
|
159 |
childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null; |
|
160 |
if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME) || !SetChildSymbolMapping(childSymbol)) |
|
161 |
return false; |
|
162 |
} |
|
136 | 163 |
} |
137 | 164 |
|
138 | 165 |
foreach (var item in LINES) |
... | ... | |
181 | 208 |
if (string.IsNullOrEmpty(item.SPPID.MAPPINGNAME)) |
182 | 209 |
return false; |
183 | 210 |
} |
211 |
|
|
184 | 212 |
return true; |
185 | 213 |
} |
186 | 214 |
|
215 |
private bool SetChildSymbolMapping(ChildSymbol item) |
|
216 |
{ |
|
217 |
foreach (var childSymbol in item.ChildSymbols) |
|
218 |
{ |
|
219 |
ChildSymbolMapping childMapping = ChildSymbolMappings.Find(x => x.UID == childSymbol.NAME); |
|
220 |
childSymbol.SPPID.MAPPINGNAME = childMapping != null ? childMapping.SPPIDSYMBOLNAME : null; |
|
221 |
if (string.IsNullOrEmpty(childSymbol.SPPID.MAPPINGNAME)) |
|
222 |
return false; |
|
223 |
else |
|
224 |
return SetChildSymbolMapping(childSymbol); |
|
225 |
} |
|
226 |
|
|
227 |
return true; |
|
228 |
} |
|
187 | 229 |
#region Grouping Source |
188 | 230 |
private bool SetGrouping() |
189 | 231 |
{ |
DTI_PID/SPPIDConverter/SPPIDConverter.csproj | ||
---|---|---|
146 | 146 |
<Compile Include="Model\SPPID_Document.cs" /> |
147 | 147 |
<Compile Include="Model\LineMapping.cs" /> |
148 | 148 |
<Compile Include="Model\AttributeMapping.cs" /> |
149 |
<Compile Include="Model\ChildSymbolMapping.cs" /> |
|
149 | 150 |
<Compile Include="Model\SymbolMapping.cs" /> |
150 | 151 |
<Compile Include="Program.cs" /> |
151 | 152 |
<Compile Include="Properties\AssemblyInfo.cs" /> |
내보내기 Unified diff