개정판 4d2571ab
dev issue #683 : 우선순위 Symbol 모델링 추가 - 1. Angle Valve, 2. 3개의 Symbol이 연결되있는 경우, 3. Connector가 3개 이상인 Symbol 순으로 모델링
Change-Id: I3faf7ec8f8e50eb80e8fcc427c65d5d2cbfdd477
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
3 | 3 |
using System.Linq; |
4 | 4 |
using System.Text; |
5 | 5 |
using System.Threading.Tasks; |
6 |
using System.Data; |
|
6 | 7 |
using Llama; |
7 | 8 |
using Plaice; |
8 | 9 |
using Ingr.RAD2D.Interop.RAD2D; |
... | ... | |
102 | 103 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStep, AllCount); |
103 | 104 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText); |
104 | 105 |
|
105 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Group Symbol Modeling"); |
|
106 |
List<List<Symbol>> symbolGroups = SPPIDUtil.GetThreeConnectedSymbolGroup(document); |
|
107 |
foreach (List<Symbol> symbolGroup in symbolGroups) |
|
108 |
SymbolModelingByThreeSymbolGroup(symbolGroup); |
|
106 |
//SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Group Symbol Modeling"); |
|
107 |
//List<List<Symbol>> symbolGroups = SPPIDUtil.GetThreeConnectedSymbolGroup(document); |
|
108 |
//foreach (List<Symbol> symbolGroup in symbolGroups) |
|
109 |
// SymbolModelingByThreeSymbolGroup(symbolGroup); |
|
110 |
|
|
111 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Priority Symbol Modeling"); |
|
112 |
List<Symbol> prioritySymbols = GetPrioritySymbol(); |
|
113 |
foreach (var item in prioritySymbols) |
|
114 |
SymbolModelingByPriority(item); |
|
109 | 115 |
|
110 | 116 |
// Equipment Modeling |
111 | 117 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Equipments Modeling"); |
... | ... | |
456 | 462 |
/// <param name="prevSymbol"></param> |
457 | 463 |
private void SymbolModeling(Symbol symbol, Symbol targetSymbol) |
458 | 464 |
{ |
465 |
#if DEBUG |
|
466 |
try |
|
467 |
{ |
|
468 |
#endif |
|
459 | 469 |
// OWNERSYMBOL Attribute, 값을 가지고 있을 경우 |
460 | 470 |
BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(attr => attr.ATTRIBUTE == "OWNERSYMBOL"); |
461 | 471 |
if (itemAttribute != null && string.IsNullOrEmpty(itemAttribute.VALUE) && itemAttribute.VALUE != "None") |
... | ... | |
504 | 514 |
|
505 | 515 |
ReleaseCOMObjects(_LMSymbol); |
506 | 516 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
517 |
#if DEBUG |
|
518 |
|
|
519 |
} |
|
520 |
catch (Exception ex) |
|
521 |
{ |
|
522 |
System.Windows.Forms.MessageBox.Show(ex.StackTrace); |
|
523 |
} |
|
524 |
#endif |
|
507 | 525 |
} |
508 | 526 |
|
509 | 527 |
/// <summary> |
... | ... | |
792 | 810 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
793 | 811 |
} |
794 | 812 |
|
795 |
/// <summary> |
|
796 |
/// 3개의 Symbol이 붙어있을경우 CenterSymbol을 Grid기준으로 맞추기 위해서 모델링 |
|
797 |
/// </summary> |
|
798 |
/// <param name="group"></param> |
|
799 |
private void SymbolModelingByThreeSymbolGroup(List<Symbol> group) |
|
813 |
private void SymbolModelingByPriority(Symbol symbol) |
|
800 | 814 |
{ |
801 |
// Group의 가운데 찾기 |
|
802 |
Symbol symbol1 = null; |
|
803 |
Symbol symbol2 = null; |
|
804 |
Symbol centerSymbol = null; |
|
805 |
foreach (var symbol in group) |
|
806 |
{ |
|
807 |
int count = 0; |
|
808 |
foreach (var connector in symbol.CONNECTORS) |
|
809 |
{ |
|
810 |
object item = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
|
811 |
if (item != null && item.GetType() == typeof(Symbol)) |
|
812 |
count++; |
|
813 |
} |
|
815 |
// Angle, Center, 우선순위 모델링 |
|
816 |
SymbolModeling(symbol, null); |
|
817 |
List<Symbol> group = new List<Symbol>() { symbol }; |
|
818 |
SPPIDUtil.FindConnectedSymbolGroup(document, symbol, group); |
|
814 | 819 |
|
815 |
// Center Symbol |
|
816 |
if (count == 2) |
|
820 |
List<Symbol> endModeling = new List<Symbol>() { symbol }; |
|
821 |
while (endModeling.Count != group.Count) |
|
822 |
{ |
|
823 |
foreach (var item in group) |
|
817 | 824 |
{ |
818 |
SymbolModeling(symbol, null); |
|
819 |
centerSymbol = symbol; |
|
825 |
if (!endModeling.Contains(item)) |
|
826 |
{ |
|
827 |
bool result = false; |
|
828 |
foreach (var connector in item.CONNECTORS) |
|
829 |
{ |
|
830 |
Symbol connSymbol = group.Find(x => x.UID == connector.CONNECTEDITEM); |
|
831 |
if (connSymbol == item) |
|
832 |
throw new Exception(connSymbol.UID); |
|
833 |
|
|
834 |
if (connSymbol != null && endModeling.Contains(connSymbol)) |
|
835 |
{ |
|
836 |
SymbolModeling(item, connSymbol); |
|
837 |
endModeling.Add(item); |
|
838 |
result = true; |
|
839 |
break; |
|
840 |
} |
|
841 |
} |
|
842 |
|
|
843 |
if (result) |
|
844 |
break; |
|
845 |
} |
|
820 | 846 |
} |
821 |
else if (symbol1 == null) |
|
822 |
symbol1 = symbol; |
|
823 |
else |
|
824 |
symbol2 = symbol; |
|
825 | 847 |
} |
826 |
|
|
827 |
SymbolModeling(symbol1, centerSymbol); |
|
828 |
SymbolModeling(symbol2, centerSymbol); |
|
829 | 848 |
} |
830 | 849 |
|
831 | 850 |
/// <summary> |
... | ... | |
1064 | 1083 |
line.SPPID.ModelItemId = _lMConnector.ModelItemID; |
1065 | 1084 |
_lMConnector.Commit(); |
1066 | 1085 |
if (startBranchLine != null || endBranchLine != null) |
1067 |
{ |
|
1068 | 1086 |
BranchLines.Add(new Tuple<string, Line, Line>(_lMConnector.ModelItemID, startBranchLine, endBranchLine)); |
1069 |
} |
|
1070 | 1087 |
} |
1071 | 1088 |
|
1072 |
|
|
1073 | 1089 |
if (_LMSymbol1 != null) |
1074 | 1090 |
ReleaseCOMObjects(_LMSymbol1); |
1075 | 1091 |
if (_LMSymbol2 != null) |
... | ... | |
2406 | 2422 |
} |
2407 | 2423 |
|
2408 | 2424 |
/// <summary> |
2425 |
/// Symbol의 우선순위 Modeling 목록을 가져온다. |
|
2426 |
/// 1. Angle Valve |
|
2427 |
/// 2. 3개로 이루어진 Symbol Group |
|
2428 |
/// </summary> |
|
2429 |
/// <returns></returns> |
|
2430 |
private List<Symbol> GetPrioritySymbol() |
|
2431 |
{ |
|
2432 |
DataTable symbolTable = document.SymbolTable; |
|
2433 |
|
|
2434 |
// List에 순서대로 쌓는다. |
|
2435 |
List<Symbol> symbols = new List<Symbol>(); |
|
2436 |
// Angle Valve 부터 |
|
2437 |
foreach (var symbol in document.SYMBOLS.FindAll(x => x.CONNECTORS.Count == 2)) |
|
2438 |
{ |
|
2439 |
if (!symbols.Contains(symbol)) |
|
2440 |
{ |
|
2441 |
double originX = 0; |
|
2442 |
double originY = 0; |
|
2443 |
|
|
2444 |
// ID2 Table에서 Original Point 가져옴. |
|
2445 |
string OriginalPoint = symbolTable.Select(string.Format("UID = {0}",symbol.DBUID))[0]["OriginalPoint"].ToString(); |
|
2446 |
SPPIDUtil.ConvertPointBystring(OriginalPoint, ref originX, ref originY); |
|
2447 |
|
|
2448 |
SlopeType slopeType1 = SlopeType.None; |
|
2449 |
SlopeType slopeType2 = SlopeType.None; |
|
2450 |
foreach (Connector connector in symbol.CONNECTORS) |
|
2451 |
{ |
|
2452 |
double connectorX = 0; |
|
2453 |
double connectorY = 0; |
|
2454 |
SPPIDUtil.ConvertPointBystring(connector.CONNECTPOINT, ref connectorX, ref connectorY); |
|
2455 |
if (slopeType1 == SlopeType.None) |
|
2456 |
slopeType1 = SPPIDUtil.CalcSlope(originX, originY, connectorX, connectorY); |
|
2457 |
else |
|
2458 |
slopeType2 = SPPIDUtil.CalcSlope(originX, originY, connectorX, connectorY); |
|
2459 |
} |
|
2460 |
|
|
2461 |
if ((slopeType1 == SlopeType.VERTICAL && slopeType2 == SlopeType.HORIZONTAL) || |
|
2462 |
(slopeType2 == SlopeType.VERTICAL && slopeType1 == SlopeType.HORIZONTAL)) |
|
2463 |
symbols.Add(symbol); |
|
2464 |
} |
|
2465 |
} |
|
2466 |
|
|
2467 |
// 3개의 Symbol이 뭉쳐 있을 때 |
|
2468 |
foreach (var item in document.SYMBOLS) |
|
2469 |
{ |
|
2470 |
List<Symbol> group = new List<Symbol>(); |
|
2471 |
SPPIDUtil.FindConnectedSymbolGroup(document, item, group); |
|
2472 |
if (group.Count == 3) |
|
2473 |
{ |
|
2474 |
Symbol symbol = SPPIDUtil.FindCenterAtThreeSymbols(document, group); |
|
2475 |
if (!symbols.Contains(symbol)) |
|
2476 |
symbols.Add(symbol); |
|
2477 |
} |
|
2478 |
} |
|
2479 |
|
|
2480 |
// Connection Point가 3개 이상 |
|
2481 |
foreach (var symbol in document.SYMBOLS) |
|
2482 |
if (symbol.CONNECTORS.Count > 2 && !symbols.Contains(symbol)) |
|
2483 |
symbols.Add(symbol); |
|
2484 |
|
|
2485 |
return symbols; |
|
2486 |
} |
|
2487 |
|
|
2488 |
/// <summary> |
|
2409 | 2489 |
/// Graphic OID로 해당 Symbol의 크기를 구하여 Zoom |
2410 | 2490 |
/// </summary> |
2411 | 2491 |
/// <param name="graphicOID"></param> |
DTI_PID/SPPIDConverter/BaseModel/Document.cs | ||
---|---|---|
217 | 217 |
{ |
218 | 218 |
foreach (XElement item in node.Elements("LINE_NO")) |
219 | 219 |
{ |
220 |
LineNumber lineNumber = new LineNumber()
|
|
220 |
try
|
|
221 | 221 |
{ |
222 |
UID = item.Element("UID").Value, |
|
223 |
TEXT = item.Element("TEXT").Value, |
|
224 |
LOCATION = item.Element("LOCATION").Value, |
|
225 |
WIDTH = item.Element("WIDTH").Value, |
|
226 |
HEIGHT = item.Element("HEIGHT").Value, |
|
227 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
|
228 |
AREA = item.Element("AREA").Value, |
|
229 |
CONNLINE = item.Element("CONNLINE").Value, |
|
230 |
SCENE = item.Element("SCENE").Value |
|
231 |
}; |
|
232 |
SetLineNumberRuns(item, lineNumber.RUNS); |
|
233 |
SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES); |
|
234 |
SetAttributes(item, lineNumber.ATTRIBUTES); |
|
235 |
LINENUMBERS.Add(lineNumber); |
|
222 |
LineNumber lineNumber = new LineNumber() |
|
223 |
{ |
|
224 |
UID = item.Element("UID").Value, |
|
225 |
TEXT = item.Element("TEXT").Value, |
|
226 |
LOCATION = item.Element("LOCATION").Value, |
|
227 |
WIDTH = item.Element("WIDTH").Value, |
|
228 |
HEIGHT = item.Element("HEIGHT").Value, |
|
229 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
|
230 |
AREA = item.Element("AREA").Value, |
|
231 |
CONNLINE = item.Element("CONNLINE").Value, |
|
232 |
SCENE = item.Element("SCENE").Value |
|
233 |
}; |
|
234 |
SetLineNumberRuns(item, lineNumber.RUNS); |
|
235 |
SetProperties(item.Element("PROPERTIES"), lineNumber.PROPERTIES); |
|
236 |
SetAttributes(item, lineNumber.ATTRIBUTES); |
|
237 |
LINENUMBERS.Add(lineNumber); |
|
238 |
} |
|
239 |
catch (Exception ex) |
|
240 |
{ |
|
241 |
StringBuilder sb = new StringBuilder(); |
|
242 |
sb.AppendLine(item.Element("UID").Value); |
|
243 |
sb.AppendLine(""); |
|
244 |
sb.AppendLine(ex.Message); |
|
245 |
sb.AppendLine(ex.StackTrace); |
|
246 |
MessageBox.Show(sb.ToString()); |
|
247 |
} |
|
236 | 248 |
} |
237 | 249 |
} |
238 | 250 |
|
DTI_PID/SPPIDConverter/ConverterForm.cs | ||
---|---|---|
41 | 41 |
private DataTable _ID2AttributeDT = new DataTable(); |
42 | 42 |
private DataTable _ID2LinePropertyDT = new DataTable(); |
43 | 43 |
private DataTable _ID2SymbolTypeDT = new DataTable(); |
44 |
private DataTable _ID2SymbolTable = new DataTable(); |
|
44 | 45 |
|
45 | 46 |
|
46 | 47 |
private List<SymbolMapping> symbolMappings = new List<SymbolMapping>(); |
... | ... | |
198 | 199 |
Project_Info _ProjectInfo = Project_Info.GetInstance(); |
199 | 200 |
if (_ProjectInfo.Enable) |
200 | 201 |
{ |
202 |
if (_ID2SymbolTable != null) |
|
203 |
{ |
|
204 |
_ID2SymbolTable.Dispose(); |
|
205 |
_ID2SymbolTable = null; |
|
206 |
} |
|
207 |
_ID2SymbolTable = Project_DB.SelectID2SymbolTable(); |
|
201 | 208 |
InitID2Symbol(); |
202 | 209 |
InitID2Line(); |
203 | 210 |
InitID2LineNumber(); |
... | ... | |
482 | 489 |
document.DrawingNumber = _DrawingNumber; |
483 | 490 |
document.DrawingName = _DrawingName; |
484 | 491 |
|
492 |
document.SymbolTable = _ID2SymbolTable; |
|
485 | 493 |
document.SymbolMappings = symbolMappings; |
486 | 494 |
document.ChildSymbolMappings = childSymbolMappings; |
487 | 495 |
document.LineMappings = lineMappings; |
DTI_PID/SPPIDConverter/DB/Project_DB.cs | ||
---|---|---|
470 | 470 |
return dt; |
471 | 471 |
} |
472 | 472 |
|
473 |
public static DataTable SelectID2SymbolTable() |
|
474 |
{ |
|
475 |
DataTable dt = new DataTable(); |
|
476 |
Project_Info projectInfo = Project_Info.GetInstance(); |
|
477 |
using (SQLiteConnection connection = new SQLiteConnection(string.Format(CultureInfo.CurrentCulture, "Data Source = {0}", projectInfo.DBFilePath))) |
|
478 |
{ |
|
479 |
try |
|
480 |
{ |
|
481 |
connection.Open(); |
|
482 |
using (SQLiteCommand cmd = connection.CreateCommand()) |
|
483 |
{ |
|
484 |
cmd.CommandText = "SELECT * FROM Symbol"; |
|
485 |
using (SQLiteDataReader dr = cmd.ExecuteReader()) |
|
486 |
dt.Load(dr); |
|
487 |
} |
|
488 |
connection.Close(); |
|
489 |
} |
|
490 |
catch (Exception ex) |
|
491 |
{ |
|
492 |
|
|
493 |
} |
|
494 |
finally |
|
495 |
{ |
|
496 |
connection.Dispose(); |
|
497 |
} |
|
498 |
} |
|
499 |
|
|
500 |
return dt; |
|
501 |
} |
|
502 |
|
|
473 | 503 |
|
474 | 504 |
|
475 | 505 |
public static bool InsertSymbolMapping(List<Tuple<string, string, string, bool>> datas) |
DTI_PID/SPPIDConverter/SPPIDModel/SPPID_Document.cs | ||
---|---|---|
22 | 22 |
public List<LineNumberMapping> LineNumberMappings; |
23 | 23 |
public List<AttributeMapping> AttributeMappings; |
24 | 24 |
public ETCSetting ETCSetting; |
25 |
public DataTable SymbolTable { get; set; } |
|
25 | 26 |
|
26 | 27 |
public List<Group> GROUPS = new List<Group>(); |
27 | 28 |
|
DTI_PID/SPPIDConverter/Util/SPPIDUtil.cs | ||
---|---|---|
154 | 154 |
} |
155 | 155 |
} |
156 | 156 |
} |
157 |
|
|
157 | 158 |
public static void ConvertGridPointOnlyOnePoint(ref double value) |
158 | 159 |
{ |
159 | 160 |
GridSetting _GridSetting = GridSetting.GetInstance(); |
... | ... | |
313 | 314 |
return lines; |
314 | 315 |
} |
315 | 316 |
|
316 |
public static List<Symbol> GetPrioritySymbol(Document document)
|
|
317 |
public static void FindConnectedSymbolGroup(Document document, Symbol symbol, List<Symbol> group)
|
|
317 | 318 |
{ |
318 |
// List에 순서대로 쌓는다. |
|
319 |
List<Symbol> symbols = new List<Symbol>(); |
|
320 |
|
|
321 |
// Angle Valve 부터 |
|
322 |
foreach (var symbol in document.SYMBOLS.FindAll(x => x.CONNECTORS.Count == 2)) |
|
319 |
foreach (var connector in symbol.CONNECTORS) |
|
323 | 320 |
{ |
324 |
if (!symbols.Contains(symbol)) |
|
321 |
object connectedItem = FindObjectByUID(document, connector.CONNECTEDITEM); |
|
322 |
if (connectedItem != null && connectedItem.GetType() == typeof(Symbol)) |
|
325 | 323 |
{ |
326 |
double originX = 0; |
|
327 |
double originY = 0; |
|
328 |
ConvertPointBystring(symbol.ORIGINALPOINT, ref originX, ref originY); |
|
329 |
|
|
330 |
SlopeType slopeType1 = SlopeType.None; |
|
331 |
SlopeType slopeType2 = SlopeType.None; |
|
332 |
foreach (Connector connector in symbol.CONNECTORS) |
|
324 |
Symbol connSymbol = connectedItem as Symbol; |
|
325 |
if (!group.Contains(connSymbol)) |
|
333 | 326 |
{ |
334 |
double connectorX = 0; |
|
335 |
double connectorY = 0; |
|
336 |
ConvertPointBystring(connector.SCENECONNECTPOINT, ref connectorX, ref connectorY); |
|
337 |
if (slopeType1 == SlopeType.None) |
|
338 |
slopeType1 = CalcSlope(originX, originY, connectorX, connectorY); |
|
339 |
else |
|
340 |
slopeType2 = CalcSlope(originX, originY, connectorX, connectorY); |
|
327 |
group.Add(connSymbol); |
|
328 |
FindConnectedSymbolGroup(document, connSymbol, group); |
|
341 | 329 |
} |
342 |
|
|
343 |
if ((slopeType1 == SlopeType.VERTICAL && slopeType2 == SlopeType.HORIZONTAL) || |
|
344 |
(slopeType2 == SlopeType.VERTICAL && slopeType1 == SlopeType.HORIZONTAL)) |
|
345 |
symbols.Add(symbol); |
|
346 | 330 |
} |
347 | 331 |
} |
348 |
|
|
349 |
// 3개의 Symbol이 뭉쳐 있을 때 |
|
350 |
foreach (var item in document.SYMBOLS) |
|
351 |
{ |
|
352 |
|
|
353 |
} |
|
354 |
|
|
355 |
|
|
356 |
|
|
357 |
return symbols; |
|
358 | 332 |
} |
359 | 333 |
|
360 |
public static List<List<Symbol>> GetThreeConnectedSymbolGroup(Document document)
|
|
334 |
public static Symbol FindCenterAtThreeSymbols(Document document, List<Symbol> group)
|
|
361 | 335 |
{ |
362 |
List<List<Symbol>> tempGroups = new List<List<Symbol>>(); |
|
363 |
foreach (Symbol symbol in document.SYMBOLS) |
|
336 |
Symbol result = null; |
|
337 |
|
|
338 |
// Group의 가운데 찾기 |
|
339 |
if (group.Count == 3) |
|
364 | 340 |
{ |
365 |
if (tempGroups.Find(x => x.Find(y => y.UID == symbol.UID) != null) != null) |
|
366 |
continue; |
|
341 |
foreach (var symbol in group) |
|
342 |
{ |
|
343 |
int count = 0; |
|
344 |
foreach (var connector in symbol.CONNECTORS) |
|
345 |
{ |
|
346 |
object item = FindObjectByUID(document, connector.CONNECTEDITEM); |
|
347 |
if (item != null && item.GetType() == typeof(Symbol) && group.Contains(item as Symbol)) |
|
348 |
count++; |
|
349 |
} |
|
367 | 350 |
|
368 |
List<Symbol> symbolGroup = new List<Symbol>() { symbol }; |
|
369 |
GetConnectedSymbol(document, symbol, symbolGroup); |
|
370 |
tempGroups.Add(symbolGroup); |
|
351 |
if (count == 2) |
|
352 |
{ |
|
353 |
result = symbol; |
|
354 |
break; |
|
355 |
} |
|
356 |
} |
|
371 | 357 |
} |
372 |
List<List<Symbol>> symbolGroups = new List<List<Symbol>>(); |
|
373 |
foreach (var group in tempGroups) |
|
374 |
if (group.Count == 3) |
|
375 |
symbolGroups.Add(group); |
|
376 | 358 |
|
377 |
return symbolGroups;
|
|
359 |
return result;
|
|
378 | 360 |
} |
379 | 361 |
|
380 | 362 |
private static void GetConnectedSymbol(Document document, Symbol symbol, List<Symbol> symbolGroup) |
내보내기 Unified diff